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

fix:agent限制子包新增时应用名称不允许同名

hidewnd 4 месяцев назад
Родитель
Сommit
473c547ca1

+ 5 - 0
yt-agent/agent-service/src/main/java/com/ytpm/dao/AppMapper.java

@@ -46,6 +46,11 @@ public interface AppMapper {
      */
     YtApp getByDitchIdAndSuperiorId(@Param("ditchId") Long ditchId, @Param("superiorId") String superiorId);
 
+    /**
+     * 根据子包名称查询子包
+     */
+    YtApp getByAppName(@Param("appName") String appName);
+
     List<YtApp> getBySuperiorId(@Param("superiorId") String superiorId);
 
     /**

+ 5 - 1
yt-agent/agent-service/src/main/java/com/ytpm/service/impl/AgentAppServiceImpl.java

@@ -113,10 +113,14 @@ public class AgentAppServiceImpl implements AgentAppService {
             appMapper.updateOne(app);
         }else{
             //同一个应用同一个渠道只能出一个包
-            YtApp exist =  appMapper.getByDitchIdAndSuperiorId(param.getDitchId(),param.getSuperiorId());
+            YtApp exist = appMapper.getByDitchIdAndSuperiorId(param.getDitchId(),param.getSuperiorId());
             if(Objects.nonNull(exist)){
                 throw new CustomerException("该渠道已存在:"+exist.getAppName()+", 请选择其他渠道");
             }
+            exist = appMapper.getByAppName(param.getAppName());
+            if(Objects.nonNull(exist)){
+                throw new CustomerException("已存同名应用名称:"+exist.getAppName()+", 请重新填写");
+            }
             app.setAppId(IdUtil.fastSimpleUUID());
             app.setUserId(userId);
             app.setEnabled(1);

+ 6 - 0
yt-agent/agent-service/src/main/resources/mapper/AppMapper.xml

@@ -210,4 +210,10 @@
         from yt_app
         where superior_id = #{superiorId}
     </select>
+    <select id="getByAppName" resultType="com.ytpm.agent.model.YtApp">
+        select
+            app_id, app_key, app_name, user_id, app_type, apk_url, qr_code, version_code, update_tips, enabled, store_on_sale, store_type, store_url, package_name, domain, category, sub_category, coppa, screen_orientation, ccpa, feign_path, ditch_id, ditch_name, superior_id
+        from yt_app
+        where app_name = #{appName} and enabled = 1
+    </select>
 </mapper>