6 Коміти b0789e1f8a ... eb8e63e765

Автор SHA1 Опис Дата
  yonghuifan eb8e63e765 Merge remote-tracking branch 'origin/master' 1 рік тому
  yonghuifan cb1cd5b12b 收藏应用专项工具与非专项 1 рік тому
  yonghuifan d1a83e3485 修改批量收藏删除逻辑 1 рік тому
  yonghuifan c83ffae027 修改应用&业务 收藏分页 1 рік тому
  yonghuifan 23a7756cc8 批量修改收藏 1 рік тому
  yonghuifan 264ebbb419 应用&业务批量修改 业务模糊查询 1 рік тому

+ 15 - 0
src/main/java/com/dragon/tj/portal/controller/AppController.java

@@ -4,14 +4,17 @@ 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;
 import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 @RestController
 @RequestMapping("/app")
@@ -22,6 +25,9 @@ public class AppController {
     @Autowired
     private AppService appService;
 
+    @Autowired
+    private InstallInfoService installInfoService;
+
     /*
      *    1. 我的应用查询 批量排序收藏
      * */
@@ -83,6 +89,15 @@ public class AppController {
         return R.ok(appService.update(appInfo));
     }
 
+    /*
+     *   批量更新收藏
+     * */
+    @PostMapping("batchUpdate")
+    public R batchUpdate(@RequestBody List<InstallInfo> list) {
+        installInfoService.batchUpdate(list,0);
+        return R.ok();
+    }
+
     //    @SysLog("通过ID获取应用")
     @GetMapping("info/{id}")
     public R detail(@PathVariable("id") Long id) {

+ 16 - 0
src/main/java/com/dragon/tj/portal/controller/BusinessController.java

@@ -4,14 +4,17 @@ 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;
 import org.springframework.web.bind.annotation.*;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 @RestController
 @RequestMapping("/business")
@@ -22,6 +25,9 @@ public class BusinessController {
     @Autowired
     private BusinessService businessService;
 
+    @Autowired
+    private InstallInfoService installInfoService;
+
     /*
      *    1. 我的业务查询 批量排序收藏
      * */
@@ -95,6 +101,16 @@ public class BusinessController {
         return R.ok(businessService.update(businessInfo));
     }
 
+    /*
+     *   批量更新收藏
+     * */
+    @PostMapping("batchUpdate")
+    public R batchUpdate(@RequestBody List<InstallInfo> list) {
+        installInfoService.batchUpdate(list,1);
+        return R.ok();
+    }
+
+
     //    @SysLog("通过ID获取应用")
     @GetMapping("info/{id}")
     public R detail(@PathVariable("id") Long id) {

+ 6 - 1
src/main/java/com/dragon/tj/portal/entity/AppInfo.java

@@ -1,6 +1,7 @@
 package com.dragon.tj.portal.entity;
 
 import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.baomidou.mybatisplus.annotation.TableName;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -105,5 +106,9 @@ public class AppInfo implements Serializable {
      */
     private Long star;
 
-
+    /*
+     * 排序
+     */
+    @TableField(exist = false)
+    private int seq;
 }

+ 6 - 0
src/main/java/com/dragon/tj/portal/entity/BusinessInfo.java

@@ -94,4 +94,10 @@ public class BusinessInfo {
      * 收藏数量
      */
     private Long star;
+
+    /*
+     * 排序
+     */
+    @TableField(exist = false)
+    private int seq;
 }

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

@@ -59,5 +59,8 @@ public class InstallInfo {
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     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);
 }

+ 3 - 1
src/main/java/com/dragon/tj/portal/service/SysDictService.java

@@ -5,6 +5,8 @@ import com.dragon.tj.portal.common.base.R;
 import com.dragon.tj.portal.entity.SysDict;
 import com.dragon.tj.portal.entity.SysDictItem;
 
+import java.util.List;
+
 /**
  * <p>
  * 字典表 服务类
@@ -34,5 +36,5 @@ public interface SysDictService extends IService<SysDict> {
      * @param type 字典类型
      * @return
      */
-    R getDict(String type);
+    List<SysDict> getDict(String type);
 }

+ 25 - 4
src/main/java/com/dragon/tj/portal/service/impl/AppServiceImpl.java

@@ -6,12 +6,11 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.dragon.tj.portal.auth.model.LoginUser;
 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.entity.*;
 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.SysDictItemService;
 import com.dragon.tj.portal.service.SysDictService;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -35,6 +34,17 @@ public class AppServiceImpl implements AppService {
     @Autowired
     private SysDictService sysDictService;
 
+
+    private static List<SysDict> appTypeDict;
+
+    public List<SysDict> getAppTypeDict(){
+        if (appTypeDict == null || appTypeDict.size() == 0) {
+            appTypeDict = sysDictService.getDict("app_type");
+        }
+
+        return appTypeDict;
+    }
+
     /*
      * CRUD
      * */
@@ -69,7 +79,7 @@ public class AppServiceImpl implements AppService {
      * */
     @Override
     public R getType() {
-        return sysDictService.getDict("app_type");
+        return R.ok(sysDictService.getDict("app_type"));
     }
 
     /*
@@ -149,6 +159,17 @@ public class AppServiceImpl implements AppService {
         Map map = new HashMap();
 
         map.put("delFlag", params.getDelFlag());
+        Integer appType = params.getAppType();
+        if (appType != null){
+            List<SysDict> appTypeList = getAppTypeDict();
+            SysDict  specialToolDict = appTypeList.stream().filter(item -> "专项工具".equals(item.getDescription())).findFirst().get();
+            map.put("std", specialToolDict.getId());//专项工具
+
+            if (appType == specialToolDict.getId()){
+                map.put("isSt", 1);//专项工具查询
+            }
+        }
+
         map.put("idcard", loginUser.getIdCard());
 
         return appInfoMapper.getInstalledApp(iPage,map);

+ 6 - 1
src/main/java/com/dragon/tj/portal/service/impl/BusinessServiceImpl.java

@@ -90,7 +90,7 @@ public class BusinessServiceImpl implements BusinessService {
      * */
     @Override
     public R getType() {
-        return sysDictService.getDict("app_type");
+        return R.ok(sysDictService.getDict("app_type"));
     }
 
     /*
@@ -107,6 +107,11 @@ public class BusinessServiceImpl implements BusinessService {
         //应用名称
         queryWrapper.like(StringUtils.isNotEmpty(businessInfo.getAppName()),
                 BusinessInfo::getAppName, businessInfo.getAppName());
+
+        //业务名称
+        queryWrapper.like(StringUtils.isNotEmpty(businessInfo.getBusinessName()),
+                BusinessInfo::getBusinessName, businessInfo.getBusinessName());
+
         //类型
         queryWrapper.eq(businessInfo.getBusinessType() != null,
                 BusinessInfo::getBusinessType,

+ 27 - 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,26 @@ public class InstallInfoServiceImpl extends ServiceImpl<InstallInfoMapper, Insta
         }
         return Sets.newHashSet();
     }
+
+    @Override
+    @Transactional()
+    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);
+
+        //更新
+        list.forEach(item ->{
+            item.setUserIdcard(loginUser.getIdCard());
+            installInfoMapper.insert(item);
+        });
+
+    }
 }
 
 

+ 7 - 3
src/main/java/com/dragon/tj/portal/service/impl/SysDictServiceImpl.java

@@ -15,6 +15,8 @@ import org.springframework.cache.annotation.CacheEvict;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.List;
+
 /**
  * <p>
  * 字典表 服务实现类
@@ -70,10 +72,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
      * @return
      */
     @Override
-    public R getDict(String type) {
-        QueryWrapper wrapper = new QueryWrapper();
+    public List<SysDict> getDict(String type) {
+        QueryWrapper<SysDict> wrapper = new QueryWrapper();
         wrapper.eq("type",type);
         wrapper.eq("del_flag",0);
-        return R.ok(dictMapper.selectList(wrapper));
+        List<SysDict> sysDicts = dictMapper.selectList(wrapper);
+
+        return sysDicts;
     }
 }

+ 12 - 13
src/main/resources/mapper/BusinessMapper.xml

@@ -5,20 +5,19 @@
 
     <select id="getInstalledApp" resultType="com.dragon.tj.portal.entity.BusinessInfo">
         select * from business_info t1
-        where t1.del_flag = 0
-        and t1.id in  (
-            select business_id from install_info t2
-            <where>
-                business_id != 0
-                <if test="map.idcard != null and map.idcard != ''">
-                    and t2.user_idcard = #{map.idcard}
-                </if>
-                <if test="map.delFlag != null">
-                    and t2.del_flag = #{map.delFlag}
-                </if>
-            </where>
+        right join install_info t2 on t1.id = t2.business_id
+        <where>
+            t1.del_flag = 0
+            and t2.business_id != 0
+            <if test="map.idcard != null and map.idcard != ''">
+                and t2.user_idcard = #{map.idcard}
+            </if>
+            <if test="map.delFlag != null">
+                and t2.del_flag = #{map.delFlag}
+            </if>
+        </where>
 
-        )
+        order by t2.seq desc
     </select>
 
 

+ 23 - 11
src/main/resources/mapper/app/AppInfoMapper.xml

@@ -30,20 +30,32 @@
 
     <select id="getInstalledApp" resultType="com.dragon.tj.portal.entity.AppInfo">
         select * from app_info t1
-        where t1.del_flag = 0
-        and t1.id in  (
-            select app_id from install_info t2
-            <where>
-                business_id = 0
-                <if test="map.idcard != null and map.idcard != ''">
-                    and t2.user_idcard = #{map.idcard}
+        right join install_info t2 on t1.id = t2.app_id
+        <where>
+            t2.business_id = 0
+            <if test="map.idcard != null and map.idcard != ''">
+                and t2.user_idcard = #{map.idcard}
+            </if>
+            <if test="map.delFlag != null">
+                and t2.del_flag = #{map.delFlag}
+            </if>
+
+            <if test="map.std != null">
+                <if test="map.isSt != null">
+                    and t1.app_type = #{map.std}
                 </if>
-                <if test="map.delFlag != null">
-                    and t2.del_flag = #{map.delFlag}
+                <if test="map.isSt == null">
+                    and t1.app_type != #{map.std}
                 </if>
-            </where>
 
-        )
+            </if>
+
+
+
+        </where>
+
+        order by t2.seq desc
+
     </select>