diff --git a/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubMyApplyController.java b/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubMyApplyController.java index fa7643a..d34a8da 100644 --- a/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubMyApplyController.java +++ b/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubMyApplyController.java @@ -58,7 +58,7 @@ public class ClubMyApplyController { public Object pageData(PageForm pageForm, @Param(value = "name",required = false) String name, @Param(value = "year",required = false)String year) { - CndPlus cnd = CndPlus.create(); + Cnd cnd = Cnd.NEW(); Sql sql = Sqls.create(""" SELECT c.*, @@ -77,14 +77,14 @@ public class ClubMyApplyController { LEFT JOIN audit_state s ON s.stateId = c.state $condition """); - cnd.andEx("c.name", "LIKE", "%" + name + "%"); - cnd.andEx("year(c.create_time)", "=", year); + cnd.andEX("c.name", "LIKE", "%" + name + "%"); + cnd.andEX("year(c.create_time)", "=", year); if(!ShiroUtil.hasAnyRoles("sysadmin, A06, xxhgly")) { cnd.and("c.userid", "=", ShiroUtil.getPlatformUid()); } - cnd.asc("state").desc("create_time"); + cnd.asc("c.code"); sql.setCondition(cnd); Pagination pagination = baseService.listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql); return pagination; diff --git a/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubRegistApplyController.java b/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubRegistApplyController.java index 2598f3c..0514586 100644 --- a/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubRegistApplyController.java +++ b/src/main/java/io/v/nutz/sys/controllers/platform/sys/club/regist/ClubRegistApplyController.java @@ -26,6 +26,7 @@ import org.nutz.mvc.annotation.Param; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.Objects; /** * @Author JyuHsin @@ -58,7 +59,7 @@ public class ClubRegistApplyController { @RequiresPermissions("sys.club.clubRegist.clubRegistApply") public Object getClubCode() { String maxNum = (String) dao.func2(Sys_club.class, "max", "code", Cnd.where("year(create_time)", "=", DateUtil.getYear())); - if(StrUtil.isBlank(maxNum)) { + if (StrUtil.isBlank(maxNum)) { maxNum = DateUtil.getYear() + "000"; } return Integer.parseInt(maxNum) + 1; @@ -77,7 +78,7 @@ public class ClubRegistApplyController { club.setFoundTime(DateUtil.getDateTime()); club.setState(isSave ? ClubRegistAuditState.NOT_SUBMIT : ClubRegistAuditState.SCHOOL_PASS); } else { - if(isSave) { + if (isSave) { club.setState(ClubRegistAuditState.NOT_SUBMIT); } else { club.setState(club.getSponsorType() == 1 ? ClubRegistAuditState.UNIT_PART_READY : ClubRegistAuditState.XT_READY); @@ -125,13 +126,13 @@ public class ClubRegistApplyController { } private String getRoleId(int sf) { - if(sf == 1) { + if (sf == 1) { return Roles.club01; - } else if(sf == 3) { + } else if (sf == 3) { return Roles.club02; - } else if(sf == 4) { + } else if (sf == 4) { return Roles.club03; - } else if(sf == 5) { + } else if (sf == 5) { return Roles.club04; } return ""; @@ -146,24 +147,23 @@ public class ClubRegistApplyController { @Param(value = "::deleteIds", required = false) List deleteIds, @Param(value = "::managePerson", required = false) List managePerson) throws IOException { + //如果不是管理员,并且点的提交按钮 if (!isSave && !ShiroUtil.hasAnyRoles("sysadmin, A06, xxhgly")) { club.setState(club.getSponsorType() == 1 ? ClubRegistAuditState.UNIT_PART_READY : ClubRegistAuditState.XT_READY); club.setXtAuditId(""); club.setXldAuditId(""); + club.setUnitPartAuditId(""); + club.setXghAuditId(""); } - if (!isSave && ShiroUtil.hasAnyRoles("sysadmin, A06, xxhgly")) { - club.setState(ClubRegistAuditState.SCHOOL_PASS); - } + sysClubService.update(club); dao.clear(Sys_club_sponsor.class, Cnd.where("clubId", "=", club.getId())); dao.insertLinks(club, "sponsors"); - //插入新建社团时填入的理事机构 dao.clear(Sys_club_user.class, Cnd.where("id", "in", deleteIds)); - dao.clear(Sys_user_role.class, Cnd.where("stid", "=", club.getId()) - .and("roleid", "in", Lang.array(Roles.club01, Roles.club02, Roles.club03, Roles.club04))); + List clubUsers = new ArrayList<>(); - //List userRoles = new ArrayList<>(); + List userRoles = new ArrayList<>(); managePerson.forEach(item -> { Sys_club_user cUser = new Sys_club_user(); Sys_club_user fetch = dao.fetch(Sys_club_user.class, Cnd.where("clubid", "=", club.getId()) @@ -183,17 +183,25 @@ public class ClubRegistApplyController { cUser.setIsNormal(true); } clubUsers.add(cUser); - dao.insertOrUpdate(cUser); - /*Sys_user_role uRole = new Sys_user_role(); - uRole.setUserId(item.getString("userId")); - uRole.setRoleId(item.getString("roleId")); - uRole.setStid(club.getId()); - userRoles.add(uRole);*/ + + //如果是管理员创建的社团,直接加角色 + if(ShiroUtil.hasAnyRoles("sysadmin, A06, xxhgly") && Objects.equals(club.getState(), ClubRegistAuditState.SCHOOL_PASS)) { + Sys_user_role uRole = new Sys_user_role(); + uRole.setUserId(item.getString("userId")); + uRole.setRoleId(getRoleId(item.getInt("sf"))); + uRole.setStid(club.getId()); + userRoles.add(uRole); + } }); - //dao.insert(userRoles); + if(ShiroUtil.hasAnyRoles("sysadmin, A06, xxhgly") && Objects.equals(club.getState(), ClubRegistAuditState.SCHOOL_PASS)) { + dao.clear(Sys_user_role.class, Cnd.where("stid", "=", club.getId()) + .and("roleid", "in", Lang.array(Roles.club01, Roles.club02, Roles.club03, Roles.club04))); + dao.insert(userRoles); + } + + dao.insertOrUpdate(clubUsers); flushDict(); - return null; } diff --git a/src/main/resources/views/platform/sys/club/regist/clubMyApply.html b/src/main/resources/views/platform/sys/club/regist/clubMyApply.html index a2e6adf..025bec1 100644 --- a/src/main/resources/views/platform/sys/club/regist/clubMyApply.html +++ b/src/main/resources/views/platform/sys/club/regist/clubMyApply.html @@ -74,11 +74,15 @@ layout("/layouts/platform.html"){