mitao
2025-03-10 9dbb6c26c81e94e8f969805b40b0e183bf306f83
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
package com.ruoyi.system.controller;
 
 
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.utils.page.BeanUtils;
import com.ruoyi.system.domain.Agreement;
import com.ruoyi.system.domain.dto.AgreementDTO;
import com.ruoyi.system.service.IAgreementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
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.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author mitao
 * @since 2024-05-21
 */
@RestController
@RequestMapping("/agreement")
@Api(tags = "系统管理相关接口")
public class AgreementController {
    @Resource
    private IAgreementService  iAgreementService;
 
    @RequestMapping(value = "/getAgreement/{agreementType}", method = RequestMethod.GET)
    @ApiOperation(value = "获取用户协议/隐私协议/竞拍说明")
    public R<Agreement> getAgreement(
            @ApiParam(name = "agreementType", value = "协议类型1:用户协议 2:隐私协议 3:竞拍说明") @PathVariable("agreementType") Integer agreementType) {
        return R.ok(iAgreementService.getAgreement(agreementType));
    }
 
    /**
     * 管理后台-获取协议列表
     *
     * @return List<AgreementDTO>
     */
    @ApiOperation("管理后台-获取协议列表")
    @GetMapping("/list")
    public R<List<AgreementDTO>> getAgreementList() {
        List<Agreement> list = iAgreementService.lambdaQuery().last("limit 3").list();
        return R.ok(BeanUtils.copyList(list, AgreementDTO.class));
    }
 
    /**
     * 保存协议
     *
     * @param dto 协议对象
     */
    @ApiOperation(value = "管理后台-保存用户协议", notes = "接收一个包含多个AgreementDTO的列表")
    @PostMapping("/save")
    public R<?> saveAgreement(@Validated @RequestBody AgreementDTO dto) {
        iAgreementService.saveAgreement(dto);
        return R.ok();
    }
}