福利修改选择结束后不能修改

This commit is contained in:
2026-02-06 09:27:24 +08:00
parent e97ab46b75
commit d36d909851
2 changed files with 21 additions and 3 deletions
@@ -32,9 +32,7 @@ import org.nutz.mvc.annotation.Param;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid; import javax.validation.Valid;
import java.util.Collections; import java.util.*;
import java.util.Date;
import java.util.List;
@IocBean @IocBean
@Ok("json:full") @Ok("json:full")
@@ -96,6 +94,11 @@ public class WelfareSelectionSituationController {
return Result.error("此用户没有选择的权限"); return Result.error("此用户没有选择的权限");
} }
int sum = Arrays.stream(selections).mapToInt(selection -> Objects.requireNonNullElse(selection.getSelectNum(), 0)).sum();
if (sum > project.getMultiSelectNum()) {
return Result.error("选择的数量不能超过" + project.getMultiSelectNum());
}
//删除上次选择的 //删除上次选择的
dao.clear(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId).and(WelfareUserSelection::getSelectUserId, "=", userId)); dao.clear(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId).and(WelfareUserSelection::getSelectUserId, "=", userId));
for (WelfareUserSelection welfareUserSelection : selections) { for (WelfareUserSelection welfareUserSelection : selections) {
@@ -2,11 +2,14 @@ package com.budwk.app.zhgh.welfare.controller;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import com.budwk.app.base.annotation.SLog; import com.budwk.app.base.annotation.SLog;
import com.budwk.app.base.constant.RoleConstant;
import com.budwk.app.base.page.Pagination; import com.budwk.app.base.page.Pagination;
import com.budwk.app.base.param.PageForm; import com.budwk.app.base.param.PageForm;
import com.budwk.app.base.result.Result; import com.budwk.app.base.result.Result;
import com.budwk.app.web.commons.auth.utils.AuthUtil;
import com.budwk.app.web.commons.auth.utils.SecurityUtil; import com.budwk.app.web.commons.auth.utils.SecurityUtil;
import com.budwk.app.zhgh.welfare.model.WelfareList; import com.budwk.app.zhgh.welfare.model.WelfareList;
import com.budwk.app.zhgh.welfare.model.WelfareProject;
import com.budwk.app.zhgh.welfare.model.WelfareUserSelection; import com.budwk.app.zhgh.welfare.model.WelfareUserSelection;
import com.budwk.app.zhgh.welfare.service.WelfareProjectService; import com.budwk.app.zhgh.welfare.service.WelfareProjectService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -23,8 +26,10 @@ import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok; import org.nutz.mvc.annotation.Ok;
import org.nutz.mvc.annotation.Param; import org.nutz.mvc.annotation.Param;
import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
@IocBean @IocBean
@Ok("json:full") @Ok("json:full")
@@ -82,10 +87,20 @@ public class WelfareUserSelectController {
@SLog(type = "welfare", tag = "选择福利", msg = "福利") @SLog(type = "welfare", tag = "选择福利", msg = "福利")
@SaCheckPermission("welfare.user.select") @SaCheckPermission("welfare.user.select")
public Result confirmSelect(@Param("selections") WelfareUserSelection[] selections, String projectId) { public Result confirmSelect(@Param("selections") WelfareUserSelection[] selections, String projectId) {
WelfareProject project = dao.fetch(WelfareProject.class, projectId);
if (!AuthUtil.hasRoleOr(RoleConstant.SYSADMIN.name(), RoleConstant.SCHOOL_UNION_ADMIN.name())) {
if(project.getChoiceTimeEnd().getTime()<new Date().getTime()){
return Result.error("选择时间已结束暂时不能修改!");
}
}
int count = dao.count(WelfareList.class, Cnd.where(WelfareList::getProjectId, "=", projectId).and(WelfareList::getUserId, "=", SecurityUtil.getUserId())); int count = dao.count(WelfareList.class, Cnd.where(WelfareList::getProjectId, "=", projectId).and(WelfareList::getUserId, "=", SecurityUtil.getUserId()));
if(count==0){ if(count==0){
return Result.error("您没有选择的权限"); return Result.error("您没有选择的权限");
} }
int sum = Arrays.stream(selections).mapToInt(selection -> Objects.requireNonNullElse(selection.getSelectNum(), 0)).sum();
if (sum > project.getMultiSelectNum()) {
return Result.error("选择的数量不能超过" + project.getMultiSelectNum());
}
//删除上次选择的 //删除上次选择的
dao.clear(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId).and(WelfareUserSelection::getSelectUserId, "=", SecurityUtil.getUserId())); dao.clear(WelfareUserSelection.class, Cnd.where(WelfareUserSelection::getWelfareId, "=", projectId).and(WelfareUserSelection::getSelectUserId, "=", SecurityUtil.getUserId()));