|
|
|
@ -4,6 +4,7 @@ package com.zh.project0512.controller.manage;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
|
import com.zh.project0512.annotation.adminTokenValid;
|
|
|
|
|
import com.zh.project0512.model.Admin;
|
|
|
|
|
import com.zh.project0512.model.User;
|
|
|
|
|
import com.zh.project0512.service.IAdminService;
|
|
|
|
@ -74,42 +75,28 @@ public class AdminController {
|
|
|
|
|
return Result.success(admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// @Operation(summary = "小程序注册", parameters = {
|
|
|
|
|
// @Parameter(name = "code", description = "login返回的code(未使用过!)"),
|
|
|
|
|
// @Parameter(name = "userInfo", description = "getUserInfo接口的iv和encryptedData"),
|
|
|
|
|
// @Parameter(name = "phone", description = "getPhoneNumber接口的iv和encryptedData")
|
|
|
|
|
// })
|
|
|
|
|
// @PostMapping("register")
|
|
|
|
|
// public Result register(@RequestBody @Parameter(hidden = true) JSONObject obj) {
|
|
|
|
|
// JSONObject res = weChatUtil.auth(obj.getString("code"));
|
|
|
|
|
// String openid = res.getString("openid");
|
|
|
|
|
// if (null == openid) {
|
|
|
|
|
// return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "无效的openid");
|
|
|
|
|
// }
|
|
|
|
|
// if (null != userService.selByOpenid(openid)) {
|
|
|
|
|
// return Result.fail(HttpStatusEnum.TEL_REGISTERED, "已注册");
|
|
|
|
|
// }
|
|
|
|
|
// String session_key = (String) res.get("session_key");
|
|
|
|
|
// JSONObject userinfo = obj.getJSONObject("userinfo");
|
|
|
|
|
// JSONObject phone = obj.getJSONObject("phone");
|
|
|
|
|
// String info = CoderUtil.decrypt(session_key, userinfo.getString("iv"), userinfo.getString("encryptedData"));
|
|
|
|
|
// String info2 = CoderUtil.decrypt(session_key, phone.getString("iv"), phone.getString("encryptedData"));
|
|
|
|
|
// JSONObject j = JSONObject.parseObject(info);
|
|
|
|
|
// JSONObject k = JSONObject.parseObject(info2);
|
|
|
|
|
// if (null == j || null == k) {
|
|
|
|
|
// return Result.fail(HttpStatusEnum.CUSTOM_EXCEPTION, "session_key解析失败");
|
|
|
|
|
// }
|
|
|
|
|
// User u = new User();
|
|
|
|
|
// u.setAvatar((String) j.get("avatarUrl"));
|
|
|
|
|
// u.setName((String) j.get("nickName"));
|
|
|
|
|
// u.setGender((Integer) j.get("gender"));
|
|
|
|
|
// u.setOpenid(openid);
|
|
|
|
|
// u.setTel(k.getString("phoneNumber"));
|
|
|
|
|
// u.setToken(new JwtUtil().createJWT(openid));
|
|
|
|
|
//// u.setToken(new JwtUtils().generateToken(openid, new Date().getTime()));
|
|
|
|
|
// u.setCreatAt(LocalDateTime.now());
|
|
|
|
|
// userService.save(u);
|
|
|
|
|
// return Result.success(u);
|
|
|
|
|
// }
|
|
|
|
|
@Data
|
|
|
|
|
static class registerParam {
|
|
|
|
|
@NotNull(message = "name不能为空")
|
|
|
|
|
@Schema(title = "账号名称")
|
|
|
|
|
private String name;
|
|
|
|
|
@NotNull(message = "密码不能为空")
|
|
|
|
|
@Schema(title = "密码")
|
|
|
|
|
@NotNull(message = "密码不能为空")
|
|
|
|
|
private String tel;
|
|
|
|
|
@Schema(title = "密码")
|
|
|
|
|
private String password;
|
|
|
|
|
@Schema(title = "真实名称")
|
|
|
|
|
private String realName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Operation(summary = "注册")
|
|
|
|
|
@PostMapping("register")
|
|
|
|
|
@adminTokenValid
|
|
|
|
|
public Result register(@Validated @RequestBody registerParam param) {
|
|
|
|
|
Admin admin = new Admin().setName(param.getName()).setPassword(param.getPassword()).setRealName(param.getRealName()).setCreatAt(LocalDateTime.now());
|
|
|
|
|
adminService.save(admin);
|
|
|
|
|
return Result.success(admin);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|