Changes
This commit is contained in:
+45
-5
@@ -25,6 +25,7 @@ import org.nutz.dao.util.cri.SqlExpressionGroup;
|
||||
import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Strings;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
@@ -68,11 +69,15 @@ public class TeacherCongressInstitutionController {
|
||||
Teacher_congress_institution rootInstitution = new Teacher_congress_institution();
|
||||
rootInstitution.setId("0");
|
||||
rootInstitution.setParentId("");
|
||||
rootInstitution.setName("教代会机构");
|
||||
rootInstitution.setName("两代会组织机构");
|
||||
rootInstitution.setLocation(0);
|
||||
institutionList.add(rootInstitution);
|
||||
|
||||
List<TreeNode<String>> treeNodes = institutionList.stream().map(institution -> new TreeNode<>(institution.getId(), institution.getParentId(), institution.getName(), institution.getLocation())).toList();
|
||||
List<TreeNode<String>> treeNodes = institutionList.stream().map(institution -> {
|
||||
TreeNode<String> treeNode = new TreeNode<>(institution.getId(), institution.getParentId(), institution.getName(), institution.getLocation());
|
||||
treeNode.setExtra(Map.of("code", Strings.sNull(institution.getCode())));
|
||||
return treeNode;
|
||||
}).toList();
|
||||
List<Tree<String>> treeList = TreeUtil.build(treeNodes, "");
|
||||
return Result.success(treeList);
|
||||
}
|
||||
@@ -97,6 +102,16 @@ public class TeacherCongressInstitutionController {
|
||||
return Result.success(Map.of("treeFlat", children, "treeList", treeList));
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("tc.institution")
|
||||
public Result specialCommitteeRoleOptions() {
|
||||
Sys_dict parent = sysDictService.fetch(Cnd.where(Sys_dict::getCode, "=", "SPECIAL_COMMITTEE_ROLES"));
|
||||
if (ObjectUtil.isEmpty(parent)) {
|
||||
return Result.success(List.of());
|
||||
}
|
||||
List<Sys_dict> children = sysDictService.query(Cnd.where(Sys_dict::getPath, "like", parent.getPath() + "%").and(Sys_dict::getId, "!=", parent.getId()).asc(Sys_dict::getLocation));
|
||||
return Result.success(children);
|
||||
}
|
||||
|
||||
/**
|
||||
* 机构分页查询
|
||||
@@ -113,6 +128,7 @@ public class TeacherCongressInstitutionController {
|
||||
cnd.and("parentId", "=", parentId);
|
||||
cnd.and("sessionId", "=", sessionId);
|
||||
cnd.asc("location");
|
||||
cnd.asc("code");
|
||||
Pagination pagination = baseService.listPage(pageForm.getPageNumber(), pageForm.getPageSize(), "teacher_congress_institution", cnd);
|
||||
return Result.success(pagination);
|
||||
}
|
||||
@@ -129,7 +145,7 @@ public class TeacherCongressInstitutionController {
|
||||
if (dao.count(Teacher_congress_institution.class, Cnd.where(Teacher_congress_institution::getCode, "=", institution.getCode()).and(Teacher_congress_institution::getSessionId, "=", institution.getSessionId())) > 0) {
|
||||
return Result.error("机构已存在");
|
||||
}
|
||||
if (StrUtil.isNotBlank(institution.getParentId()) && !institution.getParentId().equals("0")) {
|
||||
if (StrUtil.isNotBlank(institution.getParentId()) && !institution.getParentId().equals("0") && dao.count(Teacher_congress_institution.class, Cnd.where(Teacher_congress_institution::getId, "=", institution.getParentId()).and(Teacher_congress_institution::getSessionId, "=", institution.getSessionId())) == 0) {
|
||||
Sys_dict sysDict = sysDictService.fetch(Cnd.where(Sys_dict::getId, "=", institution.getParentId()));
|
||||
Teacher_congress_institution parentInstitution = dao.fetch(Teacher_congress_institution.class,
|
||||
Cnd.where(Teacher_congress_institution::getCode, "=", sysDict.getCode())
|
||||
@@ -151,10 +167,34 @@ public class TeacherCongressInstitutionController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@At
|
||||
@SaCheckPermission("tc.institution")
|
||||
public Result update(Teacher_congress_institution institution) {
|
||||
Teacher_congress_institution dbInstitution = dao.fetch(Teacher_congress_institution.class, institution.getId());
|
||||
if (ObjectUtil.isEmpty(dbInstitution)) {
|
||||
return Result.error("机构不存在");
|
||||
}
|
||||
dbInstitution.setName(institution.getName());
|
||||
dbInstitution.setIntroduce(institution.getIntroduce());
|
||||
dbInstitution.setLocation(institution.getLocation());
|
||||
dao.update(dbInstitution);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
@At
|
||||
@SaCheckPermission("tc.institution")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result delete(@Valid String id) {
|
||||
Teacher_congress_institution institution = dao.fetch(Teacher_congress_institution.class, id);
|
||||
if (ObjectUtil.isEmpty(institution)) {
|
||||
return Result.error("机构不存在");
|
||||
}
|
||||
List<Teacher_congress_institution> siblingList = dao.query(Teacher_congress_institution.class, Cnd.where(Teacher_congress_institution::getParentId, "=", institution.getParentId()).and(Teacher_congress_institution::getSessionId, "=", institution.getSessionId()).asc(Teacher_congress_institution::getLocation).asc(Teacher_congress_institution::getCode));
|
||||
for (int i = 0; i < siblingList.size() && i < 6; i++) {
|
||||
if (id.equals(siblingList.get(i).getId())) {
|
||||
return Result.error("你选择的组织机构是两代会基本机构,不允许删除。");
|
||||
}
|
||||
}
|
||||
dao.delete(Teacher_congress_institution.class, id);
|
||||
dao.clear(Teacher_congress_institution_user.class, Cnd.where("institutionId", "=", id));
|
||||
return Result.success();
|
||||
@@ -214,8 +254,8 @@ public class TeacherCongressInstitutionController {
|
||||
@SaCheckPermission("tc.institution")
|
||||
@SLog(tag = "教代会-机构设置", msg = "添加人员")
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public Result userInsert(@Valid String userId, @Valid String institutionId, @Valid String sessionId, @Valid String identity) {
|
||||
teacherCongressInstitutionUserService.userInsert(userId, institutionId, sessionId, identity);
|
||||
public Result userInsert(@Valid String userId, @Valid String institutionId, @Valid String sessionId, @Valid String identity, String roleCode) {
|
||||
teacherCongressInstitutionUserService.userInsert(userId, institutionId, sessionId, identity, roleCode);
|
||||
return Result.success();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ public interface TeacherCongressInstitutionUserService extends BaseService<Teach
|
||||
* @param sessionId 届次id
|
||||
* @param identity 身份 主任|副主任|成员
|
||||
*/
|
||||
void userInsert(String userId, String institutionId, String sessionId, String identity);
|
||||
void userInsert(String userId, String institutionId, String sessionId, String identity, String roleCode);
|
||||
|
||||
/**
|
||||
* 删除机构成员
|
||||
|
||||
+24
-1
@@ -1,5 +1,6 @@
|
||||
package com.budwk.app.zhgh.democratic.teachercongress.institution.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.exception.BaseException;
|
||||
import com.budwk.app.base.service.impl.BaseServiceImpl;
|
||||
@@ -30,7 +31,7 @@ public class TeacherCongressInstitutionUserServiceImpl extends BaseServiceImpl<T
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void userInsert(String userId, String institutionId, String sessionId, String identity) {
|
||||
public void userInsert(String userId, String institutionId, String sessionId, String identity, String roleCode) {
|
||||
int count = dao().count(Teacher_congress_institution_user.class,
|
||||
Cnd.where(Teacher_congress_institution_user::getInstitutionId, "=", institutionId)
|
||||
.and(Teacher_congress_institution_user::getUserId, "=", userId)
|
||||
@@ -49,6 +50,28 @@ public class TeacherCongressInstitutionUserServiceImpl extends BaseServiceImpl<T
|
||||
dao().insert(institutionUser);
|
||||
|
||||
Teacher_congress_institution institution = dao().fetch(Teacher_congress_institution.class, institutionId);
|
||||
if ("ZWH001".equals(institution.getCode()) || "ZXWYH".equals(institution.getCode()) || "DBZGSCXZ".equals(institution.getCode())) {
|
||||
if (StrUtil.isBlank(roleCode)) {
|
||||
throw new BaseException("请选择角色");
|
||||
}
|
||||
Sys_role sysRole = sysRoleService.fetch(Cnd.where(Sys_role::getCode, "=", roleCode));
|
||||
if (sysRole == null) {
|
||||
throw new BaseException("无法找到" + roleCode + "对应编码的角色");
|
||||
}
|
||||
int existsRole = dao().count(Sys_user_role.class, Cnd.where(Sys_user_role::getUserId, "=", userId)
|
||||
.and(Sys_user_role::getTcSessionId, "=", sessionId)
|
||||
.and(Sys_user_role::getRoleId, "=", sysRole.getId())
|
||||
);
|
||||
if (existsRole == 0) {
|
||||
Sys_user_role insertSysUserRole = new Sys_user_role();
|
||||
insertSysUserRole.setRoleId(sysRole.getId());
|
||||
insertSysUserRole.setUserId(userId);
|
||||
insertSysUserRole.setTcSessionId(sessionId);
|
||||
dao().insert(insertSysUserRole);
|
||||
sysRoleService.clearCache();
|
||||
sysUserService.clearCache();
|
||||
}
|
||||
}
|
||||
if (institution.getCode().contains("TEACHER_CONGRESS_INSTITUTION_PROPOSAL_COMMITTEE") && identity.equals("主任")) {
|
||||
Sys_role sysRole = sysRoleService.getByCode(RoleConstant.PROPOSAL_COMMITTEE_DIRECTOR);
|
||||
int existsRole = dao().count(Sys_user_role.class, Cnd.where(Sys_user_role::getUserId, "=", userId)
|
||||
|
||||
Reference in New Issue
Block a user