From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交

---
 server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java |   69 ++++++++++++++++++++++++++++++++--
 1 files changed, 65 insertions(+), 4 deletions(-)

diff --git a/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java b/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java
index d367c4a..0e4ab81 100644
--- a/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java
+++ b/server/web/src/main/java/com/doumee/api/web/CustomerManageApi.java
@@ -1,27 +1,46 @@
 package com.doumee.api.web;
 
+import cn.hutool.http.HttpRequest;
+import com.amazonaws.util.Md5Utils;
+import com.doumee.biz.system.SystemDataPermissionBiz;
+import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.biz.zbom.ZbomCRMService;
 import com.doumee.biz.zbom.ZbomZhongTaiService;
 import com.doumee.config.annotation.LoginRequired;
 import com.doumee.config.annotation.UserLoginRequired;
+import com.doumee.core.annotation.pr.PreventRepeat;
 import com.doumee.core.annotation.trace.Trace;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
 import com.doumee.core.model.ApiResponse;
 import com.doumee.core.model.PageData;
 import com.doumee.core.model.PageWrap;
+import com.doumee.core.utils.Constants;
 import com.doumee.dao.business.model.News;
+import com.doumee.dao.web.reqeust.GenerateQRCodeRequest;
 import com.doumee.dao.web.response.DailyUpdatesResponse;
 import com.doumee.dao.web.response.ZSZXCatalogResponse;
 import com.doumee.service.business.GetZhongTaiDataService;
 import com.doumee.service.business.NewsService;
 import com.doumee.service.business.SmsEmailService;
+import com.doumee.service.business.UsersService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.codec.digest.DigestUtils;
+import org.apache.commons.codec.digest.Md5Crypt;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.apache.tomcat.util.security.MD5Encoder;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.InputStream;
 
 /**
  * Created by IntelliJ IDEA.
@@ -51,6 +70,12 @@
     @Autowired
     public GetZhongTaiDataService getZhongTaiDataService;
 
+    @Autowired
+    public UsersService usersService;
+
+    @Autowired
+    public SystemDictDataBiz systemDictDataBiz;
+
 
     @UserLoginRequired
     @LoginRequired
@@ -65,15 +90,17 @@
 
 
 
+
+
+
     @UserLoginRequired
     @ApiOperation(value = "銆怋绔皬绋嬪簭銆戞瘡鏃ヤ笂鏂版暟鎹�")
     @GetMapping("/getDailyUpdates")
     @ApiImplicitParams({
-            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鐢ㄦ埛token鍊�", required = true),
-            @ApiImplicitParam(paramType = "query", dataType = "Integer", name = "fileType", value = "闄勪欢绫诲瀷 0鍥剧墖 1瑙嗛", required = false)
+            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鐢ㄦ埛token鍊�", required = true)
     })
-    public ApiResponse<DailyUpdatesResponse> getDailyUpdates(Integer fileType) {
-        return  ApiResponse.success(newsService.getDailyUpdatesResponse(fileType));
+    public ApiResponse<DailyUpdatesResponse> getDailyUpdates() {
+        return  ApiResponse.success(newsService.getDailyUpdatesResponse());
     }
 
 
@@ -84,6 +111,7 @@
             @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "鐢ㄦ埛token鍊�", required = true),
     })
     public ApiResponse<PageData<News>> newsPage (@RequestBody PageWrap<News> pageWrap) {
+        pageWrap.getModel().setIsPublish(Constants.ONE);
         return ApiResponse.success(newsService.findPage(pageWrap));
     }
 
@@ -99,4 +127,37 @@
     public ApiResponse<String> getCrmAuthUrl(@RequestParam Integer type) {
         return  ApiResponse.success(zbomCRMService.getCrmGoUrl(this.getLoginUserInfo().getIamUsername(),type));
     }
+
+    @PreventRepeat(lockTime = 2000)
+    @ApiOperation(value = "鐢熸垚灏忕▼搴忕爜", notes = "PAD绔�")
+    @PostMapping("/getQrCode")
+    @ApiImplicitParams({
+            @ApiImplicitParam(paramType = "header", dataType = "String", name = "sign", value = "绛惧悕锛堜娇鐢╰imestamp+appkey杩涜md5鍔犲瘑锛�", required = true),
+            @ApiImplicitParam(paramType = "header", dataType = "Long", name = "timestamp", value = "鏃堕棿鎴筹紙褰撳墠鏃堕棿姣锛�2灏忔椂鍐呮湁鏁堬級", required = true),
+    })
+    public void getQrCode(@RequestParam(value = "sign")String sign,
+                          @RequestParam(value = "timestamp")Long timestamp,
+                          @RequestBody GenerateQRCodeRequest generateQRCodeRequest,HttpServletResponse response) {
+        if(StringUtils.isBlank(sign) || timestamp == null){
+            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
+        String interfaceKey = systemDictDataBiz.queryByCode(Constants.ZBOM,Constants.ZBOM_PAD_INTERFACE_KEY).getCode();
+        //鍒ゆ柇鏃堕棿鎴虫槸鍚﹁秴杩囦袱灏忔椂
+        if(System.currentTimeMillis()-timestamp > 2 * 60 * 3600 * 1000){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"token宸插け鏁�!");
+        }
+        String token = DigestUtils.md5Hex(timestamp+interfaceKey);
+        if(!token.equals(sign)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"token宸插け鏁�!");
+        }
+        try{
+            response.setHeader("Cache-Control", "no-store, no-cache");
+            response.setContentType("image/jpeg");
+            InputStream inputStream = usersService.getQrCode(generateQRCodeRequest);
+            ImageIO.write(ImageIO.read(inputStream),"png",response.getOutputStream());
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
 }

--
Gitblit v1.9.3