|
@@ -1,17 +1,21 @@
|
1
|
1
|
package com.huiju.estateagents.controller;
|
2
|
2
|
|
3
|
3
|
|
|
4
|
+import com.alibaba.fastjson.JSONObject;
|
|
5
|
+import com.huiju.estateagents.base.BaseController;
|
4
|
6
|
import com.huiju.estateagents.base.ResponseBean;
|
5
|
7
|
import com.huiju.estateagents.common.AliOSSUtils;
|
6
|
8
|
import com.huiju.estateagents.common.CommConstant;
|
7
|
9
|
import com.huiju.estateagents.common.SMSUtils;
|
8
|
10
|
import com.huiju.estateagents.common.StringUtils;
|
|
11
|
+import com.huiju.estateagents.service.IMiniAppService;
|
9
|
12
|
import com.huiju.estateagents.service.ITdMiniappTemplateTypeService;
|
10
|
13
|
import org.apache.ibatis.annotations.Mapper;
|
11
|
14
|
import org.springframework.beans.factory.annotation.Autowired;
|
12
|
15
|
import org.springframework.web.bind.annotation.*;
|
13
|
16
|
import org.springframework.web.multipart.MultipartFile;
|
14
|
17
|
|
|
18
|
+import javax.servlet.http.HttpServletRequest;
|
15
|
19
|
import java.io.IOException;
|
16
|
20
|
import java.util.ArrayList;
|
17
|
21
|
import java.util.HashMap;
|
|
@@ -20,13 +24,16 @@ import java.util.Map;
|
20
|
24
|
|
21
|
25
|
@RestController
|
22
|
26
|
@RequestMapping("/api")
|
23
|
|
-public class CommonController {
|
|
27
|
+public class CommonController extends BaseController {
|
24
|
28
|
@Autowired
|
25
|
29
|
SMSUtils smsUtils;
|
26
|
30
|
|
27
|
31
|
@Autowired
|
28
|
32
|
ITdMiniappTemplateTypeService iTdMiniappTemplateTypeService;
|
29
|
33
|
|
|
34
|
+ @Autowired
|
|
35
|
+ IMiniAppService iMiniAppService;
|
|
36
|
+
|
30
|
37
|
/**
|
31
|
38
|
* 图片
|
32
|
39
|
* @param multipartFile
|
|
@@ -42,6 +49,43 @@ public class CommonController {
|
42
|
49
|
}
|
43
|
50
|
}
|
44
|
51
|
|
|
52
|
+ @PostMapping("/admin/qrcode")
|
|
53
|
+ public ResponseBean createQrCode(@RequestBody String jsonStr, HttpServletRequest request) {
|
|
54
|
+ Integer orgId = getOrgId(request);
|
|
55
|
+
|
|
56
|
+ if (StringUtils.isEmpty(jsonStr)) {
|
|
57
|
+ return ResponseBean.error("参数不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
58
|
+ }
|
|
59
|
+
|
|
60
|
+ JSONObject params = JSONObject.parseObject(jsonStr);
|
|
61
|
+ if (params == null) {
|
|
62
|
+ return ResponseBean.error("参数是非法的 JSON 对象", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
63
|
+ }
|
|
64
|
+
|
|
65
|
+ String paramStr = params.getString("params");
|
|
66
|
+ if (StringUtils.isEmpty(paramStr)) {
|
|
67
|
+ ResponseBean.error("参数 params 不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
68
|
+ }
|
|
69
|
+
|
|
70
|
+ JSONObject qrObj = JSONObject.parseObject(paramStr);
|
|
71
|
+ if (qrObj == null) {
|
|
72
|
+ return ResponseBean.error("小程序码参数是非法", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
73
|
+ }
|
|
74
|
+
|
|
75
|
+ String scene = qrObj.getString("scene");
|
|
76
|
+ String page = qrObj.getString("page");
|
|
77
|
+
|
|
78
|
+ if (StringUtils.isEmpty(scene) || StringUtils.isEmpty(page)) {
|
|
79
|
+ return ResponseBean.error("小程序码参数: scene 或者 page 不能为空", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
80
|
+ }
|
|
81
|
+
|
|
82
|
+ if (scene.indexOf("id=") == -1) {
|
|
83
|
+ return ResponseBean.error("小程序码参数: 必须存在 id 参数", ResponseBean.ERROR_ILLEGAL_PARAMS);
|
|
84
|
+ }
|
|
85
|
+
|
|
86
|
+ return iMiniAppService.getOrgQrCode(paramStr, orgId);
|
|
87
|
+ }
|
|
88
|
+
|
45
|
89
|
/**
|
46
|
90
|
* 为适应 ANTD 特制的图片上传
|
47
|
91
|
* plat 中心端传 center 管理端传 admin
|