From 367c359b5ecd891f372f7507a731dd8f6008adc5 Mon Sep 17 00:00:00 2001 From: ChenYan <3139166962@qq.com> Date: Fri, 14 Feb 2025 10:33:56 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E7=94=A8=E6=88=B7=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE/=E9=9A=90=E7=A7=81=E6=94=BF=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../memberCenter/MemberController.java | 3 + .../memberCenter/MemberLevelController.java | 3 + .../rabbitmq/config/AliPayConfig.java | 2 +- .../web/controller/system/PerController.java | 62 +++++++++++++++++++ .../java/com/mcwl/system/domain/Policy.java | 48 ++++++++++++++ .../com/mcwl/system/mapper/PolicyMapper.java | 24 +++++++ .../mcwl/system/service/PolicyService.java | 24 +++++++ .../service/impl/PolicyServiceImpl.java | 36 +++++++++++ .../resources/mapper/system/PolicyMapper.xml | 13 ++++ 9 files changed, 214 insertions(+), 1 deletion(-) create mode 100644 mcwl-admin/src/main/java/com/mcwl/web/controller/system/PerController.java create mode 100644 mcwl-system/src/main/java/com/mcwl/system/domain/Policy.java create mode 100644 mcwl-system/src/main/java/com/mcwl/system/mapper/PolicyMapper.java create mode 100644 mcwl-system/src/main/java/com/mcwl/system/service/PolicyService.java create mode 100644 mcwl-system/src/main/java/com/mcwl/system/service/impl/PolicyServiceImpl.java create mode 100644 mcwl-system/src/main/resources/mapper/system/PolicyMapper.xml diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberController.java index d2f0501..8f0e235 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberController.java @@ -25,6 +25,9 @@ import javax.validation.constraints.NotNull; import java.text.SimpleDateFormat; import java.util.*; +/*** + * 会员中心 + */ @RestController @RequestMapping("member") @RequiredArgsConstructor diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberLevelController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberLevelController.java index f1a2d59..a679c32 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberLevelController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/memberCenter/MemberLevelController.java @@ -16,6 +16,9 @@ import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; +/*** + * 模型评论 + */ @RestController @RequestMapping("memberLevel") @RequiredArgsConstructor diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/rabbitmq/config/AliPayConfig.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/rabbitmq/config/AliPayConfig.java index a0ebbb8..9ebf916 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/rabbitmq/config/AliPayConfig.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/rabbitmq/config/AliPayConfig.java @@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; -/** +/**支付宝配置 * @Author:ChenYan * @Project:McWl * @Package:com.mcwl.common.config diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/system/PerController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/PerController.java new file mode 100644 index 0000000..bc578d1 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/system/PerController.java @@ -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); + } + } +} diff --git a/mcwl-system/src/main/java/com/mcwl/system/domain/Policy.java b/mcwl-system/src/main/java/com/mcwl/system/domain/Policy.java new file mode 100644 index 0000000..24af945 --- /dev/null +++ b/mcwl-system/src/main/java/com/mcwl/system/domain/Policy.java @@ -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; +} diff --git a/mcwl-system/src/main/java/com/mcwl/system/mapper/PolicyMapper.java b/mcwl-system/src/main/java/com/mcwl/system/mapper/PolicyMapper.java new file mode 100644 index 0000000..e91722a --- /dev/null +++ b/mcwl-system/src/main/java/com/mcwl/system/mapper/PolicyMapper.java @@ -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 { + /** + * 根据类型查询 + * @param type + * @return + */ + Policy findByType(String type); + +} diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/PolicyService.java b/mcwl-system/src/main/java/com/mcwl/system/service/PolicyService.java new file mode 100644 index 0000000..f33adc2 --- /dev/null +++ b/mcwl-system/src/main/java/com/mcwl/system/service/PolicyService.java @@ -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 getPolicyByType(String type); + + + void updatePolicyContent(String type, String content); + +} diff --git a/mcwl-system/src/main/java/com/mcwl/system/service/impl/PolicyServiceImpl.java b/mcwl-system/src/main/java/com/mcwl/system/service/impl/PolicyServiceImpl.java new file mode 100644 index 0000000..9e6241c --- /dev/null +++ b/mcwl-system/src/main/java/com/mcwl/system/service/impl/PolicyServiceImpl.java @@ -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 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); + } + } + +} diff --git a/mcwl-system/src/main/resources/mapper/system/PolicyMapper.xml b/mcwl-system/src/main/resources/mapper/system/PolicyMapper.xml new file mode 100644 index 0000000..918a759 --- /dev/null +++ b/mcwl-system/src/main/resources/mapper/system/PolicyMapper.xml @@ -0,0 +1,13 @@ + + + + + + +