121 lines
6.6 KiB
Plaintext
121 lines
6.6 KiB
Plaintext
|
package ${basePackage}.controller.apis.${lowerTableName};
|
|||
|
|
|||
|
import com.cm.common.annotation.CheckRequestBodyAnnotation;
|
|||
|
import com.cm.common.base.AbstractController;
|
|||
|
import com.cm.common.component.SecurityComponent;
|
|||
|
import com.cm.common.constants.ISystemConstant;
|
|||
|
import com.cm.common.exception.RemoveException;
|
|||
|
import com.cm.common.exception.SearchException;
|
|||
|
import com.cm.common.pojo.ListPage;
|
|||
|
import com.cm.common.pojo.dtos.CurrentUserIdInfoDTO;
|
|||
|
import com.cm.common.result.ErrorResult;
|
|||
|
import com.cm.common.result.SuccessResult;
|
|||
|
import com.cm.common.result.SuccessResultData;
|
|||
|
import com.cm.common.result.SuccessResultList;
|
|||
|
import ${basePackage}.pojo.dtos.${lowerTableName}.${firstUpperTableName}DTO;
|
|||
|
import ${basePackage}.pojo.vos.${lowerTableName}.${firstUpperTableName}VO;
|
|||
|
import ${basePackage}.service.${lowerTableName}.I${firstUpperTableName}Service;
|
|||
|
import io.swagger.annotations.*;
|
|||
|
import org.springframework.beans.factory.annotation.Autowired;
|
|||
|
import org.springframework.web.bind.annotation.*;
|
|||
|
|
|||
|
import java.util.Arrays;
|
|||
|
import java.util.List;
|
|||
|
import java.util.Map;
|
|||
|
|
|||
|
/**
|
|||
|
* @ClassName: ${firstUpperTableName}Controller
|
|||
|
* @Description: ${tableExplain}
|
|||
|
* @Author: ${author}
|
|||
|
* @Date: ${date}
|
|||
|
* @Version: ${version}
|
|||
|
**/
|
|||
|
@Api(tags = ISystemConstant.API_TAGS_SYSTEM_PREFIX + "${tableExplain}接口")
|
|||
|
@RestController
|
|||
|
@RequestMapping(ISystemConstant.API_PREFIX + "/${lowerTableName}")
|
|||
|
public class ${firstUpperTableName}Controller extends AbstractController {
|
|||
|
|
|||
|
@Autowired
|
|||
|
private I${firstUpperTableName}Service ${firstLowerTableName}Service;
|
|||
|
@Autowired
|
|||
|
private SecurityComponent securityComponent;
|
|||
|
|
|||
|
@ApiOperation(value = "新增${tableExplain}", notes = "新增${tableExplain}接口")
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@PostMapping("save${lowerTableName}")
|
|||
|
@CheckRequestBodyAnnotation
|
|||
|
public SuccessResult save${firstUpperTableName}(@RequestBody ${firstUpperTableName}VO ${firstLowerTableName}VO) throws Exception {
|
|||
|
return ${firstLowerTableName}Service.save${firstUpperTableName}(${firstLowerTableName}VO);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "删除${tableExplain}(id列表)", notes = "删除${tableExplain}(id列表)接口")
|
|||
|
@ApiImplicitParams({
|
|||
|
@ApiImplicitParam(name = "ids", value = "ID列表,用下划线分隔", paramType = "path", example = "1_2_3")
|
|||
|
})
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@DeleteMapping("remove${lowerTableName}/{ids}")
|
|||
|
public SuccessResult remove${firstUpperTableName}(@PathVariable("ids") String ids) throws RemoveException {
|
|||
|
return ${firstLowerTableName}Service.remove${firstUpperTableName}(ids);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "修改${tableExplain}", notes = "修改${tableExplain}接口")
|
|||
|
@ApiImplicitParams({
|
|||
|
@ApiImplicitParam(name = "${firstLowerTableName}Id", value = "${tableExplain}ID", paramType = "path")
|
|||
|
})
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@PutMapping("update${lowerTableName}/{${firstLowerTableName}Id}")
|
|||
|
@CheckRequestBodyAnnotation
|
|||
|
public SuccessResult update${firstUpperTableName}(@PathVariable("${firstLowerTableName}Id") String ${firstLowerTableName}Id, @RequestBody ${firstUpperTableName}VO ${firstLowerTableName}VO) throws Exception {
|
|||
|
return ${firstLowerTableName}Service.update${firstUpperTableName}(${firstLowerTableName}Id, ${firstLowerTableName}VO);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "${tableExplain}详情(通过ID)", notes = "${tableExplain}详情(通过ID)接口")
|
|||
|
@ApiImplicitParams({
|
|||
|
@ApiImplicitParam(name = "${firstLowerTableName}Id", value = "${tableExplain}ID", paramType = "path")
|
|||
|
})
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@GetMapping("get${lowerTableName}byid/{${firstLowerTableName}Id}")
|
|||
|
public ${firstUpperTableName}DTO get${firstUpperTableName}ById(@PathVariable("${firstLowerTableName}Id") String ${firstLowerTableName}Id) throws SearchException {
|
|||
|
return ${firstLowerTableName}Service.get${firstUpperTableName}ById(${firstLowerTableName}Id);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "${tableExplain}列表", notes = "${tableExplain}列表接口")
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@GetMapping("list${lowerTableName}")
|
|||
|
public List<${firstUpperTableName}DTO> list${firstUpperTableName}() throws SearchException {
|
|||
|
Map<String, Object> params = requestParams();
|
|||
|
return ${firstLowerTableName}Service.list${firstUpperTableName}(params);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "${tableExplain}分页列表", notes = "${tableExplain}分页列表接口")
|
|||
|
@ApiImplicitParams({
|
|||
|
@ApiImplicitParam(name = "page", value = "当前页码", paramType = "query", dataType = "int", defaultValue = "1"),
|
|||
|
@ApiImplicitParam(name = "rows", value = "显示数量", paramType = "query", dataType = "int", defaultValue = "20"),
|
|||
|
@ApiImplicitParam(name = "keywords", value = "关键字", paramType = "query", dataType = "String"),
|
|||
|
@ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataType = "String"),
|
|||
|
@ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataType = "String")
|
|||
|
})
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@GetMapping("listpage${lowerTableName}")
|
|||
|
public SuccessResultList<List<${firstUpperTableName}DTO>> listPage${firstUpperTableName}(ListPage page) throws SearchException {
|
|||
|
Map<String, Object> params = requestParams();
|
|||
|
page.setParams(params);
|
|||
|
return ${firstLowerTableName}Service.listPage${firstUpperTableName}(page);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "${tableExplain}统计", notes = "${tableExplain}统计接口")
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@GetMapping("count${lowerTableName}")
|
|||
|
SuccessResultData<Integer> count${firstUpperTableName}() throws SearchException {
|
|||
|
Map<String, Object> params = requestParams();
|
|||
|
return ${firstLowerTableName}Service.count${firstUpperTableName}(params);
|
|||
|
}
|
|||
|
|
|||
|
@ApiOperation(value = "当前用户id信息", notes = "当前用户id信息接口")
|
|||
|
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
|
|||
|
@GetMapping("getcurrentuseridinfo")
|
|||
|
public CurrentUserIdInfoDTO getCurrentUserIdInfo() {
|
|||
|
return securityComponent.getCurrentUserIdInfo();
|
|||
|
}
|
|||
|
|
|||
|
}
|