|
|
@@ -1,11 +1,8 @@
|
|
|
package com.xjrsoft.module.activity.controller;
|
|
|
|
|
|
-import camundajar.impl.com.google.gson.JsonArray;
|
|
|
-import camundajar.impl.com.google.gson.JsonElement;
|
|
|
-import camundajar.impl.com.google.gson.JsonParser;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import cn.dev33.satoken.stp.StpUtil;
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.xjrsoft.common.exception.MyException;
|
|
|
import com.xjrsoft.common.model.result.RT;
|
|
|
@@ -16,6 +13,7 @@ import com.xjrsoft.module.activity.dto.ActivityInfoPageDto;
|
|
|
import com.xjrsoft.module.activity.dto.AddActivityInfoDto;
|
|
|
import com.xjrsoft.module.activity.dto.ChangeStatusDto;
|
|
|
import com.xjrsoft.module.activity.dto.UpdateActivityInfoDto;
|
|
|
+import com.xjrsoft.module.activity.entity.ActivityEnroll;
|
|
|
import com.xjrsoft.module.activity.entity.ActivityInfo;
|
|
|
import com.xjrsoft.module.activity.service.IActivityEnrollService;
|
|
|
import com.xjrsoft.module.activity.service.IActivityInfoService;
|
|
|
@@ -87,33 +85,29 @@ public class ActivityInfoController {
|
|
|
return RT.error("找不到此数据!");
|
|
|
}
|
|
|
ActivityInfoVo infoVo = BeanUtil.toBean(activityInfo, ActivityInfoVo.class);
|
|
|
- if(activityInfo.getEnrollRange() != null && !"".equals(activityInfo.getEnrollRange())){
|
|
|
- JsonParser parser = new JsonParser();
|
|
|
- JsonArray asJsonArray = parser.parse(activityInfo.getEnrollRange()).getAsJsonArray();
|
|
|
- List<ActivityEnrollRangeVo> userRelationList = new ArrayList<>();
|
|
|
- for (JsonElement jsonElement : asJsonArray) {
|
|
|
- ActivityEnrollRangeVo relationDto = JSONUtil.toBean(jsonElement.getAsJsonObject().toString(), ActivityEnrollRangeVo.class);
|
|
|
- if(relationDto.getUserId() != null){
|
|
|
- XjrUser xjrUser = xjrUserService.getById(relationDto.getUserId());
|
|
|
- if(xjrUser != null){
|
|
|
- relationDto.setName(xjrUser.getName());
|
|
|
- }
|
|
|
- }else if(relationDto.getDeptId() != null){
|
|
|
- Department department = departmentService.getById(relationDto.getDeptId());
|
|
|
- if(department != null){
|
|
|
- relationDto.setName(department.getName());
|
|
|
- }
|
|
|
-
|
|
|
- }else if(relationDto.getClassId() != null){
|
|
|
- BaseClass aClass = classService.getById(relationDto.getClassId());
|
|
|
- if(aClass != null){
|
|
|
- relationDto.setName(aClass.getName());
|
|
|
- }
|
|
|
+ List<ActivityEnrollRangeVo> userRelationList = new ArrayList<>();
|
|
|
+ for (ActivityEnroll jsonElement : activityInfo.getActivityEnrollList()) {
|
|
|
+ ActivityEnrollRangeVo relationDto = BeanUtil.toBean(jsonElement, ActivityEnrollRangeVo.class);
|
|
|
+ if(relationDto.getUserId() != null){
|
|
|
+ XjrUser xjrUser = xjrUserService.getById(relationDto.getUserId());
|
|
|
+ if(xjrUser != null){
|
|
|
+ relationDto.setName(xjrUser.getName());
|
|
|
+ }
|
|
|
+ }else if(relationDto.getDeptId() != null){
|
|
|
+ Department department = departmentService.getById(relationDto.getDeptId());
|
|
|
+ if(department != null){
|
|
|
+ relationDto.setName(department.getName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if(relationDto.getClassId() != null){
|
|
|
+ BaseClass aClass = classService.getById(relationDto.getClassId());
|
|
|
+ if(aClass != null){
|
|
|
+ relationDto.setName(aClass.getName());
|
|
|
}
|
|
|
- userRelationList.add(relationDto);
|
|
|
}
|
|
|
- infoVo.setActivityEnrollRangeList(userRelationList);
|
|
|
+ userRelationList.add(relationDto);
|
|
|
}
|
|
|
+ infoVo.setActivityEnrollRangeList(userRelationList);
|
|
|
|
|
|
ActivityEnrollPageDto dto = new ActivityEnrollPageDto();
|
|
|
dto.setActivityInfoId(id);
|
|
|
@@ -174,4 +168,38 @@ public class ActivityInfoController {
|
|
|
return RT.ok(activityInfoService.delete(ids));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @GetMapping(value = "/effective-list")
|
|
|
+ @ApiOperation(value="移动端活动信息列表(分页)")
|
|
|
+ @SaCheckPermission("activityinfo:detail")
|
|
|
+ public RT<PageOutput<ActivityInfoPageVo>> mobilePage(@Valid ActivityInfoPageDto dto){
|
|
|
+ dto.setIsEffective(1);
|
|
|
+ Page<ActivityInfoPageVo> page = activityInfoService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+
|
|
|
+ ActivityEnrollPageDto enrollDto = new ActivityEnrollPageDto();
|
|
|
+ enrollDto.setLoginUserId(StpUtil.getLoginIdAsLong());
|
|
|
+ List<ActivityEnrollPageVo> enrolList = enrollService.getList(enrollDto);
|
|
|
+ Set<String> collect = enrolList.stream().map(ActivityEnrollPageVo::getActivityInfoId).collect(Collectors.toSet());
|
|
|
+
|
|
|
+ for (ActivityInfoPageVo record : page.getRecords()) {
|
|
|
+ record.setIsEnroll(0);
|
|
|
+ if(collect.contains(record.getId())){
|
|
|
+ record.setIsEnroll(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ PageOutput<ActivityInfoPageVo> pageOutput = ConventPage.getPageOutput(page, ActivityInfoPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping(value = "/enroll")
|
|
|
+ @ApiOperation(value="报名")
|
|
|
+ @SaCheckPermission("activityinfo:detail")
|
|
|
+ public RT<PageOutput<ActivityInfoPageVo>> enroll(@Valid ActivityInfoPageDto dto){
|
|
|
+ dto.setIsEffective(1);
|
|
|
+ Page<ActivityInfoPageVo> page = activityInfoService.getPage(new Page<>(dto.getLimit(), dto.getSize()), dto);
|
|
|
+ PageOutput<ActivityInfoPageVo> pageOutput = ConventPage.getPageOutput(page, ActivityInfoPageVo.class);
|
|
|
+ return RT.ok(pageOutput);
|
|
|
+ }
|
|
|
+
|
|
|
}
|