新增前后端分离代码生成器 菜单在维护-》代码生成
This commit is contained in:
@@ -0,0 +1,103 @@
|
||||
package ${package}.${moduleName}.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import ${package}.${moduleName}.entity.${className}Entity;
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
import ${mainPath}.common.utils.PageUtils;
|
||||
import ${mainPath}.common.utils.R;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* ${comments} 控制器
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: ${author}
|
||||
* +----------------------------------------------------------------------
|
||||
* | @date ${datetime}
|
||||
* +----------------------------------------------------------------------
|
||||
* | @date ${email}
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("${moduleName}/${pathName}")
|
||||
public class ${className}Controller {
|
||||
@Autowired
|
||||
private ${className}Service ${classname}Service;
|
||||
|
||||
/**
|
||||
* 列表信息
|
||||
*/
|
||||
@RequestMapping("/list")
|
||||
@PreAuthorize("${moduleName}:${pathName}:list")
|
||||
public CommonResult<CommonPage<${classname}>> list(@RequestParam Map<String, Object> params){
|
||||
CommonPage<${classname}> page = CommonPage.restPag(${classname}Service.queryPage(params));
|
||||
|
||||
return CommonResult.success(page);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 详情数据
|
||||
*/
|
||||
@RequestMapping("/info/{${pk.attrname}}")
|
||||
@PreAuthorize("${moduleName}:${pathName}:info")
|
||||
public CommonResult<${classname}> info(@PathVariable("${pk.attrname}") ${pk.attrType} ${pk.attrname}){
|
||||
${className}Entity ${classname} = ${classname}Service.getById(${pk.attrname});
|
||||
|
||||
return CommonResult.success(${classname});
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
@PreAuthorize("${moduleName}:${pathName}:save")
|
||||
public CommonResult<String> save(@RequestBody ${className}Entity ${classname}){
|
||||
if (${classname}Service.save(${classname})) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*/
|
||||
@RequestMapping("/update")
|
||||
@PreAuthorize("${moduleName}:${pathName}:update")
|
||||
public CommonResult<String> update(@RequestBody ${className}Entity ${classname}){
|
||||
if (${classname}Service.updateById(${classname})) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除:根据id集合
|
||||
*/
|
||||
@RequestMapping("/delete")
|
||||
@PreAuthorize("${moduleName}:${pathName}:delete")
|
||||
public CommonResult<String> delete(@RequestBody ${pk.attrType}[] ${pk.attrname}s){
|
||||
if (${classname}Service.removeByIds(Arrays.asList(${pk.attrname}))) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package ${package}.${moduleName}.dao;
|
||||
|
||||
import ${package}.${moduleName}.entity.${className}Entity;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* ${comments} DAO 映射层
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* @author: ${author}
|
||||
* +----------------------------------------------------------------------
|
||||
* @date ${datetime}
|
||||
* +----------------------------------------------------------------------
|
||||
* @email ${email}
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Mapper
|
||||
public interface ${className}Dao extends BaseMapper<${className}Entity> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package ${package}.${moduleName}.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
|
||||
#if(${hasBigDecimal})
|
||||
import java.math.BigDecimal;
|
||||
#end
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ${comments} Entity 实体类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* @author: ${author}
|
||||
* +----------------------------------------------------------------------
|
||||
* @date ${datetime}
|
||||
* +----------------------------------------------------------------------
|
||||
* @email ${email}
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
public class ${className}Entity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
#foreach ($column in $columns)
|
||||
/**
|
||||
* $column.comments
|
||||
*/
|
||||
#if($column.columnName == $pk.columnName)
|
||||
@TableId
|
||||
#end
|
||||
private $column.attrType $column.attrname;
|
||||
#end
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package ${package}.${moduleName}.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import ${mainPath}.common.utils.PageUtils;
|
||||
import ${package}.${moduleName}.entity.${className}Entity;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ${comments} 业务接口
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* @author: ${author}
|
||||
* +----------------------------------------------------------------------
|
||||
* @date ${datetime}
|
||||
* +----------------------------------------------------------------------
|
||||
* @email ${email}
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
public interface ${className}Service extends IService<${className}Entity> {
|
||||
|
||||
/**
|
||||
* ${className} 列表查询
|
||||
* @param request 默认是是体类 根据自己需求修改或者创建自己的request
|
||||
* @param pageParamRequest 分页参数对象
|
||||
* @return
|
||||
*/
|
||||
List<${className}> getList(${className}Entity request, PageParamRequest pageParamRequest)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package ${package}.${moduleName}.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.pageQueryUtils.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import ${mainPath}.common.utils.PageUtils;
|
||||
import ${mainPath}.common.utils.Query;
|
||||
|
||||
import ${package}.${moduleName}.dao.${className}Dao;
|
||||
import ${package}.${moduleName}.entity.${className}Entity;
|
||||
import ${package}.${moduleName}.service.${className}Service;
|
||||
|
||||
|
||||
/**
|
||||
* ${comments} 接口实现类
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* @author: ${author}
|
||||
* +----------------------------------------------------------------------
|
||||
* @date ${datetime}
|
||||
* +----------------------------------------------------------------------
|
||||
* @email ${email}
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
@Service("${classname}Service")
|
||||
public class ${className}ServiceImpl extends ServiceImpl<${className}Dao, ${className}Entity> implements ${className}Service {
|
||||
|
||||
/**
|
||||
* ${className}列表查询
|
||||
* @param request 默认是是体类 根据自己需求修改或者创建自己的request
|
||||
* @param pageParamRequest 分页参数对象
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageUtils queryPage(${className}Entity request, PageParamRequest pageParamRequest) {
|
||||
PageHelper.startPage(pageParamRequest.getPageNum(), pageParamRequest.getPageSize());
|
||||
|
||||
//列表查询 ${className} 类的多条件查询
|
||||
LambdaQueryWrapper<${className}> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
${className} model = new ${className}();
|
||||
BeanUtils.copyProperties(request, model);
|
||||
lambdaQueryWrapper.setEntity(model);
|
||||
return dao.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user