MrShi
昨天 7ee466ebc953bb5640bcf42f2b8e2a87aa471c21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package com.doumee.api.web;
 
import com.doumee.config.jwt.JwtTokenUtil;
import com.doumee.core.annotation.LoginRequired;
import com.doumee.core.annotation.trace.Trace;
import com.doumee.core.model.ApiResponse;
import com.doumee.dao.business.model.Member;
import com.doumee.dao.dto.ShopLoginDTO;
import com.doumee.dao.dto.WxPhoneRequest;
import com.doumee.dao.vo.AccountResponse;
import com.doumee.dao.vo.ShopLoginVO;
import com.doumee.service.business.MemberService;
import com.doumee.service.business.ShopInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Rk
 * @create 2025/7/10 9:29
 */
@Api(tags = "1、登录业务")
@Trace(exclude = true)
@RestController
@RequestMapping("/web/account")
@Slf4j
public class AccountApi extends  ApiController{
 
 
    @Autowired
    private MemberService memberService;
 
    @Autowired
    private ShopInfoService shopInfoService;
 
 
    @Trace
    @ApiOperation(value = "会员微信授权", notes = "小程序端")
    @GetMapping("/wxLogin")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "微信code", required = true)
    })
    public ApiResponse<AccountResponse> wxLogin(@RequestParam String code) {
        return  ApiResponse.success("操作成功",memberService.wxLogin(code));
    }
 
 
    @ApiOperation(value = "会员授权手机号", notes = "小程序端")
    @PostMapping("/wxAuthPhone")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "code", value = "微信code", required = true)
    })
    public ApiResponse<AccountResponse> wxAuthPhone(@RequestBody WxPhoneRequest wxPhoneRequest) {
        return  ApiResponse.success("操作成功",memberService.wxAuthPhone(wxPhoneRequest));
    }
 
    @ApiOperation(value = "门店账号密码登录", notes = "小程序端,门店用户通过手机号+密码登录")
    @PostMapping("/shopLogin")
    public ApiResponse<ShopLoginVO> shopLogin(@RequestBody @Validated ShopLoginDTO dto) {
        return ApiResponse.success("操作成功", shopInfoService.shopPasswordLogin(dto));
    }
 
    @ApiOperation(value = "门店静默登录", notes = "根据openid自动登录门店,未绑定则返回空")
    @GetMapping("/shopSilentLogin")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "String", name = "openid", value = "微信openid", required = true)
    })
    public ApiResponse<ShopLoginVO> shopSilentLogin(@RequestParam String openid) {
        return ApiResponse.success("操作成功", shopInfoService.shopSilentLogin(openid));
    }
 
    @LoginRequired
    @ApiOperation(value = "退出登录", notes = "小程序端")
    @GetMapping("/logOut")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
    })
    public ApiResponse logOut() {
        String token = this.getRequest().getHeader(JwtTokenUtil.HEADER_KEY);
        memberService.logOut(token,getMemberId());
        return  ApiResponse.success("操作成功");
    }
 
    @LoginRequired
    @ApiOperation(value = "用户注销", notes = "小程序端")
    @GetMapping("/logOff")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "header", dataType = "String", name = "token", value = "用户token值", required = true),
    })
    public ApiResponse logOff() {
        String token = this.getRequest().getHeader(JwtTokenUtil.HEADER_KEY);
        memberService.logOff(token,getMemberId());
        return  ApiResponse.success("操作成功");
    }
 
 
 
 
 
 
 
}