|
|
@@ -10,6 +10,7 @@ import com.fs.common.core.page.TableDataInfo;
|
|
|
import com.fs.common.enums.BusinessType;
|
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.ServletUtils;
|
|
|
+import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
import com.fs.course.domain.FsUserCoursePeriod;
|
|
|
import com.fs.course.domain.FsUserCoursePeriodDays;
|
|
|
@@ -37,10 +38,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.time.LocalDate;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.util.*;
|
|
|
|
|
|
|
|
|
/**
|
|
|
@@ -104,6 +102,20 @@ public class FsUserCoursePeriodController extends BaseController {
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
fsUserCoursePeriod.setCompanyIdList(Collections.singletonList(loginUser.getCompany().getCompanyId()));
|
|
|
List<FsUserCoursePeriodVO> list = fsUserCoursePeriodService.selectFsUserCoursePeriodPage(fsUserCoursePeriod);
|
|
|
+ // 使用Stream API的简洁写法
|
|
|
+ Long currentCompanyId = loginUser.getCompany().getCompanyId();
|
|
|
+ for (FsUserCoursePeriodVO vo : list) {
|
|
|
+ String isNeedRegisterMember = vo.getIsNeedRegisterMember();
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(isNeedRegisterMember)) {
|
|
|
+ boolean containsCurrentCompany = Arrays.stream(isNeedRegisterMember.split(","))
|
|
|
+ .map(String::trim)
|
|
|
+ .anyMatch(id -> id.equals(String.valueOf(currentCompanyId)));
|
|
|
+ vo.setIsNeedRegisterMember(containsCurrentCompany ? "1" : "0");
|
|
|
+ } else {
|
|
|
+ vo.setIsNeedRegisterMember("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
PageInfo<FsUserCoursePeriodVO> pageInfo = new PageInfo<>(list);
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
result.put("rows", pageInfo.getList());
|
|
|
@@ -173,7 +185,13 @@ public class FsUserCoursePeriodController extends BaseController {
|
|
|
@PutMapping("/editIsNeedRegisterMember")
|
|
|
public AjaxResult editIsNeedRegisterMember(@RequestBody FsUserCoursePeriod fsUserCoursePeriod)
|
|
|
{
|
|
|
- return toAjax(fsUserCoursePeriodService.editIsNeedRegisterMember(fsUserCoursePeriod));
|
|
|
+ FsUserCoursePeriod fsUserCoursePeriod1 = fsUserCoursePeriodService.selectFsUserCoursePeriodById(fsUserCoursePeriod.getPeriodId());
|
|
|
+ LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
+ if (ObjectUtil.isEmpty(fsUserCoursePeriod.getIsNeedRegisterMember())){
|
|
|
+ throw new CustomException("修改失败!");
|
|
|
+ }
|
|
|
+
|
|
|
+ return toAjax(fsUserCoursePeriodService.editIsNeedRegisterMember(fsUserCoursePeriod,loginUser.getCompany().getCompanyId().toString()));
|
|
|
}
|
|
|
|
|
|
/**
|