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()));
|
}
|
}
|