|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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.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.ResponseCodeEnum; | 
|---|
|  |  |  | import com.moral.constant.ResultMessage; | 
|---|
|  |  |  | 
|---|
|  |  |  | import lombok.extern.slf4j.Slf4j; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.web.bind.annotation.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import javax.servlet.http.HttpServletRequest; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @ClassName OrganizationController | 
|---|
|  |  |  | 
|---|
|  |  |  | **/ | 
|---|
|  |  |  | @Slf4j | 
|---|
|  |  |  | @Api(tags = {"用户组织控制器"}) | 
|---|
|  |  |  | @CrossOrigin(origins = "*", maxAge = 3600) | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping("/organization") | 
|---|
|  |  |  | @RequestMapping("/organization") | 
|---|
|  |  |  | public class OrganizationController { | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | OrganizationService organizationService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("insert") | 
|---|
|  |  |  | public ResultMessage insert(@RequestBody OrganizationInsertForm organizationInsertForm) { | 
|---|
|  |  |  | //判断参数是否缺少参数 | 
|---|
|  |  |  | if (!organizationInsertForm.valid()) | 
|---|
|  |  |  | public ResultMessage insert(@RequestBody OrganizationInsertForm form) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断参数是否有效 | 
|---|
|  |  |  | OrganizationDTO conditionDTO = organizationInsertForm.paramValid(); | 
|---|
|  |  |  | OrganizationDTO conditionDTO = form.paramValid(); | 
|---|
|  |  |  | if (conditionDTO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) { | 
|---|
|  |  |  | return new ResultMessage(conditionDTO.getCode(), conditionDTO.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理插入业务 | 
|---|
|  |  |  | OrganizationDTO organizationDTO = organizationService.insertOrganization(organizationInsertForm); | 
|---|
|  |  |  | OrganizationDTO dto = organizationService.insertOrganization(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端需要的参数 | 
|---|
|  |  |  | OrganizationInsertVO organizationInsertVO = OrganizationInsertVO.convert(organizationDTO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(organizationDTO.getCode(),organizationDTO.getMsg(),organizationInsertVO); | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("update") | 
|---|
|  |  |  | public ResultMessage update(@RequestBody OrganizationUpdateForm organizationUpdateForm){ | 
|---|
|  |  |  | //判断参数是否缺少参数 | 
|---|
|  |  |  | if (!organizationUpdateForm.valid()) | 
|---|
|  |  |  | public ResultMessage update(@RequestBody OrganizationUpdateForm form) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断参数是否有效 | 
|---|
|  |  |  | OrganizationDTO conditionDTO = organizationUpdateForm.paramValid(); | 
|---|
|  |  |  | OrganizationDTO conditionDTO = form.paramValid(); | 
|---|
|  |  |  | if (conditionDTO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) { | 
|---|
|  |  |  | return new ResultMessage(conditionDTO.getCode(), conditionDTO.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理更新业务 | 
|---|
|  |  |  | OrganizationDTO organizationDTO = organizationService.updateOrganization(organizationUpdateForm); | 
|---|
|  |  |  | OrganizationDTO dto = organizationService.updateOrganization(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端需要的参数 | 
|---|
|  |  |  | OrganizationUpdateVO organizationUpdateVO = OrganizationUpdateVO.convert(organizationDTO); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return new ResultMessage(organizationDTO.getCode(),organizationDTO.getMsg(),organizationUpdateVO); | 
|---|
|  |  |  | return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostMapping("delete") | 
|---|
|  |  |  | public ResultMessage delete(@RequestBody OrganizationDeleteForm organizationDeleteForm){ | 
|---|
|  |  |  | //判断参数是否缺少参数 | 
|---|
|  |  |  | if (!organizationDeleteForm.valid()) | 
|---|
|  |  |  | public ResultMessage delete(@RequestBody OrganizationDeleteForm form) { | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理删除业务 | 
|---|
|  |  |  | OrganizationDTO dto = organizationService.deleteOrganization(organizationDeleteForm); | 
|---|
|  |  |  | 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 organizationQueryForm){ | 
|---|
|  |  |  | public ResultMessage query(OrganizationQueryForm form) { | 
|---|
|  |  |  | //判断是否缺少参数 | 
|---|
|  |  |  | if (!organizationQueryForm.valid()) | 
|---|
|  |  |  | if (!form.valid()) | 
|---|
|  |  |  | return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
|---|
|  |  |  | ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //判断参数是否有效 | 
|---|
|  |  |  | OrganizationDTO conditionDTO = organizationQueryForm.paramValid(); | 
|---|
|  |  |  | if (conditionDTO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) { | 
|---|
|  |  |  | return new ResultMessage(conditionDTO.getCode(), conditionDTO.getMsg(), null); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //处理查询业务 | 
|---|
|  |  |  | OrganizationQueryDTO organizationQueryDTO = organizationService.queryOrganization(organizationQueryForm); | 
|---|
|  |  |  | OrganizationQueryDTO dto = organizationService.queryOrganization(form); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //转换前端需要参数 | 
|---|
|  |  |  | OrganizationQueryVO vo = OrganizationQueryVO.convert(dto); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|