lidongdong
2022-11-18 97bb97c13ad63c40a8baf73b0f5e08d93c0e7559
springcloud_k8s_panzhihuazhihuishequ/applets/src/main/java/com/panzhihua/applets/api/LoginApi.java
@@ -2,6 +2,8 @@
import javax.annotation.Resource;
import com.panzhihua.common.constants.Constants;
import com.panzhihua.common.utlis.RSAUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
@@ -39,6 +41,9 @@
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException;
import java.util.HashMap;
import java.util.Map;
/**
 * @program: springcloud_k8s_panzhihuazhihuishequ
@@ -91,6 +96,10 @@
        }
        userService.addOrUpdate(openid, sessionKey, unionid,this.getAppId());
        return tokenService.loginApplets(openid,this.getAppId());
    }
    @PostMapping("/loginTest")
    public R loginTest(@RequestBody LoginRequest loginRequest){
        return tokenService.loginApplets(loginRequest.getCode(),this.getAppId());
    }
    @ApiOperation(value = "H5登录", response = LoginReturnVO.class)
@@ -313,10 +322,22 @@
    @GetMapping("uu/getQRCode")
    public R uuLogin(@RequestParam("couponId") String couponId) {
        try {
            WxMaQrcodeService qrCodeService = wxMaConfiguration.getMaService("wx118de8a734d269f0").getQrcodeService();
            byte[] bytes = qrCodeService.createWxaCodeUnlimitBytes("couponId=" + couponId,
                "packageD/pages/user/getCoupon/getCoupon", true, "release", 30, true, null, false);
            return R.ok(String.format("data:image/png;base64,%s", Base64.encode(bytes)));
            //i小懒
            WxMaQrcodeService wsCodeService = wxMaConfiguration.getMaService("wx98d62711dfbd8425").getQrcodeService();
            byte[] bytes = wsCodeService.createWxaCodeUnlimitBytes("couponId=" + couponId,
                "pages/user/getCoupon/getCoupon", true, "release", 30, true, null, false);
            String res = String.format("data:image/png;base64,%s", Base64.encode(bytes));
            //花城
            WxMaQrcodeService uuCodeService = wxMaConfiguration.getMaService("wx118de8a734d269f0").getQrcodeService();
            byte[] hcBytes = uuCodeService.createWxaCodeUnlimitBytes("couponId=" + couponId,
                    "packageD/pages/user/getCoupon/getCoupon", true, "release", 30, true, null, false);
            String hcRes = String.format("data:image/png;base64,%s", Base64.encode(hcBytes));
            Map<String,String> retMap = new HashMap<>();
            retMap.put("ixiaolan",res);
            retMap.put("huacheng",hcRes);
            return R.ok(retMap);
        } catch (Exception e) {
            log.error("generate QRCode failed:" + e.getMessage());
            return R.fail("generate QRCode failed");
@@ -326,8 +347,20 @@
    @ApiOperation("天府通办登录")
    @PostMapping("tfLogin")
    public R tfLogin(@RequestBody UuLoginVO uuLoginVO){
        try {
            uuLoginVO.setMobile(RSAUtils.decrypt(uuLoginVO.getMobile(), Constants.PRIVATE_KEY));
            //测试是否能正常添加用户
        } catch (Exception e) {
            e.printStackTrace();
            return R.fail();
        }
        userService.tfLogin(uuLoginVO);
        R r=tokenService.tfLogin(uuLoginVO.getMobile(),"Huacheng@123","wx118de8a734d269f0");
        return r;
    }
    @ApiOperation("用户授权")
    @GetMapping("/accept")
    public R accept(){
        return userService.accept(this.getUserId());
    }
}