Jelajahi Sumber

前后端联调
测试服务配置修改

marxjaw 5 bulan lalu
induk
melakukan
dc24c35867

+ 5 - 5
yt-agent/agent-service/src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: local
+    active: dev
 ---
 spring:
   profiles: local
@@ -27,9 +27,9 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 118.195.137.98:8848
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        server-addr: 127.0.0.1:8848
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020
       config:
-        server-addr: 118.195.137.98:8848
+        server-addr: 127.0.0.1:8848
         file-extension: yml
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020

+ 20 - 0
yt-common/src/main/java/com/ytpm/risk/model/YtRiskTemplateConfig.java

@@ -0,0 +1,20 @@
+package com.ytpm.risk.model;
+
+import io.swagger.annotations.ApiModel;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel("配置模板关联配置表")
+public class YtRiskTemplateConfig {
+    private String templateId;
+    private String configId;
+    private String operator;
+    private String operatorName;
+    private Date operatorTime;
+}

+ 4 - 0
yt-common/src/main/java/com/ytpm/risk/param/RiskConfigParam.java

@@ -30,4 +30,8 @@ public class RiskConfigParam extends BaseParam {
     private String templateCode;
     @ApiModelProperty(value = "渠道ID")
     private String channelId;
+    @ApiModelProperty(value = "操作人")
+    private String operator;
+    @ApiModelProperty(value = "操作人名称")
+    private String operatorName;
 }

+ 2 - 1
yt-common/src/main/java/com/ytpm/risk/param/RiskRelativeAppParam.java

@@ -1,5 +1,6 @@
 package com.ytpm.risk.param;
 
+import com.ytpm.agent.view.AgentEnableAppView;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -14,7 +15,7 @@ import java.util.List;
 @ApiModel("风控配置关联app入参")
 public class RiskRelativeAppParam {
     @ApiModelProperty("选中的应用列表")
-    private List<String> appIdList;
+    private List<AgentEnableAppView> appList;
     @ApiModelProperty("关联的配置模版ID")
     private String templateId;
     @ApiModelProperty("操作人")

+ 4 - 4
yt-common/src/main/java/com/ytpm/risk/view/RiskConfigListView.java

@@ -36,10 +36,10 @@ public class RiskConfigListView extends PageMeta {
     private Integer enabled;
     @ApiModelProperty("创建人名称")
     private String nickName;
-    @ApiModelProperty("appId")
-    private String appId;
-    @ApiModelProperty("appName")
-    private String appName;
+    @ApiModelProperty("关联的应用ID")
+    private String appIds;
+    @ApiModelProperty("关联的应用名称")
+    private String appNames;
     @ApiModelProperty("修改者")
     private String updateNickName;
 }

+ 5 - 5
yt-gateway/src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: local
+    active: dev
 ---
 spring:
   profiles: local
@@ -23,9 +23,9 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 118.195.137.98:8848
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        server-addr: 127.0.0.1:8848
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020
       config:
-        server-addr: 118.195.137.98:8848
+        server-addr: 127.0.0.1:8848
         file-extension: yml
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020

+ 5 - 5
yt-oauth/oauth-service/src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: local
+    active: dev
 ---
 spring:
   profiles: local
@@ -27,9 +27,9 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 118.195.137.98:8848
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        server-addr: 127.0.0.1:8848
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020
       config:
-        server-addr: 118.195.137.98:8848
+        server-addr: 127.0.0.1:8848
         file-extension: yml
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020

+ 2 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/controller/RiskConfigController.java

@@ -46,6 +46,8 @@ public class RiskConfigController {
     @PostMapping("/saveConfig")
     public Result<?> saveConfig(@RequestBody RiskConfigParam param, @ApiIgnore @AuthenticationPrincipal AgentUserInfo userInfo){
         param.setChannelId(userInfo.getUserId());
+        param.setOperator(userInfo.getUserId());
+        param.setOperatorName(userInfo.getNickName());
         return riskService.saveConfig(param);
     }
 

+ 6 - 0
yt-risk/risk-manage/src/main/java/com/ytpm/dao/RiskConfigMapper.java

@@ -47,4 +47,10 @@ public interface RiskConfigMapper {
      * 修改配置值
      */
     void updateConfigVal(YtRiskConfig config);
+
+    /**
+     * 新增模版关联配置
+     */
+    void addRelease(@Param("templateId") String templateId, @Param("configIds") List<String> configIds,
+                    @Param("operator") String operator, @Param("operatorName") String operatorName);
 }

+ 19 - 6
yt-risk/risk-manage/src/main/java/com/ytpm/service/impl/RiskServiceImpl.java

@@ -10,6 +10,7 @@ import com.ytpm.agent.enums.UserStatusEnum;
 import com.ytpm.agent.model.YtAppUser;
 import com.ytpm.agent.model.YtPlatformBanned;
 import com.ytpm.agent.model.YtPlatformDeblocking;
+import com.ytpm.agent.view.AgentEnableAppView;
 import com.ytpm.app.model.YtAppUserLoginRecord;
 import com.ytpm.app.view.YtAppUserListView;
 import com.ytpm.custom.CustomField;
@@ -104,7 +105,6 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
         if(CollUtil.isEmpty(param.getConfigList())){
             return Result.resultErr(RepMessage.COLLECTION_EMPTY);
         }
-        YtRiskTemplate template = new YtRiskTemplate();
         List<YtRiskConfig> configs = new ArrayList<>();
         YtRiskConfig config;
         StringBuilder content = new StringBuilder();
@@ -120,14 +120,27 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
             configs.add(config);
         }
         configMapper.insertAll(configs);
+        addTemplateAndRelative(param,content.toString(),configs);
+        return Result.resultOk(RepMessage.SAVE_SUCCESS);
+    }
+
+    /**
+     * 新增模版和关联配置
+     */
+    private void addTemplateAndRelative(RiskConfigParam param,String content,List<YtRiskConfig> configs) {
+        YtRiskTemplate template = new YtRiskTemplate();
         BeanUtil.copyProperties(param,template);
         template.setTemplateId(IdUtil.fastSimpleUUID());
-        template.setTemplateContent(content.toString());
+        template.setTemplateContent(content);
         template.setEnabled(0);
         template.setCreateUserId(param.getChannelId());
         template.setCreateTime(new Date());
         configMapper.saveTemplate(template);
-        return Result.resultOk(RepMessage.SAVE_SUCCESS);
+
+        configMapper.addRelease(template.getTemplateId(),
+                configs.stream().map(YtRiskConfig::getConfigId).collect(Collectors.toList()),
+                param.getOperator(),param.getOperatorName()
+        );
     }
 
 
@@ -238,8 +251,8 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
     @Override
     @Transactional(rollbackFor = Exception.class)
     public Result<?> relativeApp(RiskRelativeAppParam param) {
-        List<String> appIdList = param.getAppIdList();
-        if(CollUtil.isEmpty(appIdList)){
+        List<AgentEnableAppView> appList = param.getAppList();
+        if(CollUtil.isEmpty(appList)){
             return Result.resultErr(RepMessage.COLLECTION_EMPTY);
         }
         riskManageMapper.deleteRelatives(param.getTemplateId());
@@ -293,7 +306,7 @@ public class RiskServiceImpl extends ReflectUtil implements RiskService {
             config.setConfigId(listParam.getConfigId());
             config.setConfigVal(listParam.getConfigVal());
             configMapper.updateConfigVal(config);
-            String format = String.format(config.getFieldDesc(), config.getConfigVal());
+            String format = String.format(listParam.getFieldDesc(), listParam.getConfigVal());
             if(StrUtil.isNotBlank(format)){
                 content.append(format).append(",");
             }

+ 5 - 5
yt-risk/risk-manage/src/main/resources/bootstrap.yml

@@ -1,6 +1,6 @@
 spring:
   profiles:
-    active: local
+    active: dev
 ---
 spring:
   profiles: local
@@ -27,9 +27,9 @@ spring:
   cloud:
     nacos:
       discovery:
-        server-addr: 118.195.137.98:8848
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        server-addr: 127.0.0.1:8848
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020
       config:
-        server-addr: 118.195.137.98:8848
+        server-addr: 127.0.0.1:8848
         file-extension: yml
-        namespace: 3a082e81-f4e3-4d4c-b63d-ba0b28d04579
+        namespace: ad14a1aa-fe06-473a-9050-9afa26ec0020

+ 29 - 6
yt-risk/risk-manage/src/main/resources/mapper/RiskConfigMapper.xml

@@ -52,6 +52,26 @@
                 #{enabled}
             );
     </insert>
+    <insert id="addRelease">
+        insert into yt_risk_template_config
+        (
+         template_id,
+         config_id,
+         operator,
+         operator_time,
+         operator_name
+        )
+        values
+        <foreach collection="configIds" item="item" separator="," index="index">
+            (
+             #{templateId},
+             #{item},
+             #{operator},
+             now(),
+             #{operatorName}
+            )
+        </foreach>
+    </insert>
     <update id="updateByTempId">
         update yt_risk_template
         <set>
@@ -76,6 +96,9 @@
             <if test="updateUserId != null">
                 update_user_id = #{updateUserId},
             </if>
+            <if test="enabled != null">
+                enabled = #{enabled},
+            </if>
         </set>
         where template_id = #{templateId}
     </update>
@@ -84,8 +107,8 @@
     </update>
     <select id="getRiskConfigList" resultType="com.ytpm.risk.view.RiskConfigListView">
         SELECT
-            t.app_id,
-            p.app_name,
+            group_concat(ca.app_id) appIds,
+            group_concat(ca.app_name) appNames,
             t.template_name,
             t.create_time,
             t.template_id,
@@ -93,16 +116,16 @@
             t.template_content,
             u.nick_name as nickName,
             t.enabled,
-            p.app_name,
             t.update_time,
             u_update.nick_name as updateNickName
         FROM
             yt_risk_template t
                 JOIN yt_platform_user u on t.create_user_id = u.user_id
-                JOIN yt_app p ON t.app_id = p.app_id
+                LEFT JOIN yt_cofig_app ca ON t.template_id = ca.template_id
                 LEFT JOIN yt_platform_user u_update ON t.update_user_id = u_update.user_id
         WHERE
             t.channel_id = #{channelId}
+        group by t.template_id
     </select>
     <select id="selectOneTemplate" resultType="com.ytpm.risk.model.YtRiskTemplate">
         select
@@ -140,8 +163,8 @@
             rc.multy
         FROM
             yt_risk_template rt
-                JOIN yt_risk_template_config rtc ON rt.template_id = rtc.template_id
-                JOIN yt_risk_config rc ON rtc.config_id = rc.config_id
+               LEFT JOIN yt_risk_template_config rtc ON rt.template_id = rtc.template_id
+               LEFT JOIN yt_risk_config rc ON rtc.config_id = rc.config_id
         WHERE
             rt.template_id = #{templateId}
           AND rt.channel_id = #{channelId}

+ 12 - 8
yt-risk/risk-manage/src/main/resources/mapper/RiskManageMapper.xml

@@ -26,25 +26,29 @@
         )
     </insert>
     <insert id="relativeApps" parameterType="com.ytpm.risk.param.RiskRelativeAppParam">
-        insert into yt_risk_template_config
+        insert into yt_cofig_app
             (
              template_id,
-             config_id,
+             app_id,
+             app_name,
              operator,
+             operator_name,
              operator_time
             )
         values
-        <foreach collection="appIdList" separator="," index="index" item="item">
+        <foreach collection="appList" separator="," index="index" item="item">
             (
-             #{item.templateId},
-             #{item.configId},
-             #{item.operator},
-             #{item.operatorName}
+             #{templateId},
+             #{item.appId},
+             #{item.appName},
+             #{operator},
+             #{operatorName},
+             now()
             )
         </foreach>
     </insert>
     <delete id="deleteRelatives">
-        delete from yt_risk_template_config where template_id = #{templateId}
+        delete from yt_cofig_app where template_id = #{templateId}
     </delete>
     <select id="getDeblockingList" resultType="com.ytpm.risk.view.RiskDeblockingListView">
         SELECT