From 9ec0948ba7aa0a30e30396c78885cb200ba8d05b Mon Sep 17 00:00:00 2001 From: zhouwentao <1577701412@qq.com> Date: Mon, 14 Aug 2023 17:47:47 +0800 Subject: [PATCH] updates --- .../resources/yangliu/XXXController.javai | 10 +++---- src/main/resources/yangliu/XXXService.javai | 13 ++++++++ .../resources/yangliu/XXXServiceImpl.javai | 30 ++++++++++++++++++- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/src/main/resources/yangliu/XXXController.javai b/src/main/resources/yangliu/XXXController.javai index 00008fd..b92085f 100644 --- a/src/main/resources/yangliu/XXXController.javai +++ b/src/main/resources/yangliu/XXXController.javai @@ -92,8 +92,7 @@ public class ${entityName}Controller extends BaseController { @Log(title = "新增", businessType = BusinessType.INSERT) @PostMapping public AjaxResult add(@RequestBody Add${entityName}PVO add${entityName}PVO) { - ${entityName?uncap_first}Service.save(add${entityName}PVO); - return AjaxResult.success("新增成功!"); + return ${entityName?uncap_first}Service.save${entityName}PVO(add${entityName}PVO); } /** @@ -105,10 +104,9 @@ public class ${entityName}Controller extends BaseController { @ApiOperation(value="编辑", notes="编辑") @PutMapping public AjaxResult edit(@RequestBody Edit${entityName}PVO edit${entityName}PVO) { - ${entityName?uncap_first}Service.updateById(edit${entityName}PVO); - return AjaxResult.success("编辑成功!"); - } - + return ${entityName?uncap_first}Service.modify${entityName}PVO(edit${entityName}PVO); + } + /** * 删除 * @param id diff --git a/src/main/resources/yangliu/XXXService.javai b/src/main/resources/yangliu/XXXService.javai index f855d3f..162da04 100644 --- a/src/main/resources/yangliu/XXXService.javai +++ b/src/main/resources/yangliu/XXXService.javai @@ -1,8 +1,11 @@ package ${bussiPackage}.service; +import com.enjoy.common.core.web.domain.AjaxResult; import com.enjoy.common.core.web.page.TableDataInfo; import ${bussiPackage}.dto.${entityName}DTO; import ${bussiPackage}.vo.Query${entityName}VO; +import ${bussiPackage}.vo.Add${entityName}PVO; +import ${bussiPackage}.vo.Edit${entityName}PVO; import ${bussiPackage}.${entityPackage}.${entityName}; import com.baomidou.mybatisplus.extension.service.IService; @@ -17,4 +20,14 @@ public interface I${entityName}Service extends IService<${entityName}> { * 自定义分页 */ TableDataInfo pageList(Query${entityName}VO query${entityName}VO); + + /** + * 新增 + */ + AjaxResult save${entityName}PVO(Add${entityName}PVO add${entityName}PVO); + + /** + * 编辑 + */ + AjaxResult modify${entityName}PVO(Edit${entityName}PVO edit${entityName}PVO); } \ No newline at end of file diff --git a/src/main/resources/yangliu/XXXServiceImpl.javai b/src/main/resources/yangliu/XXXServiceImpl.javai index 147d546..dfc2631 100644 --- a/src/main/resources/yangliu/XXXServiceImpl.javai +++ b/src/main/resources/yangliu/XXXServiceImpl.javai @@ -1,6 +1,8 @@ package ${bussiPackage}.service.impl; +import com.enjoy.common.core.web.domain.AjaxResult; import com.enjoy.oqc.utils.BeanHkUtils; +import com.enjoy.oqc.utils.CollectionUtil; import com.enjoy.common.core.i18n.InternationalizationService; import com.enjoy.common.core.constant.Constants; import com.enjoy.common.core.constant.HttpStatus; @@ -18,6 +20,8 @@ import ${bussiPackage}.dto.${entityName}DTO; import ${bussiPackage}.vo.Query${entityName}VO; import ${bussiPackage}.mapper.${entityName}Mapper; import ${bussiPackage}.service.I${entityName}Service; +import ${bussiPackage}.vo.Add${entityName}PVO; +import ${bussiPackage}.vo.Edit${entityName}PVO; /** @@ -47,7 +51,7 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ List<${entityName}> dbEntityList = this.list(queryWrapper); - if(dbEntityList!=null &&dbEntityList.size()>0){ + if (CollectionUtil.isNotEmpty(dbEntityList)) { dbEntityList.stream().forEach(entity->{ ${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO(); BeanHkUtils.copyProperties(entity,${uncap_first}DTO); @@ -58,9 +62,33 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $ rspData.setRows(list); rspData.setMsg(internationalizationService.getMessage(Constants.QUERY_SUCCESS)); rspData.setTotal(new PageInfo(list).getTotal()); + return rspData; }catch(Exception e){ log.error("获取 分页异常:",e); } + rspData.setCode(HttpStatus.BAD_REQUEST); + rspData.setMsg(internationalizationService.getMessage(Constants.OPERATION_ERROR)); + rspData.setTotal(0); return rspData; } + /** + * 新增 + */ + @Override + public AjaxResult save${entityName}PVO(Add${entityName}PVO add${entityName}PVO){ + ${entityName} ${uncap_first}=new ${entityName}(); + ${uncap_first} =(${entityName}) BeanHkUtils.copyProperties(add${entityName}PVO,${uncap_first}); + this.save(${uncap_first}); + return AjaxResult.success("新增成功!"); + } + /** + * 编辑 + */ + @Override + public AjaxResult modify${entityName}PVO(Edit${entityName}PVO edit${entityName}PVO){ + ${entityName} ${uncap_first}=new ${entityName}(); + ${uncap_first} =(${entityName}) BeanHkUtils.copyProperties(edit${entityName}PVO,${uncap_first}); + this.updateById(${uncap_first}); + return AjaxResult.success("编辑成功!"); + } }