pms服务改造首上传
This commit is contained in:
92
src/test/resources/generator/template/controller-restful.ftl
Normal file
92
src/test/resources/generator/template/controller-restful.ftl
Normal file
@@ -0,0 +1,92 @@
|
||||
package ${basePackage}.web;
|
||||
|
||||
import com.deer.wms.project.seed.annotation.OperateLog;
|
||||
import com.deer.wms.project.seed.constant.SystemManageConstant;
|
||||
import com.deer.wms.project.seed.core.result.CommonCode;
|
||||
import com.deer.wms.project.seed.core.result.Result;
|
||||
import com.deer.wms.project.seed.core.result.ResultGenerator;
|
||||
import ${basePackage}.model.${modelNameUpperCamel};
|
||||
import ${basePackage}.model.${modelNameUpperCamel}Params;
|
||||
import ${basePackage}.service.${modelNameUpperCamel}Service;
|
||||
import com.deer.wms.intercept.annotation.User;
|
||||
import com.deer.wms.intercept.common.data.CurrentUser;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Created by ${author} on ${date}.
|
||||
*/
|
||||
@Api(description = "xxx接口")
|
||||
@RestController
|
||||
@RequestMapping("${baseRequestMapping}s")
|
||||
public class ${modelNameUpperCamel}Controller {
|
||||
|
||||
@Autowired
|
||||
private ${modelNameUpperCamel}Service ${modelNameLowerCamel}Service;
|
||||
|
||||
@OperateLog(description = "添加xxx", type = "增加")
|
||||
@ApiOperation(value = "添加xxx", notes = "添加xxx")
|
||||
@PostMapping("/add")
|
||||
public Result add(@RequestBody ${modelNameUpperCamel} ${modelNameLowerCamel}, @ApiIgnore @User CurrentUser currentUser) {
|
||||
if(currentUser==null){
|
||||
return ResultGenerator.genFailResult( CommonCode.SERVICE_ERROR,"未登录错误",null );
|
||||
}
|
||||
${modelNameLowerCamel}.setCreateTime(new Date());
|
||||
${modelNameLowerCamel}.setCompanyId(currentUser.getCompanyId());
|
||||
${modelNameLowerCamel}Service.save(${modelNameLowerCamel});
|
||||
return ResultGenerator.genSuccessResult();
|
||||
}
|
||||
|
||||
@OperateLog(description = "删除xxx", type = "删除")
|
||||
@ApiOperation(value = "删除xxx", notes = "删除xxx")
|
||||
@DeleteMapping("/delete/{id}")
|
||||
public Result delete(@PathVariable ${type} Id) {
|
||||
${modelNameLowerCamel}Service.deleteById(${modelNameLowerCamel}Id);
|
||||
return ResultGenerator.genSuccessResult();
|
||||
}
|
||||
|
||||
@OperateLog(description = "修改xxx", type = "更新")
|
||||
@ApiOperation(value = "修改xxx", notes = "修改xxx")
|
||||
@PostMapping("/update")
|
||||
public Result update(@RequestBody ${modelNameUpperCamel} ${modelNameLowerCamel}) {
|
||||
${modelNameLowerCamel}.setUpdateTime(new Date());
|
||||
${modelNameLowerCamel}Service.update(${modelNameLowerCamel});
|
||||
return ResultGenerator.genSuccessResult();
|
||||
}
|
||||
|
||||
@GetMapping("/detail/{id}")
|
||||
public Result detail(@PathVariable ${type} id) {
|
||||
${modelNameUpperCamel} ${modelNameLowerCamel} = ${modelNameLowerCamel}Service.findById(id);
|
||||
return ResultGenerator.genSuccessResult(${modelNameLowerCamel});
|
||||
}
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result list(${modelNameUpperCamel}Params params, @ApiIgnore @User CurrentUser currentUser) {
|
||||
if(currentUser==null){
|
||||
return ResultGenerator.genFailResult(CommonCode.SERVICE_ERROR,"未登录错误",null );
|
||||
}
|
||||
|
||||
if (currentUser.getCompanyType() != SystemManageConstant.COMPANY_TYPE_MT){
|
||||
params.setCompanyId(currentUser.getCompanyId());
|
||||
}else{
|
||||
params.setCompanyId(null);
|
||||
}
|
||||
PageHelper.startPage(params.getPageNum(), params.getPageSize());
|
||||
List<${modelNameUpperCamel}> list = ${modelNameLowerCamel}Service.findList(params);
|
||||
PageInfo pageInfo = new PageInfo(list);
|
||||
return ResultGenerator.genSuccessResult(pageInfo);
|
||||
}
|
||||
|
||||
}
|
||||
9
src/test/resources/generator/template/params.ftl
Normal file
9
src/test/resources/generator/template/params.ftl
Normal file
@@ -0,0 +1,9 @@
|
||||
package ${basePackage}.model;
|
||||
|
||||
import com.deer.wms.project.seed.core.service.QueryParams;
|
||||
|
||||
/**
|
||||
* Created by ${author} on ${date}.
|
||||
*/
|
||||
public class ${modelNameUpperCamel}Params extends QueryParams {
|
||||
}
|
||||
29
src/test/resources/generator/template/service-impl.ftl
Normal file
29
src/test/resources/generator/template/service-impl.ftl
Normal file
@@ -0,0 +1,29 @@
|
||||
package ${basePackage}.service.impl;
|
||||
|
||||
import ${basePackage}.dao.${modelNameUpperCamel}Mapper;
|
||||
import ${basePackage}.model.${modelNameUpperCamel};
|
||||
import ${basePackage}.model.${modelNameUpperCamel}Params;
|
||||
import ${basePackage}.service.${modelNameUpperCamel}Service;
|
||||
|
||||
import com.deer.wms.project.seed.core.service.AbstractService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ${author} on ${date}.
|
||||
*/
|
||||
@Service
|
||||
@Transactional
|
||||
public class ${modelNameUpperCamel}ServiceImpl extends AbstractService<${modelNameUpperCamel}, ${type}> implements ${modelNameUpperCamel}Service {
|
||||
|
||||
@Autowired
|
||||
private ${modelNameUpperCamel}Mapper ${modelNameLowerCamel}Mapper;
|
||||
|
||||
|
||||
@Override
|
||||
public List<${modelNameUpperCamel}> findList(${modelNameUpperCamel}Params params) {
|
||||
return ${modelNameLowerCamel}Mapper.findList(params);
|
||||
}
|
||||
}
|
||||
17
src/test/resources/generator/template/service.ftl
Normal file
17
src/test/resources/generator/template/service.ftl
Normal file
@@ -0,0 +1,17 @@
|
||||
package ${basePackage}.service;
|
||||
|
||||
import ${basePackage}.model.${modelNameUpperCamel};
|
||||
import ${basePackage}.model.${modelNameUpperCamel}Params;
|
||||
|
||||
import com.deer.wms.project.seed.core.service.Service;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by ${author} on ${date}.
|
||||
*/
|
||||
public interface ${modelNameUpperCamel}Service extends Service<${modelNameUpperCamel}, ${type}> {
|
||||
|
||||
|
||||
List<${modelNameUpperCamel}> findList(${modelNameUpperCamel}Params params) ;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user