Alpha Sprint Essay 2

NoFantasy 2024-12-07 02:02:26
Course for This Assignment2401_MU_SE_FZU
Team NameNoFantasy
Assignment RequirementsFifth Assignment——Alpha Sprint
Objectives of This AssignmentAlpha Sprint
Other ReferencesNO reference

1. Burn Down Chart

img

2. Front-end

Aim: Add information editing and modification in personal interface
Problem: None
Partial code

img

Achieve effect

img

3. Back-end

Aim: set an upper limit of inactivity for each user
Problem: None

@PostMapping("/wxLogin")

    public AjaxResult wxLogin(@RequestBody WxLoginBody wxLoginBody) {

        String code = wxLoginBody.getCode();

        //秘钥

        String encryptedIv = wxLoginBody.getEncryptedIv();

        //加密数据

        String encryptedData = wxLoginBody.getEncryptedData();

        //向微信服务器发送请求获取用户信息

        String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + HellConfig.getAppId() + "&secret=" + HellConfig.getAppSecret() + "&js_code=" + code + "&grant_type=authorization_code";

        String res = restTemplate.getForObject(url, String.class);

        JSONObject jsonObject = JSONObject.parseObject(res);

        //获取session_key和openid

        String sessionKey = jsonObject.getString("session_key");

        String openid = jsonObject.getString("openid");

        //解密

        String decryptResult = "";

        try {

            //如果没有绑定微信开放平台,解析结果是没有unionid的。

            decryptResult = decrypt(sessionKey, encryptedIv, encryptedData);

        } catch (Exception e) {

            e.printStackTrace();

            return AjaxResult.error("微信登录失败!");

        }

        if (StringUtils.hasText(decryptResult)) {

            //如果解析成功,获取token

            String token = loginService.wxLogin(decryptResult,wxLoginBody.getAvatarUrl());

            AjaxResult ajax = AjaxResult.success();

            ajax.put(Constants.TOKEN, token);

            return ajax;

        } else {

            return AjaxResult.error("微信登录失败!");

        }

    }
...全文
41 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

170

社区成员

发帖
与我相关
我的任务
社区描述
2401_MU_SE_FZU
软件工程 高校
社区管理员
  • FZU_SE_TeacherL
  • 助教-吴可仪
  • 助教-孔志豪
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧