|  |  |  | 
|---|
|  |  |  | package com.moral.api.controller; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.moral.api.aop.log.OperationLogAnno; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.organization.OrganizationDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.organization.OrganizationQueryDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.form.organization.OrganizationDeleteForm; | 
|---|
|  |  |  | import com.moral.api.pojo.form.organization.OrganizationInsertForm; | 
|---|
|  |  |  | import com.moral.api.pojo.form.organization.OrganizationQueryForm; | 
|---|
|  |  |  | import com.moral.api.pojo.form.organization.OrganizationUpdateForm; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.organization.OrganizationDeleteVO; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.organization.OrganizationInsertVO; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.organization.OrganizationQueryVO; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.organization.OrganizationUpdateVO; | 
|---|
|  |  |  | import com.moral.api.pojo.dto.organization.OrganizationQueryNamesDTO; | 
|---|
|  |  |  | import com.moral.api.pojo.form.organization.*; | 
|---|
|  |  |  | import com.moral.api.pojo.vo.organization.*; | 
|---|
|  |  |  | import com.moral.api.service.OrganizationService; | 
|---|
|  |  |  | import com.moral.constant.Constants; | 
|---|
|  |  |  | import com.moral.constant.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"用户组织控制器"}) | 
|---|
|  |  |  | @CrossOrigin(origins = "*", maxAge = 3600) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/organization") | 
|---|
|  |  |  | @RequestMapping("/organization") | 
|---|
|  |  |  | public class OrganizationController { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | OrganizationService organizationService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("insert") | 
|---|
|  |  |  | @OperationLogAnno(module = Constants.ORGANIZATION_MODULE_NAME,type = Constants.INSERT_OPERATE_TYPE) | 
|---|
|  |  |  | public ResultMessage insert(@RequestBody OrganizationInsertForm form, HttpServletRequest request) { | 
|---|
|  |  |  | //请求参数存入request中 | 
|---|
|  |  |  | request.setAttribute("parameters",form); | 
|---|
|  |  |  | public ResultMessage insert(@RequestBody OrganizationInsertForm form) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | 
|---|
|  |  |  | //处理插入业务 | 
|---|
|  |  |  | OrganizationDTO dto = organizationService.insertOrganization(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端需要的参数 | 
|---|
|  |  |  | OrganizationInsertVO vo = OrganizationInsertVO.convert(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("update") | 
|---|
|  |  |  | public ResultMessage update(@RequestBody OrganizationUpdateForm form){ | 
|---|
|  |  |  | public ResultMessage update(@RequestBody OrganizationUpdateForm form) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | 
|---|
|  |  |  | //处理更新业务 | 
|---|
|  |  |  | OrganizationDTO dto = organizationService.updateOrganization(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端需要的参数 | 
|---|
|  |  |  | OrganizationUpdateVO vo = OrganizationUpdateVO.convert(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("delete") | 
|---|
|  |  |  | public ResultMessage delete(@RequestBody OrganizationDeleteForm form){ | 
|---|
|  |  |  | public ResultMessage delete(@RequestBody OrganizationDeleteForm form) { | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | 
|---|
|  |  |  | //处理删除业务 | 
|---|
|  |  |  | OrganizationDTO dto = organizationService.deleteOrganization(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端需要的参数 | 
|---|
|  |  |  | OrganizationDeleteVO vo = OrganizationDeleteVO.convert(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("query") | 
|---|
|  |  |  | public ResultMessage query(OrganizationQueryForm form){ | 
|---|
|  |  |  | public ResultMessage query(OrganizationQueryForm form) { | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | 
|---|
|  |  |  | //转换前端需要参数 | 
|---|
|  |  |  | OrganizationQueryVO vo = OrganizationQueryVO.convert(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(), dto.getMsg(), vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @GetMapping("queryNames") | 
|---|
|  |  |  | public ResultMessage queryNames(OrganizationQueryNamesForm form){ | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理查询业务 | 
|---|
|  |  |  | OrganizationQueryNamesDTO dto = organizationService.queryNames(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端所需参数 | 
|---|
|  |  |  | OrganizationQueryAllNamesVO vo = OrganizationQueryAllNamesVO.convert(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(),dto.getMsg(),vo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|