liujie
2026-09-14 82a8bc62d5b9d5d607f6952329952b17eda2f0a0
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
package com.tourguide.api.admin;
 
import com.tourguide.common.api.ApiResponse;
import com.tourguide.modules.operation.dto.AgreementContentRequest;
import com.tourguide.modules.operation.dto.AgreementResponse;
import com.tourguide.modules.operation.service.AgreementSettingService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.List;
 
/**
 * 管理后台协议内容维护接口。
 * 提供协议列表查询和按协议编码更新正文的能力,协议类型由后端预置编码约束。
 */
@RestController
@RequestMapping("/api/admin/agreements")
public class AdminAgreementSettingController {
    private final AgreementSettingService agreementService;
 
    public AdminAgreementSettingController(AgreementSettingService agreementService) {
        this.agreementService = agreementService;
    }
 
    /**
     * 查询后台当前支持维护的全部协议及其最新内容。
     *
     * @return 协议编码、名称、正文和更新时间组成的列表
     */
    @GetMapping
    public ApiResponse<List<AgreementResponse>> list() {
        return ApiResponse.success(agreementService.list());
    }
 
    /**
     * 更新指定协议编码对应的正文内容。
     *
     * @param code 协议唯一编码,用于定位用户协议、隐私政策等具体协议
     * @param request 协议正文保存参数
     * @return 更新后的协议完整信息
     */
    @PutMapping("/{code}")
    public ApiResponse<AgreementResponse> update(@PathVariable String code,
                                                 @Valid @RequestBody AgreementContentRequest request) {
        return ApiResponse.success(agreementService.update(code, request.getContent()));
    }
}