|
@@ -0,0 +1,85 @@
|
|
|
+package com.fdkankan.manage.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.fdkankan.common.response.Result;
|
|
|
+import com.fdkankan.common.response.ResultData;
|
|
|
+import com.fdkankan.manage.common.ResultCode;
|
|
|
+import com.fdkankan.manage.entity.AgentNew;
|
|
|
+import com.fdkankan.manage.entity.User;
|
|
|
+import com.fdkankan.manage.exception.BusinessException;
|
|
|
+import com.fdkankan.manage.service.IAgentIncrementService;
|
|
|
+import com.fdkankan.manage.service.IAgentNewService;
|
|
|
+import com.fdkankan.manage.service.IUserService;
|
|
|
+import com.fdkankan.manage.vo.request.AgentParam;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 前端控制器
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author
|
|
|
+ * @since 2022-11-08
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/service/manage/agentNew")
|
|
|
+public class AgentNewController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ IAgentNewService agentNewService;
|
|
|
+ @Autowired
|
|
|
+ IAgentIncrementService agentIncrementService;
|
|
|
+ @Autowired
|
|
|
+ IUserService userService;
|
|
|
+
|
|
|
+ @PostMapping("/list")
|
|
|
+ public ResultData list(@RequestBody AgentParam agentParam){
|
|
|
+
|
|
|
+ return ResultData.ok(agentNewService.pageList(agentParam));
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/checkUserName")
|
|
|
+ public ResultData checkUserName(@RequestParam(required = false) String userName){
|
|
|
+ userService.checkUserName(userName);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/add")
|
|
|
+ public ResultData add(@RequestBody AgentNew param){
|
|
|
+ if(StringUtils.isBlank(param.getName()) || StringUtils.isBlank(param.getUserName())){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ userService.checkUserName(param.getUserName());
|
|
|
+ agentNewService.save(param);
|
|
|
+ agentIncrementService.saveByAgent(param);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+ @PostMapping("/update")
|
|
|
+ public ResultData update(@RequestBody AgentNew param){
|
|
|
+ if(param.getId() == null || StringUtils.isBlank(param.getName())){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<AgentNew> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(AgentNew::getId,param.getId());
|
|
|
+ wrapper.set(AgentNew::getName,param.getName());
|
|
|
+ wrapper.set(AgentNew::getNickName,param.getNickName());
|
|
|
+ agentNewService.update(wrapper);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+ @PostMapping("/delete")
|
|
|
+ public ResultData delete(@RequestBody AgentNew param){
|
|
|
+ if(param.getId() == null ){
|
|
|
+ throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ agentNewService.removeById(param.getId());
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|