فهرست منبع

修改resultData

lyhzzz 3 سال پیش
والد
کامیت
f75b8d7487

+ 7 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/PlatformApplication.java

@@ -1,10 +1,12 @@
 package com.fdkankan;
 
+import com.fdkankan.common.exception.GlobalExceptionHandler;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
 import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Bean;
 
 
 @SpringBootApplication
@@ -16,6 +18,11 @@ public class PlatformApplication {
 	public static void main(String[] args) {
 		SpringApplication.run(PlatformApplication.class, args);
 	}
+
+	@Bean
+	public GlobalExceptionHandler globalExceptionHandler(){
+		return new GlobalExceptionHandler();
+	}
 }
 
 

+ 36 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/AgentAuditController.java

@@ -0,0 +1,36 @@
+package com.fdkankan.agent.controller;
+
+
+import com.fdkankan.agent.service.IAgentAuditService;
+import com.fdkankan.common.response.ResultData;
+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;
+
+//经销商申请模块
+@RestController
+@RequestMapping("/api")
+public class AgentAuditController {
+
+
+    @Autowired
+    IAgentAuditService agentAuditService;
+
+
+    /**
+     * 保存申请信息
+     * @return
+     */
+    @PostMapping("/agentAduit/save")
+    public ResultData agentAuditSave(
+            @RequestParam (value = "name",required = true) String name
+
+    ) throws Exception {
+
+        System.out.println(1/0);
+        return ResultData.ok("");
+    }
+
+}

+ 26 - 10
4dkankan-center-platform/src/main/java/com/fdkankan/agent/controller/AgentController.java

@@ -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);
     }
 
 }

+ 65 - 0
4dkankan-center-platform/src/main/java/com/fdkankan/agent/vo/AgentNoticeVo.java

@@ -0,0 +1,65 @@
+package com.fdkankan.agent.vo;
+
+
+public class AgentNoticeVo implements java.io.Serializable {
+	private static final long serialVersionUID = 1L;
+
+	private String id; // 
+	private String title; // 标题
+	private String content; // 公告内容
+	private String createTime; // 创建时间
+	private String updateTime; // 更新时间
+	private String recStatus; // 记录的状态,A: 生效,I: 禁用
+	private Integer tbStatus; // 0正常,1删除
+
+	public String getId() {
+		return id;
+	}
+	public void setId(String id) {
+		this.id = id;
+	}
+
+	public String getTitle() {
+		return title;
+	}
+	public void setTitle(String title) {
+		this.title = title;
+	}
+
+	public String getContent() {
+		return content;
+	}
+	public void setContent(String content) {
+		this.content = content;
+	}
+
+	public String getCreateTime() {
+		return createTime;
+	}
+	public void setCreateTime(String createTime) {
+		this.createTime = createTime;
+	}
+
+	public String getUpdateTime() {
+		return updateTime;
+	}
+	public void setUpdateTime(String updateTime) {
+		this.updateTime = updateTime;
+	}
+
+	public String getRecStatus() {
+		return recStatus;
+	}
+	public void setRecStatus(String recStatus) {
+		this.recStatus = recStatus;
+	}
+
+	public Integer getTbStatus() {
+		return tbStatus;
+	}
+	public void setTbStatus(Integer tbStatus) {
+		this.tbStatus = tbStatus;
+	}
+
+}
+

+ 2 - 2
4dkankan-center-platform/src/main/java/com/fdkankan/agent/dto/AgentDto.java

@@ -1,7 +1,7 @@
-package com.fdkankan.agent.dto;
+package com.fdkankan.agent.vo;
 
 
-public class AgentDto implements java.io.Serializable {
+public class AgentVo implements java.io.Serializable {
 	private static final long serialVersionUID = 1L;
 
 	private String id; // 

+ 1 - 4
4dkankan-center-scene/src/main/java/com/fdkankan/scene/SceneApplication.java

@@ -1,13 +1,10 @@
 package com.fdkankan.scene;
 
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.util.StrExtUtil;
 import com.fdkankan.scene.dto.TestDto;
 import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
-import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
@@ -26,7 +23,7 @@ public class SceneApplication {
         System.out.println("进入了");
         if(test.getName().equals("aaa")){
 //            throw new BusinessException(1000,"asdfaswdfasdfsdf");
-//            int i = test.getId() / 0;
+            int i = test.getId() / 0;
         }
         return test;
     }

+ 4 - 7
4dkankan-common/src/main/java/com/fdkankan/common/exception/GlobalExceptionHandler.java

@@ -4,7 +4,6 @@ import cn.hutool.core.exceptions.ExceptionUtil;
 import com.fdkankan.common.constant.ServerCode;
 import com.fdkankan.common.response.ResultData;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.ControllerAdvice;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.ResponseBody;
@@ -18,16 +17,14 @@ import javax.servlet.http.HttpServletRequest;
 @Slf4j
 public class GlobalExceptionHandler {
 
-    @Autowired
-    private ResultData resultData;
     /**
      * 处理未知异常
      */
     @ResponseBody
     @ExceptionHandler(value = Exception.class)
-    public String exceptionHandler(HttpServletRequest httpServletRequest, Exception e) {
+    public ResultData exceptionHandler(HttpServletRequest httpServletRequest, Exception e) {
         log.error("服务错误:", e);
-        return resultData.error(ServerCode.SYSTEM_ERROR.code(), ExceptionUtil.stacktraceToString(e, 3000));
+        return ResultData.error(ServerCode.SYSTEM_ERROR.code(), ExceptionUtil.stacktraceToString(e, 3000));
     }
 
     /**
@@ -35,8 +32,8 @@ public class GlobalExceptionHandler {
      */
     @ResponseBody
     @ExceptionHandler(value = BusinessException.class)
-    public String businessExceptionHandler(HttpServletRequest httpServletRequest, BusinessException e) {
+    public ResultData businessExceptionHandler(HttpServletRequest httpServletRequest, BusinessException e) {
         log.info("业务异常-----code:" + e.getCode() + "msg:" + e.getMsg());
-        return resultData.error(e.getCode(), e.getMsg());
+        return ResultData.error(e.getCode(), e.getMsg());
     }
 }

+ 12 - 15
4dkankan-common/src/main/java/com/fdkankan/common/response/ResultData.java

@@ -1,15 +1,12 @@
 package com.fdkankan.common.response;
 
-import com.alibaba.fastjson.JSON;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
-import org.springframework.stereotype.Component;
 
 import java.io.Serializable;
 import java.util.Calendar;
 
-@Component
 @Data
 @NoArgsConstructor
 @AllArgsConstructor
@@ -31,28 +28,28 @@ public class ResultData implements Serializable {
      */
     private long timestamp = Calendar.getInstance().getTimeInMillis();
 
-    public String ok() {
-        return this.ok("");
+    public static ResultData ok() {
+        return ok("");
     }
-    public String ok(Object data) {
-        return this.ok("", data);
+    public static ResultData ok(Object data) {
+        return ok("", data);
     }
-    public String ok(String msg, Object data) {
-        return this.base(200, msg, data);
+    public static ResultData ok(String msg, Object data) {
+        return base(200, msg, data);
     }
 
-    public String error(int code, String msg) {
-        return this.error(code, msg, "");
+    public static  ResultData error(int code, String msg) {
+        return error(code, msg, "");
     }
-    public String error(int code, String msg, Object data) {
-        return this.base(code, msg, data);
+    public static ResultData error(int code, String msg, Object data) {
+        return base(code, msg, data);
     }
 
-    private String base(int code, String msg, Object data) {
+    private static ResultData  base(int code, String msg, Object data) {
         ResultData rd = new ResultData();
         rd.setCode(code);
         rd.setMessage(msg);
         rd.setData(data);
-        return JSON.toJSONString(rd);
+        return rd;
     }
 }