Commit a8bfaf25 authored by 李丛阳's avatar 李丛阳

完善 ftl

parent 94b2ca18
...@@ -13,6 +13,12 @@ import org.rcisoft.core.result.Result; ...@@ -13,6 +13,12 @@ import org.rcisoft.core.result.Result;
import org.rcisoft.core.result.ResultServiceEnums; import org.rcisoft.core.result.ResultServiceEnums;
import org.rcisoft.core.model.PersistModel; import org.rcisoft.core.model.PersistModel;
import org.rcisoft.core.constant.MessageConstant; import org.rcisoft.core.constant.MessageConstant;
import org.rcisoft.common.controller.PaginationController;
import org.rcisoft.core.util.UserUtil;
import org.rcisoft.common.model.GridModel;
import org.rcisoft.core.exception.ServiceException;
import javax.validation.Valid;
import org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName}; import org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName};
import org.rcisoft.business.${table.entityName?lower_case}.service.${table.entityName}Service; import org.rcisoft.business.${table.entityName?lower_case}.service.${table.entityName}Service;
...@@ -36,6 +42,7 @@ public class ${table.entityName}Controller extends PaginationController<${table. ...@@ -36,6 +42,7 @@ public class ${table.entityName}Controller extends PaginationController<${table.
public Result add(@Valid ${table.entityName} ${table.entityName?uncap_first}, BindingResult bindingResult) { public Result add(@Valid ${table.entityName} ${table.entityName?uncap_first}, BindingResult bindingResult) {
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(), throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(),
bindingResult.getFieldError().getDefaultMessage());
} }
${table.entityName?uncap_first}.setToken(getToken()); ${table.entityName?uncap_first}.setToken(getToken());
PersistModel data = ${table.entityName?uncap_first}ServiceImpl.save(${table.entityName?uncap_first}); PersistModel data = ${table.entityName?uncap_first}ServiceImpl.save(${table.entityName?uncap_first});
...@@ -49,7 +56,7 @@ public class ${table.entityName}Controller extends PaginationController<${table. ...@@ -49,7 +56,7 @@ public class ${table.entityName}Controller extends PaginationController<${table.
@ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")}) @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "id", required = false, dataType = "varchar")})
@DeleteMapping("/{id:\\d+}") @DeleteMapping("/{id:\\d+}")
public Result delete(@PathVariable String id) { public Result delete(@PathVariable String id) {
${table.entityName} ${table.entityName?uncap_first} = new ${table.entityName?uncap_first}(); ${table.entityName} ${table.entityName?uncap_first} = new ${table.entityName}();
${table.entityName?uncap_first}.setBusinessId(id); ${table.entityName?uncap_first}.setBusinessId(id);
${table.entityName?uncap_first}.setToken(getToken()); ${table.entityName?uncap_first}.setToken(getToken());
PersistModel data = ${table.entityName?uncap_first}ServiceImpl.remove(${table.entityName?uncap_first}); PersistModel data = ${table.entityName?uncap_first}ServiceImpl.remove(${table.entityName?uncap_first});
...@@ -62,9 +69,10 @@ public class ${table.entityName}Controller extends PaginationController<${table. ...@@ -62,9 +69,10 @@ public class ${table.entityName}Controller extends PaginationController<${table.
@ApiOperation(value="修改${table.tableRemark!}", notes="修改${table.tableRemark!}") @ApiOperation(value="修改${table.tableRemark!}", notes="修改${table.tableRemark!}")
@ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")}) @ApiImplicitParams({@ApiImplicitParam(name = "businessId", value = "businessId", required = false, dataType = "varchar")})
@PutMapping("/{id:\\d+}") @PutMapping("/{id:\\d+}")
public Result update(${table.entityName} ${table.entityName?uncap_first}) { public Result update(@Valid ${table.entityName} ${table.entityName?uncap_first}, BindingResult bindingResult) {
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(), throw new ServiceException(ResultServiceEnums.PARAMETER_ERROR.getCode(),
bindingResult.getFieldError().getDefaultMessage());
} }
${table.entityName?uncap_first}.setToken(getToken()); ${table.entityName?uncap_first}.setToken(getToken());
PersistModel data = ${table.entityName?uncap_first}ServiceImpl.merge(${table.entityName?uncap_first}); PersistModel data = ${table.entityName?uncap_first}ServiceImpl.merge(${table.entityName?uncap_first});
......
package org.rcisoft.business.${table.entityName?lower_case}.dao; package org.rcisoft.business.${table.entityName?lower_case}.dao;
import org.rcisoft.core.base.BaseMapper import org.rcisoft.core.base.BaseMapper;
import org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName}; import org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName};
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List; import java.util.List;
......
package org.rcisoft.business.${table.entityName?lower_case}.service.impl; package org.rcisoft.business.${table.entityName?lower_case}.service.impl;
import org.rcisoft.core.util.UserUtil; import org.rcisoft.core.util.UserUtil;
import org.rcisoft.core.aop.PageUtil;
import org.rcisoft.core.model.PersistModel;
import org.rcisoft.business.${table.entityName?lower_case}.dao.${table.entityName}Repository; import org.rcisoft.business.${table.entityName?lower_case}.dao.${table.entityName}Repository;
import org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName}; import org.rcisoft.business.${table.entityName?lower_case}.entity.${table.entityName};
import org.rcisoft.business.${table.entityName?lower_case}.service.${table.entityName}Service; import org.rcisoft.business.${table.entityName?lower_case}.service.${table.entityName}Service;
...@@ -12,6 +14,8 @@ import org.springframework.transaction.annotation.Isolation; ...@@ -12,6 +14,8 @@ import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
...@@ -33,11 +37,11 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic ...@@ -33,11 +37,11 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
PersistModel save(${table.entityName} ${table.entityName?uncap_first}){ public PersistModel save(${table.entityName} ${table.entityName?uncap_first}){
${table.entityName?uncap_first}.setCommonBusinessId(); ${table.entityName?uncap_first}.setCommonBusinessId();
//增加操作 //增加操作
UserUtil.setCurrentPersistOperation(${table.entityName?uncap_first}); UserUtil.setCurrentPersistOperation(${table.entityName?uncap_first});
int line = ${table.entityName?uncap_first}Repository.insertSelective(${table.entityName?uncap_first}Repository); int line = ${table.entityName?uncap_first}Repository.insertSelective(${table.entityName?uncap_first});
log.info(UserUtil.getUserInfoProp(${table.entityName?uncap_first}.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+ log.info(UserUtil.getUserInfoProp(${table.entityName?uncap_first}.getToken(),UserUtil.USER_USERNAME)+"新增了ID为"+
${table.entityName?uncap_first}.getBusinessId()+"的信息"); ${table.entityName?uncap_first}.getBusinessId()+"的信息");
return new PersistModel(line); return new PersistModel(line);
...@@ -45,12 +49,12 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic ...@@ -45,12 +49,12 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
/** /**
* 逻辑删除 * 逻辑删除
* @param id * @param ${table.entityName?uncap_first}
* @return * @return
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
PersistModel remove(${table.entityName} ${table.entityName?uncap_first}){ public PersistModel remove(${table.entityName} ${table.entityName?uncap_first}){
UserUtil.setCurrentMergeOperation(${table.entityName?uncap_first}); UserUtil.setCurrentMergeOperation(${table.entityName?uncap_first});
int line = ${table.entityName?uncap_first}Repository.logicalDelete(${table.entityName?uncap_first}); int line = ${table.entityName?uncap_first}Repository.logicalDelete(${table.entityName?uncap_first});
log.info(UserUtil.getUserInfoProp(${table.entityName?uncap_first}.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+ log.info(UserUtil.getUserInfoProp(${table.entityName?uncap_first}.getToken(),UserUtil.USER_USERNAME)+"逻辑删除了ID为"+
...@@ -65,7 +69,7 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic ...@@ -65,7 +69,7 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
*/ */
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT) @Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
@Override @Override
PersistModel merge(${table.entityName} ${table.entityName?uncap_first}){ public PersistModel merge(${table.entityName} ${table.entityName?uncap_first}){
UserUtil.setCurrentMergeOperation(${table.entityName?uncap_first}); UserUtil.setCurrentMergeOperation(${table.entityName?uncap_first});
int line = ${table.entityName?uncap_first}Repository.updateByPrimaryKeySelective(${table.entityName?uncap_first}); int line = ${table.entityName?uncap_first}Repository.updateByPrimaryKeySelective(${table.entityName?uncap_first});
log.info(UserUtil.getUserInfoProp(${table.entityName?uncap_first}.getToken(),UserUtil.USER_USERNAME)+"修改了ID为"+ log.info(UserUtil.getUserInfoProp(${table.entityName?uncap_first}.getToken(),UserUtil.USER_USERNAME)+"修改了ID为"+
...@@ -78,16 +82,16 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic ...@@ -78,16 +82,16 @@ public class ${table.entityName}ServiceImpl implements ${table.entityName}Servic
* @param id * @param id
* @return * @return
*/ */
${table.entityName} findById(String id){ public ${table.entityName} findById(String id){
return ${table.entityName?uncap_first}Repository.selectByPrimaryKey(id); return ${table.entityName?uncap_first}Repository.selectByPrimaryKey(id);
} }
/** /**
* 分页查询 ${table.entityName?uncap_first} * 分页查询 ${table.entityName?uncap_first}
* @param id * @param ${table.entityName?uncap_first}
* @return * @return
*/ */
List<${table.entityName}> findAllByPagination(PageUtil<${table.entityName}> paginationUtility, public List<${table.entityName}> findAllByPagination(PageUtil<${table.entityName}> paginationUtility,
${table.entityName} ${table.entityName?uncap_first}){ ${table.entityName} ${table.entityName?uncap_first}){
return ${table.entityName?uncap_first}Repository.query${table.entityName}s(${table.entityName?uncap_first}); return ${table.entityName?uncap_first}Repository.query${table.entityName}s(${table.entityName?uncap_first});
} }
......
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