|
@@ -0,0 +1,65 @@
|
|
|
|
+package com.backendsys.controller.api.Systems;
|
|
|
|
+
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
|
+import com.backendsys.entity.PageDTO;
|
|
|
|
+import com.backendsys.entity.System.SysAgreementDTO;
|
|
|
|
+import com.backendsys.service.System.SysAgreementService;
|
|
|
|
+import com.backendsys.utils.response.Result;
|
|
|
|
+import jakarta.servlet.http.HttpServletResponse;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
+
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@Validated
|
|
|
|
+@RestController
|
|
|
|
+public class SysAgreementController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysAgreementService sysAgreementService;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @GetMapping("/api/public/system/getAgreementView")
|
|
|
|
+ public String getAgreementView(HttpServletResponse response, @RequestParam(name = "tag", required = false) String tag) {
|
|
|
|
+
|
|
|
|
+ // 校验
|
|
|
|
+ if (StrUtil.isEmpty(tag)) return "tag 参数不能为空";
|
|
|
|
+ Map<String, Object> detail = sysAgreementService.querySysAgreementByTag(tag);
|
|
|
|
+ if (detail == null) return "找不到内容";
|
|
|
|
+
|
|
|
|
+ String title = (String) detail.get("title");
|
|
|
|
+ String content = (String) detail.get("content");
|
|
|
|
+
|
|
|
|
+ // 设置响应的类型为 text/html,这样浏览器就知道接收到的是 HTML 内容
|
|
|
|
+ response.setContentType("text/html;charset=UTF-8");
|
|
|
|
+
|
|
|
|
+ // 直接返回 HTML 字符串
|
|
|
|
+ return "<html>" +
|
|
|
|
+ "<head><title>" + title + "</title></head>" +
|
|
|
|
+ "<body>" +
|
|
|
|
+ content +
|
|
|
|
+ "</body>" +
|
|
|
|
+ "</html>";
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获得协议
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/api/public/system/getAgreement")
|
|
|
|
+ public Result getUser(@Validated PageDTO pageDTO, @Validated(SysAgreementDTO.List.class) SysAgreementDTO sysAgreementDTO) {
|
|
|
|
+ return Result.success(sysAgreementService.querySysAgreement(pageDTO.getPage_num(), pageDTO.getPage_size(), sysAgreementDTO));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获得协议详情
|
|
|
|
+ */
|
|
|
|
+ @GetMapping("/api/public/system/getAgreementByTag")
|
|
|
|
+ public Result getUser(@Validated(SysAgreementDTO.Detail.class) SysAgreementDTO sysAgreementDTO) {
|
|
|
|
+ return Result.success(sysAgreementService.querySysAgreementByTag(sysAgreementDTO.getTag()));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+}
|