|
@@ -1,60 +1,115 @@
|
|
|
package com.fdkankan.agent.controller;
|
|
|
|
|
|
|
|
|
+import com.fdkankan.agent.controller.request.RequestAgentAudit;
|
|
|
+import com.fdkankan.agent.controller.request.RequestNote;
|
|
|
+import com.fdkankan.agent.controller.request.RequestSearch;
|
|
|
+import com.fdkankan.agent.entity.AgentAudit;
|
|
|
import com.fdkankan.agent.service.IAgentAuditService;
|
|
|
import com.fdkankan.common.constant.ConstantRegex;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
+import com.fdkankan.common.validation.ValidationUtils;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-//经销商申请模块
|
|
|
+import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 经销商申请模块
|
|
|
+ */
|
|
|
@RestController
|
|
|
@RequestMapping("/api")
|
|
|
public class AgentAuditController {
|
|
|
|
|
|
-
|
|
|
@Autowired
|
|
|
IAgentAuditService agentAuditService;
|
|
|
|
|
|
+ private static Logger log = LoggerFactory.getLogger("programLog");
|
|
|
|
|
|
/**
|
|
|
* 保存申请信息
|
|
|
- * @param name 经销商名称
|
|
|
- * @param address 地址
|
|
|
- * @param country 国家
|
|
|
- * @param surName 申请人的姓
|
|
|
- * @param userName 申请人的名字
|
|
|
- * @param post 申请人职位
|
|
|
- * @param areaCode 区号
|
|
|
- * @param phone 手机号
|
|
|
- * @param email 邮箱地址
|
|
|
- * @param region 地区
|
|
|
- * @return
|
|
|
- * @throws Exception
|
|
|
*/
|
|
|
@PostMapping("/agentAduit/save")
|
|
|
public ResultData agentAuditSave(
|
|
|
- @RequestParam(required = true) String name,
|
|
|
- @RequestParam(required = true) String address,
|
|
|
- @RequestParam(required = true) String country,
|
|
|
- @RequestParam(required = true) String surName,
|
|
|
- @RequestParam(required = true) String userName,
|
|
|
- @RequestParam(required = true) String post,
|
|
|
- @RequestParam(required = true) String areaCode,
|
|
|
- @RequestParam(required = true) String phone,
|
|
|
- @RequestParam(required = true) String email,
|
|
|
- @RequestParam(required = true) String region
|
|
|
- ) throws Exception {
|
|
|
-
|
|
|
- if(!email.matches(ConstantRegex.EMAIL_REGEX)){
|
|
|
+ @RequestBody RequestAgentAudit param) {
|
|
|
+ if(param == null || StringUtils.isEmpty(param.getName()) || StringUtils.isEmpty(param.getAddress()) ||
|
|
|
+ StringUtils.isEmpty(param.getCountry()) || StringUtils.isEmpty(param.getRegion()) ||
|
|
|
+ StringUtils.isEmpty(param.getSurName()) || StringUtils.isEmpty(param.getUserName()) ||
|
|
|
+ StringUtils.isEmpty(param.getPost()) || StringUtils.isEmpty(param.getAreaCode()) ||
|
|
|
+ StringUtils.isEmpty(param.getPhone()) || StringUtils.isEmpty(param.getEmail())){
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!param.getEmail().matches(ConstantRegex.EMAIL_REGEX)){
|
|
|
return ResultData.error(ErrorCode.FAILURE_CODE_3019);
|
|
|
}
|
|
|
|
|
|
- return ResultData.ok("");
|
|
|
+ AgentAudit agentAudit = new AgentAudit();
|
|
|
+ BeanUtils.copyProperties(param,agentAudit);
|
|
|
+ agentAudit.setRecStatus("A");
|
|
|
+ agentAudit.setNoteType(1);
|
|
|
+ agentAudit.setState(1);
|
|
|
+ agentAuditService.insert(agentAudit);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/manager/agentAduit/list")
|
|
|
+ public ResultData list(
|
|
|
+ @RequestParam(value="pageNum", defaultValue="1", required = false) Integer pageNum,
|
|
|
+ @RequestParam(value="pageSize", defaultValue="10", required = false) Integer pageSize) {
|
|
|
+
|
|
|
+ LinkedHashMap<String,String> condition = new LinkedHashMap<>();
|
|
|
+ condition.put("rec_status = 'A'","and");
|
|
|
+ List<AgentAudit> agentAuditList = agentAuditService.getList(condition,pageNum, pageSize, "create_time desc");
|
|
|
+ int count = agentAuditService.getCount(condition, null);
|
|
|
+ return ResultData.ok(pageNum,pageSize,count,agentAuditList);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping("/manager/agentAduit/update/active/{id}/{state}")
|
|
|
+ private ResultData updateActive(
|
|
|
+ @PathVariable("id") Long id, @PathVariable("state") String state) {
|
|
|
+ LinkedHashMap<String,String> condition = new LinkedHashMap<>();
|
|
|
+ condition.put("id ="+id,"and");
|
|
|
+ condition.put("rec_status = 'A'","and");
|
|
|
+ AgentAudit agentAudit = agentAuditService.getOne(condition);
|
|
|
+ int iState = Integer.parseInt(state);
|
|
|
+ if (agentAudit == null || !ValidationUtils.validateState(iState)) {
|
|
|
+ log.info("state: {}", state);
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+ agentAudit.setState(iState);
|
|
|
+ agentAuditService.update(agentAudit);
|
|
|
+ return ResultData.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @PostMapping("/manager/agentAduit/update/note")
|
|
|
+ private ResultData updateNote(@RequestBody RequestNote param){
|
|
|
+ LinkedHashMap<String,String> condition = new LinkedHashMap<>();
|
|
|
+ condition.put("id ="+param.getId(),"and");
|
|
|
+ condition.put("rec_status = 'A'","and");
|
|
|
+ AgentAudit agentAudit = agentAuditService.getOne(condition);
|
|
|
+ if (agentAudit == null) {
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+ if (!ValidationUtils.validateInteger(param.getNoteType())){
|
|
|
+ log.info("NoteType: {}", param.getNoteType());
|
|
|
+ return ResultData.error(ErrorCode.FAILURE_CODE_3001);
|
|
|
+ }
|
|
|
+ agentAudit.setNoteType(param.getNoteType());
|
|
|
+ agentAudit.setNoteContent(param.getNoteContent());
|
|
|
+ agentAuditService.update(agentAudit);
|
|
|
+ return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/manager/agentAduit/search")
|
|
|
+ private ResultData search(@RequestBody RequestSearch param) {
|
|
|
+ return agentAuditService.searchLike(param);
|
|
|
+ }
|
|
|
}
|