yonghuifan преди 1 година
родител
ревизия
23a7756cc8

+ 8 - 6
src/main/java/com/dragon/tj/portal/controller/AppController.java

@@ -4,8 +4,10 @@ import com.dragon.tj.portal.auth.model.LoginUser;
 import com.dragon.tj.portal.auth.util.SecurityUtils;
 import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.entity.AppInfo;
+import com.dragon.tj.portal.entity.InstallInfo;
 import com.dragon.tj.portal.entity.PageParam;
 import com.dragon.tj.portal.service.AppService;
+import com.dragon.tj.portal.service.InstallInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -23,6 +25,9 @@ public class AppController {
     @Autowired
     private AppService appService;
 
+    @Autowired
+    private InstallInfoService installInfoService;
+
     /*
      *    1. 我的应用查询 批量排序收藏
      * */
@@ -85,14 +90,11 @@ public class AppController {
     }
 
     /*
-     *   批量更新
+     *   批量更新收藏
      * */
     @PostMapping("batchUpdate")
-    public R batchUpdate(@RequestBody List<AppInfo> list) {
-        list.forEach(info -> {
-            info.setUpdateTime(LocalDateTime.now());
-            appService.update(info);
-        });
+    public R batchUpdate(@RequestBody List<InstallInfo> list) {
+        installInfoService.batchUpdate(list,0);
         return R.ok();
     }
 

+ 8 - 6
src/main/java/com/dragon/tj/portal/controller/BusinessController.java

@@ -4,8 +4,10 @@ import com.dragon.tj.portal.auth.model.LoginUser;
 import com.dragon.tj.portal.auth.util.SecurityUtils;
 import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.entity.BusinessInfo;
+import com.dragon.tj.portal.entity.InstallInfo;
 import com.dragon.tj.portal.entity.PageParam;
 import com.dragon.tj.portal.service.BusinessService;
+import com.dragon.tj.portal.service.InstallInfoService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -23,6 +25,9 @@ public class BusinessController {
     @Autowired
     private BusinessService businessService;
 
+    @Autowired
+    private InstallInfoService installInfoService;
+
     /*
      *    1. 我的业务查询 批量排序收藏
      * */
@@ -97,14 +102,11 @@ public class BusinessController {
     }
 
     /*
-     *   批量更新
+     *   批量更新收藏
      * */
     @PostMapping("batchUpdate")
-    public R batchUpdate(@RequestBody List<BusinessInfo> list) {
-        list.forEach(info -> {
-            info.setUpdateTime(LocalDateTime.now());
-            businessService.update(info);
-        });
+    public R batchUpdate(@RequestBody List<InstallInfo> list) {
+        installInfoService.batchUpdate(list,1);
         return R.ok();
     }
 

+ 4 - 1
src/main/java/com/dragon/tj/portal/entity/InstallInfo.java

@@ -56,5 +56,8 @@ public class InstallInfo {
      */
     private LocalDateTime updateTime;
 
-
+    /**
+     * 排序
+     */
+    private int seq;
 }

+ 7 - 0
src/main/java/com/dragon/tj/portal/service/InstallInfoService.java

@@ -3,6 +3,7 @@ package com.dragon.tj.portal.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.dragon.tj.portal.entity.InstallInfo;
 
+import java.util.List;
 import java.util.Set;
 
 public interface InstallInfoService extends IService<InstallInfo> {
@@ -14,4 +15,10 @@ public interface InstallInfoService extends IService<InstallInfo> {
      * @return
     */
     Set<String> findUsersByAppId(String appId);
+
+    /*
+    * 批量修改收藏
+    * isBusiness: 0 应用级别,other 业务级别
+    * */
+    void batchUpdate(List<InstallInfo> list,int isBusiness);
 }

+ 31 - 0
src/main/java/com/dragon/tj/portal/service/impl/InstallInfoServiceImpl.java

@@ -3,14 +3,19 @@ package com.dragon.tj.portal.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 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.InstallInfo;
 import com.dragon.tj.portal.mapper.app.InstallInfoMapper;
 import com.dragon.tj.portal.service.InstallInfoService;
 import com.google.common.collect.Sets;
 import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.Set;
@@ -19,6 +24,8 @@ import java.util.stream.Collectors;
 @Service
 public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, InstallInfo> implements InstallInfoService {
 
+    @Autowired
+    private InstallInfoMapper installInfoMapper;
 
     @Override
     public Set<String> findUsersByAppId(String appId) {
@@ -33,6 +40,30 @@ public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, Insta
         }
         return Sets.newHashSet();
     }
+
+    @Override
+    @Transactional()
+    public void batchUpdate(List<InstallInfo> list,int isBusiness) {
+        List<Integer> allUpdateAppId = list.stream().map(InstallInfo::getAppId).collect(Collectors.toList());
+        //删除
+        QueryWrapper<InstallInfo> wrapper = new QueryWrapper<>();
+        wrapper.in("app_id",allUpdateAppId);
+
+        wrapper.eq(isBusiness == 0,"business_id",isBusiness);
+        wrapper.ne(isBusiness != 0,"business_id",0);
+
+        installInfoMapper.delete(wrapper);
+
+        //更新
+
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+        list.forEach(item ->{
+            item.setUserIdcard(loginUser.getIdCard());
+            installInfoMapper.insert(item);
+        });
+
+
+    }
 }