commit
This commit is contained in:
+2
@@ -13,4 +13,6 @@ public interface UserPatUpService extends ViService<UserPartUp> {
|
||||
void largeDataInsert(List<UserPartUp> list);
|
||||
|
||||
void renewUserState();
|
||||
|
||||
void deleteNotInSourceUser();
|
||||
}
|
||||
|
||||
+39
@@ -3,12 +3,18 @@ package io.v.nutz.web.commons.controller.userpartupdate.service.impl;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import io.v.nutz.base.service.impl.ViServiceImpl;
|
||||
import io.v.nutz.base.utils.DateUtil;
|
||||
import io.v.nutz.base.utils.Roles;
|
||||
import io.v.nutz.sys.models.Sys_user;
|
||||
import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.web.commons.controller.userpartupdate.models.UserPartUp;
|
||||
import io.v.nutz.web.commons.controller.userpartupdate.service.UserPatUpService;
|
||||
import io.v.nutz.sys.models.Sys_dict;
|
||||
import io.v.nutz.sys.services.SysDictService;
|
||||
import io.v.nutz.zhgh.data.model.UserSource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.impl.NutTxDao;
|
||||
@@ -17,6 +23,7 @@ import org.nutz.ioc.aop.Aop;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.lang.Lang;
|
||||
import org.nutz.lang.util.NutMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -143,4 +150,36 @@ public class UserPartUpServiceImpl extends ViServiceImpl<UserPartUp> implements
|
||||
|
||||
sysDictService.clearCache();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Aop(TransAop.READ_COMMITTED)
|
||||
public void deleteNotInSourceUser() {
|
||||
Sql maxPullTimeSql = Sqls.create("select pullTime from user_source GROUP BY pullTime ORDER BY pullTime desc LIMIT 1");
|
||||
maxPullTimeSql.setCallback(Sqls.callback.map());
|
||||
dao().execute(maxPullTimeSql);
|
||||
NutMap map = (NutMap) maxPullTimeSql.getResult();
|
||||
|
||||
// 修改不在人事库的人员状态
|
||||
Sql querySql = Sqls.create("select id,loginname from sys_user where loginname not in (select loginname from user_source where pullTime = @pullTime) and loginname != 'superadmin'")
|
||||
.setParam("pullTime", map.getString("pullTime"));
|
||||
querySql.setCallback(Sqls.callback.maps());
|
||||
dao().execute(querySql);
|
||||
List<NutMap> list = (List<NutMap>) querySql.getResult();
|
||||
|
||||
if (Lang.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> userIdList = list.stream().map(v -> v.getString("id")).toList();
|
||||
List<String> userLoginNameList = list.stream().map(v -> v.getString("loginname")).toList();
|
||||
|
||||
// 修改不在人事库人员的状态
|
||||
dao().update(Sys_user.class, Chain.make("userState", "非人事库人员").add("personType", "非人事库人员")
|
||||
.add("member", 0).add("welfareMember", 0),
|
||||
Cnd.where("loginname", "in", userLoginNameList));
|
||||
|
||||
// 去除不在人事库的人员角色,只保留公共角色
|
||||
dao().clear(Sys_user_role.class, Cnd.where("userId", "in", userIdList).and("roleId", "!=", Roles.PUBLIC));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package io.v.nutz.web.commons.ext.beetl;
|
||||
|
||||
import org.beetl.core.Resource;
|
||||
import org.beetl.core.misc.BeetlUtil;
|
||||
import org.beetl.core.resource.ClasspathResource;
|
||||
import org.beetl.core.resource.ClasspathResourceLoader;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class BeetlCustomResourceLoader extends ClasspathResourceLoader {
|
||||
|
||||
public Resource getResource(String key) {
|
||||
Resource resource = new ClasspathResource(key, this.getChildPath(super.getRoot(), key), this);
|
||||
return resource;
|
||||
}
|
||||
|
||||
public String getResourceId(Resource resource, String id) {
|
||||
// return resource == null ? id : BeetlUtil.getRelPath(resource.getId(), id);
|
||||
return getRelPath(resource.getId(), id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 增加判断相对路径
|
||||
* 光见鬼
|
||||
*/
|
||||
private String getRelPath(String siblings, String resourceId) {
|
||||
// 参数校验
|
||||
if (resourceId == null || resourceId.isEmpty()) {
|
||||
throw new RuntimeException("资源ID为空,参数错");
|
||||
}
|
||||
|
||||
// 如果是绝对路径,直接返回(以 / 或 \ 开头)
|
||||
if (resourceId.charAt(0) == '\\' || resourceId.charAt(0) == '/') {
|
||||
if (BeetlUtil.isOutsideOfRoot(resourceId)) {
|
||||
throw new RuntimeException("不能访问外部文件或者模板");
|
||||
}
|
||||
return resourceId;
|
||||
}
|
||||
|
||||
// 处理相对路径
|
||||
String baseDir = siblings;
|
||||
// 如果siblings是文件路径,获取其所在目录
|
||||
int lastSeparatorIndex = Math.max(siblings.lastIndexOf('/'), siblings.lastIndexOf('\\'));
|
||||
if (lastSeparatorIndex > 0) {
|
||||
baseDir = siblings.substring(0, lastSeparatorIndex + 1);
|
||||
}
|
||||
|
||||
// 分割路径
|
||||
String[] parts = resourceId.replace('\\', '/').split("/");
|
||||
List<String> baseParts = new ArrayList<>(
|
||||
Arrays.asList(baseDir.replace('\\', '/').split("/"))
|
||||
);
|
||||
baseParts.removeIf(String::isEmpty);
|
||||
|
||||
// 处理 ../ 和 ./
|
||||
for (String part : parts) {
|
||||
if ("..".equals(part)) {
|
||||
if (!baseParts.isEmpty()) {
|
||||
baseParts.remove(baseParts.size() - 1);
|
||||
}
|
||||
} else if (!".".equals(part) && !part.isEmpty()) {
|
||||
baseParts.add(part);
|
||||
}
|
||||
}
|
||||
|
||||
// 组合最终路径
|
||||
String result = "/" + String.join("/", baseParts);
|
||||
|
||||
// 检查是否访问外部文件
|
||||
if (BeetlUtil.isOutsideOfRoot(result)) {
|
||||
throw new RuntimeException("不能访问外部文件或者模板");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user