From 247493f0980f703d163620ccc139b25927c28f8f Mon Sep 17 00:00:00 2001 From: lige <bestlige@outlook.com> Date: 星期二, 05 三月 2024 18:21:03 +0800 Subject: [PATCH] 文件服务器 --- ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java | 40 +++++++++++++++++++++++++++++++++------- 1 files changed, 33 insertions(+), 7 deletions(-) diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java index 10c1554..65ba644 100644 --- a/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java +++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/app/WxloginController.java @@ -1,5 +1,6 @@ package com.ltkj.web.controller.app; +import cn.hutool.core.date.DateTime; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -25,6 +26,7 @@ import org.aspectj.bridge.MessageWriter; import org.bouncycastle.jce.provider.BouncyCastleProvider; import org.springframework.beans.factory.annotation.Value; +import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; import org.springframework.web.client.RestTemplate; import sun.misc.BASE64Decoder; @@ -71,6 +73,7 @@ /** * 灏忕▼搴忕櫥褰� + * * @param code 灏忕▼搴弚x.login杩斿洖鐨勪复鏃跺嚟璇� * @return */ @@ -110,7 +113,7 @@ wxuser.setCreateTime(new Date()); wxuser.setWxMiniOpenId(openId); wxuserService.save(wxuser); - map.put("wxuser",wxuser); + map.put("wxuser", wxuser); } // 鐢熸垚浠ょ墝 String token = JwtUtils.getToken(map); @@ -130,11 +133,12 @@ @ApiOperation(value = "灏忕▼搴忚幏鍙栫敤鎴疯鎯呬俊鎭帴鍙�") public AjaxResult getWxInfo() { Wxuser wxuser = UserHoder.getWxuser(); - LambdaQueryWrapper<Wxuser>wq=new LambdaQueryWrapper<>(); - wq.eq(Wxuser::getOpenid,wxuser.getOpenid()); + LambdaQueryWrapper<Wxuser> wq = new LambdaQueryWrapper<>(); + wq.eq(Wxuser::getOpenid, wxuser.getOpenid()); Wxuser one = wxuserService.getOne(wq); return AjaxResult.success(one); } + /** * 寰俊鎵嬫満鍙风爜缁戝畾 */ @@ -156,7 +160,7 @@ byte[] raw = decoder.decodeBuffer(sessionKey); SecretKeySpec skeySpec = new SecretKeySpec(raw, "AES"); IvParameterSpec iv1 = new IvParameterSpec(decoder.decodeBuffer(iv)); - Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding","BC"); + Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding", "BC"); cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv1); OkHttpClient client = new OkHttpClient(); Request okrequest = new Request.Builder() @@ -191,6 +195,7 @@ /** * 鍙戦�佽姹傜敤code鎹㈠彇sessionKey鍜岀浉鍏充俊鎭� + * * @param code * @return */ @@ -226,7 +231,7 @@ byte[] ivByte = Base64.decode(iv); try { - // 濡傛灉瀵嗛挜涓嶈冻16浣嶏紝閭d箞灏辫ˉ瓒�. 杩欎釜if 涓殑鍐呭寰堥噸瑕� + // 濡傛灉瀵嗛挜涓嶈冻16浣嶏紝閭d箞灏辫ˉ瓒�. 杩欎釜if 涓殑鍐呭寰堥噸瑕� int base = 16; if (keyByte.length % base != 0) { int groups = keyByte.length / base + (keyByte.length % base != 0 ? 1 : 0); @@ -235,7 +240,7 @@ System.arraycopy(keyByte, 0, temp, 0, keyByte.length); keyByte = temp; } - // 鍒濆鍖� + // 鍒濆鍖� Security.addProvider(new BouncyCastleProvider()); /** * 瑙e喅java涓嶆敮鎸丄ES/CBC/PKCS7Padding妯″紡瑙e瘑 @@ -257,7 +262,6 @@ } return null; } - /** @@ -346,5 +350,27 @@ return response; } + + @PostMapping("/wx/wxbindphone") + @ApiOperation("鎵嬪姩缁戝畾鎵嬫満鍙锋帴鍙�") + @Transactional + public AjaxResult wxbindphone(@RequestParam @ApiParam(value = "openId") String openId, + @RequestParam @ApiParam(value = "phone") String phone) { + + LambdaQueryWrapper<Wxuser> wq = new LambdaQueryWrapper<>(); + wq.eq(Wxuser::getOpenid, openId); + Wxuser one = wxuserService.getOne(wq); + + if (one!=null){ + one.setPhone(phone); + one.setUpdateTime(new DateTime()); + final boolean b = wxuserService.updateById(one); + if (b){ + return AjaxResult.success("缁戝畾鎴愬姛锛�"); + } + } + return AjaxResult.error("缁戝畾澶辫触锛�"); + } + } -- Gitblit v1.8.0