Commit 27336103 authored by liqin's avatar liqin 💬

bug fixed

parent db7a3b73
...@@ -61,16 +61,12 @@ public class ${table.controllerName} { ...@@ -61,16 +61,12 @@ public class ${table.controllerName} {
@Resource @Resource
private ${table.serviceName} ${table.entityPath}Service; private ${table.serviceName} ${table.entityPath}Service;
/**
* 批量新增业务系统节点
*
* @return 操作结果
*/
@PostMapping("/batchSave") @PostMapping("/batchSave")
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:batch:save") @RequiresPermissions("$!{cfg.colonTableName}:batch:save")
#end #end
public Map<String, Object> batchSave${entity}(#if(${cfg.paramValidation})@Validated#end @RequestBody List<${entity}> ${table.entityPath}List) { @ApiOperation(value = "批量添加$!{table.comment}", notes = "批量添加$!{table.comment}")
public Map<String, Object> batchSave${entity}(#if(${cfg.paramValidation})@Validated(value = {Add.class})#end List<${entity}> ${table.entityPath}List) {
// 保存业务节点信息 // 保存业务节点信息
boolean result = ${table.entityPath}Service.saveBatch(${table.entityPath}List); boolean result = ${table.entityPath}Service.saveBatch(${table.entityPath}List);
// 返回操作结果 // 返回操作结果
...@@ -82,15 +78,12 @@ public class ${table.controllerName} { ...@@ -82,15 +78,12 @@ public class ${table.controllerName} {
} }
} }
/**
* 添加$!{table.comment}
*/
@PostMapping("/save") @PostMapping("/save")
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:save") @RequiresPermissions("$!{cfg.colonTableName}:save")
#end #end
@ApiOperation(value = "添加${entity}对象", notes = "添加$!{table.comment}") @ApiOperation(value = "添加$!{table.comment}", notes = "添加$!{table.comment}")
public Map<String, Object> save${entity}(#if(${cfg.paramValidation})@Validated#end ${entity} ${table.entityPath}) { public Map<String, Object> save${entity}(#if(${cfg.paramValidation})@Validated(value = {Add.class})#end ${entity} ${table.entityPath}) {
// 保存业务节点信息 // 保存业务节点信息
boolean result = ${table.entityPath}Service.save(${table.entityPath}); boolean result = ${table.entityPath}Service.save(${table.entityPath});
// 返回操作结果 // 返回操作结果
...@@ -102,40 +95,12 @@ public class ${table.controllerName} { ...@@ -102,40 +95,12 @@ public class ${table.controllerName} {
} }
} }
/**
* 重命名业务节点
*
* @param id 业务节点ID
* @param newName 业务节点新名称
* @return 操作结果
*/
@PutMapping("/rename")
#if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:rename")
#end
public Map<String, Object> rename(Long id, String newName) {
${entity} entity = new ${entity}();
entity.setId(id);
entity.set${entity}Name(newName);
boolean result = ${table.entityPath}Service.updateById(entity);
if (result) {
// 返回操作结果
return getSuccessResult();
} else {
// 修改失败,业务节点名称重复
return getFailResult(RESPONSE_CODE_ENUM.CREATE_FLOW_NODE_ERROR.getCode(), RESPONSE_CODE_ENUM.CREATE_FLOW_NODE_ERROR.getMsg());
}
}
/**
* 修改$!{table.comment}
*/
@PutMapping("/update") @PutMapping("/update")
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:update") @RequiresPermissions("$!{cfg.colonTableName}:update")
#end #end
@ApiOperation(value = "修改${entity}对象", notes = "修改$!{table.comment}") @ApiOperation(value = "修改$!{table.comment}信息", notes = "修改$!{table.comment}信息")
public Map<String, Object> update${entity}(#if(${cfg.paramValidation})@Validated#end @RequestBody ${entity} ${cfg.entityObjectName}) { public Map<String, Object> update${entity}(#if(${cfg.paramValidation})@Validated#end ${entity} ${cfg.entityObjectName}) {
#if(${cfg.generatorStrategy} == 'ALL') #if(${cfg.generatorStrategy} == 'ALL')
boolean flag = ${table.entityPath}Service.update${entity}(${cfg.entityObjectName}); boolean flag = ${table.entityPath}Service.update${entity}(${cfg.entityObjectName});
#else #else
...@@ -147,16 +112,28 @@ public class ${table.controllerName} { ...@@ -147,16 +112,28 @@ public class ${table.controllerName} {
return getFailResult(); return getFailResult();
} }
/** @PutMapping("/updateAuditStatus/{id}")
* 删除$!{table.comment} @RequiresPermissions("$!{cfg.colonTableName}:update:audit:status")
*/ @ApiOperation(value = "更新$!{table.comment}审核状态", notes = "更新$!{table.comment}审核状态")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path"),
@ApiImplicitParam(name = "status", value = "状态", paramType = "query", dataType = "String")
})
public Map<String, Object> updateStatus(@NotNull(message = "$!{table.comment}ID不能为空") @PathVariable("id") Long id, @RequestParam("status") AuditStatusEnum status) {
boolean flag = atomicIndexService.updateAuditStatusById(id, status);
if (flag) {
return getSuccessResult();
}
return getFailResult();
}
@DeleteMapping("/delete/{id}") @DeleteMapping("/delete/{id}")
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:delete") @RequiresPermissions("$!{cfg.colonTableName}:delete")
#end #end
@ApiOperation(value = "删除${entity}对象", notes = "删除$!{table.comment}") @ApiOperation(value = "根据ID删除$!{table.comment}", notes = "根据ID删除$!{table.comment}")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "id", value = "对象标识ID", paramType = "path", dataType = "Long") @ApiImplicitParam(name = "id", value = "标识ID", paramType = "path", dataType = "String")
}) })
public Map<String, Object> delete${entity}(@PathVariable("id") Long id) { public Map<String, Object> delete${entity}(@PathVariable("id") Long id) {
boolean result = ${table.entityPath}Service.removeById(id); boolean result = ${table.entityPath}Service.removeById(id);
...@@ -170,48 +147,62 @@ public class ${table.controllerName} { ...@@ -170,48 +147,62 @@ public class ${table.controllerName} {
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:list") @RequiresPermissions("$!{cfg.colonTableName}:list")
#end #end
@ApiOperation(value = "获取${entity}列表", notes = "$!{table.comment}列表") @ApiOperation(value = "获取$!{table.comment}全部列表(无分页)", notes = "获取$!{table.comment}全部列表(无分页)")
public Map<String, Object> get${entity}List() { @ApiImplicitParams(value = {
// 通过业务流程ID和业务ID获取未删除业务节点集合 @ApiImplicitParam(name = "status", value = "审核状态", paramType = "query", dataType = "String")
List<${entity}> ${table.entityPath}s = ${table.entityPath}Service.list(); })
// 初始化返回对象 public Map<String, Object> get${entity}List(@RequestParam(value = "status", defaultValue = "APPROVED", required = false) ModelStatusEnum status) {
Map<String, Object> map = new HashMap<>(); List<${entity}> ${table.entityPath}List = ${table.entityPath}Service.list(Wrappers.<${entity}>lambdaQuery().eq(${entity}::getStatus, status.name()));
map.put("data", ${table.entityPath}s); return getResult(${table.entityPath}List);
return getResult(map);
} }
/** @ApiImplicitParams(value = {
* $!{table.comment}分页列表 @ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"),
*/ @ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer"),
@ApiImplicitParams(value = { @ApiImplicitParam(name = "nameOrCode", value = "名称或编码", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "_index", value = "分页起始偏移量", paramType = "query", dataType = "Integer"), @ApiImplicitParam(name = "copyrightOwner", value = "版权方", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "_size", value = "返回条数", paramType = "query", dataType = "Integer")} @ApiImplicitParam(name = "startDate", value = "创建时间-开始", paramType = "query", dataType = "String"),
) @ApiImplicitParam(name = "endDate", value = "创建时间-结束", paramType = "query", dataType = "String")
})
@PostMapping("/getPageList") @PostMapping("/getPageList")
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
@RequiresPermissions("$!{cfg.colonTableName}:page") @RequiresPermissions("$!{cfg.colonTableName}:page")
#end #end
@ApiOperation(value = "获取${entity}分页列表", notes = "$!{table.comment}分页列表") @ApiOperation(value = "获取$!{table.comment}分页列表", notes = "获取$!{table.comment}分页列表")
public Map<String, Object> get${entity}PageList() { public Map<String, Object> get${entity}PageList(GenericPageParam genericPageParam) {
Page<${entity}> page = getPage(); LambdaQueryWrapper<${entity}> queryWrapper = new LambdaQueryWrapper<>();
QueryWrapper<${entity}> categoryWrapper = new QueryWrapper<>(); // 对名称或编码模糊查询
categoryWrapper.orderByDesc("SORT"); if (StringUtils.isNotBlank(genericPageParam.getNameOrCode())) {
IPage<${entity}> categoryPage = this.${table.entityPath}Service.page(page, categoryWrapper); queryWrapper.like(${entity}::getName, genericPageParam.getNameOrCode());
}
// 对版权方模糊查询
if (StringUtils.isNotBlank(genericPageParam.getCopyrightOwner())) {
queryWrapper.like(${entity}::getCopyrightOwner, genericPageParam.getCopyrightOwner());
}
// 根据创建时间区间检索
if (genericPageParam.getStartDate() != null && genericPageParam.getEndDate() != null) {
queryWrapper.ge(${entity}::getCreateTime, genericPageParam.getStartDate().atTime(0, 0, 0))
.le(AtomicIndex::getModifyDate, genericPageParam.getEndDate().atTime(23, 59, 59));
}
// 设置排序规则
queryWrapper.orderByDesc(${entity}::getCreateDate);
// 设置查询内容
queryWrapper.select(
${entity}::getId,
${entity}::getName,
${entity}::getAuditStatus,
${entity}::getCreateTime,
${entity}::getUpdateTime);
Page<${entity}> page = this.${table.entityPath}Service.page(getPage(), queryWrapper);
for (${entity} ${table.entityPath} : page.getRecords()) {
// 初始化返回对象 }
Map<String, Object> map = new HashMap<>(); return getResult(page);
map.put("data", categoryPage);
return getResult(map);
} }
/** @ApiOperation(value = "获取$!{table.comment}详情", notes = "获取$!{table.comment}详情")
* 获取$!{table.comment}
*
* @param id $!{table.comment}ID
*/
@ApiOperation(value = "获取${entity}对象详情", notes = "查看$!{table.comment}")
@ApiImplicitParams({ @ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "对象标识ID", dataType = "Long", paramType = "path") @ApiImplicitParam(name = "id", value = "标识ID", dataType = "String", paramType = "path")
}) })
@GetMapping("/get/{id}") @GetMapping("/get/{id}")
#if(${cfg.requiresPermissions}) #if(${cfg.requiresPermissions})
...@@ -219,133 +210,9 @@ public class ${table.controllerName} { ...@@ -219,133 +210,9 @@ public class ${table.controllerName} {
#end #end
public Map<String, Object> getById(@PathVariable("id") Long id) { public Map<String, Object> getById(@PathVariable("id") Long id) {
${entity} ${table.entityPath} = ${table.entityPath}Service.getById(id); ${entity} ${table.entityPath} = ${table.entityPath}Service.getById(id);
// 初始化返回对象 return getResult(${table.entityPath});
Map<String, Object> map = new HashMap<>();
map.put("data", ${table.entityPath});
return getResult(map);
} }
/**
* 通用排序方法(偏移量为1并且点击后实时触发保存)
*
* @param firstId 第一个待排序实体ID
* @param secondId 第二个待排序实体ID
* @return
*/
@PutMapping("/updateSortorderByOneStep")
public Map<String, Object> updateSortorderByOneStep(Long firstId, Long secondId) {
${entity} theFirst = this.${table.entityPath}Service.getById(firstId);
${entity} theSecond = this.${table.entityPath}Service.getById(secondId);
Long firstSortorder = theFirst.getSort();
Long secondSortorder = theSecond.getSort();
boolean flag = false;
if (firstSortorder > secondSortorder && firstSortorder > 1) {
flag = true;
theFirst.setSort(firstSortorder - 1L);
theSecond.setSort(secondSortorder + 1L);
} else if (firstSortorder < secondSortorder && secondSortorder > 1) {
flag = true;
theFirst.setSort(firstSortorder + 1L);
theSecond.setSort(secondSortorder - 1L);
}
if (flag) {
boolean firstResult = this.${table.entityPath}Service.updateById(theFirst);
boolean secondResult = this.${table.entityPath}Service.updateById(theSecond);
if (firstResult && secondResult) {
return getSuccessResult();
}
}
return getFailResult();
}
/**
* 通用排序方法(拖拽排序/所有排序完成后点击保存)
*
* @param sourceId 源实体ID
* @param targetId 目标实体ID
* @return Void
*/
@PutMapping("/updateSortorder")
public Map<String,Object> updateSortorder(Long sourceId, Long targetId) {
String moveType = null;
${entity} theSource = this.${table.entityPath}Service.getById(sourceId);
${entity} theTarget = this.${table.entityPath}Service.getById(targetId);
if(theSource.getSort() > theTarget.getSort()) {
moveType = "down";
} else {
moveType = "up";
}
Long sourceSortorder = theSource.getSort();
Long targetSortorder = theTarget.getSort();
boolean flag = false;
//默认sortorder为降序排序,向上移动
if ("up".equalsIgnoreCase(moveType) && sourceSortorder < targetSortorder) {
flag = true;
QueryWrapper<${entity}> wrapper = new QueryWrapper<>();
wrapper.between("sortorder", sourceSortorder, targetSortorder);
wrapper.select("id", "sortorder");
List<${entity}> list = this.${table.entityPath}Service.list(wrapper);
for (${entity} entity : list) {
if (!entity.getId().equals(sourceId)) {
entity.setSort(entity.getSort() - 1L);
this.${table.entityPath}Service.updateById(entity);
}
}
}
//默认sortorder为降序排序,向下移动
else if ("down".equalsIgnoreCase(moveType) && sourceSortorder > targetSortorder) {
flag = true;
QueryWrapper<${entity}> wrapper = new QueryWrapper<>();
wrapper.between("sortorder", targetSortorder, sourceSortorder);
wrapper.select("id", "sortorder");
List<${entity}> slideList = this.${table.entityPath}Service.list(wrapper);
for (${entity} entity : slideList) {
if (!entity.getId().equals(sourceId)) {
entity.setSort(entity.getSort() + 1L);
this.${table.entityPath}Service.updateById(entity);
}
}
}
//默认sortorder为正序排序,向下移动
else if ("down".equalsIgnoreCase(moveType) && sourceSortorder < targetSortorder) {
flag = true;
QueryWrapper<${entity}> wrapper = new QueryWrapper<>();
wrapper.between("sortorder", sourceSortorder, targetSortorder);
wrapper.select("id", "sortorder");
List<${entity}> slideList = this.${table.entityPath}Service.list(wrapper);
for (${entity} slide : slideList) {
if (!slide.getId().equals(sourceId)) {
slide.setSort(slide.getSort() - 1L);
this.${table.entityPath}Service.updateById(slide);
}
}
}
//默认sortorder为正序排序,向上移动
else if ("up".equalsIgnoreCase(moveType) && sourceSortorder > targetSortorder) {
flag = true;
QueryWrapper<${entity}> wrapper = new QueryWrapper<>();
wrapper.between("sortorder", targetSortorder, sourceSortorder);
wrapper.select("id", "sortorder");
List<${entity}> slideList = this.${table.entityPath}Service.list(wrapper);
for (${entity} slide : slideList) {
if (!slide.getId().equals(sourceId)) {
slide.setSort(slide.getSort() + 1L);
this.${table.entityPath}Service.updateById(slide);
}
}
}
if (flag) {
theSource.setSort(targetSortorder);
this.${table.entityPath}Service.updateById(theSource);
return getSuccessResult();
}
return getFailResult();
}
} }
#end #end
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment