张涛 2 jaren geleden
bovenliggende
commit
b2906a90d2

db/.back_文明创办/.back_文明创办/文明创办-backup-2023511112401.pdma.json → db/.back_文明创办/.back_文明创办/文明创办-backup-2023525163727.pdma.json Bestand weergeven

@@ -4,7 +4,7 @@
4 4
   "avatar": "",
5 5
   "version": "4.1.1",
6 6
   "createdTime": "2022-12-12 09:36:12",
7
-  "updatedTime": "2023-5-11 10:30:13",
7
+  "updatedTime": "2023-5-11 16:31:13",
8 8
   "dbConns": [],
9 9
   "profile": {
10 10
     "default": {
@@ -3713,7 +3713,7 @@
3713 3713
         {
3714 3714
           "defKey": "source_type",
3715 3715
           "defName": "来源类型",
3716
-          "comment": "feedback市民上报,issue模拟测评,dailySpe日常督查",
3716
+          "comment": "feedback市民上报,check模拟测评",
3717 3717
           "type": "",
3718 3718
           "len": "",
3719 3719
           "scale": "",
@@ -3930,6 +3930,23 @@
3930 3930
           "extProps": {},
3931 3931
           "domain": "16120F75-6AA7-4483-868D-F07F511BB081",
3932 3932
           "id": "1F85BFC4-DBF4-4BA5-9BD8-DC9C2BFA1646"
3933
+        },
3934
+        {
3935
+          "defKey": "source_type2",
3936
+          "defName": "问题来源PC",
3937
+          "comment": "check 模拟测评  feedback 市民上报  inspector 督查员上报",
3938
+          "type": "",
3939
+          "len": "",
3940
+          "scale": "",
3941
+          "primaryKey": false,
3942
+          "notNull": false,
3943
+          "autoIncrement": false,
3944
+          "defaultValue": "",
3945
+          "hideInGraph": false,
3946
+          "refDict": "",
3947
+          "extProps": {},
3948
+          "domain": "73FD2BAD-2358-4336-B96D-45DC897BD792",
3949
+          "id": "42892AD2-FF8E-4D87-8705-14737E34AE9A"
3933 3950
         }
3934 3951
       ],
3935 3952
       "correlations": [],

+ 10088
- 0
db/.back_文明创办/文明创办-backup-2023510115646.pdma.json
Diff onderdrukt omdat het te groot bestand
Bestand weergeven


+ 87
- 87
src/main/java/com/example/civilizedcity/common/HttpUtils.java Bestand weergeven

@@ -1,87 +1,87 @@
1
-//package com.example.civilizedcity.common;
2
-//
3
-//import org.springframework.http.*;
4
-//import org.springframework.stereotype.Component;
5
-//import org.springframework.web.client.RestTemplate;
6
-//
7
-//import java.io.UnsupportedEncodingException;
8
-//import java.net.URLDecoder;
9
-//import java.util.*;
10
-//
11
-//@Component
12
-//public class HttpUtils {
13
-//    public String get(String url) throws Exception {
14
-//        RestTemplate restTemplate = new RestTemplate();
15
-//        HttpHeaders headers = new HttpHeaders();
16
-//        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
17
-//        HttpEntity<String> entity = new HttpEntity<String>(headers);
18
-//
19
-//        Map<String, Object> urlAndParams = parseURL(url);
20
-//        String formatURL = (String) urlAndParams.get("url");
21
-//        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
22
-//
23
-//        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, String.class, params);
24
-//        return resp.getBody();
25
-//    }
26
-//
27
-//    public String post(String url, Map<String, String> header, String body) throws Exception {
28
-//        RestTemplate restTemplate = new RestTemplate();
29
-//        HttpHeaders headers = new HttpHeaders();
30
-//        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
31
-//        headers.setContentType(type);
32
-//        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
33
-//        headers.setAll(header);
34
-//        HttpEntity<String> entity = new HttpEntity<String>(body, headers);
35
-//
36
-//        Map<String, Object> urlAndParams = parseURL(url);
37
-//        String formatURL = (String) urlAndParams.get("url");
38
-//        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
39
-//
40
-//        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.POST, entity, String.class, params);
41
-//        return resp.getBody();
42
-//    }
43
-//
44
-//    // RestTemplate 不能正常的处理 querystring, 必须按照约定的方式处理
45
-//    private Map<String, Object> parseURL(String url) {
46
-//        Map<String, Object> res = new HashMap<>();
47
-//
48
-//        String[] parts = url.split("\\?");
49
-//        String baseURL = parts[0];
50
-//
51
-//        if (parts.length < 2) {
52
-//            res.put("url", baseURL);
53
-//            res.put("params", new HashMap<>());
54
-//            return res;
55
-//        }
56
-//
57
-//
58
-//        String[] fields = parts[1].split("&");
59
-//        Map<String, String> params = new HashMap<>();
60
-//        List<String> searchList = new ArrayList<>();
61
-//        for (String field : fields) {
62
-//            String[] pairs = field.split("=");
63
-//            if (2 != pairs.length) {
64
-//                continue;
65
-//            }
66
-//
67
-//            try {
68
-//                String key = URLDecoder.decode(pairs[0].trim(), "UTF-8");
69
-//                String val = URLDecoder.decode(pairs[1].trim(), "UTF-8");
70
-//
71
-//                // 转化为 "foo={foo}" 这种字符串
72
-//                searchList.add(String.format("%s={%s}", key, key));
73
-//                // 把 foo 对应的值存储起来
74
-//                params.put(key, val);
75
-//            } catch (UnsupportedEncodingException e) {
76
-//                e.printStackTrace();
77
-//            }
78
-//        }
79
-//
80
-//        // url 格式类似 http://foo.org/bar?name={name}
81
-//        String formatURL = baseURL + "?" + String.join("&", searchList);
82
-//        res.put("url", formatURL);
83
-//        res.put("params", params);
84
-//
85
-//        return res;
86
-//    }
87
-//}
1
+package com.example.civilizedcity.common;
2
+
3
+import org.springframework.http.*;
4
+import org.springframework.stereotype.Component;
5
+import org.springframework.web.client.RestTemplate;
6
+
7
+import java.io.UnsupportedEncodingException;
8
+import java.net.URLDecoder;
9
+import java.util.*;
10
+
11
+@Component
12
+public class HttpUtils {
13
+    public String get(String url) throws Exception {
14
+        RestTemplate restTemplate = new RestTemplate();
15
+        HttpHeaders headers = new HttpHeaders();
16
+        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
17
+        HttpEntity<String> entity = new HttpEntity<String>(headers);
18
+
19
+        Map<String, Object> urlAndParams = parseURL(url);
20
+        String formatURL = (String) urlAndParams.get("url");
21
+        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
22
+
23
+        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.GET, entity, String.class, params);
24
+        return resp.getBody();
25
+    }
26
+
27
+    public String post(String url, Map<String, String> header, String body) throws Exception {
28
+        RestTemplate restTemplate = new RestTemplate();
29
+        HttpHeaders headers = new HttpHeaders();
30
+        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");
31
+        headers.setContentType(type);
32
+        headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
33
+        headers.setAll(header);
34
+        HttpEntity<String> entity = new HttpEntity<String>(body, headers);
35
+
36
+        Map<String, Object> urlAndParams = parseURL(url);
37
+        String formatURL = (String) urlAndParams.get("url");
38
+        Map<String, String> params = (Map<String, String>) urlAndParams.get("params");
39
+
40
+        ResponseEntity<String> resp = restTemplate.exchange(formatURL, HttpMethod.POST, entity, String.class, params);
41
+        return resp.getBody();
42
+    }
43
+
44
+    // RestTemplate 不能正常的处理 querystring, 必须按照约定的方式处理
45
+    private Map<String, Object> parseURL(String url) {
46
+        Map<String, Object> res = new HashMap<>();
47
+
48
+        String[] parts = url.split("\\?");
49
+        String baseURL = parts[0];
50
+
51
+        if (parts.length < 2) {
52
+            res.put("url", baseURL);
53
+            res.put("params", new HashMap<>());
54
+            return res;
55
+        }
56
+
57
+
58
+        String[] fields = parts[1].split("&");
59
+        Map<String, String> params = new HashMap<>();
60
+        List<String> searchList = new ArrayList<>();
61
+        for (String field : fields) {
62
+            String[] pairs = field.split("=");
63
+            if (2 != pairs.length) {
64
+                continue;
65
+            }
66
+
67
+            try {
68
+                String key = URLDecoder.decode(pairs[0].trim(), "UTF-8");
69
+                String val = URLDecoder.decode(pairs[1].trim(), "UTF-8");
70
+
71
+                // 转化为 "foo={foo}" 这种字符串
72
+                searchList.add(String.format("%s={%s}", key, key));
73
+                // 把 foo 对应的值存储起来
74
+                params.put(key, val);
75
+            } catch (UnsupportedEncodingException e) {
76
+                e.printStackTrace();
77
+            }
78
+        }
79
+
80
+        // url 格式类似 http://foo.org/bar?name={name}
81
+        String formatURL = baseURL + "?" + String.join("&", searchList);
82
+        res.put("url", formatURL);
83
+        res.put("params", params);
84
+
85
+        return res;
86
+    }
87
+}

+ 50
- 0
src/main/java/com/example/civilizedcity/common/SMSCaptcha.java Bestand weergeven

@@ -0,0 +1,50 @@
1
+package com.example.civilizedcity.common;
2
+
3
+
4
+import lombok.extern.slf4j.Slf4j;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.beans.factory.annotation.Value;
7
+import org.springframework.scheduling.annotation.EnableScheduling;
8
+import org.springframework.stereotype.Component;
9
+
10
+import java.util.Hashtable;
11
+
12
+@Slf4j
13
+@Component
14
+@EnableScheduling
15
+public class SMSCaptcha {
16
+
17
+    @Value("${sms.captcha.code}")
18
+    String code;
19
+    @Value("${sms.captcha.sign}")
20
+    String sign;
21
+
22
+    @Autowired
23
+    SMSUtils smsUtils;
24
+
25
+    /**
26
+     * 发送提醒短信
27
+     *
28
+     * @param tel
29
+     * @param captcha
30
+     * @throws Exception
31
+     */
32
+    public void send(String tel, String captcha) throws Exception {
33
+
34
+
35
+        SMSUtils.Message message = new SMSUtils.Message()
36
+                .setCode(code)
37
+                .setSign(sign)
38
+                .setTel(tel)
39
+                .setContent("{ \"status\": \"" + captcha + "\" }");
40
+
41
+        try {
42
+            smsUtils.sendMessage(message);
43
+        } catch (Exception e) {
44
+            e.printStackTrace();
45
+            // 修改友好点的错误
46
+            throw new Exception("发送验证码失败");
47
+        }
48
+
49
+    }
50
+}

+ 101
- 58
src/main/java/com/example/civilizedcity/common/SMSUtils.java Bestand weergeven

@@ -1,65 +1,108 @@
1
-//package com.example.civilizedcity.common;
2
-//
1
+
2
+package com.example.civilizedcity.common;
3
+import com.alibaba.fastjson.JSONObject;
4
+import lombok.Data;
5
+import lombok.experimental.Accessors;
6
+import lombok.extern.slf4j.Slf4j;
7
+import org.springframework.beans.factory.InitializingBean;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.beans.factory.annotation.Value;
10
+
11
+import org.springframework.stereotype.Component;
12
+
13
+import java.util.HashMap;
14
+import java.util.Map;
15
+
16
+@Slf4j
17
+@Component
18
+
19
+public class SMSUtils implements InitializingBean {
20
+    @Autowired
21
+    HttpUtils httpUtils;
22
+    @Value("${yz.sms.api}")
23
+    String smsAPI;
24
+
25
+    @Value("${yz.sms.appid}")
26
+    String appid;
27
+
28
+    public void sendMessage(Message message) throws Exception {
29
+        long nowMills = System.currentTimeMillis();
30
+        String timestamp = String.valueOf(nowMills);
31
+        String secret = appid + timestamp;
32
+
33
+        Map<String, String> header = new HashMap<>();
34
+        header.put("x-appid", appid);
35
+        header.put("x-timestamp", timestamp);
36
+        header.put("x-sign", EncryptUtils.md5(appid + secret, timestamp));
37
+
38
+        Map<String, String> body = new HashMap<>();
39
+        body.put("PhoneNumbers", message.getTel());
40
+        body.put("SignName", message.getSign());
41
+        body.put("TemplateCode", message.getCode());
42
+        body.put("TemplateParam", message.getContent());
43
+
44
+        httpUtils.post(smsAPI, header, JSONObject.toJSONString(body, false));
45
+
46
+    }
47
+
48
+    @Override
49
+    public void afterPropertiesSet() throws Exception {
50
+    }
51
+
52
+    @Data
53
+    @Accessors(chain = true)
54
+    public static class Message {
55
+        String code;
56
+        String tel;
57
+        String sign;
58
+        String content;
59
+    }
60
+
61
+}
62
+
3 63
 //import com.alibaba.fastjson.JSONObject;
4
-//import lombok.Data;
5
-//import lombok.experimental.Accessors;
6
-//import lombok.extern.slf4j.Slf4j;
7
-//import org.springframework.beans.factory.InitializingBean;
8
-//import org.springframework.beans.factory.annotation.Autowired;
9
-//import org.springframework.beans.factory.annotation.Value;
10
-//import org.springframework.scheduling.annotation.EnableAsync;
11
-//import org.springframework.scheduling.annotation.EnableScheduling;
12
-//import org.springframework.stereotype.Component;
64
+//import com.aliyuncs.CommonRequest;
65
+//import com.aliyuncs.CommonResponse;
66
+//import com.aliyuncs.DefaultAcsClient;
67
+//import com.aliyuncs.IAcsClient;
68
+//import com.aliyuncs.exceptions.ClientException;
69
+//import com.aliyuncs.http.MethodType;
70
+//import com.aliyuncs.profile.DefaultProfile;
71
+//import org.springframework.stereotype.Service;
13 72
 //
14
-//import java.util.HashMap;
15 73
 //import java.util.Map;
16
-//
17
-//@Slf4j
18
-//@Component
19
-//@EnableScheduling //开启定时任务
20
-//@EnableAsync  //开启多线程
21
-//public class SMSUtils implements InitializingBean {
22
-//    @Autowired
23
-//    HttpUtils httpUtils;
24
-//    @Value("${yz.sms.api}")
25
-//    String smsAPI;
26
-//
27
-//    @Value("${yz.sms.appid}")
28
-//    String appid;
29
-//
30
-//    //    @Async
74
+
75
+//@Service
76
+////@EnableScheduling //开启定时任务
77
+////@EnableAsync  //开启多线程
78
+//public class SMSUtils {
79
+//    //    @Override
80
+////    @Async
31 81
 ////    @Scheduled(cron = "0 30 8 * * ?") //时隔多少秒
32
-//    public void SendMessage(Message message) throws Exception {
33
-//        long nowMills = System.currentTimeMillis();
34
-//        String timestamp = String.valueOf(nowMills);
35
-//        String secret = appid + timestamp;
36
-//
37
-//        Map<String, String> header = new HashMap<>();
38
-//        header.put("x-appid", appid);
39
-//        header.put("x-timestamp", timestamp);
40
-//        header.put("x-sign", EncryptUtils.md5(appid + secret, timestamp));
41
-//
42
-//        Map<String, String> body = new HashMap<>();
43
-//        body.put("PhoneNumbers", message.getTel());
44
-//        body.put("SignName", message.getSign());
45
-//        body.put("TemplateCode", message.getCode());
46
-//        body.put("TemplateParam", message.getContent());
47
-//
48
-//        httpUtils.post(smsAPI, header, JSONObject.toJSONString(body, false));
49
-//
50
-//    }
51
-//
52
-//    @Override
53
-//    public void afterPropertiesSet() throws Exception {
54
-//    }
82
+//    public static void smsMessage(String phoneNumber, String TemplateCode, Map code) {  //AccessKey ID 账号 AccessKey secret密码
83
+//        DefaultProfile profile = DefaultProfile.getProfile("cn-nanjing", "LTAI4G16F251gw8zRaePUPQo", "你自己的密码");
84
+//        IAcsClient client = new DefaultAcsClient(profile);
85
+//        //阿里云原有的配置信息我们不需要改动
86
+//        CommonRequest request = new CommonRequest();
87
+//        request.setSysMethod(MethodType.POST);
88
+//        request.setSysDomain("dysmsapi.aliyuncs.com");
89
+//        request.setSysVersion("2017-05-25");
90
+//        request.setSysAction("SendSms");
91
+//        //自定义短信信息
92
+//        request.putQueryParameter("phoneNumber", phoneNumber); //发送给哪个手机号
93
+//        request.putQueryParameter("SignName", "清峰小栈");  //自己配置的短信签名
94
+//        request.putQueryParameter("TemplateCode", TemplateCode); //自己配置的模板 模版CODE
55 95
 //
56
-//    @Data
57
-//    @Accessors(chain = true)
58
-//    public static class Message {
59
-//        String code;
60
-//        String tel;
61
-//        String sign;
62
-//        String content;
96
+//        //构建一个短信验证码
97
+////        HashMap<String, Object> map = new HashMap<>();
98
+////        map.put("code", 8456);
99
+//        request.putQueryParameter("TemplateParam", JSONObject.toJSONString(code));   //转换成json字符串
100
+//        try {
101
+//            CommonResponse response = client.getCommonResponse(request); //发送至客户端
102
+//            System.out.println(response.getData());
103
+//        } catch (ClientException e) {
104
+//            e.printStackTrace();
105
+//        }
63 106
 //    }
64 107
 //
65
-//}
108
+//}

+ 18
- 0
src/main/java/task/everyDayMessage.java Bestand weergeven

@@ -0,0 +1,18 @@
1
+package task;
2
+import org.springframework.scheduling.annotation.Async;
3
+import org.springframework.scheduling.annotation.EnableAsync;
4
+import org.springframework.scheduling.annotation.EnableScheduling;
5
+import org.springframework.scheduling.annotation.Scheduled;
6
+@EnableScheduling //开启定时任务
7
+@EnableAsync  //开启多线程
8
+public class everyDayMessage {
9
+
10
+    @Async
11
+    @Scheduled(cron = "0 30 8 * * ?") //时隔多少秒
12
+    public void remind() {
13
+
14
+
15
+
16
+
17
+    }
18
+}

+ 12
- 1
src/main/resources/application.yml Bestand weergeven

@@ -14,6 +14,12 @@ spring:
14 14
   profiles:
15 15
     active: @profileActive@
16 16
 
17
+###
18
+sms:
19
+  captcha:
20
+    code: SMS 460785881
21
+    sign: 荟居
22
+
17 23
 ###
18 24
 yz:
19 25
   filter:
@@ -27,7 +33,12 @@ yz:
27 33
       - "/ma/captcha"
28 34
       - "/ma/change-password"
29 35
       - "/ma/auth-phone"
30
-
36
+  sms:
37
+    ##任意命名
38
+    appid:
39
+    api:
40
+    ## 帮助文档
41
+    help: http://sms.njyunzhi.com/help
31 42
 sa-token:
32 43
   # jwt秘钥
33 44
   jwt-secret-key: d4d778d279cf11ed9b1d525400e8554f