feat:用户协议/隐私政策
parent
b4ae47cf28
commit
367c359b5e
|
@ -25,6 +25,9 @@ import javax.validation.constraints.NotNull;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 会员中心
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("member")
|
@RequestMapping("member")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
|
|
@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 模型评论
|
||||||
|
*/
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("memberLevel")
|
@RequestMapping("memberLevel")
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
/**
|
/**支付宝配置
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
* @Project:McWl
|
* @Project:McWl
|
||||||
* @Package:com.mcwl.common.config
|
* @Package:com.mcwl.common.config
|
||||||
|
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.mcwl.web.controller.system;
|
||||||
|
|
||||||
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
|
import com.mcwl.system.domain.Policy;
|
||||||
|
import com.mcwl.system.service.PolicyService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:mcwl-ai
|
||||||
|
* @Package:com.mcwl.web.controller.system
|
||||||
|
* @Filename:PerController
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/2/14 10:11
|
||||||
|
*/
|
||||||
|
@Api(tags = "隐私政策/用户协议")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("Policy")
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class PerController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private PolicyService policyService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取指定类型的政策内容
|
||||||
|
*
|
||||||
|
* @param type 政策类型
|
||||||
|
* @return 政策内容
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "获取指定类型的政策内容")
|
||||||
|
@GetMapping("/{type}")
|
||||||
|
public ResponseEntity<?> getPolicy(@PathVariable("type") String type) {
|
||||||
|
Policy policy = policyService.getPolicyByType(type);
|
||||||
|
if (policy == null) {
|
||||||
|
return new ResponseEntity<>("Policy not found", HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(policy.getContent(), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 更新指定类型的政策内容
|
||||||
|
*
|
||||||
|
* @param type 政策类型
|
||||||
|
* @param content 政策内容
|
||||||
|
* @return 更新结果
|
||||||
|
*/
|
||||||
|
@ApiOperation(value = "更新指定类型的政策内容")
|
||||||
|
@PutMapping("/{type}")
|
||||||
|
public ResponseEntity<?> updatePolicy(@PathVariable("type") String type, @RequestBody String content) {
|
||||||
|
try {
|
||||||
|
policyService.updatePolicyContent(type, content);
|
||||||
|
return new ResponseEntity<>("Policy updated successfully", HttpStatus.OK);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.mcwl.system.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import io.swagger.annotations.ApiParam;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**协议 隐私
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:mcwl-ai
|
||||||
|
* @Package:com.mcwl.system.domain
|
||||||
|
* @Filename:Per
|
||||||
|
* @Description 用户协议/隐私政策
|
||||||
|
* @Date:2025/2/14 10:05
|
||||||
|
*/
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
@ApiModel(description = "用户协议/隐私政策表")
|
||||||
|
@TableName("mcwl_policies")
|
||||||
|
public class Policy extends BaseEntity {
|
||||||
|
@TableId
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "id")
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 标题
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "标题")
|
||||||
|
private String title;
|
||||||
|
/**
|
||||||
|
* 内容
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "内容")
|
||||||
|
private String content;
|
||||||
|
/**
|
||||||
|
* 类型 用户协议/隐私政策
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "类型 用户协议/隐私政策")
|
||||||
|
private Integer type;
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mcwl.system.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.system.domain.Policy;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:mcwl-ai
|
||||||
|
* @Package:com.mcwl.system.mapper
|
||||||
|
* @Filename:PolicyMapper
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/2/14 10:21
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface PolicyMapper extends BaseMapper<Policy> {
|
||||||
|
/**
|
||||||
|
* 根据类型查询
|
||||||
|
* @param type
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Policy findByType(String type);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
package com.mcwl.system.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.system.domain.Policy;
|
||||||
|
|
||||||
|
import static com.qcloud.cos.exception.CosServiceException.ErrorType.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:mcwl-ai
|
||||||
|
* @Package:com.mcwl.system.service
|
||||||
|
* @Filename:PolicyService
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/2/14 10:13
|
||||||
|
*/
|
||||||
|
public interface PolicyService extends IService<Policy> {
|
||||||
|
|
||||||
|
|
||||||
|
Policy getPolicyByType(String type);
|
||||||
|
|
||||||
|
|
||||||
|
void updatePolicyContent(String type, String content);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.mcwl.system.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.system.domain.Policy;
|
||||||
|
import com.mcwl.system.mapper.PolicyMapper;
|
||||||
|
import com.mcwl.system.service.PolicyService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:ChenYan
|
||||||
|
* @Project:mcwl-ai
|
||||||
|
* @Package:com.mcwl.system.service.impl
|
||||||
|
* @Filename:PolicyServiceImpl
|
||||||
|
* @Description TODO
|
||||||
|
* @Date:2025/2/14 10:13
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class PolicyServiceImpl extends ServiceImpl<PolicyMapper, Policy> implements PolicyService {
|
||||||
|
@Autowired
|
||||||
|
private PolicyMapper policyMapper;
|
||||||
|
public Policy getPolicyByType(String type) {
|
||||||
|
return policyMapper.findByType(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updatePolicyContent(String type, String content) {
|
||||||
|
Policy policy = policyMapper.findByType(type);
|
||||||
|
if (policy != null) {
|
||||||
|
policy.setContent(content);
|
||||||
|
policyMapper.insert(policy);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("Policy not found for type: " + type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.mcwl.system.mapper.PolicyMapper">
|
||||||
|
|
||||||
|
<!-- 根据类型查找策略 -->
|
||||||
|
<select id="findByType" parameterType="String" resultType="com.mcwl.system.domain.Policy">
|
||||||
|
SELECT id, title, content, type, created_at, updated_at
|
||||||
|
FROM policies
|
||||||
|
WHERE type = #{type}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
Loading…
Reference in New Issue