|
@@ -2,21 +2,23 @@ package com.fdkankan.agent.controller;
|
|
|
|
|
|
|
|
|
import com.auth0.jwt.JWT;
|
|
|
-import com.fdkankan.agent.dto.AgentDto;
|
|
|
import com.fdkankan.agent.entity.Agent;
|
|
|
+import com.fdkankan.agent.entity.AgentNotice;
|
|
|
+import com.fdkankan.agent.service.IAgentNoticeService;
|
|
|
import com.fdkankan.agent.service.IAgentService;
|
|
|
+import com.fdkankan.agent.vo.AgentNoticeVo;
|
|
|
+import com.fdkankan.agent.vo.AgentVo;
|
|
|
import com.fdkankan.common.response.ResultData;
|
|
|
-import lombok.extern.log4j.Log4j2;
|
|
|
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.RequestMethod;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import java.util.LinkedHashMap;
|
|
|
+import java.util.List;
|
|
|
|
|
|
-@Log4j2
|
|
|
@RestController
|
|
|
@RequestMapping("/api/agent")
|
|
|
public class AgentController {
|
|
@@ -24,25 +26,39 @@ public class AgentController {
|
|
|
|
|
|
@Autowired
|
|
|
IAgentService agentService;
|
|
|
-
|
|
|
@Autowired
|
|
|
- ResultData resultData;
|
|
|
+ IAgentNoticeService agentNoticeService;
|
|
|
|
|
|
/**
|
|
|
* 获取代理商信息
|
|
|
* @return
|
|
|
*/
|
|
|
- @RequestMapping(value = {"/detail"}, method = RequestMethod.POST)
|
|
|
- public String detail(HttpServletRequest request ) throws Exception {
|
|
|
+ @PostMapping(value = "/detail")
|
|
|
+ public ResultData detail(HttpServletRequest request ) throws Exception {
|
|
|
String userName = JWT.decode( request.getHeader("token")).getClaim("userName").asString();
|
|
|
String agentId = userName.split(":")[1];
|
|
|
LinkedHashMap<String,String > queryMap = new LinkedHashMap<>();
|
|
|
queryMap.put("agent_id = "+agentId ,"and");
|
|
|
queryMap.put("rec_status = A" ,"and");
|
|
|
Agent one = agentService.getOne(queryMap);
|
|
|
- AgentDto agentDto = new AgentDto();
|
|
|
+ AgentVo agentDto = new AgentVo();
|
|
|
BeanUtils.copyProperties(one, agentDto);
|
|
|
- return resultData.ok(agentDto);
|
|
|
+ return ResultData.ok(agentDto);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * 获取代理商公告
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/notice")
|
|
|
+ public ResultData notice(HttpServletRequest request ) throws Exception {
|
|
|
+ AgentNoticeVo agentNoticeVo = new AgentNoticeVo();
|
|
|
+ LinkedHashMap<String,String> queryMap = new LinkedHashMap<>();
|
|
|
+ queryMap.put("rec_status = A" ,"and");
|
|
|
+ List<AgentNotice> notices = agentNoticeService.getList(queryMap, 1, 1, "create_time desc");
|
|
|
+ if (notices != null && notices.size() > 0){
|
|
|
+ BeanUtils.copyProperties(notices.get(0), agentNoticeVo);
|
|
|
+ }
|
|
|
+ return ResultData.ok(agentNoticeVo);
|
|
|
}
|
|
|
|
|
|
}
|