commit
This commit is contained in:
@@ -9,6 +9,8 @@ import cn.hutool.http.HtmlUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.event.role.RoleEventMsg;
|
||||
import com.budwk.app.base.event.role.RoleEventPublisher;
|
||||
import com.budwk.app.base.event.user.UserChangeMsg;
|
||||
import com.budwk.app.base.event.user.UserChangePublisher;
|
||||
import com.budwk.app.base.utils.PwdUtil;
|
||||
import com.budwk.app.sys.annotation.DataCenterColumn;
|
||||
import com.budwk.app.sys.models.*;
|
||||
@@ -60,6 +62,9 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
@Inject
|
||||
private ThreadPoolTaskExecutor executorService;
|
||||
|
||||
|
||||
private static Map<String, String> unitIdNameMap;
|
||||
|
||||
/**
|
||||
* 字段映射类,用于缓存反射结果
|
||||
*/
|
||||
@@ -150,6 +155,10 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
Sys_role publicRole = sysRoleService.getByCode(RoleConstant.PUBLIC);
|
||||
Sys_role memberRole = sysRoleService.getByCode(RoleConstant.MEMBER);
|
||||
|
||||
// 获取单位信息,后续判断单位变更
|
||||
List<Sys_unit> unitList = dao.query(Sys_unit.class, Cnd.where("unitTypeCode", "=", "1"));
|
||||
unitIdNameMap = unitList.stream().collect(Collectors.toMap(Sys_unit::getId, Sys_unit::getName));
|
||||
|
||||
// 查询数据源
|
||||
Cnd cnd = Cnd.where(Sys_user_source::getPullTime, "=", updateParam.getPullTime());
|
||||
|
||||
@@ -443,9 +452,13 @@ public class SysDataUserAllUpdateServiceImpl implements SysDataUserUpdateService
|
||||
NutMap change = NutMap.NEW();
|
||||
change.put("fieldName", "单位");
|
||||
change.put("field", "unitId");
|
||||
change.put("sourceValue", user.getUnitId());
|
||||
change.put("newValue", source.getUnitId());
|
||||
change.put("sourceValue", unitIdNameMap.get(user.getUnitId()));
|
||||
change.put("newValue", unitIdNameMap.get(user.getUnitId()));
|
||||
changeList.add(change);
|
||||
|
||||
// 单位异动发送订阅消息,清空原单位的所有角色
|
||||
UserChangePublisher.broadcast(new UserChangeMsg(List.of(user.getId()),
|
||||
UserChangeMsg.UNIT_CHANGE_OPERATION, user.getUnitId(), source.getUnitId()));
|
||||
}
|
||||
|
||||
// 如果没有任何变更,返回null
|
||||
|
||||
@@ -6,12 +6,15 @@ import cn.hutool.core.thread.AsyncUtil;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.budwk.app.base.constant.RoleConstant;
|
||||
import com.budwk.app.base.event.role.RoleEventMsg;
|
||||
import com.budwk.app.base.event.role.RoleEventPublisher;
|
||||
import com.budwk.app.base.utils.ConditionGroupUtil;
|
||||
import com.budwk.app.base.utils.PwdUtil;
|
||||
import com.budwk.app.sys.models.*;
|
||||
import com.budwk.app.sys.param.SysDataUserUpdateParam;
|
||||
import com.budwk.app.sys.services.SysDataUserUpdateService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.zhgh.democratic.proposal.models.ProposalConfig;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
@@ -143,6 +146,12 @@ public class SysDataUserIncrUpdateServiceImpl implements SysDataUserUpdateServic
|
||||
// 计算设置为会员的人数
|
||||
long memberCount = sysUsers.stream().filter(Sys_user::getMember).count();
|
||||
|
||||
// 6.1 更新提案的校领导角色,发送订阅
|
||||
ProposalConfig config = dao.fetch(ProposalConfig.class, Cnd.where("delFlag", "=", false).desc("updatedAt"));
|
||||
for (String unitId : config.getSchoolLeaderUnitIds()) {
|
||||
RoleEventPublisher.broadcast(new RoleEventMsg(unitId, RoleConstant.PROPOSAL_BRANCH_SCHOOL_LEADER.name(), RoleEventMsg.RENEW_ROLE));
|
||||
}
|
||||
|
||||
return StrUtil.format("增量更新成功,本次更新新入职老师{}人,新增单位{}个,设置为会员{}人。", sysUsers.size(), insertUnits.size(), memberCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ public class SysUnionGroupServiceImpl extends BaseServiceImpl<Sys_union_group> i
|
||||
throw new BaseException("小组编码已存在");
|
||||
}
|
||||
dao().insert(group);
|
||||
grantRole(group.getId(), group.getLeader());
|
||||
grantRole(group.getId(), group.getLeaders());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -59,7 +59,7 @@ public class SysUnionGroupServiceImpl extends BaseServiceImpl<Sys_union_group> i
|
||||
throw new BaseException("小组编码已存在");
|
||||
}
|
||||
dao().updateIgnoreNull(group);
|
||||
grantRole(group.getId(), group.getLeader());
|
||||
grantRole(group.getId(), group.getLeaders());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,20 +88,46 @@ public class SysUnionGroupServiceImpl extends BaseServiceImpl<Sys_union_group> i
|
||||
public Pagination pageData(PageForm pageForm, String unionId) {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.username AS leaderUserName,
|
||||
t2.mobile AS leaderMobile
|
||||
t1.id,
|
||||
t1.`code`,
|
||||
t1.unionId,
|
||||
t1.`name`,
|
||||
t1.leaders,
|
||||
t1.unitIds,
|
||||
u_agg.unitInfos,
|
||||
l_agg.leaderInfos
|
||||
FROM
|
||||
sys_union_group t1
|
||||
LEFT JOIN sys_user t2 ON t2.id = t1.leader
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tg.id,
|
||||
GROUP_CONCAT(u.NAME ORDER BY u.id) AS unitInfos
|
||||
FROM
|
||||
sys_union_group tg
|
||||
JOIN JSON_TABLE (tg.unitIds, '$[*]' COLUMNS (unitId VARCHAR (50) PATH '$')) ju
|
||||
JOIN sys_unit u ON u.id = ju.unitId
|
||||
GROUP BY
|
||||
tg.id
|
||||
) u_agg ON u_agg.id = t1.id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
tg.id,
|
||||
GROUP_CONCAT(CONCAT(u1.username, '(', u1.loginname, ')') ORDER BY u1.username) AS leaderInfos
|
||||
FROM
|
||||
sys_union_group tg
|
||||
JOIN JSON_TABLE (tg.leaders, '$[*]' COLUMNS (userId VARCHAR (50) PATH '$')) jl
|
||||
JOIN sys_user u1 ON u1.id = jl.userId
|
||||
GROUP BY
|
||||
tg.id
|
||||
) l_agg ON l_agg.id = t1.id
|
||||
$condition
|
||||
""");
|
||||
Cnd cnd = Cnd.NEW();
|
||||
cnd.and("t1.unionId", "=", unionId);
|
||||
if (StrUtil.isNotBlank(pageForm.getSearchKeyword())) {
|
||||
cnd.where().andLike("t1.name", pageForm.getSearchKeyword());
|
||||
cnd.where().andLike("t1.`name`", pageForm.getSearchKeyword());
|
||||
}
|
||||
cnd.asc("t1.code");
|
||||
cnd.asc("t1.`code`");
|
||||
sql.setCondition(cnd);
|
||||
Pagination pagination = listPageMap(pageForm.getPageNumber(), pageForm.getPageSize(), sql);
|
||||
return pagination;
|
||||
@@ -124,16 +150,19 @@ public class SysUnionGroupServiceImpl extends BaseServiceImpl<Sys_union_group> i
|
||||
* @param groupId 小组id
|
||||
* @param groupLeader 组长id
|
||||
*/
|
||||
private void grantRole(String groupId, String groupLeader) {
|
||||
private void grantRole(String groupId, List<String> groupLeader) {
|
||||
// 小组长权限
|
||||
Sys_role unionGroupRole = sysRoleService.getByCode(RoleConstant.BRANCH_UNION_GROUP_LEADER.name());
|
||||
deleteUserRole(groupId, unionGroupRole.getId());
|
||||
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
userRole.setRoleId(unionGroupRole.getId());
|
||||
userRole.setUnionGroupId(groupId);
|
||||
userRole.setUserId(groupLeader);
|
||||
dao().insert(userRole);
|
||||
List<Sys_user_role> roleList = groupLeader.stream().map(v -> {
|
||||
Sys_user_role userRole = new Sys_user_role();
|
||||
userRole.setRoleId(unionGroupRole.getId());
|
||||
userRole.setUnionGroupId(groupId);
|
||||
userRole.setUserId(v);
|
||||
return userRole;
|
||||
}).toList();
|
||||
dao().insert(roleList);
|
||||
|
||||
sysUserService.clearCache();
|
||||
sysRoleService.clearCache();
|
||||
|
||||
@@ -18,6 +18,7 @@ import com.budwk.app.sys.models.*;
|
||||
import com.budwk.app.sys.services.SysMenuService;
|
||||
import com.budwk.app.sys.services.SysRoleService;
|
||||
import com.budwk.app.sys.services.SysUserService;
|
||||
import com.budwk.app.sys.views.View_user;
|
||||
import com.budwk.app.web.commons.base.Globals;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
@@ -388,7 +389,17 @@ public class SysUserServiceImpl extends BaseServiceImpl<Sys_user> implements Sys
|
||||
|
||||
StpUtil.login(user.getId());
|
||||
StpUtil.checkLogin();
|
||||
StpUtil.getSession(true).set("loginname", Strings.sNull(user.getLoginname())).set("username", Strings.sNull(user.getUsername())).set("unitId", Strings.sNull(user.getUnitId())).set("unitPath", Strings.sNull(user.getUnitPath())).set("unionId", ObjectUtil.isEmpty(user.getUnion()) ? "" : user.getUnion().getId());
|
||||
// 查询一下视图,存储一些sys_user表中没有的字段
|
||||
View_user viewUser = dao().fetch(View_user.class, Cnd.where("id", "=", user.getId()));
|
||||
StpUtil.getSession(true)
|
||||
.set("loginname", Strings.sNull(user.getLoginname()))
|
||||
.set("username", Strings.sNull(user.getUsername()))
|
||||
.set("unitId", Strings.sNull(user.getUnitId()))
|
||||
.set("unitPath", Strings.sNull(user.getUnitPath()))
|
||||
.set("unionId", ObjectUtil.isEmpty(user.getUnion()) ? "" : user.getUnion().getId())
|
||||
.set("unionGroupId", Strings.sNull(viewUser.getUnionGroupId()))
|
||||
.set("clubIds", Strings.sNull(viewUser.getClubIds()));
|
||||
|
||||
Sys_log sysLog = new Sys_log();
|
||||
sysLog.setType("info");
|
||||
sysLog.setTag("用户登陆");
|
||||
|
||||
Reference in New Issue
Block a user