puzhibing
2026-02-25 594986ad49f559374aabaa734257d572fba84e31
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
package com.xiaopeng.operation.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.xiaopeng.api.model.maintenance.XpAgreementAppUser;
import com.xiaopeng.common.core.domain.R;
import com.xiaopeng.common.core.web.controller.BaseController;
import com.xiaopeng.operation.dto.XpAgreementAppUserDto;
import com.xiaopeng.operation.service.XpAgreementAppUserService;
import com.xiaopeng.unifiedverification.interceptor.XpClientCheck;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
 
@Slf4j
@RestController
@RequestMapping("/api/v1/mini-program")
@Api(tags = "用户协议模块")
public class XpAgreementUserController extends BaseController {
 
    private final XpAgreementAppUserService xpAgreementAppUserService;
 
    public XpAgreementUserController(XpAgreementAppUserService xpAgreementAppUserService) {
        this.xpAgreementAppUserService = xpAgreementAppUserService;
    }
 
 
    /**
     * 用户同意隐私协议/法律条款操作
     */
    @ApiOperation(value = "用户同意隐私协议法律条款",tags = {"小程序-用户协议"})
    @PostMapping("/privacy/agreement")
    @XpClientCheck(checkToken = false, checkOtpToken = true)
    public R<?> privacyAgreement(@RequestBody XpAgreementAppUserDto dto, HttpServletRequest request) {
        // uid已通过拦截器otp校验,可以直接使用
        String uid = request.getHeader("XP-Uid");
        xpAgreementAppUserService.addXpAgreementAppUser(dto, Long.valueOf(uid));
        return R.ok();
    }
 
 
    /**
     * 用户获取隐私协议/法律条款操作
     */
    @ApiOperation(value = "用户获取隐私协议法律条款操作",tags = {"小程序-用户协议"})
    @PostMapping("/privacy/getAgreement")
    @XpClientCheck(checkToken = false, checkOtpToken = true)
    public R<Boolean> getPrivacyAgreement(HttpServletRequest request) {
        // uid已通过拦截器otp校验,可以直接使用
        String uid = request.getHeader("XP-Uid");
        long count = xpAgreementAppUserService.count(new LambdaQueryWrapper<XpAgreementAppUser>().eq(XpAgreementAppUser::getAppUserId, uid));
        if (count > 0) {
            return R.ok(true);
        }
        return R.ok(false);
    }
 
}