浏览代码

fix 商品上架

he2802 3 年之前
父节点
当前提交
8aeec46593

+ 11 - 0
zhongzheng-admin/src/main/java/com/zhongzheng/controller/base/ProfileTpController.java

@@ -54,6 +54,17 @@ public class ProfileTpController extends BaseController {
         return getDataTable(list);
     }
 
+    /**
+     * 获取所有使用商品ID
+     */
+    @ApiOperation("获取所有使用商品ID")
+    @PreAuthorize("@ss.hasPermi('system:tp:list')")
+    @GetMapping("/goods_list")
+    public AjaxResult<List<String>> goods_list(ProfileTpQueryBo bo) {
+        List<String> list = iProfileTpService.selectAllUseGoods(bo);
+        return AjaxResult.success(list);
+    }
+
     /**
      * 导出资料模板列表
      */

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/IProfileTpService.java

@@ -30,6 +30,8 @@ public interface IProfileTpService extends IService<ProfileTp> {
 
 	List<ProfileTpVo> selectList(ProfileTpQueryBo bo);
 
+	List<String> selectAllUseGoods(ProfileTpQueryBo bo);
+
 	/**
 	 * 根据新增业务对象插入资料模板
 	 * @param bo 资料模板新增业务对象

+ 17 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/base/service/impl/ProfileTpServiceImpl.java

@@ -1,6 +1,7 @@
 package com.zhongzheng.modules.base.service.impl;
 
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.zhongzheng.common.utils.DateUtils;
 import com.zhongzheng.common.utils.ServletUtils;
@@ -27,10 +28,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.github.pagehelper.Page;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -68,6 +66,21 @@ public class ProfileTpServiceImpl extends ServiceImpl<ProfileTpMapper, ProfileTp
         return profileTpMapper.selectList(bo);
     }
 
+    @Override
+    public List<String> selectAllUseGoods(ProfileTpQueryBo bo) {
+        List<ProfileTpVo> list = profileTpMapper.selectList(bo);
+        List<String> strList = new ArrayList<>();
+        for(int i=0;i<list.size();i++){
+            if(Validator.isNotEmpty(list.get(i).getGoodsIds())){
+                List<String> idList = Arrays.asList(list.get(i).getGoodsIds().split(","));
+                strList.addAll(idList);
+            }
+        }
+        LinkedHashSet<String> hashSet = new LinkedHashSet<>(strList);
+        ArrayList<String> listWithoutDuplicates = new ArrayList<>(hashSet);
+        return listWithoutDuplicates;
+    }
+
     /**
     * 实体类转化成视图对象
     *

+ 1 - 1
zhongzheng-system/src/main/resources/mapper/modules/course/CourseMenuMapper.xml

@@ -59,7 +59,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 AND m.type = 3
         WHERE
             m.course_id = #{courseId}
-        ORDER BY m.sort 
+        ORDER BY m.sort
     </select>
 
 </mapper>