فهرست منبع

Merge remote-tracking branch 'origin/master_exclusive_shop_20250718' into master_fhhx_20250718

xdd 2 هفته پیش
والد
کامیت
e65b6bb7be

+ 2 - 2
fs-company/src/main/java/com/fs/company/controller/live/LiveController.java

@@ -316,8 +316,8 @@ public class LiveController extends BaseController
         HashMap<String, String> map = new HashMap<>();
         map.put("grant_type","client_credential");
         // 芳华惠选
-        map.put("appid","wx503cf8ab31f83dd4");
-        map.put("secret","1ba1972363889dcb4a37ecb685744435");
+        map.put("appid","wx4d225cc86cc7885d");
+        map.put("secret","f938f86cfebde0f4d34dad3b0d81b974");
         String accessToken = HttpUtils.endApi(url, null, map);
         // 创建Gson对象
         Gson gson = new Gson();

+ 14 - 0
fs-company/src/main/java/com/fs/company/controller/live/LiveVideoController.java

@@ -6,6 +6,8 @@ import com.fs.common.core.domain.AjaxResult;
 import com.fs.common.core.page.TableDataInfo;
 import com.fs.common.enums.BusinessType;
 import com.fs.common.utils.poi.ExcelUtil;
+import com.fs.company.domain.CompanyUser;
+import com.fs.core.security.SecurityUtils;
 import com.fs.live.domain.LiveVideo;
 import com.fs.live.service.ILiveVideoService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +36,8 @@ public class LiveVideoController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(LiveVideo liveVideo)
     {
+        // 设置当前登录用户的companyId,用于权限筛选
+        setCompanyId(liveVideo);
         startPage();
         List<LiveVideo> list = liveVideoService.selectLiveVideoList(liveVideo);
         return getDataTable(list);
@@ -47,6 +51,8 @@ public class LiveVideoController extends BaseController
     @GetMapping("/export")
     public AjaxResult export(LiveVideo liveVideo)
     {
+        // 设置当前登录用户的companyId,用于权限筛选
+        setCompanyId(liveVideo);
         List<LiveVideo> list = liveVideoService.selectLiveVideoList(liveVideo);
         ExcelUtil<LiveVideo> util = new ExcelUtil<LiveVideo>(LiveVideo.class);
         return util.exportExcel(list, "直播视频数据");
@@ -113,4 +119,12 @@ public class LiveVideoController extends BaseController
         return toAjax(liveVideoService.deleteLiveVideoByVideoIds(videoIds));
     }
 
+    /**
+     * 设置当前登录用户的companyId,用于权限筛选
+     * @param liveVideo 直播视频对象
+     */
+    private void setCompanyId(LiveVideo liveVideo) {
+        CompanyUser user = SecurityUtils.getLoginUser().getUser();
+        liveVideo.setCompanyId(user.getCompanyId());
+    }
 }

+ 9 - 0
fs-service-system/src/main/java/com/fs/live/domain/LiveVideo.java

@@ -1,11 +1,14 @@
 package com.fs.live.domain;
 
 
+import com.alibaba.fastjson.annotation.JSONField;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntity;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.util.List;
+
 /**
  * 直播视频对象 live_video
  *
@@ -43,4 +46,10 @@ public class LiveVideo extends BaseEntity {
     private Long sort;
     @Excel(name = "转码状态")
     private Integer finishStatus;
+
+    /** 企业ID列表 */
+    private List<Long> companyIds;
+
+    /** 查询条件:企业ID(不映射到数据库,仅用于查询筛选) */
+    private transient Long companyId;
 }

+ 61 - 0
fs-service-system/src/main/java/com/fs/live/domain/handler/CompanyIdsTypeHandler.java

@@ -0,0 +1,61 @@
+package com.fs.live.domain.handler;
+
+import com.alibaba.fastjson.JSON;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * CompanyIds List<Long> 与 JSON 字符串的 TypeHandler
+ */
+@MappedTypes({List.class})
+@MappedJdbcTypes(JdbcType.VARCHAR)
+public class CompanyIdsTypeHandler extends BaseTypeHandler<List<Long>> {
+
+    @Override
+    public void setNonNullParameter(PreparedStatement ps, int i, List<Long> parameter, JdbcType jdbcType) throws SQLException {
+        if (parameter == null || parameter.isEmpty()) {
+            ps.setString(i, null);
+        } else {
+            ps.setString(i, JSON.toJSONString(parameter));
+        }
+    }
+
+    @Override
+    public List<Long> getNullableResult(ResultSet rs, String columnName) throws SQLException {
+        String json = rs.getString(columnName);
+        return parseJson(json);
+    }
+
+    @Override
+    public List<Long> getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+        String json = rs.getString(columnIndex);
+        return parseJson(json);
+    }
+
+    @Override
+    public List<Long> getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+        String json = cs.getString(columnIndex);
+        return parseJson(json);
+    }
+
+    private List<Long> parseJson(String json) {
+        if (json == null || json.trim().isEmpty()) {
+            return new ArrayList<>();
+        }
+        try {
+            return JSON.parseArray(json, Long.class);
+        } catch (Exception e) {
+            return new ArrayList<>();
+        }
+    }
+}
+

+ 8 - 1
fs-service-system/src/main/resources/mapper/live/LiveVideoMapper.xml

@@ -18,10 +18,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="remark"    column="remark"    />
         <result property="fileSize"    column="file_size"    />
         <result property="finishStatus"    column="finish_status"    />
+        <result property="companyIds"    column="company_ids"    typeHandler="com.fs.live.domain.handler.CompanyIdsTypeHandler"    />
     </resultMap>
 
     <sql id="selectLiveVideoVo">
-        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration,file_size,finish_status from live_video
+        select video_id, live_id, video_url, video_type, sort, create_time, create_by, update_by, update_time, remark,duration,file_size,finish_status,company_ids from live_video
     </sql>
 
     <select id="selectLiveVideoList" parameterType="LiveVideo" resultMap="LiveVideoResult">
@@ -33,6 +34,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="sort != null "> and sort = #{sort}</if>
             <if test="remark != null "> and remark like CONCAT('%',#{remark},'%')</if>
             <if test="finishStatus != null "> and finish_status  = #{finishStatus}</if>
+            <if test="companyId != null">
+                and (company_ids IS NULL OR company_ids = '' OR company_ids = '[]' OR JSON_CONTAINS(company_ids, CAST(#{companyId} AS JSON), '$'))
+            </if>
         </where>
     </select>
 
@@ -60,6 +64,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="duration != null">duration,</if>
             <if test="fileSize != null">file_size,</if>
             <if test="finishStatus != null">finish_status,</if>
+            <if test="companyIds != null">company_ids,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="liveId != null">#{liveId},</if>
@@ -74,6 +79,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="duration != null">#{duration},</if>
             <if test="fileSize != null">#{fileSize},</if>
             <if test="finishStatus != null">#{finishStatus},</if>
+            <if test="companyIds != null">#{companyIds, typeHandler=com.fs.live.domain.handler.CompanyIdsTypeHandler},</if>
          </trim>
     </insert>
 
@@ -92,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="remark != null">remark = #{remark},</if>
             <if test="fileSize != null">file_size = #{fileSize},</if>
             <if test="finishStatus != null">finish_status = #{finishStatus},</if>
+            <if test="companyIds != null">company_ids = #{companyIds, typeHandler=com.fs.live.domain.handler.CompanyIdsTypeHandler},</if>
         </trim>
         where video_id = #{videoId}
     </update>