perf(流程分类): 优化流程分类代码书写格式
This commit is contained in:
@@ -38,7 +38,7 @@ import java.util.List;
|
||||
@RequestMapping("/workflow/category")
|
||||
public class WfCategoryController extends BaseController {
|
||||
|
||||
private final IWfCategoryService flowCategoryService;
|
||||
private final IWfCategoryService categoryService;
|
||||
|
||||
/**
|
||||
* 查询流程分类列表
|
||||
@@ -46,7 +46,7 @@ public class WfCategoryController extends BaseController {
|
||||
@SaCheckPermission("workflow:category:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<WfCategoryVo> list(@Validated(QueryGroup.class) WfCategoryBo bo, PageQuery pageQuery) {
|
||||
return flowCategoryService.queryPageList(bo, pageQuery);
|
||||
return categoryService.queryPageList(bo, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +55,7 @@ public class WfCategoryController extends BaseController {
|
||||
@SaCheckLogin
|
||||
@GetMapping("/listAll")
|
||||
public R<List<WfCategoryVo>> listAll(@Validated(QueryGroup.class) WfCategoryBo bo) {
|
||||
return R.ok(flowCategoryService.queryList(bo));
|
||||
return R.ok(categoryService.queryList(bo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public class WfCategoryController extends BaseController {
|
||||
@Log(title = "流程分类", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(@Validated WfCategoryBo bo, HttpServletResponse response) {
|
||||
List<WfCategoryVo> list = flowCategoryService.queryList(bo);
|
||||
List<WfCategoryVo> list = categoryService.queryList(bo);
|
||||
ExcelUtil.exportExcel(list, "流程分类", WfCategoryVo.class, response);
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class WfCategoryController extends BaseController {
|
||||
@SaCheckPermission("workflow:category:query")
|
||||
@GetMapping("/{categoryId}")
|
||||
public R<WfCategoryVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable("categoryId") Long categoryId) {
|
||||
return R.ok(flowCategoryService.queryById(categoryId));
|
||||
return R.ok(categoryService.queryById(categoryId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,8 +86,8 @@ public class WfCategoryController extends BaseController {
|
||||
@Log(title = "流程分类", businessType = BusinessType.INSERT)
|
||||
@RepeatSubmit()
|
||||
@PostMapping()
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WfCategoryBo bo) {
|
||||
return toAjax(flowCategoryService.insertByBo(bo) ? 1 : 0);
|
||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody WfCategoryBo categoryBo) {
|
||||
return toAjax(categoryService.insertCategory(categoryBo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,8 +97,8 @@ public class WfCategoryController extends BaseController {
|
||||
@Log(title = "流程分类", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WfCategoryBo bo) {
|
||||
return toAjax(flowCategoryService.updateByBo(bo) ? 1 : 0);
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody WfCategoryBo categoryBo) {
|
||||
return toAjax(categoryService.updateCategory(categoryBo));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,6 +109,6 @@ public class WfCategoryController extends BaseController {
|
||||
@Log(title = "流程分类" , businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{categoryIds}")
|
||||
public R<Void> remove(@NotEmpty(message = "主键不能为空") @PathVariable Long[] categoryIds) {
|
||||
return toAjax(flowCategoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true) ? 1 : 0);
|
||||
return toAjax(categoryService.deleteWithValidByIds(Arrays.asList(categoryIds), true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,27 +29,28 @@ public interface IWfCategoryService {
|
||||
/**
|
||||
* 查询列表
|
||||
*/
|
||||
List<WfCategoryVo> queryList(WfCategoryBo bo);
|
||||
List<WfCategoryVo> queryList(WfCategoryBo categoryBo);
|
||||
|
||||
/**
|
||||
* 根据新增业务对象插入【请填写功能名称】
|
||||
* @param bo 【请填写功能名称】新增业务对象
|
||||
* @return
|
||||
* 新增流程分类
|
||||
*
|
||||
* @param categoryBo 流程分类信息
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean insertByBo(WfCategoryBo bo);
|
||||
int insertCategory(WfCategoryBo categoryBo);
|
||||
|
||||
/**
|
||||
* 根据编辑业务对象修改【请填写功能名称】
|
||||
* @param bo 【请填写功能名称】编辑业务对象
|
||||
* @return
|
||||
* 编辑流程分类
|
||||
* @param categoryBo 流程分类信息
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean updateByBo(WfCategoryBo bo);
|
||||
int updateCategory(WfCategoryBo categoryBo);
|
||||
|
||||
/**
|
||||
* 校验并删除数据
|
||||
* @param ids 主键集合
|
||||
* @param isValid 是否校验,true-删除前校验,false-不校验
|
||||
* @return
|
||||
* @return 结果
|
||||
*/
|
||||
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
int deleteWithValidByIds(Collection<Long> ids, Boolean isValid);
|
||||
}
|
||||
|
||||
@@ -37,58 +37,43 @@ public class WfCategoryServiceImpl implements IWfCategoryService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDataInfo<WfCategoryVo> queryPageList(WfCategoryBo bo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WfCategory> lqw = buildQueryWrapper(bo);
|
||||
public TableDataInfo<WfCategoryVo> queryPageList(WfCategoryBo categoryBo, PageQuery pageQuery) {
|
||||
LambdaQueryWrapper<WfCategory> lqw = buildQueryWrapper(categoryBo);
|
||||
Page<WfCategoryVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<WfCategoryVo> queryList(WfCategoryBo bo) {
|
||||
LambdaQueryWrapper<WfCategory> lqw = buildQueryWrapper(bo);
|
||||
public List<WfCategoryVo> queryList(WfCategoryBo categoryBo) {
|
||||
LambdaQueryWrapper<WfCategory> lqw = buildQueryWrapper(categoryBo);
|
||||
return baseMapper.selectVoList(lqw);
|
||||
}
|
||||
|
||||
private LambdaQueryWrapper<WfCategory> buildQueryWrapper(WfCategoryBo bo) {
|
||||
Map<String, Object> params = bo.getParams();
|
||||
private LambdaQueryWrapper<WfCategory> buildQueryWrapper(WfCategoryBo categoryBo) {
|
||||
Map<String, Object> params = categoryBo.getParams();
|
||||
LambdaQueryWrapper<WfCategory> lqw = Wrappers.lambdaQuery();
|
||||
lqw.like(StringUtils.isNotBlank(bo.getCategoryName()), WfCategory::getCategoryName, bo.getCategoryName());
|
||||
lqw.eq(StringUtils.isNotBlank(bo.getCode()), WfCategory::getCode, bo.getCode());
|
||||
lqw.like(StringUtils.isNotBlank(categoryBo.getCategoryName()), WfCategory::getCategoryName, categoryBo.getCategoryName());
|
||||
lqw.eq(StringUtils.isNotBlank(categoryBo.getCode()), WfCategory::getCode, categoryBo.getCode());
|
||||
return lqw;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean insertByBo(WfCategoryBo bo) {
|
||||
WfCategory add = BeanUtil.toBean(bo, WfCategory.class);
|
||||
validEntityBeforeSave(add);
|
||||
boolean flag = baseMapper.insert(add) > 0;
|
||||
if (flag) {
|
||||
bo.setCategoryId(add.getCategoryId());
|
||||
}
|
||||
return flag;
|
||||
public int insertCategory(WfCategoryBo categoryBo) {
|
||||
WfCategory add = BeanUtil.toBean(categoryBo, WfCategory.class);
|
||||
return baseMapper.insert(add);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateByBo(WfCategoryBo bo) {
|
||||
WfCategory update = BeanUtil.toBean(bo, WfCategory.class);
|
||||
validEntityBeforeSave(update);
|
||||
return baseMapper.updateById(update) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存前的数据校验
|
||||
*
|
||||
* @param entity 实体类数据
|
||||
*/
|
||||
private void validEntityBeforeSave(WfCategory entity){
|
||||
//TODO 做一些数据校验,如唯一约束
|
||||
public int updateCategory(WfCategoryBo categoryBo) {
|
||||
WfCategory update = BeanUtil.toBean(categoryBo, WfCategory.class);
|
||||
return baseMapper.updateById(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
public int deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
|
||||
if(isValid){
|
||||
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
}
|
||||
return baseMapper.deleteBatchIds(ids) > 0;
|
||||
return baseMapper.deleteBatchIds(ids);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user