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

完善 ftl

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