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

@ -92,8 +92,7 @@ public class ${entityName}Controller extends BaseController {
@Log(title = "新增", businessType = BusinessType.INSERT) @Log(title = "新增", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody Add${entityName}PVO add${entityName}PVO) { public AjaxResult add(@RequestBody Add${entityName}PVO add${entityName}PVO) {
${entityName?uncap_first}Service.save(add${entityName}PVO); return ${entityName?uncap_first}Service.save${entityName}PVO(add${entityName}PVO);
return AjaxResult.success("新增成功!");
} }
/** /**
@ -105,9 +104,8 @@ public class ${entityName}Controller extends BaseController {
@ApiOperation(value="编辑", notes="编辑") @ApiOperation(value="编辑", notes="编辑")
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody Edit${entityName}PVO edit${entityName}PVO) { public AjaxResult edit(@RequestBody Edit${entityName}PVO edit${entityName}PVO) {
${entityName?uncap_first}Service.updateById(edit${entityName}PVO); return ${entityName?uncap_first}Service.modify${entityName}PVO(edit${entityName}PVO);
return AjaxResult.success("编辑成功!"); }
}
/** /**
* 删除 * 删除

@ -1,8 +1,11 @@
package ${bussiPackage}.service; package ${bussiPackage}.service;
import com.enjoy.common.core.web.domain.AjaxResult;
import com.enjoy.common.core.web.page.TableDataInfo; import com.enjoy.common.core.web.page.TableDataInfo;
import ${bussiPackage}.dto.${entityName}DTO; import ${bussiPackage}.dto.${entityName}DTO;
import ${bussiPackage}.vo.Query${entityName}VO; import ${bussiPackage}.vo.Query${entityName}VO;
import ${bussiPackage}.vo.Add${entityName}PVO;
import ${bussiPackage}.vo.Edit${entityName}PVO;
import ${bussiPackage}.${entityPackage}.${entityName}; import ${bussiPackage}.${entityPackage}.${entityName};
import com.baomidou.mybatisplus.extension.service.IService; 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); 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; package ${bussiPackage}.service.impl;
import com.enjoy.common.core.web.domain.AjaxResult;
import com.enjoy.oqc.utils.BeanHkUtils; import com.enjoy.oqc.utils.BeanHkUtils;
import com.enjoy.oqc.utils.CollectionUtil;
import com.enjoy.common.core.i18n.InternationalizationService; import com.enjoy.common.core.i18n.InternationalizationService;
import com.enjoy.common.core.constant.Constants; import com.enjoy.common.core.constant.Constants;
import com.enjoy.common.core.constant.HttpStatus; import com.enjoy.common.core.constant.HttpStatus;
@ -18,6 +20,8 @@ import ${bussiPackage}.dto.${entityName}DTO;
import ${bussiPackage}.vo.Query${entityName}VO; import ${bussiPackage}.vo.Query${entityName}VO;
import ${bussiPackage}.mapper.${entityName}Mapper; import ${bussiPackage}.mapper.${entityName}Mapper;
import ${bussiPackage}.service.I${entityName}Service; 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> </#if>
</#list> </#list>
List<${entityName}> dbEntityList = this.list(queryWrapper); List<${entityName}> dbEntityList = this.list(queryWrapper);
if(dbEntityList!=null &&dbEntityList.size()>0){ if (CollectionUtil.isNotEmpty(dbEntityList)) {
dbEntityList.stream().forEach(entity->{ dbEntityList.stream().forEach(entity->{
${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO(); ${entityName}DTO ${uncap_first}DTO=new ${entityName}DTO();
BeanHkUtils.copyProperties(entity,${uncap_first}DTO); BeanHkUtils.copyProperties(entity,${uncap_first}DTO);
@ -58,9 +62,33 @@ public class ${entityName}ServiceImpl extends ServiceImpl<${entityName}Mapper, $
rspData.setRows(list); rspData.setRows(list);
rspData.setMsg(internationalizationService.getMessage(Constants.QUERY_SUCCESS)); rspData.setMsg(internationalizationService.getMessage(Constants.QUERY_SUCCESS));
rspData.setTotal(new PageInfo(list).getTotal()); rspData.setTotal(new PageInfo(list).getTotal());
return rspData;
}catch(Exception e){ }catch(Exception e){
log.error("获取 分页异常:",e); log.error("获取 分页异常:",e);
} }
rspData.setCode(HttpStatus.BAD_REQUEST);
rspData.setMsg(internationalizationService.getMessage(Constants.OPERATION_ERROR));
rspData.setTotal(0);
return rspData; 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