diff --git a/TODOs.md b/TODOs.md
index 151f142..397afec 100644
--- a/TODOs.md
+++ b/TODOs.md
@@ -3,4 +3,6 @@
更多:
完成项目代码中的 TODO 部分
-身份码后端接口考虑与其他系统的集成逻辑
\ No newline at end of file
+身份码后端接口考虑与其他系统的集成逻辑
+
+Java代码中小程序AppID、密钥处理,小程序代码中小程序AppID处理
\ No newline at end of file
diff --git a/backend/microservice-provider-access-8002/pom.xml b/backend/microservice-provider-access-8002/pom.xml
index a816e77..5cd9249 100644
--- a/backend/microservice-provider-access-8002/pom.xml
+++ b/backend/microservice-provider-access-8002/pom.xml
@@ -98,6 +98,11 @@
fastjson2
+
+
+ com.squareup.okhttp3
+ okhttp
+
diff --git a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/WeChatTokenController.java b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/WeChatTokenController.java
index 7965355..872e8e4 100644
--- a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/WeChatTokenController.java
+++ b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/controller/WeChatTokenController.java
@@ -1,11 +1,15 @@
package com.cxyxiaomo.epp.access.controller;
+import com.cxyxiaomo.epp.access.pojo.UnlimitedQRCodeParam;
import com.cxyxiaomo.epp.access.service.WeChatTokenServiceImpl;
import com.cxyxiaomo.epp.common.response.Res;
+import lombok.SneakyThrows;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@@ -21,4 +25,24 @@ public class WeChatTokenController {
String accessToken = weChatTokenService.getAccessToken();
return Res.success(accessToken);
}
+
+ @GetMapping(value = "/getUnlimitedQRCode", produces = MediaType.IMAGE_PNG_VALUE)
+ @ResponseBody
+ @SneakyThrows
+ public byte[] getUnlimitedQRCode(@RequestParam(value = "envVersion", required = false, defaultValue = "develop") String envVersion,
+ @RequestParam(value = "page", required = false, defaultValue = "pages/index/index") String page,
+ @RequestParam(value = "autoColor", required = false, defaultValue = "false") Boolean autoColor,
+ @RequestParam(value = "isHyaline", required = false, defaultValue = "false") Boolean isHyaline,
+ @RequestParam(value = "scene", required = true) String scene) {
+ String accessToken = weChatTokenService.getAccessToken();
+ UnlimitedQRCodeParam unlimitedQRCodeParam = new UnlimitedQRCodeParam();
+ unlimitedQRCodeParam.setScene(scene);
+ unlimitedQRCodeParam.setPage(page);
+ unlimitedQRCodeParam.setEnvVersion(envVersion);
+ unlimitedQRCodeParam.setAutoColor(autoColor);
+ unlimitedQRCodeParam.setIsHyaline(isHyaline);
+ okhttp3.ResponseBody responseBody = weChatTokenService.getUnlimitedQRCodeFromApi(accessToken, unlimitedQRCodeParam);
+
+ return responseBody.bytes();
+ }
}
diff --git a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/pojo/UnlimitedQRCodeParam.java b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/pojo/UnlimitedQRCodeParam.java
new file mode 100644
index 0000000..83b0b05
--- /dev/null
+++ b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/pojo/UnlimitedQRCodeParam.java
@@ -0,0 +1,35 @@
+package com.cxyxiaomo.epp.access.pojo;
+
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+
+@Data
+@NoArgsConstructor
+@Accessors(chain = true) // 链式写法
+public class UnlimitedQRCodeParam implements Serializable {
+
+ // 最大32个可见字符,只支持数字,大小写英文以及部分特殊字符:!#$&'()*+,/:;=?@-._~
+ private String scene;
+
+ // 页面 page
+ private String page = "pages/index/index";
+
+ // 检查 page 是否存在
+ private Boolean checkPath = true;
+
+ // 要打开的小程序版本
+ // 正式版为 "release",体验版为 "trial",开发版为 "develop"。默认是正式版。
+ private String envVersion;
+
+ // 二维码的宽度,单位 px,最小 280px,最大 1280px
+ private Integer width = 430;
+
+ // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调,默认 false
+ private Boolean autoColor;
+
+ // 是否需要透明底色,为 true 时,生成透明底色的小程序,默认是false
+ private Boolean isHyaline;
+}
diff --git a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/WeChatTokenServiceImpl.java b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/WeChatTokenServiceImpl.java
index 13fb784..88d0c73 100644
--- a/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/WeChatTokenServiceImpl.java
+++ b/backend/microservice-provider-access-8002/src/main/java/com/cxyxiaomo/epp/access/service/WeChatTokenServiceImpl.java
@@ -1,14 +1,20 @@
package com.cxyxiaomo.epp.access.service;
+import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.cxyxiaomo.epp.access.dao.AccessDao;
+import com.cxyxiaomo.epp.access.pojo.UnlimitedQRCodeParam;
import com.cxyxiaomo.epp.access.utils.RestUtil;
import com.cxyxiaomo.epp.common.pojo.Setting;
+import lombok.SneakyThrows;
+import okhttp3.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
+import java.util.HashMap;
+import java.util.Map;
@Service
public class WeChatTokenServiceImpl implements WeChatTokenService {
@@ -20,8 +26,12 @@ public class WeChatTokenServiceImpl implements WeChatTokenService {
final String SETTING_KEY = "wechat_access_token";
// 小程序信息
- final String APPID = "wxa70348746d2b562f";
- final String APPSECRET = "7da57703136fefb0584a5a6ab1aca152";
+ // 小程序测试号
+ // final String APPID = "wxa70348746d2b562f";
+ // final String APPSECRET = "7da57703136fefb0584a5a6ab1aca152";
+ // 小程序个人号
+ final String APPID = "wx332e2e578f09873a";
+ final String APPSECRET = "ebcd79d303e37983d691fe1dfdfb8818";
@Override
public String getAccessToken() {
@@ -74,11 +84,35 @@ public class WeChatTokenServiceImpl implements WeChatTokenService {
String jsonStr = RestUtil.doGetRequest(url, headers);
return JSONObject.parseObject(jsonStr);
}
+
+ @SneakyThrows
+ public ResponseBody getUnlimitedQRCodeFromApi(String accessToken, UnlimitedQRCodeParam unlimitedQRCodeParam) {
+ // refer: https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/qrcode-link/qr-code/getUnlimitedQRCode.html
+ String url = String.format("https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=%s", accessToken);
+
+ //添加参数
+ Map params = new HashMap<>();
+ params.put("scene", unlimitedQRCodeParam.getScene());
+ params.put("page", unlimitedQRCodeParam.getPage());
+ params.put("check_path", unlimitedQRCodeParam.getCheckPath());
+ params.put("env_version", unlimitedQRCodeParam.getEnvVersion());
+ params.put("width", unlimitedQRCodeParam.getWidth());
+ params.put("auto_color",unlimitedQRCodeParam.getAutoColor());
+ params.put("is_hyaline",unlimitedQRCodeParam.getIsHyaline());
+ String paramsString = JSON.toJSONString(params);
+
+ OkHttpClient okHttpClient = new OkHttpClient();
+ Request request = new Request.Builder()
+ .addHeader("content-type", "application/json")
+ .url(url)
+ .post(RequestBody.create(paramsString, MediaType.parse("application/json; charset=utf-8")))
+ .build();
+ Response response = okHttpClient.newCall(request).execute();
+ // String result = response.body()response.body().string();
+
+ // System.out.println("headers: " + response.headers());
+ // System.out.println("body: " + response.body());
+ System.out.println("paramsString: " + paramsString);
+ return response.body();
+ }
}
-/*
-{
- "success": true,
- "msg": "操作成功",
- "data": "{\"access_token\":\"63_ez5i6A4ib1-kwi-g6n_3LLqdthenpZGIHTs1tXXcYqia8mnntJlTc_Mkl8CtuiXx0oplHbEVXrkVycvNwkyXhbA2Yj5K1kCan-AjOjH_-zaleYfg-S3zDWO9uoUQWVbACALRQ\",\"expires_in\":7200}"
-}
-*/
diff --git a/backend/pom.xml b/backend/pom.xml
index 5882bef..fbcdbd0 100644
--- a/backend/pom.xml
+++ b/backend/pom.xml
@@ -108,19 +108,26 @@
runtime
${mysql.version}
-
+
com.alibaba
druid
${druid.version}
-
+
org.mybatis.spring.boot
mybatis-spring-boot-starter
2.2.2
+
+
+ com.squareup.okhttp3
+ okhttp
+ 4.10.0
+
+
com.alibaba.fastjson2
diff --git a/client-entrance-guard/html/index.css b/client-entrance-guard/html/index.css
new file mode 100644
index 0000000..603786b
--- /dev/null
+++ b/client-entrance-guard/html/index.css
@@ -0,0 +1,65 @@
+* {
+ margin: 0;
+ padding: 0;
+}
+html,
+body {
+ height: 100%;
+ color: white;
+}
+
+.container {
+ width: 100%;
+ height: 100%;
+ background-color: #0556c6;
+ display: grid;
+ grid-template-columns: 3fr 4fr;
+ /* align-items: center; */
+ place-items: center;
+ /* justify-items: center; */
+ /* place-content: center; */
+}
+
+.left-container {
+ text-shadow: 2px 2px 2px #00000066;
+}
+
+h1 {
+ margin-bottom: 30px;
+ font-size: 4vw;
+}
+
+h3 {
+ margin-bottom: 10px;
+ margin-top: 22px;
+ font-size: 2vw;
+}
+
+p {
+ font-size: 1.4vw;
+ line-height: 1.5em;
+}
+
+.right-container {
+}
+
+#qrcode {
+ box-shadow: 0px 0px 17px 12px rgb(0 0 0 / 50%);
+ border-radius: 50%;
+ display: block;
+ width: min(40vw, 68vh);
+ height: min(40vw, 68vh);
+}
+
+#refreshTimeCountDown {
+ text-align: center;
+ margin-top: 30px;
+ font-size: 2em;
+ color: #ffffff9c;
+}
+
+/* #fullscreen-button {
+ position: absolute;
+ right: 0;
+ top: 0;
+} */
diff --git a/client-entrance-guard/html/index.html b/client-entrance-guard/html/index.html
index a6f4a90..890bc26 100644
--- a/client-entrance-guard/html/index.html
+++ b/client-entrance-guard/html/index.html
@@ -3,17 +3,36 @@
-
-
- Hello World!
+
+
+
+ 社区疫情防控系统 - 门禁端
+
- Hello World!
- We are using Node.js ,
- Chromium ,
- and Electron .
-
+
+
+
进出社区请扫码
+
+
社区居民
+
1. 打开 微信 > 扫一扫,扫描右侧小程序码
+
2. 点击确认进入,门即开启
+
+
外来访客
+
1. 打开 微信 > 扫一扫,扫描右侧小程序码
+
2. 填写进入申请表
+
+
长期租客
+
1. 请联系管理员为你添加进出权限
+
+
+
+
+
+
+
+