package com.tcm.training.admin.app.system.controller;
|
|
import com.tcm.training.admin.common.ApiResponse;
|
import com.tcm.training.admin.system.entity.AgreementContent;
|
import com.tcm.training.admin.system.service.AgreementContentAppService;
|
import com.tcm.training.admin.system.vo.AgreementContentItemVO;
|
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.RequestMapping;
|
import org.springframework.web.bind.annotation.RestController;
|
|
/**
|
* APP 协议内容接口。
|
*/
|
@Validated
|
@RestController
|
@RequestMapping({"/api/app/agreement-contents", "/api/v1/app/agreement-contents"})
|
public class AppAgreementContentController {
|
|
private final AgreementContentAppService agreementContentAppService;
|
|
/**
|
* 注入协议内容服务。
|
*/
|
public AppAgreementContentController(AgreementContentAppService agreementContentAppService) {
|
this.agreementContentAppService = agreementContentAppService;
|
}
|
|
/**
|
* 获取单条协议详情,并兼容 APP 页面已有的 user/privacy 参数。
|
*/
|
@GetMapping("/{agreementType}")
|
public ApiResponse<AgreementContentItemVO> detail(@PathVariable("agreementType") String agreementType) {
|
return ApiResponse.ok(agreementContentAppService.detail(normalizeAgreementType(agreementType)));
|
}
|
|
/**
|
* 将 APP 页面路由参数转换为后台协议类型常量。
|
*/
|
private String normalizeAgreementType(String agreementType) {
|
if (agreementType == null) {
|
return null;
|
}
|
String normalized = agreementType.trim();
|
if ("user".equalsIgnoreCase(normalized)) {
|
return AgreementContent.TYPE_USER_AGREEMENT;
|
}
|
if ("privacy".equalsIgnoreCase(normalized)) {
|
return AgreementContent.TYPE_PRIVACY_POLICY;
|
}
|
return normalized;
|
}
|
}
|