|
@@ -40,6 +40,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import javax.validation.Valid;
|
|
import javax.validation.Valid;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequestMapping("/course/playSourceConfig")
|
|
@RequestMapping("/course/playSourceConfig")
|
|
@@ -82,6 +83,9 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
List<FsCoursePlaySourceConfigVO> list = fsCoursePlaySourceConfigService.selectCoursePlaySourceConfigVOListByMap(params);
|
|
List<FsCoursePlaySourceConfigVO> list = fsCoursePlaySourceConfigService.selectCoursePlaySourceConfigVOListByMap(params);
|
|
|
|
|
+ for (FsCoursePlaySourceConfigVO item : list) {
|
|
|
|
|
+ item.setCompanyIds(parseCompanyIds(item.getCompanyIdsText(), item.getCompanyId()));
|
|
|
|
|
+ }
|
|
|
return getDataTable(list);
|
|
return getDataTable(list);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -95,6 +99,7 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
|
|
|
|
|
FsCoursePlaySourceConfigVO configVO = new FsCoursePlaySourceConfigVO();
|
|
FsCoursePlaySourceConfigVO configVO = new FsCoursePlaySourceConfigVO();
|
|
|
BeanUtils.copyProperties(config, configVO);
|
|
BeanUtils.copyProperties(config, configVO);
|
|
|
|
|
+ configVO.setCompanyIds(parseCompanyIds(config.getCompanyIds(), config.getCompanyId()));
|
|
|
return AjaxResult.success(configVO);
|
|
return AjaxResult.success(configVO);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -124,6 +129,7 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
config.setCreateUserId(loginUser.getUserId());
|
|
config.setCreateUserId(loginUser.getUserId());
|
|
|
config.setCreateDeptId(loginUser.getDeptId());
|
|
config.setCreateDeptId(loginUser.getDeptId());
|
|
|
BeanUtils.copyProperties(param, config);
|
|
BeanUtils.copyProperties(param, config);
|
|
|
|
|
+ applyCompanyIds(param.getCompanyId(), param.getCompanyIds(), config);
|
|
|
|
|
|
|
|
config.setIsDel(0);
|
|
config.setIsDel(0);
|
|
|
config.setCreateTime(LocalDateTime.now());
|
|
config.setCreateTime(LocalDateTime.now());
|
|
@@ -160,6 +166,7 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(param, config);
|
|
BeanUtils.copyProperties(param, config);
|
|
|
|
|
+ applyCompanyIds(param.getCompanyId(), param.getCompanyIds(), config);
|
|
|
|
|
|
|
|
fsCoursePlaySourceConfigService.updateById(config);
|
|
fsCoursePlaySourceConfigService.updateById(config);
|
|
|
return AjaxResult.success();
|
|
return AjaxResult.success();
|
|
@@ -278,7 +285,11 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
queryWrapper.eq("create_user_id", loginUser.getUserId()).eq(config.getDept() == null || !config.getDept(), "create_dept_id", loginUser.getDeptId());
|
|
queryWrapper.eq("create_user_id", loginUser.getUserId()).eq(config.getDept() == null || !config.getDept(), "create_dept_id", loginUser.getDeptId());
|
|
|
}
|
|
}
|
|
|
if(companyId != null){
|
|
if(companyId != null){
|
|
|
- queryWrapper.and(e -> e.eq("company_id", companyId).or().isNull("company_id"));
|
|
|
|
|
|
|
+ queryWrapper.and(e -> e.eq("company_id", companyId)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .apply("(company_ids is not null and company_ids != '' and find_in_set({0}, company_ids))", companyId)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .isNull("company_id"));
|
|
|
}
|
|
}
|
|
|
queryWrapper.in("status","0","1");//查询正常、半封禁小程序
|
|
queryWrapper.in("status","0","1");//查询正常、半封禁小程序
|
|
|
return R.ok().put("data", fsCoursePlaySourceConfigService.list(queryWrapper));
|
|
return R.ok().put("data", fsCoursePlaySourceConfigService.list(queryWrapper));
|
|
@@ -337,4 +348,46 @@ public class FsCoursePlaySourceConfigController extends BaseController {
|
|
|
return AjaxResult.success(result);
|
|
return AjaxResult.success(result);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private static void applyCompanyIds(Long companyId, List<Long> companyIds, FsCoursePlaySourceConfig config) {
|
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
|
+ if (companyIds != null) {
|
|
|
|
|
+ for (Long id : companyIds) {
|
|
|
|
|
+ if (id != null) {
|
|
|
|
|
+ ids.add(id);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ids.isEmpty() && companyId != null) {
|
|
|
|
|
+ ids.add(companyId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
|
|
+ List<Long> distinct = ids.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
+ config.setCompanyId(config.getCompanyId() != null ? config.getCompanyId() : distinct.get(0));
|
|
|
|
|
+ config.setCompanyIds(distinct.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ config.setCompanyIds(null);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private static List<Long> parseCompanyIds(String companyIds, Long companyId) {
|
|
|
|
|
+ List<Long> ids = new ArrayList<>();
|
|
|
|
|
+ if (companyIds != null && !companyIds.trim().isEmpty()) {
|
|
|
|
|
+ for (String s : companyIds.split(",")) {
|
|
|
|
|
+ String v = s == null ? "" : s.trim();
|
|
|
|
|
+ if (!v.isEmpty()) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ ids.add(Long.parseLong(v));
|
|
|
|
|
+ } catch (NumberFormatException ignored) {
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (ids.isEmpty() && companyId != null) {
|
|
|
|
|
+ ids.add(companyId);
|
|
|
|
|
+ }
|
|
|
|
|
+ return ids.stream().distinct().collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
|
|
+
|