Prechádzať zdrojové kódy

应用保存专项与非专项

yonghuifan 1 rok pred
rodič
commit
c2b365e1f3

+ 2 - 0
src/main/java/com/dragon/tj/portal/service/AppInfoService.java

@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.dragon.tj.portal.entity.AppInfo;
 
 import java.util.List;
+import java.util.Map;
 
 public interface AppInfoService extends IService<AppInfo> {
 
     List<String> getAllAppSysCodes();
+
 }

+ 5 - 0
src/main/java/com/dragon/tj/portal/service/AppService.java

@@ -8,6 +8,9 @@ import com.dragon.tj.portal.entity.AppInfo;
 import com.dragon.tj.portal.entity.PageParam;
 import org.springframework.web.multipart.MultipartFile;
 
+import java.util.List;
+import java.util.Map;
+
 
 public interface AppService {
     /*
@@ -54,4 +57,6 @@ public interface AppService {
     int clickIncr(Long id);
 
     boolean batchAdd(MultipartFile file);
+
+    Map<String, List<Long>> checkAppTypeById(List<Long> appIds);
 }

+ 36 - 1
src/main/java/com/dragon/tj/portal/service/impl/AppServiceImpl.java

@@ -34,6 +34,7 @@ import java.time.LocalDateTime;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class AppServiceImpl implements AppService {
@@ -87,7 +88,17 @@ public class AppServiceImpl implements AppService {
 
     @Override
     public AppInfo detail(Long id) {
-        return appInfoMapper.selectById(id);
+        AppInfo appInfo = appInfoMapper.selectById(id);
+
+        List<SysDictItem> appTypeList = getAppTypeDict();
+        SysDictItem specialToolDict = appTypeList.stream().filter(item -> "专项工具".equals(item.getLabel())).findFirst().get();
+        if (appInfo.getAppType() == specialToolDict.getId()){
+            appInfo.setIsSpecial(1);
+        }else{
+            appInfo.setIsSpecial(0);
+        }
+
+        return appInfo;
     }
 
     /*
@@ -265,6 +276,30 @@ public class AppServiceImpl implements AppService {
         return true;
     }
 
+    @Override
+    public Map<String, List<Long>> checkAppTypeById(List<Long> appIds) {
+
+        List<SysDictItem> appTypeList = getAppTypeDict();
+        SysDictItem specialToolDict = appTypeList.stream().filter(item -> "专项工具".equals(item.getLabel())).findFirst().get();
+
+        List<AppInfo> appInfos = appInfoMapper.selectBatchIds(appIds);
+        Map<String, List<Long>> appTYpe = new HashMap<>();
+
+        List<Long> specialApp = appInfos.stream()
+                .filter(t -> t.getAppType() == specialToolDict.getId())
+                .map(AppInfo::getId)
+                .collect(Collectors.toList());
+        List<Long> otherApp = appInfos.stream()
+                .filter(t -> t.getAppType() != specialToolDict.getId())
+                .map(AppInfo::getId)
+                .collect(Collectors.toList());
+
+        appTYpe.put("special",specialApp);
+        appTYpe.put("other",otherApp);
+
+        return appTYpe;
+    }
+
     private AppInfo parseAppInfo(AppInfo appInfo) {
         List<SysDictItem> appTypeDict = getAppTypeDict();
 

+ 37 - 6
src/main/java/com/dragon/tj/portal/service/impl/InstallInfoServiceImpl.java

@@ -8,8 +8,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.dragon.tj.portal.auth.model.LoginUser;
 import com.dragon.tj.portal.auth.util.SecurityUtils;
+import com.dragon.tj.portal.entity.AppInfo;
 import com.dragon.tj.portal.entity.InstallInfo;
+import com.dragon.tj.portal.mapper.app.AppInfoMapper;
 import com.dragon.tj.portal.mapper.app.InstallInfoMapper;
+import com.dragon.tj.portal.service.AppService;
 import com.dragon.tj.portal.service.InstallInfoService;
 import com.google.common.collect.Sets;
 import org.apache.commons.lang3.StringUtils;
@@ -18,6 +21,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 import java.util.stream.Collectors;
 
@@ -27,6 +31,9 @@ public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, Insta
     @Autowired
     private InstallInfoMapper installInfoMapper;
 
+    @Autowired
+    private AppService appService;
+
     @Override
     public Set<String> findUsersByAppId(String appId) {
         LambdaQueryWrapper<InstallInfo> wrapper = Wrappers.lambdaQuery();
@@ -46,12 +53,24 @@ public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, Insta
     public void batchUpdate(List<InstallInfo> list,int isBusiness) {
         LoginUser loginUser = SecurityUtils.getLoginUser();
 
-        //删除所有收藏
-        QueryWrapper<InstallInfo> wrapper = new QueryWrapper<>();
-        wrapper.eq(loginUser != null,"user_idcard",loginUser.getIdCard());
-        wrapper.eq(isBusiness == 0,"business_id",isBusiness);
-        wrapper.ne(isBusiness != 0,"business_id",0);
-        installInfoMapper.delete(wrapper);
+        if(list.size()>0){
+            Map<String, List<Long>> appTypes = getAppTypes(loginUser.getIdCard());
+            List<Long> specialAppIds = appTypes.get("special");
+//            List<Long> otherAppIds = appTypes.get("other");
+            AppInfo detail = appService.detail(list.get(0).getAppId().longValue());
+
+            QueryWrapper<InstallInfo> wrapper = new QueryWrapper<>();
+            wrapper.eq(loginUser != null,"user_idcard",loginUser.getIdCard());
+            wrapper.eq(isBusiness == 0,"business_id",isBusiness);
+            wrapper.ne(isBusiness != 0,"business_id",0);
+            if(detail.getIsSpecial() == 1){
+                //删除专项工具应用
+                wrapper.in("app_id",specialAppIds);
+            }else {
+                wrapper.notIn("app_id",specialAppIds);
+            }
+            installInfoMapper.delete(wrapper);
+        }
 
         //更新
         list.forEach(item ->{
@@ -60,6 +79,18 @@ public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, Insta
         });
 
     }
+
+    public Map<String,List<Long>> getAppTypes(String idCard){
+
+        QueryWrapper wrapper = new QueryWrapper<>();
+        wrapper.select("app_id");
+        wrapper.eq("user_idcard",idCard);
+        List<Long> appIds = installInfoMapper.selectObjs(wrapper);
+
+        Map<String,List<Long>> appType = appService.checkAppTypeById(appIds);
+
+        return appType;
+    }
 }