package ${basePackage}.controller.manage; import java.util.List; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.PathVariable; import ${basePackage}.bean.entity.${entityClassSimpleName}; import ${basePackage}.constants.GlobalConstants; import ${basePackage}.service.${serviceClassSimpleName}; import com.taover.util.UtilHttpRequestMap; import com.taover.util.bean.ResultInfo; @RestController("manage.${controllerMap}") @RequestMapping("/manage/${controllerMap}") public class ${controllerClassName} { @Resource private ${serviceClassSimpleName} ${serviceClassFieldName}; /** * @apiDefine ResultInfo * @apiSuccess {string} * @apiSuccessExample {json} Success-Response: * { * code:ok, * error:null * } * @apiError ThrowException 出现异常 * @apiErrorExample * { * code:fail, * error:null exception * } */ /** * @api {GET} /manage/${controllerMap} 查询${controllerMap}列表 * @apiDescription 查询${controllerMap}列表数据 * 返回分页结果 * * @apiGroup ${controllerMap} * @apiName ${controllerMap}列表 * @apiVersion 1.0.0 * @apiHeader Authorization * * @apiUse ResultInfo */ @GetMapping public ResultInfo get(HttpServletRequest request){ String pageStr = request.getParameter("page"); if(StringUtils.isEmpty(pageStr)){ pageStr = ""+GlobalConstants.DEFAULT_QUERY_PAGE; } String sizeStr = request.getParameter("size"); if(StringUtils.isEmpty(sizeStr)){ sizeStr = ""+GlobalConstants.DEFAULT_QUERY_PAGE_SIZE; } List condition = UtilHttpRequestMap.getSqlConditionListByRequestMap(request.getParameterMap(), ${entityClassSimpleName}.class, "page,size"); return this.${serviceClassFieldName}.getListManage(condition, Integer.valueOf(pageStr), Integer.valueOf(sizeStr)); } /** * @api {GET} /manage/${controllerMap}/{id} 查询id对应的${controllerMap} * @apiDescription 查询ssid对应${controllerMap}数据 * * @apiGroup ${controllerMap} * @apiName get实体数据 * @apiVersion 1.0.0 * @apiHeader Authorization * * @apiUse ResultInfo */ @GetMapping("/{id}") public ResultInfo get(@PathVariable Integer id){ return this.${serviceClassFieldName}.getOneManage(id); } /** * @api {POST} /manage/${controllerMap} 创建${controllerMap} * @apiDescription 创建${controllerMap} * * @apiGroup ${controllerMap} * @apiName get实体数据 * @apiVersion 1.0.0 * @apiHeader Authorization * * @apiUse ResultInfo */ @PostMapping public ResultInfo post(HttpServletRequest request){ return this.${serviceClassFieldName}.postManage(UtilHttpRequestMap.getMapValueStringByRequestMap(request.getParameterMap())); } /** * @api {DELETE} /manage/${controllerMap}/{id} 删除id对应的${controllerMap} * @apiDescription 删除id对应的${controllerMap}数据 * * @apiGroup ${controllerMap} * @apiName 删除实体数据 * @apiVersion 1.0.0 * @apiHeader Authorization * * @apiUse ResultInfo */ @DeleteMapping("/{id}") public ResultInfo delete(@PathVariable Integer id){ return this.${serviceClassFieldName}.deleteManage(id); } /** * @api {PUT} /manage/${controllerMap}/{id} 修改${controllerMap}数据 * @apiDescription 修改${controllerMap}数据 * * @apiGroup ${controllerMap} * @apiName 修改实体数据 * @apiVersion 1.0.0 * @apiHeader Authorization * * @apiUse ResultInfo */ @PutMapping("/{id}") public ResultInfo put(@PathVariable Integer id, HttpServletRequest request){ return this.${serviceClassFieldName}.putManage(id, UtilHttpRequestMap.getUpdateListByRequestMap(request.getParameterMap(), ${entityClassSimpleName}.class, null)); } }