|  |  | 
 |  |  | package com.moral.api.controller; | 
 |  |  |  | 
 |  |  | import com.moral.api.entity.SysArea; | 
 |  |  | import com.moral.api.pojo.dto.account.*; | 
 |  |  | import com.moral.api.pojo.dto.organization.OrganizationDTO; | 
 |  |  | import com.moral.api.pojo.form.account.AccountDeleteForm; | 
 |  |  | import com.moral.api.pojo.form.account.AccountInsertForm; | 
 |  |  | import com.moral.api.pojo.form.account.AccountQueryForm; | 
 |  |  | import com.moral.api.pojo.form.account.AccountUpdateForm; | 
 |  |  | import com.moral.api.pojo.vo.account.AccountDeleteVO; | 
 |  |  | import com.moral.api.pojo.vo.account.AccountInsertVO; | 
 |  |  | import com.moral.api.pojo.dto.accountRole.AccountRoleDTO; | 
 |  |  | import com.moral.api.pojo.form.account.*; | 
 |  |  | import com.moral.api.pojo.form.accountRole.AccountRoleUpdateForm; | 
 |  |  | import com.moral.api.pojo.vo.account.AccountQueryVO; | 
 |  |  | import com.moral.api.pojo.vo.account.AccountUpdateVO; | 
 |  |  | import com.moral.api.service.ManageAccountRoleService; | 
 |  |  | import com.moral.api.service.ManageAccountService; | 
 |  |  | import com.moral.api.service.SysAreaService; | 
 |  |  | import com.moral.constant.ResponseCodeEnum; | 
 |  |  | import com.moral.constant.ResultMessage; | 
 |  |  | import io.swagger.annotations.*; | 
 |  |  | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.util.List; | 
 |  |  |  | 
 |  |  | @Slf4j | 
 |  |  | @Api(tags = {"后台账户管理"}) | 
 |  |  | 
 |  |  | public class AccountController { | 
 |  |  |     @Autowired | 
 |  |  |     ManageAccountService accountService; | 
 |  |  |     @Autowired | 
 |  |  |     ManageAccountRoleService manageAccountRoleService; | 
 |  |  |  | 
 |  |  |     @PostMapping("insert") | 
 |  |  |     public ResultMessage insert(@RequestBody AccountInsertForm form) { | 
 |  |  | 
 |  |  |                     ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
 |  |  |  | 
 |  |  |         //判断参数是否有效 | 
 |  |  |         AccountInsertDTO conditionDTO = form.paramValid(); | 
 |  |  |         AccountDTO conditionDTO = form.paramValid(); | 
 |  |  |         if (conditionDTO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) { | 
 |  |  |             return new ResultMessage(conditionDTO.getCode(), conditionDTO.getMsg(), null); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         //处理插入业务 | 
 |  |  |         AccountDTO dto = accountService.insertAccount(form); | 
 |  |  |  | 
 |  |  |         //转换前端需要参数 | 
 |  |  |         AccountInsertVO accountInsertVO = AccountInsertVO.convert(dto); | 
 |  |  |  | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), accountInsertVO); | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("update") | 
 |  |  | 
 |  |  |                     ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
 |  |  |  | 
 |  |  |         //判断参数是否有效 | 
 |  |  |         AccountUpdateDTO conditionDTO = form.paramValid(); | 
 |  |  |         AccountDTO conditionDTO = form.paramValid(); | 
 |  |  |         if (conditionDTO.getCode() != ResponseCodeEnum.SUCCESS.getCode()) { | 
 |  |  |             return new ResultMessage(conditionDTO.getCode(), conditionDTO.getMsg(), null); | 
 |  |  |         } | 
 |  |  | 
 |  |  |         //处理更新业务 | 
 |  |  |         AccountDTO dto = accountService.updateAccount(form); | 
 |  |  |  | 
 |  |  |         //转换前端需要的参数 | 
 |  |  |         AccountUpdateVO vo = AccountUpdateVO.convert(dto); | 
 |  |  |  | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), vo); | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("delete") | 
 |  |  | 
 |  |  |         //处理删除业务 | 
 |  |  |         AccountDTO dto = accountService.deleteAccount(form); | 
 |  |  |  | 
 |  |  |         //转换前端需要的参数 | 
 |  |  |         AccountDeleteVO vo = AccountDeleteVO.convert(dto); | 
 |  |  |  | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), vo); | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @GetMapping("query") | 
 |  |  | 
 |  |  |         return new ResultMessage(accountQueryDTO.getCode(), accountQueryDTO.getMsg(), accountQueryVO); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @PostMapping("updateRole") | 
 |  |  |     public ResultMessage updateRole(@RequestBody AccountRoleUpdateForm form){ | 
 |  |  |  | 
 |  |  |         //判断是否缺少参数 | 
 |  |  |         if (!form.valid()) | 
 |  |  |             return ResultMessage.fail(ResponseCodeEnum.PARAMETERS_IS_MISSING.getCode(), | 
 |  |  |                     ResponseCodeEnum.PARAMETERS_IS_MISSING.getMsg()); | 
 |  |  |  | 
 |  |  |         //处理更新业务 | 
 |  |  |         AccountRoleDTO dto = manageAccountRoleService.updateAccountRole(form); | 
 |  |  |  | 
 |  |  |         return new ResultMessage(dto.getCode(), dto.getMsg(), null); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |