diff --git a/renren-cloud-generator/src/main/resources/application.yml b/renren-cloud-generator/src/main/resources/application.yml index ebc9caa33..f88851291 100644 --- a/renren-cloud-generator/src/main/resources/application.yml +++ b/renren-cloud-generator/src/main/resources/application.yml @@ -9,9 +9,9 @@ spring: type: com.alibaba.druid.pool.DruidDataSource #MySQL配置 driverClassName: com.mysql.jdbc.Driver - url: jdbc:mysql://localhost:3306/renren_cloud?useUnicode=true&characterEncoding=UTF-8&useSSL=false - username: renren - password: 123456 + url: jdbc:mysql://47.104.224.45:3308/esua_epdc_news?useUnicode=true&characterEncoding=UTF-8&useSSL=false + username: epdc + password: elink833066 #oracle配置 # driverClassName: oracle.jdbc.OracleDriver # url: jdbc:oracle:thin:@192.168.10.10:1521:helowin diff --git a/renren-cloud-generator/src/main/resources/generator.properties b/renren-cloud-generator/src/main/resources/generator.properties index dd5415b2c..d04d3682d 100644 --- a/renren-cloud-generator/src/main/resources/generator.properties +++ b/renren-cloud-generator/src/main/resources/generator.properties @@ -1,17 +1,17 @@ #\u4EE3\u7801\u751F\u6210\u5668\uFF0C\u914D\u7F6E\u4FE1\u606F -main=io.renren +main= #\u5305\u540D -package=io.renren -moduleName=demo +package=com.elink.esua.epdc +moduleName= #\u4F5C\u8005 -author=Mark +author=yujintao #\u7248\u672C\u53F7 version=v1.0.0 #Email -email=sunlightcs@gmail.com +email=yujintao@elink-cn.com #\u8868\u524D\u7F00(\u7C7B\u540D\u4E0D\u4F1A\u5305\u542B\u8868\u524D\u7F00) -tablePrefix=demo_ +tablePrefix=epdc_ #\u7C7B\u578B\u8F6C\u6362\uFF0C\u914D\u7F6E\u4FE1\u606F tinyint=Integer diff --git a/renren-cloud-generator/src/main/resources/template/Controller.java.vm b/renren-cloud-generator/src/main/resources/template/Controller.java.vm index aef445590..f12a2030d 100644 --- a/renren-cloud-generator/src/main/resources/template/Controller.java.vm +++ b/renren-cloud-generator/src/main/resources/template/Controller.java.vm @@ -28,8 +28,6 @@ import ${main}.commons.tools.validator.group.DefaultGroup; import ${package}.dto.${className}DTO; import ${package}.excel.${className}Excel; import ${package}.service.${className}Service; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -46,71 +44,50 @@ import java.util.Map; */ @RestController @RequestMapping("${moduleName}/${pathName}") -@Api(tags="${comments}") public class ${className}Controller { + @Autowired private ${className}Service ${classname}Service; @GetMapping("page") - @ApiOperation("分页") - @ApiImplicitParams({ - @ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataType="int") , - @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") , - @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") , - @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataType="String") - }) - public Result> page(@ApiIgnore @RequestParam Map params){ + public Result> page(@RequestParam Map params){ PageData<${className}DTO> page = ${classname}Service.page(params); - return new Result>().ok(page); } @GetMapping("{id}") - @ApiOperation("信息") public Result<${className}DTO> get(@PathVariable("id") String id){ ${className}DTO data = ${classname}Service.get(id); - return new Result<${className}DTO>().ok(data); } @PostMapping - @ApiOperation("保存") public Result save(@RequestBody ${className}DTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); - ${classname}Service.save(dto); - return new Result(); } @PutMapping - @ApiOperation("修改") public Result update(@RequestBody ${className}DTO dto){ //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); - ${classname}Service.update(dto); - return new Result(); } @DeleteMapping - @ApiOperation("删除") public Result delete(@RequestBody String[] ids){ //效验数据 AssertUtils.isArrayEmpty(ids, "id"); - ${classname}Service.delete(ids); - return new Result(); } @GetMapping("export") - @ApiOperation("导出") - public void export(@ApiIgnore @RequestParam Map params, HttpServletResponse response) throws Exception { + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { List<${className}DTO> list = ${classname}Service.list(params); - ExcelUtils.exportExcelToTarget(response, null, list, ${className}Excel.class); } diff --git a/renren-cloud-generator/src/main/resources/template/DTO.java.vm b/renren-cloud-generator/src/main/resources/template/DTO.java.vm index 186eaf379..83d0e1db5 100644 --- a/renren-cloud-generator/src/main/resources/template/DTO.java.vm +++ b/renren-cloud-generator/src/main/resources/template/DTO.java.vm @@ -17,9 +17,6 @@ package ${package}.dto; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - import java.io.Serializable; import java.util.Date; import lombok.Data; @@ -35,12 +32,14 @@ import java.math.BigDecimal; * @since ${version} ${date} */ @Data -@ApiModel(value = "${comments}") public class ${className}DTO implements Serializable { + private static final long serialVersionUID = 1L; #foreach ($column in $columns) - @ApiModelProperty(value = "$column.comments") + /** + * $column.comments + */ private $column.attrType $column.attrname; #end diff --git a/renren-cloud-generator/src/main/resources/template/Entity.java.vm b/renren-cloud-generator/src/main/resources/template/Entity.java.vm index 3773d95bb..78f0b951e 100644 --- a/renren-cloud-generator/src/main/resources/template/Entity.java.vm +++ b/renren-cloud-generator/src/main/resources/template/Entity.java.vm @@ -17,12 +17,9 @@ package ${package}.entity; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.FieldFill; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; -import ${main}.commons.mybatis.entity.BaseEntity; +import ${main}.commons.mybatis.entity.BaseEpdcEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -40,15 +37,17 @@ import java.util.Date; @Data @EqualsAndHashCode(callSuper=false) @TableName("${tableName}") -public class ${className}Entity extends BaseEntity { +public class ${className}Entity extends BaseEpdcEntity { + private static final long serialVersionUID = 1L; #foreach ($column in $columns) -#if($column.columnName != 'id' && $column.columnName != 'creator' && $column.columnName != 'create_date') +#if($column.columnName != 'ID' && $column.columnName != 'CREATED_TIME' && $column.columnName != 'CREATED_BY' && $column.columnName != 'UPDATED_TIME' && $column.columnName != 'UPDATED_BY' && $column.columnName != 'DEL_FLAG') /** * $column.comments */ private $column.attrType $column.attrname; + #end #end } \ No newline at end of file diff --git a/renren-cloud-generator/src/main/resources/template/Excel.java.vm b/renren-cloud-generator/src/main/resources/template/Excel.java.vm index be114909f..eee884747 100644 --- a/renren-cloud-generator/src/main/resources/template/Excel.java.vm +++ b/renren-cloud-generator/src/main/resources/template/Excel.java.vm @@ -33,9 +33,11 @@ import java.util.Date; */ @Data public class ${className}Excel { + #foreach ($column in $columns) @Excel(name = "$!column.comments") private $column.attrType $column.attrname; + #end } \ No newline at end of file diff --git a/renren-cloud-generator/src/main/resources/template/Service.java.vm b/renren-cloud-generator/src/main/resources/template/Service.java.vm index d43bf027c..c1d4cf168 100644 --- a/renren-cloud-generator/src/main/resources/template/Service.java.vm +++ b/renren-cloud-generator/src/main/resources/template/Service.java.vm @@ -33,15 +33,63 @@ import java.util.Map; */ public interface ${className}Service extends BaseService<${className}Entity> { + /** + * 默认分页 + * + * @param params + * @return PageData<${className}DTO> + * @author + * @date + */ PageData<${className}DTO> page(Map params); + /** + * 默认查询 + * + * @param params + * @return java.util.List<${className}DTO> + * @author + * @date + */ List<${className}DTO> list(Map params); + /** + * 单条查询 + * + * @param id + * @return ${className}DTO + * @author + * @date + */ ${className}DTO get(String id); + /** + * 默认保存 + * + * @param dto + * @return void + * @author + * @date + */ void save(${className}DTO dto); + /** + * 默认更新 + * + * @param dto + * @return void + * @author + * @date + */ void update(${className}DTO dto); + /** + * 批量删除 + * + * @param ids + * @return void + * @author + * @date + */ void delete(String[] ids); } \ No newline at end of file diff --git a/renren-cloud-generator/src/main/resources/template/ServiceImpl.java.vm b/renren-cloud-generator/src/main/resources/template/ServiceImpl.java.vm index cbf9143b2..90258609d 100644 --- a/renren-cloud-generator/src/main/resources/template/ServiceImpl.java.vm +++ b/renren-cloud-generator/src/main/resources/template/ServiceImpl.java.vm @@ -19,15 +19,14 @@ package ${package}.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; -import ${main}.commons.mybatis.enums.DelFlagEnum; +import ${main}.commons.mybatis.enums.EpdcDelFlagEnum; import ${main}.commons.mybatis.service.impl.BaseServiceImpl; -import ${main}.commons.tools.exception.RenException; import ${main}.commons.tools.page.PageData; import ${main}.commons.tools.utils.ConvertUtils; +import ${package}.commons.tools.constant.FieldConstant; import ${package}.dao.${className}Dao; import ${package}.dto.${className}DTO; import ${package}.entity.${className}Entity; -import ${package}.exception.ModuleErrorCode; import ${package}.redis.${className}Redis; import ${package}.service.${className}Service; import org.apache.commons.lang3.StringUtils; @@ -47,16 +46,16 @@ import java.util.Map; */ @Service public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${className}Entity> implements ${className}Service { + @Autowired private ${className}Redis ${classname}Redis; @Override public PageData<${className}DTO> page(Map params) { IPage<${className}Entity> page = baseDao.selectPage( - getPage(params, Constant.CREATE_DATE, false), + getPage(params, FieldConstant.CREATED_TIME, false), getWrapper(params) ); - return getPageData(page, ${className}DTO.class); } @@ -68,11 +67,11 @@ public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${ } private QueryWrapper<${className}Entity> getWrapper(Map params){ - String id = (String)params.get("id"); + String id = (String)params.get(FieldConstant.ID_HUMP); QueryWrapper<${className}Entity> wrapper = new QueryWrapper<>(); - wrapper.eq(StringUtils.isNotBlank(id), "id", id); - //wrapper.eq(Constant.DEL_FLAG, DelFlagEnum.NORMAL.value()); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id) + .eq(FieldConstant.DEL_FLAG, EpdcDelFlagEnum.NORMAL.value()); return wrapper; } @@ -80,7 +79,6 @@ public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${ @Override public ${className}DTO get(String id) { ${className}Entity entity = baseDao.selectById(id); - return ConvertUtils.sourceToTarget(entity, ${className}DTO.class); } @@ -88,7 +86,6 @@ public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${ @Transactional(rollbackFor = Exception.class) public void save(${className}DTO dto) { ${className}Entity entity = ConvertUtils.sourceToTarget(dto, ${className}Entity.class); - insert(entity); } @@ -96,7 +93,6 @@ public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${ @Transactional(rollbackFor = Exception.class) public void update(${className}DTO dto) { ${className}Entity entity = ConvertUtils.sourceToTarget(dto, ${className}Entity.class); - updateById(entity); } @@ -105,7 +101,6 @@ public class ${className}ServiceImpl extends BaseServiceImpl<${className}Dao, ${ public void delete(String[] ids) { //逻辑删除 //logicDelete(ids, ${className}Entity.class); - //物理删除 baseDao.deleteBatchIds(Arrays.asList(ids)); }