Просмотр исходного кода

feat(business): 通用条款服务接口复用

- 修改 ITermsOfServiceService 接口,增加 type 参数
- 更新 PrivacyPolicyController 和 SportTermsController,使用新的带 type 参数的方法
- 修改 SecurityConfig,添加新的开放接口路径- 更新 TermsOfService 模型,添加 type 字段
- 修改相关的 BO、VO 和 Mapper 接口,支持新的 type 字段- 更新 XML 文件,添加 type 字段的 SQL 语句
- 修改 TermsOfServiceServiceImpl,处理 type 参数
fugui001 3 месяцев назад
Родитель
Сommit
c6098cd17c

+ 2 - 1
ruoyi-common/ruoyi-common-security/src/main/java/org/dromara/common/security/config/SecurityConfig.java

@@ -55,7 +55,8 @@ public class SecurityConfig implements WebMvcConfigurer {
                     // 排除不需要登录的接口路径
                     .notMatch("/business/policy/selectPrivacyPolicyListMax",
                         "/business/ofService/selectTermsServiceListMax",
-                        "/business/terms/getSportTermsListMax") // 替换为你的开放接口路径
+                        "/business/terms/getSportTermsListMax",
+                        "/business/terms/getServiceAgreementMax") // 替换为你的开放接口路径
                     // 对未排除的路径进行检查
                     .check(() -> {
                         HttpServletRequest request = ServletUtils.getRequest();

+ 5 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/PrivacyPolicyController.java

@@ -8,7 +8,9 @@ import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.dromara.business.domain.bo.PrivacyPolicyBo;
 import org.dromara.business.domain.vo.PrivacyPolicyVo;
+import org.dromara.business.domain.vo.TermsOfServiceVo;
 import org.dromara.business.service.IPrivacyPolicyService;
+import org.dromara.business.service.ITermsOfServiceService;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -103,6 +105,7 @@ public class PrivacyPolicyController extends BaseController {
         return toAjax(privacyPolicyService.deleteWithValidByIds(List.of(ids), true));
     }
 
+    private final ITermsOfServiceService termsOfServiceService;
 
     /**
      * 查询隐私声明列表 默认数据  只会存在一条默认数据
@@ -110,8 +113,8 @@ public class PrivacyPolicyController extends BaseController {
    /* @SaCheck
    Permission("business:ofService:selectPrivacyPolicyListMax")*/
     @GetMapping("/selectPrivacyPolicyListMax")
-    public R<PrivacyPolicyVo> selectPrivacyPolicyListMax() {
-        return R.ok(privacyPolicyService.selectPrivacyPolicyListMax());
+    public R<TermsOfServiceVo> selectPrivacyPolicyListMax() {
+        return R.ok(termsOfServiceService.selectTermsServiceListMax("5"));
     }
 
 

+ 18 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/SportTermsController.java

@@ -8,7 +8,9 @@ import jakarta.validation.constraints.*;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.dromara.business.domain.bo.SportTermsBo;
 import org.dromara.business.domain.vo.SportTermsVo;
+import org.dromara.business.domain.vo.TermsOfServiceVo;
 import org.dromara.business.service.ISportTermsService;
+import org.dromara.business.service.ITermsOfServiceService;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.dromara.common.idempotent.annotation.RepeatSubmit;
@@ -103,9 +105,23 @@ public class SportTermsController extends BaseController {
         return toAjax(sportTermsService.deleteWithValidByIds(List.of(ids), true));
     }
 
+    private final ITermsOfServiceService termsOfServiceService;
+
+    /**
+     * 获取运动申明 数据
+     */
     @GetMapping("/getSportTermsListMax")
-    public R<SportTermsVo> selectSportTermsListMax() {
-        return R.ok(sportTermsService.selectSportTermsListMax());
+    public R<TermsOfServiceVo> selectSportTermsListMax() {
+        return R.ok(termsOfServiceService.selectTermsServiceListMax("3"));
+    }
+
+    /**
+     * 查询服务协议
+     * @return
+     */
+    @GetMapping("/getServiceAgreementMax")
+    public R<TermsOfServiceVo> getServiceAgreementMax() {
+        return R.ok(termsOfServiceService.selectTermsServiceListMax("4"));
     }
 
 }

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/controller/TermsOfServiceController.java

@@ -105,12 +105,12 @@ public class TermsOfServiceController extends BaseController {
 
 
     /**
-     * 查询默认的数据
+     * 查询APP使用条款
      * @return
      */
     @GetMapping("/selectTermsServiceListMax")
     public R<TermsOfServiceVo> selectTermsServiceListMax() {
-        return R.ok(termsOfServiceService.selectTermsServiceListMax());
+        return R.ok(termsOfServiceService.selectTermsServiceListMax("1"));
     }
 
 }

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/TermsOfService.java

@@ -53,5 +53,7 @@ public class TermsOfService extends BaseEntity {
      */
     private Long isDefault;
 
+    private String type;
+
 
 }

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/bo/TermsOfServiceBo.java

@@ -48,5 +48,10 @@ public class TermsOfServiceBo extends BaseEntity {
      */
     private Long isDefault;
 
+    /**
+     * 类型  1:APP使用条款、2:关于三湘杯、3:运动员声明、4:服务协议、5:隐私协议
+     */
+    private String type;
+
 
 }

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/domain/vo/TermsOfServiceVo.java

@@ -73,4 +73,6 @@ public class TermsOfServiceVo implements Serializable {
      */
     private String updateTime;
 
+    private String type;
+
 }

+ 2 - 2
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/mapper/TermsOfServiceMapper.java

@@ -43,9 +43,9 @@ public interface TermsOfServiceMapper extends BaseMapperPlus<TermsOfService, Ter
     List<TermsOfServiceVo> selectTermsServiceList(@Param("ew") Wrapper<TermsOfService> wrapper);
 
     @InterceptorIgnore(tenantLine = "true")
-    TermsOfServiceVo selectTermsServiceListMax();
+    TermsOfServiceVo selectTermsServiceListMax(@Param("type") String type);
 
     @InterceptorIgnore(tenantLine = "true")
-    int updateTermsServiceOtherFalse();
+    int updateTermsServiceOtherFalse(@Param("type") String type);
 
 }

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/ITermsOfServiceService.java

@@ -70,5 +70,5 @@ public interface ITermsOfServiceService {
      * 查询使用条款管理 默认的那一条数据
      * @return
      */
-    TermsOfServiceVo selectTermsServiceListMax();
+    TermsOfServiceVo selectTermsServiceListMax(String type);
 }

+ 7 - 6
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/business/service/impl/TermsOfServiceServiceImpl.java

@@ -83,6 +83,7 @@ public class TermsOfServiceServiceImpl implements ITermsOfServiceService {
         lqw.eq(StringUtils.isNotBlank(bo.getTitle()), TermsOfService::getTitle, bo.getTitle());
         lqw.eq(StringUtils.isNotBlank(bo.getContent()), TermsOfService::getContent, bo.getContent());
         lqw.eq(StringUtils.isNotBlank(bo.getLanguage()), TermsOfService::getLanguage, bo.getLanguage());
+        lqw.eq(StringUtils.isNotBlank(bo.getType()), TermsOfService::getType, bo.getType());
         lqw.eq(bo.getIsDefault() != null, TermsOfService::getIsDefault, bo.getIsDefault());
         return lqw;
     }
@@ -100,9 +101,9 @@ public class TermsOfServiceServiceImpl implements ITermsOfServiceService {
         Long isDefault = bo.getIsDefault();
         if(isDefault==1L){
             //如果这个是默认的,其他的则都变成不是默认的
-            baseMapper.updateTermsServiceOtherFalse();
+            baseMapper.updateTermsServiceOtherFalse(bo.getType());
         }
-
+        add.setType(bo.getType());
         boolean flag = baseMapper.insertTermsService(add) > 0;
         if (flag) {
             bo.setId(add.getId());
@@ -122,9 +123,9 @@ public class TermsOfServiceServiceImpl implements ITermsOfServiceService {
         validEntityBeforeSave(update);
         if(bo.getIsDefault()==1L){
             //如果这个是默认的,其他的则都变成不是默认的
-            baseMapper.updateTermsServiceOtherFalse();
+            baseMapper.updateTermsServiceOtherFalse(bo.getType());
         }
-
+        update.setType(bo.getType());
         return baseMapper.updateTermsServiceById(update) > 0;
     }
 
@@ -151,8 +152,8 @@ public class TermsOfServiceServiceImpl implements ITermsOfServiceService {
     }
 
     @Override
-    public TermsOfServiceVo selectTermsServiceListMax() {
-        return baseMapper.selectTermsServiceListMax();
+    public TermsOfServiceVo selectTermsServiceListMax(String type) {
+        return baseMapper.selectTermsServiceListMax(type);
     }
 
     public static String replaceHtml(String html) {

+ 10 - 5
ruoyi-modules/ruoyi-system/src/main/resources/mapper/business/TermsOfServiceMapper.xml

@@ -6,18 +6,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
 
     <select id="selectVoPage2" resultType="org.dromara.business.domain.vo.TermsOfServiceVo">
-        SELECT id, title, content, version, language, is_default, create_time, update_time
+        SELECT id, title, content, version, language, is_default, create_time, update_time,type
         FROM terms_of_service ${ew.customSqlSegment}
     </select>
 
 
     <select id="selectTermsServiceList" resultType="org.dromara.business.domain.vo.TermsOfServiceVo">
-        SELECT id, title, content, version, language, is_default, create_time, update_time
+        SELECT id, title, content, version, language, is_default, create_time, update_time,type
         FROM terms_of_service  ${ew.customSqlSegment}
     </select>
 
     <select id="selectVoInfoById" resultType="org.dromara.business.domain.vo.TermsOfServiceVo">
-        SELECT id, title, content, version, language, is_default, create_time, update_time
+        SELECT id, title, content, version, language, is_default, create_time, update_time,type
         FROM terms_of_service   WHERE id =  #{id}
     </select>
 
@@ -39,6 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isDefault != null">
                 is_default = #{isDefault},
             </if>
+            <if test="type != null">
+                type = #{type},
+            </if>
             update_time = NOW()
         </set>
         WHERE id = #{id}
@@ -52,6 +55,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="version != null and version != ''">version,</if>
             <if test="language != null and language != ''">language,</if>
             <if test="isDefault != null">is_default,</if>
+            <if test="type != null">type,</if>
         </trim>
         VALUES
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -60,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="version != null and version != ''">#{version},</if>
             <if test="language != null and language != ''">#{language},</if>
             <if test="isDefault != null">#{isDefault},</if>
+            <if test="type != null">#{type},</if>
         </trim>
     </insert>
 
@@ -77,11 +82,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectTermsServiceListMax" resultType="org.dromara.business.domain.vo.TermsOfServiceVo">
         SELECT id, title, content, version, language, is_default, create_time, update_time
-        FROM terms_of_service where is_default = true  limit 1
+        FROM terms_of_service where is_default = true  and type = #{type}  limit 1
     </select>
 
     <update id="updateTermsServiceOtherFalse">
-        UPDATE terms_of_service  set is_default = false
+        UPDATE terms_of_service  set is_default = false where  type =#{type}
     </update>