Browse Source

增加条件 未传入老师id则使用当前人员的id

hgw 3 năm trước cách đây
mục cha
commit
f606b7e9cc

+ 11 - 4
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/support/WrapperUtil.java

@@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
 import com.yonge.toolset.base.exception.BizException;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.poi.ss.formula.functions.T;
 
 import javax.script.ScriptEngine;
 import javax.script.ScriptEngineManager;
@@ -42,6 +41,13 @@ public class WrapperUtil {
                 .orElse(0);
     }
 
+    public static <S, O> Long toLong(Map<S, O> map, S str) {
+        return Optional.ofNullable(map.get(str))
+                .map(String::valueOf)
+                .map(Long::parseLong)
+                .orElse(null);
+    }
+
     public static <S, O> Long toLong(Map<S, O> map, S str, String exMsg) {
         return Optional.ofNullable(map.get(str))
                 .map(String::valueOf)
@@ -274,12 +280,13 @@ public class WrapperUtil {
 
     /**
      * 字符串转公式
-     * @param formula 公式字符串
+     *
+     * @param formula  公式字符串
      * @param variable 变量
-     * @param param 参数
+     * @param param    参数
      * @return
      */
-    public static Object strToFormula(String formula, String variable, String param){
+    public static Object strToFormula(String formula, String variable, String param) {
         ScriptEngine jse = new ScriptEngineManager().getEngineByName("JavaScript");
         try {
             return jse.eval(formula.replace(variable, param));

+ 15 - 0
cooleshow-user/user-teacher/src/main/java/com/yonge/cooleshow/teacher/controller/TeacherCourseGroupController.java

@@ -1,21 +1,27 @@
 package com.yonge.cooleshow.teacher.controller;
 
 
+import com.yonge.cooleshow.auth.api.client.SysUserFeignService;
+import com.yonge.cooleshow.auth.api.entity.SysUser;
 import com.yonge.cooleshow.biz.dal.dto.CheckCourseTimeDto;
 import com.yonge.cooleshow.biz.dal.dto.LiveCourseGroupDto;
 import com.yonge.cooleshow.biz.dal.entity.CourseTimeEntity;
 import com.yonge.cooleshow.biz.dal.service.CourseGroupService;
+import com.yonge.cooleshow.biz.dal.support.WrapperUtil;
 import com.yonge.cooleshow.biz.dal.vo.CourseGroupVo;
 import com.yonge.cooleshow.biz.dal.vo.LiveCourseInfoVo;
 import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
+import com.yonge.toolset.base.exception.BizException;
 import com.yonge.toolset.base.page.PageInfo;
 import io.swagger.annotations.*;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
+import java.util.Optional;
 
 /**
  * 课程组表(CourseGroup)表控制层
@@ -32,6 +38,8 @@ public class TeacherCourseGroupController extends BaseController {
      */
     @Resource
     private CourseGroupService courseGroupService;
+    @Autowired
+    private SysUserFeignService sysUserFeignService;
 
     @ApiOperation("直播课详情")
     @GetMapping("/queryLiveCourseInfo")
@@ -49,6 +57,9 @@ public class TeacherCourseGroupController extends BaseController {
     @ApiOperation("分页查询直播课课程组列表")
     @PostMapping("/queryPageCourseGroup")
     public HttpResponseResult<PageInfo<CourseGroupVo>> queryPageLiveCourseGroup(@RequestBody Map<String, Object> param) {
+        Long teacherId = WrapperUtil.toLong(param, "teacherId");
+        teacherId = Optional.ofNullable(teacherId).orElseGet(() -> getSysUser().getId());
+        param.put("teacherId", teacherId);
         return succeed(courseGroupService.queryPageLiveCourseGroup(param));
     }
 
@@ -85,5 +96,9 @@ public class TeacherCourseGroupController extends BaseController {
         return succeed(courseGroupService.getLiveLockTimeCache(teacherId).get(teacherId));
     }
 
+    private SysUser getSysUser() {
+        return Optional.ofNullable(sysUserFeignService.queryUserInfo())
+                .orElseThrow(() -> new BizException("用户不存在"));
+    }
 }