123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- package com.caimei.controller.wechat;
- import com.alibaba.fastjson.JSONObject;
- import com.caimei.model.ResponseJson;
- import com.caimei.model.vo.WxClubUserVo;
- import com.caimei.service.wechat.RegisterService;
- import com.caimei.service.wechat.WxUserService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiImplicitParam;
- import io.swagger.annotations.ApiImplicitParams;
- import io.swagger.annotations.ApiOperation;
- import lombok.RequiredArgsConstructor;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.web.bind.annotation.*;
- import java.util.Map;
- /**
- * 机构用户登录API
- *
- * @author : Aslee
- * @date : 2021/5/11
- */
- @Api(tags = "机构用户API")
- @RestController
- @RequiredArgsConstructor
- @RequestMapping("/wx/user")
- public class WxUserApi {
- private final WxUserService wxUserService;
- @ApiOperation("获取用户信息")
- @ApiImplicitParams({
- @ApiImplicitParam(name = "mobile", required = true, value = "手机号"),
- @ApiImplicitParam(name = "authUserId", required = false, value = "供应商用户id"),
- @ApiImplicitParam(name = "clubUserId", required = false, value = "机构用户id")
- })
- @GetMapping("/info")
- public ResponseJson<Map<String,Object>> register(String mobile, Integer authUserId, Integer clubUserId) {
- if (StringUtils.isEmpty(mobile) && null == clubUserId) {
- return ResponseJson.error("参数异常", null);
- }
- if (null == clubUserId && null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return wxUserService.getUserInfo(mobile, authUserId, clubUserId);
- }
- @ApiOperation("登录注册验证码发送")
- @ApiImplicitParam(name = "params", value = "mobile:手机号;authUserId:供应商用户id;type:1注册验证码,2忘记密码验证码")
- @PostMapping("/login/code/send")
- public ResponseJson sendForgetCode(@RequestBody String params) {
- JSONObject parseObject = JSONObject.parseObject(params);
- String mobile = parseObject.getString("mobile");
- Integer authUserId = parseObject.getInteger("authUserId");
- Integer type = parseObject.getInteger("type");
- if (StringUtils.isEmpty(mobile)) {
- return ResponseJson.error("手机号不能为空", null);
- }
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- if (null == type) {
- return ResponseJson.error("验证码类型不能为空");
- }
- return wxUserService.sendLoginCode(mobile, authUserId, type);
- }
- @ApiOperation("修改密码")
- @ApiImplicitParam(name = "params", value = "mobile:手机号;verifyCode:验证码;password:新密码;authUserId:供应商用户id")
- @PostMapping("/password/update")
- public ResponseJson updatePassword(@RequestBody String params) {
- JSONObject parseObject = JSONObject.parseObject(params);
- String mobile = parseObject.getString("mobile");
- String verifyCode = parseObject.getString("verifyCode");
- String password = parseObject.getString("password");
- Integer authUserId = parseObject.getInteger("authUserId");
- if (StringUtils.isEmpty(mobile)) {
- return ResponseJson.error("手机号不能为空", null);
- }
- if (StringUtils.isEmpty(verifyCode)) {
- return ResponseJson.error("验证码不能为空", null);
- }
- if (StringUtils.isEmpty(password)) {
- return ResponseJson.error("新密码不能为空", null);
- }
- if (null == authUserId) {
- return ResponseJson.error("供应商用户id不能为空", null);
- }
- return wxUserService.updatePassword(mobile, verifyCode, password, authUserId);
- }
- @ApiOperation("校验token是否失效")
- @PostMapping("/token/check")
- public ResponseJson checkToken(){
- return ResponseJson.success("token有效");
- }
- }
|