Pu Zhibing
2025-03-26 7f26677ab7f9b83697370fa142dd1686cdf4082a
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
package com.ruoyi.other.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.other.api.domain.Agreement;
import com.ruoyi.other.service.IAgreementService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.time.LocalDateTime;
 
/**
 * @author zhibing.pu
 * @Date 2024/11/21 10:48
 */
@RestController
@RequestMapping("/agreement")
public class AgreementController {
    
    @Resource
    private IAgreementService agreementService;
    
    
    /**
     * 获取协议详情
     * @param type
     * @return
     */
    @ResponseBody
    @GetMapping("/getAgreement/{type}")
    @ApiOperation(value = "获取协议", tags = {"小程序-登录注册"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "类型(1=用户协议,2=隐私协议,3=技师上门免责声明,4=注销协议,5门店提现免责声明)", name = "type", required = true, dataType = "int"),
    })
    public R<String> getAgreement(@PathVariable("type") Integer type){
        Agreement one = agreementService.getOne(new LambdaQueryWrapper<Agreement>().eq(Agreement::getType, type));
        return R.ok(null == one ? "" : one.getContent());
    }
    
    
    @ResponseBody
    @GetMapping("/getAgreementByType/{type}")
    @ApiOperation(value = "协议管理-详情", tags = {"管理后台"})
    @ApiImplicitParams({
            @ApiImplicitParam(value = "类型(1=用户协议,2=隐私协议,3=技师上门免责声明,4=注销协议,5门店提现免责声明)", name = "type", required = true, dataType = "int"),
    })
    public R<Agreement> getAgreementByType(@PathVariable("type") Integer type){
        Agreement one = agreementService.getOne(new LambdaQueryWrapper<Agreement>().eq(Agreement::getType, type));
        return R.ok(one);
    }
    
    
    @ResponseBody
    @PostMapping("/saveAgreement")
    @ApiOperation(value = "协议管理-保存协议", tags = {"管理后台"})
    public R saveAgreement(@RequestBody Agreement agreement){
        if(null != agreement.getId()){
            agreementService.updateById(agreement);
        }else{
            agreement.setCreateTime(LocalDateTime.now());
            agreementService.save(agreement);
        }
        return R.ok();
    }
    
}