master
周文涛 2 years ago
parent ac1f68031f
commit 9ec0948ba7

@ -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,8 +104,7 @@ 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);
}
/**

@ -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);
}

@ -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, $
</#if>
</#list>
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("编辑成功!");
}
}

Loading…
Cancel
Save