mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-26 16:26:41 +08:00
JeecgBoot3.5.0 版本发布,开源的企业级低代码平台
This commit is contained in:
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>jeecg-system-api</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>3.4.4</version>
|
||||
<version>3.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -434,13 +434,13 @@ public interface ISysBaseAPI extends CommonAPI {
|
||||
@RequestMapping("/sys/api/queryDepartsByOrgcodes")
|
||||
List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes);
|
||||
|
||||
/**
|
||||
* 39根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sys/api/queryDepartsByOrgIds")
|
||||
List<JSONObject> queryDepartsByOrgIds(@RequestParam("ids") String ids);
|
||||
// /**
|
||||
// * 39根据多个部门编码(逗号分隔),查询返回多个部门信息
|
||||
// * @param ids
|
||||
// * @return
|
||||
// */
|
||||
// @GetMapping("/sys/api/queryDepartsByOrgIds")
|
||||
// List<JSONObject> queryDepartsByOrgIds(@RequestParam("ids") String ids);
|
||||
|
||||
/**
|
||||
* 40发送邮件消息
|
||||
|
||||
@ -303,10 +303,10 @@ public class SysBaseAPIFallback implements ISysBaseAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryDepartsByOrgIds(String ids) {
|
||||
return null;
|
||||
}
|
||||
// @Override
|
||||
// public List<JSONObject> queryDepartsByOrgIds(String ids) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<String> loadCategoryDictItem(String ids) {
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>jeecg-system-api</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>3.4.4</version>
|
||||
<version>3.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>jeecg-module-system</artifactId>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<version>3.4.4</version>
|
||||
<version>3.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-module-system</artifactId>
|
||||
<version>3.4.4</version>
|
||||
<version>3.5.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package org.jeecg.modules.aop;
|
||||
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.enums.ModuleType;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* 系统日志注解
|
||||
*
|
||||
* @Author scott
|
||||
* @email jeecgos@163.com
|
||||
* @Date 2019年1月14日
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
public @interface TenantLog {
|
||||
|
||||
/**
|
||||
* 操作日志类型(1查询,2添加,3修改,4删除)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
int value() default 0;
|
||||
|
||||
}
|
||||
@ -0,0 +1,99 @@
|
||||
package org.jeecg.modules.aop;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.AfterThrowing;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.jeecg.common.api.dto.LogDTO;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.system.entity.SysTenantPack;
|
||||
import org.jeecg.modules.system.entity.SysTenantPackUser;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Author taoYan
|
||||
* @Date 2023/2/16 14:27
|
||||
**/
|
||||
@Aspect
|
||||
@Component
|
||||
public class TenantPackUserLogAspect {
|
||||
|
||||
@Resource
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@Pointcut("@annotation(org.jeecg.modules.aop.TenantLog)")
|
||||
public void tenantLogPointCut() {
|
||||
|
||||
}
|
||||
|
||||
@Around("tenantLogPointCut()")
|
||||
public Object aroundMethod(ProceedingJoinPoint joinPoint)throws Throwable {
|
||||
//System.out.println("环绕通知>>>>>>>>>");
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
TenantLog log = method.getAnnotation(TenantLog.class);
|
||||
if(log != null){
|
||||
int opType = log.value();
|
||||
Integer logType = null;
|
||||
String content = null;
|
||||
Integer tenantId = null;
|
||||
//获取参数
|
||||
Object[] args = joinPoint.getArgs();
|
||||
if(args.length>0){
|
||||
for(Object obj: args){
|
||||
if(obj instanceof SysTenantPack){
|
||||
// logType=3 租户操作日志
|
||||
logType = 3;
|
||||
SysTenantPack pack = (SysTenantPack)obj;
|
||||
if(opType==2){
|
||||
content = "创建了角色权限 "+ pack.getPackName();
|
||||
}
|
||||
tenantId = pack.getTenantId();
|
||||
break;
|
||||
}else if(obj instanceof SysTenantPackUser){
|
||||
logType = 3;
|
||||
SysTenantPackUser packUser = (SysTenantPackUser)obj;
|
||||
if(opType==2){
|
||||
content = "将 "+packUser.getRealname()+" 添加到角色 "+ packUser.getPackName();
|
||||
}else if(opType==4){
|
||||
content = "移除了 "+packUser.getPackName()+" 成员 "+ packUser.getRealname();
|
||||
}
|
||||
tenantId = packUser.getTenantId();
|
||||
}
|
||||
}
|
||||
}
|
||||
if(logType!=null){
|
||||
LogDTO dto = new LogDTO();
|
||||
dto.setLogType(logType);
|
||||
dto.setLogContent(content);
|
||||
dto.setOperateType(opType);
|
||||
dto.setTenantId(tenantId);
|
||||
//获取登录用户信息
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if(sysUser!=null){
|
||||
dto.setUserid(sysUser.getUsername());
|
||||
dto.setUsername(sysUser.getRealname());
|
||||
|
||||
}
|
||||
dto.setCreateTime(new Date());
|
||||
//保存系统日志
|
||||
baseCommonService.addLog(dto);
|
||||
}
|
||||
}
|
||||
return joinPoint.proceed();
|
||||
}
|
||||
|
||||
@AfterThrowing("tenantLogPointCut()")
|
||||
public void afterThrowing()throws Throwable{
|
||||
System.out.println("异常通知");
|
||||
}
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class CasClientController {
|
||||
if (departs == null || departs.size() == 0) {
|
||||
obj.put("multi_depart", 0);
|
||||
} else if (departs.size() == 1) {
|
||||
sysUserService.updateUserDepart(principal, departs.get(0).getOrgCode());
|
||||
sysUserService.updateUserDepart(principal, departs.get(0).getOrgCode(),null);
|
||||
obj.put("multi_depart", 1);
|
||||
} else {
|
||||
obj.put("multi_depart", 2);
|
||||
|
||||
@ -2,6 +2,7 @@ package org.jeecg.modules.message.handle.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.jeecg.common.api.dto.message.MessageDTO;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
@ -42,6 +43,11 @@ public class EmailSendMsgHandle implements ISendMsgHandle {
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
/**
|
||||
* 真实姓名变量
|
||||
*/
|
||||
private static final String realNameExp = "{REALNAME}";
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@ -76,26 +82,81 @@ public class EmailSendMsgHandle implements ISendMsgHandle {
|
||||
List<SysUser> list = sysUserMapper.selectList(query);
|
||||
String content = messageDTO.getContent();
|
||||
String title = messageDTO.getTitle();
|
||||
String realNameExp = "{REALNAME}";
|
||||
for(SysUser user: list){
|
||||
String email = user.getEmail();
|
||||
if(email==null || "".equals(email)){
|
||||
if (ObjectUtils.isEmpty(email)) {
|
||||
continue;
|
||||
}
|
||||
if(content.indexOf(realNameExp)>0){
|
||||
content = content.replace(realNameExp, user.getRealname());
|
||||
}
|
||||
if(content.indexOf(CommonConstant.LOGIN_TOKEN)>0){
|
||||
String token = getToken(user);
|
||||
try {
|
||||
content = content.replace(CommonConstant.LOGIN_TOKEN, URLEncoder.encode(token, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("邮件消息token编码失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
content=replaceContent(user,content);
|
||||
log.info("邮件内容:"+ content);
|
||||
sendMsg(email, title, content);
|
||||
}
|
||||
//发送给抄送人
|
||||
sendMessageToCopyUser(messageDTO);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送邮件给抄送人
|
||||
* @param messageDTO
|
||||
*/
|
||||
public void sendMessageToCopyUser(MessageDTO messageDTO) {
|
||||
String copyToUser = messageDTO.getCopyToUser();
|
||||
if(ObjectUtils.isNotEmpty(copyToUser)) {
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>().in(SysUser::getUsername, copyToUser.split(","));
|
||||
List<SysUser> list = sysUserMapper.selectList(query);
|
||||
String content = messageDTO.getContent();
|
||||
String title = messageDTO.getTitle();
|
||||
|
||||
for (SysUser user : list) {
|
||||
String email = user.getEmail();
|
||||
if (ObjectUtils.isEmpty(email)) {
|
||||
continue;
|
||||
}
|
||||
content=replaceContent(user,content);
|
||||
log.info("邮件内容:" + content);
|
||||
JavaMailSender mailSender = (JavaMailSender) SpringContextUtils.getBean("mailSender");
|
||||
MimeMessage message = mailSender.createMimeMessage();
|
||||
MimeMessageHelper helper = null;
|
||||
if (oConvertUtils.isEmpty(emailFrom)) {
|
||||
StaticConfig staticConfig = SpringContextUtils.getBean(StaticConfig.class);
|
||||
setEmailFrom(staticConfig.getEmailFrom());
|
||||
}
|
||||
try {
|
||||
helper = new MimeMessageHelper(message, true);
|
||||
// 设置发送方邮箱地址
|
||||
helper.setFrom(emailFrom);
|
||||
helper.setTo(email);
|
||||
//设置抄送人
|
||||
helper.setCc(email);
|
||||
helper.setSubject(title);
|
||||
helper.setText(content, true);
|
||||
mailSender.send(message);
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 替换邮件内容变量
|
||||
* @param user
|
||||
* @param content
|
||||
* @return
|
||||
*/
|
||||
private String replaceContent(SysUser user,String content){
|
||||
if (content.indexOf(realNameExp) > 0) {
|
||||
content = content.replace("$"+realNameExp,user.getRealname()).replace(realNameExp, user.getRealname());
|
||||
}
|
||||
if (content.indexOf(CommonConstant.LOGIN_TOKEN) > 0) {
|
||||
String token = getToken(user);
|
||||
try {
|
||||
content = content.replace(CommonConstant.LOGIN_TOKEN, URLEncoder.encode(token, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
log.error("邮件消息token编码失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,6 @@ package org.jeecg.modules.message.websocket;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import javax.annotation.Resource;
|
||||
import javax.websocket.*;
|
||||
import javax.websocket.server.PathParam;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
@ -11,6 +10,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.base.BaseMap;
|
||||
import org.jeecg.common.constant.WebsocketConst;
|
||||
import org.jeecg.common.modules.redis.client.JeecgRedisClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@ -31,7 +31,7 @@ public class WebSocket {
|
||||
* Redis触发监听名字
|
||||
*/
|
||||
public static final String REDIS_TOPIC_NAME = "socketHandler";
|
||||
@Resource
|
||||
@Autowired
|
||||
private JeecgRedisClient jeecgRedisClient;
|
||||
|
||||
|
||||
@ -111,14 +111,14 @@ public class WebSocket {
|
||||
log.debug("【系统 WebSocket】收到客户端消息:" + message);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
JSONObject obj = new JSONObject();
|
||||
//业务类型
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_CHECK);
|
||||
//消息内容
|
||||
obj.put(WebsocketConst.MSG_TXT, "心跳响应");
|
||||
this.pushMessage(userId, obj.toJSONString());
|
||||
//------------------------------------------------------------------------------
|
||||
// //------------------------------------------------------------------------------
|
||||
// JSONObject obj = new JSONObject();
|
||||
// //业务类型
|
||||
// obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_CHECK);
|
||||
// //消息内容
|
||||
// obj.put(WebsocketConst.MSG_TXT, "心跳响应");
|
||||
// this.pushMessage(userId, obj.toJSONString());
|
||||
// //------------------------------------------------------------------------------
|
||||
}
|
||||
|
||||
/**
|
||||
@ -130,7 +130,7 @@ public class WebSocket {
|
||||
@OnError
|
||||
public void onError(Session session, Throwable t) {
|
||||
log.warn("【系统 WebSocket】消息出现错误");
|
||||
//t.printStackTrace();
|
||||
t.printStackTrace();
|
||||
}
|
||||
//==========【系统 WebSocket接受、推送消息等方法 —— 具体服务节点推送ws消息】========================================================================================
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ public class ActuatorRedisController {
|
||||
@GetMapping("/info")
|
||||
public Result<?> getRedisInfo() throws Exception {
|
||||
List<RedisInfo> infoList = this.redisService.getRedisInfo();
|
||||
log.info(infoList.toString());
|
||||
//log.info(infoList.toString());
|
||||
return Result.ok(infoList);
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ package org.jeecg.modules.oss.controller;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
@ -46,7 +47,8 @@ public class OssFileController {
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/upload")
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:ossFile:upload")
|
||||
public Result upload(@RequestParam("file") MultipartFile multipartFile) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
|
||||
@ -1,7 +1,9 @@
|
||||
package org.jeecg.modules.oss.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.CommonUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.oss.OssBootUtil;
|
||||
import org.jeecg.modules.oss.entity.OssFile;
|
||||
import org.jeecg.modules.oss.mapper.OssFileMapper;
|
||||
@ -25,6 +27,9 @@ public class OssFileServiceImpl extends ServiceImpl<OssFileMapper, OssFile> impl
|
||||
OssFile ossFile = new OssFile();
|
||||
ossFile.setFileName(fileName);
|
||||
String url = OssBootUtil.upload(multipartFile,"upload/test");
|
||||
if(oConvertUtils.isEmpty(url)){
|
||||
throw new JeecgBootException("上传文件失败! ");
|
||||
}
|
||||
//update-begin--Author:scott Date:20201227 for:JT-361【文件预览】阿里云原生域名可以文件预览,自己映射域名kkfileview提示文件下载失败-------------------
|
||||
// 返回阿里云原生域名前缀URL
|
||||
ossFile.setUrl(OssBootUtil.getOriginalUrl(url));
|
||||
|
||||
@ -7,6 +7,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@ -78,7 +79,8 @@ public class QuartzJobController {
|
||||
* @param quartzJob
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<?> add(@RequestBody QuartzJob quartzJob) {
|
||||
quartzJobService.saveAndScheduleJob(quartzJob);
|
||||
@ -91,7 +93,8 @@ public class QuartzJobController {
|
||||
* @param quartzJob
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:edit")
|
||||
@RequestMapping(value = "/edit", method ={RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<?> eidt(@RequestBody QuartzJob quartzJob) {
|
||||
try {
|
||||
@ -109,7 +112,8 @@ public class QuartzJobController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||
@ -127,7 +131,8 @@ public class QuartzJobController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
@ -146,7 +151,8 @@ public class QuartzJobController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:pause")
|
||||
@GetMapping(value = "/pause")
|
||||
@ApiOperation(value = "停止定时任务")
|
||||
public Result<Object> pauseJob(@RequestParam(name = "id") String id) {
|
||||
@ -164,7 +170,8 @@ public class QuartzJobController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:resume")
|
||||
@GetMapping(value = "/resume")
|
||||
@ApiOperation(value = "启动定时任务")
|
||||
public Result<Object> resumeJob(@RequestParam(name = "id") String id) {
|
||||
@ -264,7 +271,8 @@ public class QuartzJobController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:quartzJob:execute")
|
||||
@GetMapping("/execute")
|
||||
public Result<?> execute(@RequestParam(name = "id", required = true) String id) {
|
||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||
|
||||
@ -1,20 +1,25 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.CommonUtils;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.filter.FileTypeFilter;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.server.ServletServerHttpRequest;
|
||||
import org.springframework.util.AntPathMatcher;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.HandlerMapping;
|
||||
@ -23,7 +28,7 @@ import org.springframework.web.servlet.ModelAndView;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
|
||||
import java.net.URLDecoder;
|
||||
/**
|
||||
* <p>
|
||||
* 用户表 前端控制器
|
||||
|
||||
@ -10,6 +10,7 @@ import org.jeecg.modules.system.mapper.SysDictMapper;
|
||||
import org.jeecg.modules.system.model.DuplicateCheckVo;
|
||||
import org.jeecg.modules.system.security.DictQueryBlackListHandler;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.ExceptionHandler;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
@ -47,7 +48,7 @@ public class DuplicateCheckController {
|
||||
public Result<String> doDuplicateCheck(DuplicateCheckVo duplicateCheckVo, HttpServletRequest request) {
|
||||
Long num = null;
|
||||
|
||||
log.info("----duplicate check------:"+ duplicateCheckVo.toString());
|
||||
log.debug("----duplicate check------:"+ duplicateCheckVo.toString());
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {duplicateCheckVo.getTableName(),duplicateCheckVo.getFieldName()};
|
||||
@ -84,4 +85,21 @@ public class DuplicateCheckController {
|
||||
return Result.error("该值不可用,系统中已存在!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* VUEN-2584【issue】平台sql注入漏洞几个问题
|
||||
* 部分特殊函数 可以将查询结果混夹在错误信息中,导致数据库的信息暴露
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
@ExceptionHandler(java.sql.SQLException.class)
|
||||
public Result<?> handleSQLException(Exception e){
|
||||
String msg = e.getMessage();
|
||||
String extractvalue = "extractvalue";
|
||||
String updatexml = "updatexml";
|
||||
if(msg!=null && (msg.toLowerCase().indexOf(extractvalue)>=0 || msg.toLowerCase().indexOf(updatexml)>=0)){
|
||||
return Result.error("校验失败,sql解析异常!");
|
||||
}
|
||||
return Result.error("校验失败,sql解析异常!" + msg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@ -76,6 +77,11 @@ public class LoginController {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String username = sysLoginModel.getUsername();
|
||||
String password = sysLoginModel.getPassword();
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
if(isLoginFailOvertimes(username)){
|
||||
return result.error500("该用户登录失败次数过多,请于10分钟后再次登录!");
|
||||
}
|
||||
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
//update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
|
||||
//前端密码加密,后端进行密码解密
|
||||
//password = AesEncryptUtil.desEncrypt(sysLoginModel.getPassword().replaceAll("%2B", "\\+")).trim();//密码解密
|
||||
@ -119,6 +125,9 @@ public class LoginController {
|
||||
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
|
||||
String syspassword = sysUser.getPassword();
|
||||
if (!syspassword.equals(userpassword)) {
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
addLoginFailOvertimes(username);
|
||||
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
result.error500("用户名或密码错误");
|
||||
return result;
|
||||
}
|
||||
@ -128,6 +137,7 @@ public class LoginController {
|
||||
//update-begin--Author:liusq Date:20210126 for:登录成功,删除redis中的验证码
|
||||
redisUtil.del(realKey);
|
||||
//update-begin--Author:liusq Date:20210126 for:登录成功,删除redis中的验证码
|
||||
redisUtil.del(CommonConstant.LOGIN_FAIL + username);
|
||||
LoginUser loginUser = new LoginUser();
|
||||
BeanUtils.copyProperties(sysUser, loginUser);
|
||||
baseCommonService.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null,loginUser);
|
||||
@ -271,8 +281,12 @@ public class LoginController {
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
username = sysUser.getUsername();
|
||||
}
|
||||
|
||||
//获取登录部门
|
||||
String orgCode= user.getOrgCode();
|
||||
this.sysUserService.updateUserDepart(username, orgCode);
|
||||
//获取登录租户
|
||||
Integer tenantId = user.getLoginTenantId();
|
||||
this.sysUserService.updateUserDepart(username, orgCode,tenantId);
|
||||
SysUser sysUser = sysUserService.getUserByName(username);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("userInfo", sysUser);
|
||||
@ -386,7 +400,11 @@ public class LoginController {
|
||||
public Result<JSONObject> phoneLogin(@RequestBody JSONObject jsonObject) {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String phone = jsonObject.getString("mobile");
|
||||
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
if(isLoginFailOvertimes(phone)){
|
||||
return result.error500("该用户登录失败次数过多,请于10分钟后再次登录!");
|
||||
}
|
||||
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
//校验用户有效性
|
||||
SysUser sysUser = sysUserService.getUserByPhone(phone);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
@ -402,6 +420,9 @@ public class LoginController {
|
||||
//update-end-author:taoyan date:2022-9-13 for: VUEN-2245 【漏洞】发现新漏洞待处理20220906
|
||||
|
||||
if (!smscode.equals(code)) {
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
addLoginFailOvertimes(phone);
|
||||
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
result.setMessage("手机验证码错误");
|
||||
return result;
|
||||
}
|
||||
@ -427,46 +448,36 @@ public class LoginController {
|
||||
// 获取用户部门信息
|
||||
JSONObject obj = new JSONObject(new LinkedHashMap<>());
|
||||
|
||||
// 生成token
|
||||
//1.生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
// 设置token缓存有效时间
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
|
||||
obj.put("token", token);
|
||||
|
||||
// update-begin--Author:sunjianlei Date:20210802 for:获取用户租户信息
|
||||
String tenantIds = sysUser.getRelTenantIds();
|
||||
if (oConvertUtils.isNotEmpty(tenantIds)) {
|
||||
List<Integer> tenantIdList = new ArrayList<>();
|
||||
for(String id: tenantIds.split(SymbolConstant.COMMA)){
|
||||
tenantIdList.add(Integer.valueOf(id));
|
||||
}
|
||||
// 该方法仅查询有效的租户,如果返回0个就说明所有的租户均无效。
|
||||
List<SysTenant> tenantList = sysTenantService.queryEffectiveTenant(tenantIdList);
|
||||
if (tenantList.size() == 0) {
|
||||
result.error500("与该用户关联的租户均已被冻结,无法登录!");
|
||||
return result;
|
||||
} else {
|
||||
obj.put("tenantList", tenantList);
|
||||
}
|
||||
//2.设置登录租户
|
||||
Result<JSONObject> loginTenantError = sysUserService.setLoginTenant(sysUser, obj, username,result);
|
||||
if (loginTenantError != null) {
|
||||
return loginTenantError;
|
||||
}
|
||||
// update-end--Author:sunjianlei Date:20210802 for:获取用户租户信息
|
||||
|
||||
//3.设置登录用户信息
|
||||
obj.put("userInfo", sysUser);
|
||||
|
||||
|
||||
//4.设置登录部门
|
||||
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
|
||||
obj.put("departs", departs);
|
||||
if (departs == null || departs.size() == 0) {
|
||||
obj.put("multi_depart", 0);
|
||||
} else if (departs.size() == 1) {
|
||||
sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
|
||||
sysUserService.updateUserDepart(username, departs.get(0).getOrgCode(),null);
|
||||
obj.put("multi_depart", 1);
|
||||
} else {
|
||||
//查询当前是否有登录部门
|
||||
// update-begin--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去
|
||||
SysUser sysUserById = sysUserService.getById(sysUser.getId());
|
||||
if(oConvertUtils.isEmpty(sysUserById.getOrgCode())){
|
||||
sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
|
||||
sysUserService.updateUserDepart(username, departs.get(0).getOrgCode(),null);
|
||||
}
|
||||
// update-end--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去
|
||||
obj.put("multi_depart", 2);
|
||||
@ -529,6 +540,7 @@ public class LoginController {
|
||||
/**
|
||||
* 切换菜单表为vue3的表
|
||||
*/
|
||||
@RequiresRoles({"admin"})
|
||||
@GetMapping(value = "/switchVue3Menu")
|
||||
public Result<String> switchVue3Menu(HttpServletResponse response) {
|
||||
Result<String> res = new Result<String>();
|
||||
@ -547,7 +559,13 @@ public class LoginController {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String username = sysLoginModel.getUsername();
|
||||
String password = sysLoginModel.getPassword();
|
||||
JSONObject obj = new JSONObject();
|
||||
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
if(isLoginFailOvertimes(username)){
|
||||
return result.error500("该用户登录失败次数过多,请于10分钟后再次登录!");
|
||||
}
|
||||
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
//1. 校验用户是否有效
|
||||
SysUser sysUser = sysUserService.getUserByName(username);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
@ -559,10 +577,14 @@ public class LoginController {
|
||||
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
|
||||
String syspassword = sysUser.getPassword();
|
||||
if (!syspassword.equals(userpassword)) {
|
||||
//update-begin-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
addLoginFailOvertimes(username);
|
||||
//update-end-author:taoyan date:2022-11-7 for: issues/4109 平台用户登录失败锁定用户
|
||||
result.error500("用户名或密码错误");
|
||||
return result;
|
||||
}
|
||||
|
||||
//3.设置登录部门
|
||||
String orgCode = sysUser.getOrgCode();
|
||||
if(oConvertUtils.isEmpty(orgCode)) {
|
||||
//如果当前用户无选择部门 查看部门关联信息
|
||||
@ -574,15 +596,21 @@ public class LoginController {
|
||||
}else{
|
||||
orgCode = departs.get(0).getOrgCode();
|
||||
sysUser.setOrgCode(orgCode);
|
||||
this.sysUserService.updateUserDepart(username, orgCode);
|
||||
this.sysUserService.updateUserDepart(username, orgCode,null);
|
||||
}
|
||||
//update-end-author:taoyan date:20220117 for: JTC-1068【app】新建用户,没有设置部门及角色,点击登录提示暂未归属部,一直在登录页面 使用手机号登录 可正常
|
||||
}
|
||||
JSONObject obj = new JSONObject();
|
||||
//用户登录信息
|
||||
|
||||
//4. 设置登录租户
|
||||
Result<JSONObject> loginTenantError = sysUserService.setLoginTenant(sysUser, obj, username, result);
|
||||
if (loginTenantError != null) {
|
||||
return loginTenantError;
|
||||
}
|
||||
|
||||
//5. 设置登录用户信息
|
||||
obj.put("userInfo", sysUser);
|
||||
|
||||
// 生成token
|
||||
//6. 生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
// 设置超时时间
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
@ -671,4 +699,36 @@ public class LoginController {
|
||||
return Result.OK(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录失败超出次数5 返回true
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
private boolean isLoginFailOvertimes(String username){
|
||||
String key = CommonConstant.LOGIN_FAIL + username;
|
||||
Object failTime = redisUtil.get(key);
|
||||
if(failTime!=null){
|
||||
Integer val = Integer.parseInt(failTime.toString());
|
||||
if(val>5){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录登录失败次数
|
||||
* @param username
|
||||
*/
|
||||
private void addLoginFailOvertimes(String username){
|
||||
String key = CommonConstant.LOGIN_FAIL + username;
|
||||
Object failTime = redisUtil.get(key);
|
||||
Integer val = 0;
|
||||
if(failTime!=null){
|
||||
val = Integer.parseInt(failTime.toString());
|
||||
}
|
||||
// 1小时
|
||||
redisUtil.set(key, ++val, 3600);
|
||||
}
|
||||
|
||||
}
|
||||
@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.CommonSendStatus;
|
||||
import org.jeecg.common.constant.WebsocketConst;
|
||||
@ -21,6 +22,7 @@ import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.message.enums.RangeDateEnum;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
import org.jeecg.modules.system.entity.SysAnnouncement;
|
||||
@ -93,6 +95,12 @@ public class SysAnnouncementController {
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysAnnouncement.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Result<IPage<SysAnnouncement>> result = new Result<IPage<SysAnnouncement>>();
|
||||
sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
||||
QueryWrapper<SysAnnouncement> queryWrapper = QueryGenerator.initQueryWrapper(sysAnnouncement, req.getParameterMap());
|
||||
@ -547,7 +555,32 @@ public class SysAnnouncementController {
|
||||
sysAnnouncementService.updateReaded(annoceIdList);
|
||||
}
|
||||
}
|
||||
//update-begin-author:taoyan date:2022-9-25 for: VUEN-2261【移动端 系统消息】通知公告显示7条消息,点进去查看后,仍然显示7条;其他地方已读后,未读条数减少
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put(WebsocketConst.MSG_CMD, WebsocketConst.CMD_USER);
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
webSocket.sendMessage(sysUser.getId(), obj.toJSONString());
|
||||
//update-end-author:taoyan date:2022-9-25 for: VUEN-2261【移动端 系统消息】通知公告显示7条消息,点进去查看后,仍然显示7条;其他地方已读后,未读条数减少
|
||||
return Result.ok(ls);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户id获取最新一条消息发送时间(创建时间)
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getLastAnnountTime")
|
||||
public Result<Page<SysAnnouncementSend>> getLastAnnountTime(@RequestParam(name = "userId") String userId){
|
||||
Result<Page<SysAnnouncementSend>> result = new Result<>();
|
||||
Page<SysAnnouncementSend> page = new Page<>(1,1);
|
||||
LambdaQueryWrapper<SysAnnouncementSend> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysAnnouncementSend::getUserId,userId);
|
||||
query.select(SysAnnouncementSend::getCreateTime);
|
||||
query.orderByDesc(SysAnnouncementSend::getCreateTime);
|
||||
Page<SysAnnouncementSend> pageList = sysAnnouncementSendService.page(page, query);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
@ -16,6 +17,7 @@ import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.ImportExcelUtil;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.service.ISysCategoryService;
|
||||
@ -71,6 +73,12 @@ public class SysCategoryController {
|
||||
sysCategory.setPid("0");
|
||||
}
|
||||
Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
//--author:os_chengtgen---date:20190804 -----for: 分类字典页面显示错误,issues:377--------start
|
||||
//--author:liusq---date:20211119 -----for: 【vue3】分类字典页面查询条件配置--------start
|
||||
@ -93,6 +101,12 @@ public class SysCategoryController {
|
||||
|
||||
@GetMapping(value = "/childList")
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory,HttpServletRequest req) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
@ -199,6 +213,13 @@ public class SysCategoryController {
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysCategory.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
|
||||
List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
|
||||
|
||||
@ -97,7 +97,7 @@ public class SysCommentController extends JeecgController<SysComment, ISysCommen
|
||||
sysCommentService.saveOneFileComment(request);
|
||||
return Result.OK("success");
|
||||
} catch (Exception e) {
|
||||
log.error("评论文件上传失败", e.getMessage());
|
||||
log.error("评论文件上传失败:{}", e.getMessage());
|
||||
return Result.error("操作失败," + e.getMessage());
|
||||
}
|
||||
}
|
||||
@ -144,7 +144,7 @@ public class SysCommentController extends JeecgController<SysComment, ISysCommen
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
////@AutoLog(value = "系统评论回复表-分页列表查询")
|
||||
//@AutoLog(value = "系统评论回复表-分页列表查询")
|
||||
@ApiOperation(value = "系统评论回复表-分页列表查询", notes = "系统评论回复表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<SysComment>> queryPageList(SysComment sysComment,
|
||||
@ -223,7 +223,7 @@ public class SysCommentController extends JeecgController<SysComment, ISysCommen
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
////@AutoLog(value = "系统评论回复表-通过id查询")
|
||||
//@AutoLog(value = "系统评论回复表-通过id查询")
|
||||
@ApiOperation(value = "系统评论回复表-通过id查询", notes = "系统评论回复表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysComment> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
|
||||
@ -13,14 +13,18 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.dynamic.db.DataSourceCachePool;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.security.JdbcSecurityUtil;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
import org.jeecg.modules.system.service.ISysDataSourceService;
|
||||
import org.jeecg.modules.system.util.SecurityUtil;
|
||||
@ -61,14 +65,19 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-分页列表查询")
|
||||
@ApiOperation(value = "多数据源管理-分页列表查询", notes = "多数据源管理-分页列表查询")
|
||||
//@RequiresRoles("admin")
|
||||
@RequiresPermissions("system:datasource:list")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(
|
||||
SysDataSource sysDataSource,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req
|
||||
) {
|
||||
HttpServletRequest req) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDataSource.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
Page<SysDataSource> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDataSource> pageList = sysDataSourceService.page(page, queryWrapper);
|
||||
@ -77,6 +86,13 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
|
||||
|
||||
@GetMapping(value = "/options")
|
||||
public Result<?> queryOptions(SysDataSource sysDataSource, HttpServletRequest req) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDataSource.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
List<SysDataSource> pageList = sysDataSourceService.list(queryWrapper);
|
||||
JSONArray array = new JSONArray(pageList.size());
|
||||
@ -192,6 +208,12 @@ public class SysDataSourceController extends JeecgController<SysDataSource, ISys
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDataSource sysDataSource) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDataSource.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
return super.exportXls(request, sysDataSource, SysDataSource.class, "多数据源管理");
|
||||
}
|
||||
|
||||
|
||||
@ -6,8 +6,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
@ -16,6 +17,7 @@ import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.ImportExcelUtil;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
@ -148,8 +150,7 @@ public class SysDepartController {
|
||||
@GetMapping("/queryAllParentId")
|
||||
public Result queryParentIds(
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name = "orgCode", required = false) String orgCode
|
||||
) {
|
||||
@RequestParam(name = "orgCode", required = false) String orgCode) {
|
||||
try {
|
||||
JSONObject data;
|
||||
if (oConvertUtils.isNotEmpty(departId)) {
|
||||
@ -172,7 +173,7 @@ public class SysDepartController {
|
||||
* @param sysDepart
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
|
||||
@ -198,7 +199,7 @@ public class SysDepartController {
|
||||
* @param sysDepart
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) {
|
||||
@ -226,7 +227,7 @@ public class SysDepartController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) {
|
||||
@ -236,13 +237,11 @@ public class SysDepartController {
|
||||
if(sysDepart==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = sysDepartService.delete(id);
|
||||
if(ok) {
|
||||
//清除部门树内存
|
||||
//FindsDepartsChildrenUtil.clearSysDepartTreeList();
|
||||
// FindsDepartsChildrenUtil.clearDepartIdModel();
|
||||
result.success("删除成功!");
|
||||
}
|
||||
sysDepartService.deleteDepart(id);
|
||||
//清除部门树内存
|
||||
//FindsDepartsChildrenUtil.clearSysDepartTreeList();
|
||||
// FindsDepartsChildrenUtil.clearDepartIdModel();
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -254,7 +253,7 @@ public class SysDepartController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
@ -341,6 +340,13 @@ public class SysDepartController {
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDepart.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(sysDepart, request.getParameterMap());
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
@ -371,7 +377,7 @@ public class SysDepartController {
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
@ -526,4 +532,46 @@ public class SysDepartController {
|
||||
result.setResult(sysUsers);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:根据id 批量查询
|
||||
* @param deptIds
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryByIds", method = RequestMethod.GET)
|
||||
public Result<Collection<SysDepart>> queryByIds(@RequestParam String deptIds) {
|
||||
Result<Collection<SysDepart>> result = new Result<>();
|
||||
String[] ids = deptIds.split(",");
|
||||
Collection<String> idList = Arrays.asList(ids);
|
||||
Collection<SysDepart> deptList = sysDepartService.listByIds(idList);
|
||||
result.setSuccess(true);
|
||||
result.setResult(deptList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping("/getMyDepartList")
|
||||
public Result<List<SysDepart>> getMyDepartList(){
|
||||
List<SysDepart> list = sysDepartService.getMyDepartList();
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 异步查询部门list
|
||||
* @param parentId 父节点 异步加载时传递
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryBookDepTreeSync", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartTreeModel>> queryBookDepTreeSync(@RequestParam(name = "pid", required = false) String parentId,
|
||||
@RequestParam(name = "tenantId") Integer tenantId,
|
||||
@RequestParam(name = "departName",required = false) String departName) {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<>();
|
||||
try {
|
||||
List<SysDepartTreeModel> list = sysDepartService.queryBookDepTreeSync(parentId, tenantId, departName);
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@ -103,7 +104,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
|
||||
* @param sysDepartRole
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:role:add")
|
||||
@ApiOperation(value="部门角色-添加", notes="部门角色-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDepartRole sysDepartRole) {
|
||||
@ -117,8 +118,8 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
|
||||
* @param sysDepartRole
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@ApiOperation(value="部门角色-编辑", notes="部门角色-编辑")
|
||||
@RequiresPermissions("system:depart:role:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<?> edit(@RequestBody SysDepartRole sysDepartRole) {
|
||||
sysDepartRoleService.updateById(sysDepartRole);
|
||||
@ -131,9 +132,9 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@AutoLog(value = "部门角色-通过id删除")
|
||||
@ApiOperation(value="部门角色-通过id删除", notes="部门角色-通过id删除")
|
||||
@RequiresPermissions("system:depart:role:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysDepartRoleService.removeById(id);
|
||||
@ -146,9 +147,9 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@AutoLog(value = "部门角色-批量删除")
|
||||
@ApiOperation(value="部门角色-批量删除", notes="部门角色-批量删除")
|
||||
@RequiresPermissions("system:depart:role:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysDepartRoleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
@ -188,7 +189,7 @@ public class SysDepartRoleController extends JeecgController<SysDepartRole, ISys
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:depart:role:userAdd")
|
||||
@RequestMapping(value = "/deptRoleUserAdd", method = RequestMethod.POST)
|
||||
public Result<?> deptRoleAdd(@RequestBody JSONObject json) {
|
||||
String newRoleId = json.getString("newRoleId");
|
||||
|
||||
@ -8,8 +8,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
@ -19,7 +21,9 @@ import org.jeecg.common.system.vo.DictQuery;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.ImportExcelUtil;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.model.SysDictTree;
|
||||
@ -28,6 +32,7 @@ import org.jeecg.modules.system.security.DictQueryBlackListHandler;
|
||||
import org.jeecg.modules.system.service.ISysDictItemService;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.vo.SysDictPage;
|
||||
import org.jeecg.modules.system.vo.lowapp.SysDictVo;
|
||||
import org.jeecgframework.poi.excel.ExcelImportCheckUtil;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
@ -73,6 +78,12 @@ public class SysDictController {
|
||||
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
|
||||
Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDict.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
|
||||
Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
|
||||
IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
|
||||
@ -364,7 +375,7 @@ public class SysDictController {
|
||||
* @param sysDict
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<SysDict> add(@RequestBody SysDict sysDict) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
@ -385,7 +396,7 @@ public class SysDictController {
|
||||
* @param sysDict
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:edit")
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT,RequestMethod.POST })
|
||||
public Result<SysDict> edit(@RequestBody SysDict sysDict) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
@ -407,7 +418,7 @@ public class SysDictController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
|
||||
@ -426,7 +437,7 @@ public class SysDictController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
@ -474,6 +485,13 @@ public class SysDictController {
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysDict sysDict,HttpServletRequest request) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDict.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, request.getParameterMap());
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
@ -509,7 +527,7 @@ public class SysDictController {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@ -639,4 +657,36 @@ public class SysDictController {
|
||||
return Result.error("校验失败,sql解析异常!" + msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据应用id获取字典列表和详情
|
||||
* @param request
|
||||
*/
|
||||
@GetMapping("/getDictListByLowAppId")
|
||||
public Result<List<SysDictVo>> getDictListByLowAppId(HttpServletRequest request){
|
||||
String lowAppId = oConvertUtils.getString(TokenUtils.getLowAppIdByRequest(request),"0");
|
||||
List<SysDictVo> list = sysDictService.getDictListByLowAppId(lowAppId);
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字典
|
||||
* @param sysDictVo
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addDictByLowAppId")
|
||||
public Result<String> addDictByLowAppId(@RequestBody SysDictVo sysDictVo,HttpServletRequest request){
|
||||
String lowAppId = oConvertUtils.getString(TokenUtils.getLowAppIdByRequest(request),"0");
|
||||
sysDictVo.setLowAppId(lowAppId);
|
||||
sysDictService.addDictByLowAppId(sysDictVo);
|
||||
return Result.ok("添加成功");
|
||||
}
|
||||
|
||||
@PutMapping("/editDictByLowAppId")
|
||||
public Result<String> editDictByLowAppId(@RequestBody SysDictVo sysDictVo,HttpServletRequest request){
|
||||
String lowAppId = oConvertUtils.getString(TokenUtils.getLowAppIdByRequest(request),"0");
|
||||
sysDictVo.setLowAppId(lowAppId);
|
||||
sysDictService.editDictByLowAppId(sysDictVo);
|
||||
return Result.ok("编辑成功");
|
||||
}
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
@ -73,7 +74,7 @@ public class SysDictItemController {
|
||||
* @功能:新增
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:item:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDictItem> add(@RequestBody SysDictItem sysDictItem) {
|
||||
@ -94,7 +95,7 @@ public class SysDictItemController {
|
||||
* @param sysDictItem
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:item:edit")
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT,RequestMethod.POST })
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDictItem> edit(@RequestBody SysDictItem sysDictItem) {
|
||||
@ -118,7 +119,7 @@ public class SysDictItemController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:item:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDictItem> delete(@RequestParam(name="id",required=true) String id) {
|
||||
@ -140,7 +141,7 @@ public class SysDictItemController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:dict:item:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDictItem> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
|
||||
@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
@ -67,7 +68,7 @@ public class SysGatewayRouteController extends JeecgController<SysGatewayRoute,
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:getway:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysGatewayRouteService.deleteById(id);
|
||||
|
||||
@ -1,11 +1,14 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
@ -75,6 +78,7 @@ public class SysPermissionController {
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
//@RequiresPermissions("system:permission:list")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<List<SysPermissionTree>> list(SysPermission sysPermission, HttpServletRequest req) {
|
||||
long start = System.currentTimeMillis();
|
||||
@ -356,7 +360,7 @@ public class SysPermissionController {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<SysPermission> add(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<SysPermission>();
|
||||
@ -376,7 +380,7 @@ public class SysPermissionController {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:edit")
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT, RequestMethod.POST })
|
||||
public Result<SysPermission> edit(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -398,14 +402,14 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/checkPermDuplication", method = RequestMethod.GET)
|
||||
public Result<String> checkPermDuplication(@RequestParam(name = "id", required = false) String id, @RequestParam(name = "url") String url, @RequestParam(name = "alwaysShow") Boolean alwaysShow) {
|
||||
public Result<String> checkPermDuplication(@RequestParam(name = "id", required = false) String id,@RequestParam(name = "url") String url,@RequestParam(name = "alwaysShow") Boolean alwaysShow) {
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
boolean check=sysPermissionService.checkPermDuplication(id,url,alwaysShow);
|
||||
if(check){
|
||||
return Result.ok("该值可用!");
|
||||
}
|
||||
return Result.error("该值不可用,系统中已存在!");
|
||||
return Result.error("访问路径不允许重复,请重定义!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
@ -418,7 +422,7 @@ public class SysPermissionController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -437,7 +441,7 @@ public class SysPermissionController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -545,7 +549,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:saveRole")
|
||||
public Result<String> saveRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
@ -873,7 +877,7 @@ public class SysPermissionController {
|
||||
* @param sysPermissionDataRule
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:addRule")
|
||||
@RequestMapping(value = "/addPermissionRule", method = RequestMethod.POST)
|
||||
public Result<SysPermissionDataRule> addPermissionRule(@RequestBody SysPermissionDataRule sysPermissionDataRule) {
|
||||
Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
|
||||
@ -888,7 +892,7 @@ public class SysPermissionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:editRule")
|
||||
@RequestMapping(value = "/editPermissionRule", method = { RequestMethod.PUT, RequestMethod.POST })
|
||||
public Result<SysPermissionDataRule> editPermissionRule(@RequestBody SysPermissionDataRule sysPermissionDataRule) {
|
||||
Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
|
||||
@ -908,7 +912,7 @@ public class SysPermissionController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:deleteRule")
|
||||
@RequestMapping(value = "/deletePermissionRule", method = RequestMethod.DELETE)
|
||||
public Result<SysPermissionDataRule> deletePermissionRule(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysPermissionDataRule> result = new Result<SysPermissionDataRule>();
|
||||
@ -965,7 +969,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveDepartPermission", method = RequestMethod.POST)
|
||||
//@RequiresRoles({ "admin" })
|
||||
@RequiresPermissions("system:permission:saveDepart")
|
||||
public Result<String> saveDepartPermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
|
||||
@ -7,16 +7,16 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.ImportExcelUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.quartz.service.IQuartzJobService;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysPosition;
|
||||
import org.jeecg.modules.system.service.ISysPositionService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
@ -72,6 +72,12 @@ public class SysPositionController {
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysPosition>> result = new Result<IPage<SysPosition>>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysPosition.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
QueryWrapper<SysPosition> queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, req.getParameterMap());
|
||||
Page<SysPosition> page = new Page<SysPosition>(pageNo, pageSize);
|
||||
IPage<SysPosition> pageList = sysPositionService.page(page, queryWrapper);
|
||||
@ -201,6 +207,12 @@ public class SysPositionController {
|
||||
if (oConvertUtils.isNotEmpty(paramsStr)) {
|
||||
String deString = URLDecoder.decode(paramsStr, "UTF-8");
|
||||
SysPosition sysPosition = JSON.parseObject(deString, SysPosition.class);
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysPosition.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap());
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
|
||||
@ -13,29 +13,24 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.PageDTO;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.PmsUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.entity.SysRole;
|
||||
import org.jeecg.modules.system.entity.SysRolePermission;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionService;
|
||||
import org.jeecg.modules.system.service.ISysRolePermissionService;
|
||||
import org.jeecg.modules.system.service.ISysRoleService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.vo.SysUserRoleCountVo;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@ -81,14 +76,18 @@ public class SysRoleController {
|
||||
@Autowired
|
||||
private ISysPermissionService sysPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* 分页列表查询 【系统角色,不做租户隔离】
|
||||
* @param role
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@RequiresPermissions("system:role:list")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysRole>> queryPageList(SysRole role,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@ -103,13 +102,41 @@ public class SysRoleController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页列表查询【租户角色,做租户隔离】
|
||||
* @param role
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/listByTenant", method = RequestMethod.GET)
|
||||
public Result<IPage<SysRole>> listByTenant(SysRole role,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysRole>> result = new Result<IPage<SysRole>>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
role.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(role, req.getParameterMap());
|
||||
Page<SysRole> page = new Page<SysRole>(pageNo, pageSize);
|
||||
IPage<SysRole> pageList = sysRoleService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:role:add")
|
||||
public Result<SysRole> add(@RequestBody SysRole role) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
try {
|
||||
@ -128,7 +155,7 @@ public class SysRoleController {
|
||||
* @param role
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@RequestMapping(value = "/edit",method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<SysRole> edit(@RequestBody SysRole role) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
@ -152,7 +179,7 @@ public class SysRoleController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:role:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysRoleService.deleteRole(id);
|
||||
@ -164,7 +191,7 @@ public class SysRoleController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:role:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
@ -194,11 +221,43 @@ public class SysRoleController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询全部角色(参与租户隔离)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryall", method = RequestMethod.GET)
|
||||
public Result<List<SysRole>> queryall() {
|
||||
Result<List<SysRole>> result = new Result<>();
|
||||
List<SysRole> list = sysRoleService.list();
|
||||
LambdaQueryWrapper<SysRole> query = new LambdaQueryWrapper<SysRole>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query.eq(SysRole::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
List<SysRole> list = sysRoleService.list(query);
|
||||
if(list==null||list.size()<=0) {
|
||||
result.error500("未找到角色信息");
|
||||
}else {
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部系统角色(不做租户隔离)
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:role:queryallNoByTenant")
|
||||
@RequestMapping(value = "/queryallNoByTenant", method = RequestMethod.GET)
|
||||
public Result<List<SysRole>> queryallNoByTenant() {
|
||||
Result<List<SysRole>> result = new Result<>();
|
||||
LambdaQueryWrapper<SysRole> query = new LambdaQueryWrapper<SysRole>();
|
||||
List<SysRole> list = sysRoleService.list(query);
|
||||
if(list==null||list.size()<=0) {
|
||||
result.error500("未找到角色信息");
|
||||
}else {
|
||||
@ -253,6 +312,13 @@ public class SysRoleController {
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysRole.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
// Step.1 组装查询条件
|
||||
QueryWrapper<SysRole> queryWrapper = QueryGenerator.initQueryWrapper(sysRole, request.getParameterMap());
|
||||
//Step.2 AutoPoi 导出Excel
|
||||
@ -408,6 +474,5 @@ public class SysRoleController {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
@ -65,6 +67,7 @@ public class SysRoleIndexController extends JeecgController<SysRoleIndex, ISysRo
|
||||
* @param sysRoleIndex
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:roleindex:add")
|
||||
@AutoLog(value = "角色首页配置-添加")
|
||||
@ApiOperation(value = "角色首页配置-添加", notes = "角色首页配置-添加")
|
||||
@PostMapping(value = "/add")
|
||||
@ -80,6 +83,7 @@ public class SysRoleIndexController extends JeecgController<SysRoleIndex, ISysRo
|
||||
* @param sysRoleIndex
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:roleindex:edit")
|
||||
@AutoLog(value = "角色首页配置-编辑")
|
||||
@ApiOperation(value = "角色首页配置-编辑", notes = "角色首页配置-编辑")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
|
||||
@ -1,20 +1,34 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.PermissionData;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.TokenUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.service.ISysTenantPackService;
|
||||
import org.jeecg.modules.system.service.ISysTenantService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.service.ISysUserTenantService;
|
||||
import org.jeecg.modules.system.vo.SysUserTenantVo;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantDepartAuthInfo;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackModel;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackUser;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackUserCount;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -33,6 +47,15 @@ public class SysTenantController {
|
||||
@Autowired
|
||||
private ISysTenantService sysTenantService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserTenantService relationService;
|
||||
|
||||
@Autowired
|
||||
private ISysTenantPackService sysTenantPackService;
|
||||
|
||||
/**
|
||||
* 获取列表数据
|
||||
* @param sysTenant
|
||||
@ -41,6 +64,7 @@ public class SysTenantController {
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:tenant:list")
|
||||
@PermissionData(pageComponent = "system/TenantList")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysTenant>> queryPageList(SysTenant sysTenant,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@ -70,11 +94,32 @@ public class SysTenantController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户删除的列表
|
||||
* @param sysTenant
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/recycleBinPageList")
|
||||
@RequiresPermissions("system:tenant:recycleBinPageList")
|
||||
public Result<IPage<SysTenant>> recycleBinPageList(SysTenant sysTenant,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req){
|
||||
Result<IPage<SysTenant>> result = new Result<IPage<SysTenant>>();
|
||||
Page<SysTenant> page = new Page<SysTenant>(pageNo, pageSize);
|
||||
IPage<SysTenant> pageList = sysTenantService.getRecycleBinPageList(page, sysTenant);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:tenant:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<SysTenant> add(@RequestBody SysTenant sysTenant) {
|
||||
Result<SysTenant> result = new Result();
|
||||
@ -82,7 +127,7 @@ public class SysTenantController {
|
||||
return result.error500("该编号已存在!");
|
||||
}
|
||||
try {
|
||||
sysTenantService.save(sysTenant);
|
||||
sysTenantService.saveTenant(sysTenant);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@ -96,6 +141,7 @@ public class SysTenantController {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:tenant:edit")
|
||||
@RequestMapping(value = "/edit", method ={RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysTenant> edit(@RequestBody SysTenant tenant) {
|
||||
Result<SysTenant> result = new Result();
|
||||
@ -103,6 +149,9 @@ public class SysTenantController {
|
||||
if(sysTenant==null) {
|
||||
return result.error500("未找到对应实体");
|
||||
}
|
||||
if(oConvertUtils.isEmpty(sysTenant.getHouseNumber())){
|
||||
tenant.setHouseNumber(RandomUtil.randomStringUpper(6));
|
||||
}
|
||||
boolean ok = sysTenantService.updateById(tenant);
|
||||
if(ok) {
|
||||
result.success("修改成功!");
|
||||
@ -115,6 +164,7 @@ public class SysTenantController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:tenant:delete")
|
||||
@RequestMapping(value = "/delete", method ={RequestMethod.DELETE, RequestMethod.POST})
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysTenantService.removeTenantById(id);
|
||||
@ -126,6 +176,7 @@ public class SysTenantController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:tenant:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<?> result = new Result<>();
|
||||
@ -163,6 +214,19 @@ public class SysTenantController {
|
||||
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
|
||||
public Result<SysTenant> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysTenant> result = new Result<SysTenant>();
|
||||
if(oConvertUtils.isEmpty(id)){
|
||||
result.error500("参数为空!");
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
Integer loginSessionTenant = oConvertUtils.getInt(TenantContext.getTenant());
|
||||
if(loginSessionTenant!=null && !loginSessionTenant.equals(Integer.valueOf(id))){
|
||||
result.error500("无权限访问他人租户!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
SysTenant sysTenant = sysTenantService.getById(id);
|
||||
if(sysTenant==null) {
|
||||
result.error500("未找到对应实体");
|
||||
@ -178,6 +242,7 @@ public class SysTenantController {
|
||||
* 查询有效的 租户数据
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:tenant:queryList")
|
||||
@RequestMapping(value = "/queryList", method = RequestMethod.GET)
|
||||
public Result<List<SysTenant>> queryList(@RequestParam(name="ids",required=false) String ids) {
|
||||
Result<List<SysTenant>> result = new Result<List<SysTenant>>();
|
||||
@ -192,8 +257,76 @@ public class SysTenantController {
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户的所有有效租户 【当前用于vue3版本】
|
||||
* 产品包分页列表查询
|
||||
*
|
||||
* @param sysTenantPack
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/packList")
|
||||
@RequiresPermissions("system:tenant:packList")
|
||||
public Result<IPage<SysTenantPack>> queryPackPageList(SysTenantPack sysTenantPack,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysTenantPack> queryWrapper = QueryGenerator.initQueryWrapper(sysTenantPack, req.getParameterMap());
|
||||
Page<SysTenantPack> page = new Page<SysTenantPack>(pageNo, pageSize);
|
||||
IPage<SysTenantPack> pageList = sysTenantPackService.page(page, queryWrapper);
|
||||
List<SysTenantPack> records = pageList.getRecords();
|
||||
if (null != records && records.size() > 0) {
|
||||
pageList.setRecords(sysTenantPackService.setPermissions(records));
|
||||
}
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建租户产品包
|
||||
*
|
||||
* @param sysTenantPack
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/addPackPermission")
|
||||
@RequiresPermissions("system:tenant:add:pack")
|
||||
public Result<String> addPackPermission(@RequestBody SysTenantPack sysTenantPack) {
|
||||
sysTenantPackService.addPackPermission(sysTenantPack);
|
||||
return Result.ok("创建租户产品包成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建租户产品包
|
||||
*
|
||||
* @param sysTenantPack
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/editPackPermission")
|
||||
@RequiresPermissions("system:tenant:edit:pack")
|
||||
public Result<String> editPackPermission(@RequestBody SysTenantPack sysTenantPack) {
|
||||
sysTenantPackService.editPackPermission(sysTenantPack);
|
||||
return Result.ok("修改租户产品包成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除用户菜单
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/deletePackPermissions")
|
||||
@RequiresPermissions("system:tenant:delete:pack")
|
||||
public Result<String> deletePackPermissions(@RequestParam(value = "ids") String ids) {
|
||||
sysTenantPackService.deletePackPermissions(ids);
|
||||
return Result.ok("删除租户产品包成功");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===========【低代码应用,前端专用接口 —— 加入限制只能维护和查看自己拥有的租户】==========================================================
|
||||
/**
|
||||
* 查询当前用户的所有有效租户【低代码应用专用接口】
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getCurrentUserTenant", method = RequestMethod.GET)
|
||||
@ -201,13 +334,11 @@ public class SysTenantController {
|
||||
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
|
||||
try {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String tenantIds = sysUser.getRelTenantIds();
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
List<Integer> tenantIdList = relationService.getTenantIdsByUserId(sysUser.getId());
|
||||
Map<String,Object> map = new HashMap(5);
|
||||
if (oConvertUtils.isNotEmpty(tenantIds)) {
|
||||
List<Integer> tenantIdList = new ArrayList<>();
|
||||
for(String id: tenantIds.split(SymbolConstant.COMMA)){
|
||||
tenantIdList.add(Integer.valueOf(id));
|
||||
}
|
||||
if (null!=tenantIdList && tenantIdList.size()>0) {
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
// 该方法仅查询有效的租户,如果返回0个就说明所有的租户均无效。
|
||||
List<SysTenant> tenantList = sysTenantService.queryEffectiveTenant(tenantIdList);
|
||||
map.put("list", tenantList);
|
||||
@ -220,4 +351,450 @@ public class SysTenantController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请用户【低代码应用专用接口】
|
||||
* @param ids
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/invitationUserJoin")
|
||||
@RequiresPermissions("system:tenant:invitation:user")
|
||||
public Result<String> invitationUserJoin(@RequestParam("ids") String ids,@RequestParam("userIds") String userIds){
|
||||
sysTenantService.invitationUserJoin(ids,userIds);
|
||||
return Result.ok("邀请用户成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户列表数据【低代码应用专用接口】
|
||||
* @param user
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getTenantUserList", method = RequestMethod.GET)
|
||||
@RequiresPermissions("system:tenant:user:list")
|
||||
public Result<IPage<SysUser>> getTenantUserList(SysUser user,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name="userTenantId") String userTenantId,
|
||||
HttpServletRequest req) {
|
||||
Result<IPage<SysUser>> result = new Result<>();
|
||||
Page<SysUser> page = new Page<>(pageNo, pageSize);
|
||||
Page<SysUser> pageList = relationService.getPageUserList(page,Integer.valueOf(userTenantId),user);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请离用户租户【低代码应用专用接口】
|
||||
* @param userIds
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/leaveTenant")
|
||||
@RequiresPermissions("system:tenant:leave")
|
||||
public Result<String> leaveTenant(@RequestParam("userIds") String userIds,
|
||||
@RequestParam("tenantId") String tenantId){
|
||||
Result<String> result = new Result<>();
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
Integer loginSessionTenant = oConvertUtils.getInt(TenantContext.getTenant());
|
||||
if(loginSessionTenant!=null && !loginSessionTenant.equals(Integer.valueOf(tenantId))){
|
||||
result.error500("无权限访问他人租户!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
sysTenantService.leaveTenant(userIds,tenantId);
|
||||
return Result.ok("请离成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑(只允许修改自己拥有的租户)【低代码应用专用接口】
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/editOwnTenant", method ={RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<SysTenant> editOwnTenant(@RequestBody SysTenant tenant,HttpServletRequest req) {
|
||||
Result<SysTenant> result = new Result();
|
||||
String tenantId = TokenUtils.getTenantIdByRequest(req);
|
||||
if(!tenantId.equals(tenant.getId().toString())){
|
||||
return result.error500("无权修改他人租户!");
|
||||
}
|
||||
|
||||
SysTenant sysTenant = sysTenantService.getById(tenant.getId());
|
||||
if(sysTenant==null) {
|
||||
return result.error500("未找到对应实体");
|
||||
}
|
||||
if(oConvertUtils.isEmpty(sysTenant.getHouseNumber())){
|
||||
tenant.setHouseNumber(RandomUtil.randomStringUpper(6));
|
||||
}
|
||||
boolean ok = sysTenantService.updateById(tenant);
|
||||
if(ok) {
|
||||
result.success("修改成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建租户并且将用户保存到中间表【低代码应用专用接口】
|
||||
* @param sysTenant
|
||||
*/
|
||||
@PostMapping("/saveTenantJoinUser")
|
||||
public Result<Integer> saveTenantJoinUser(@RequestBody SysTenant sysTenant){
|
||||
Result<Integer> result = new Result<>();
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
//---author:scott---date:20220111-----for: 限制免费用户只能创建两个租户--
|
||||
Integer count = sysTenantService.countCreateTenantNum(sysUser.getUsername());
|
||||
if (count > 2) {
|
||||
Set<String> roles = sysUserService.getUserRolesSet(sysUser.getUsername());
|
||||
//创建一个付费角色 paymember
|
||||
if (roles==null || (!roles.contains("paymember") && !roles.contains("admin"))) {
|
||||
return result.error500("免费用户最多创建两个租户!");
|
||||
}
|
||||
}
|
||||
//---author:scott---date:20220111-----for: 限制免费用户只能创建两个租户--
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Integer tenantId = sysTenantService.saveTenantJoinUser(sysTenant, sysUser.getId());
|
||||
result.setSuccess(true);
|
||||
result.setMessage("创建成功");
|
||||
result.setResult(tenantId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加入租户通过门牌号【低代码应用专用接口】
|
||||
* @param sysTenant
|
||||
*/
|
||||
@PostMapping("/joinTenantByHouseNumber")
|
||||
public Result<Integer> joinTenantByHouseNumber(@RequestBody SysTenant sysTenant){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
Integer tenantId = sysTenantService.joinTenantByHouseNumber(sysTenant, sysUser.getId());
|
||||
Result<Integer> result = new Result<>();
|
||||
if(tenantId != 0){
|
||||
result.setMessage("申请租户成功");
|
||||
result.setSuccess(true);
|
||||
result.setResult(tenantId);
|
||||
return result;
|
||||
}else{
|
||||
result.setMessage("该门牌号不存在");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//update-begin---author:wangshuai ---date:20230107 for:[QQYUN-3725]申请加入租户,审核中状态增加接口------------
|
||||
/**
|
||||
* 分页获取租户用户数据(vue3用户租户页面)【低代码应用专用接口】
|
||||
*
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param userTenantStatus
|
||||
* @param type
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUserTenantPageList")
|
||||
//@RequiresPermissions("system:tenant:tenantPageList")
|
||||
public Result<IPage<SysUserTenantVo>> getUserTenantPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(name = "userTenantStatus") String userTenantStatus,
|
||||
@RequestParam(name = "type", required = false) String type,
|
||||
SysUser user,
|
||||
HttpServletRequest req) {
|
||||
Page<SysUserTenantVo> page = new Page<SysUserTenantVo>(pageNo, pageSize);
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String tenantId = oConvertUtils.getString(TenantContext.getTenant(), "0");
|
||||
IPage<SysUserTenantVo> list = relationService.getUserTenantPageList(page, Arrays.asList(userTenantStatus.split(SymbolConstant.COMMA)), user, Integer.valueOf(tenantId));
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户id获取租户列表【低代码应用专用接口】
|
||||
*
|
||||
* @param userTenantStatus 关系表的状态
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getTenantListByUserId")
|
||||
//@RequiresPermissions("system:tenant:getTenantListByUserId")
|
||||
public Result<List<SysUserTenantVo>> getTenantListByUserId(@RequestParam(name = "userTenantStatus", required = false) String userTenantStatus) {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<String> list = null;
|
||||
if (oConvertUtils.isNotEmpty(userTenantStatus)) {
|
||||
list = Arrays.asList(userTenantStatus.split(SymbolConstant.COMMA));
|
||||
}
|
||||
//租户状态,用户id,租户用户关系状态
|
||||
List<SysUserTenantVo> sysTenant = relationService.getTenantListByUserId(sysUser.getId(), list);
|
||||
return Result.ok(sysTenant);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户租户关系状态【低代码应用专用接口】
|
||||
*/
|
||||
@PutMapping("/updateUserTenantStatus")
|
||||
//@RequiresPermissions("system:tenant:updateUserTenantStatus")
|
||||
public Result<String> updateUserTenantStatus(@RequestBody SysUserTenant userTenant) {
|
||||
String tenantId = TenantContext.getTenant();
|
||||
if (oConvertUtils.isEmpty(tenantId)) {
|
||||
return Result.error("未找到当前租户信息");
|
||||
}
|
||||
relationService.updateUserTenantStatus(userTenant.getUserId(), tenantId, userTenant.getStatus());
|
||||
return Result.ok("更新用户租户状态成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销租户【低代码应用专用接口】
|
||||
*
|
||||
* @param sysTenant
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/cancelTenant")
|
||||
//@RequiresPermissions("system:tenant:cancelTenant")
|
||||
public Result<String> cancelTenant(@RequestBody SysTenant sysTenant,HttpServletRequest request) {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
SysTenant tenant = sysTenantService.getById(sysTenant.getId());
|
||||
if (null == tenant) {
|
||||
return Result.error("未找到当前租户信息");
|
||||
}
|
||||
if (!sysUser.getUsername().equals(tenant.getCreateBy())) {
|
||||
return Result.error("没有权限");
|
||||
}
|
||||
SysUser userById = sysUserService.getById(sysUser.getId());
|
||||
String loginPassword = request.getParameter("loginPassword");
|
||||
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(),loginPassword, userById.getSalt());
|
||||
if (!passwordEncode.equals(userById.getPassword())) {
|
||||
return Result.error("密码不正确");
|
||||
}
|
||||
sysTenantService.removeById(sysTenant.getId());
|
||||
return Result.ok("注销成功");
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20230107 for:[QQYUN-3725]申请加入租户,审核中状态增加接口------------
|
||||
|
||||
/**
|
||||
* 获取租户用户不同状态下的数量【低代码应用专用接口】
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getTenantStatusCount")
|
||||
public Result<Long> getTenantStatusCount(@RequestParam(value = "status",defaultValue = "1") String status, HttpServletRequest req){
|
||||
String tenantId = TokenUtils.getTenantIdByRequest(req);
|
||||
if (null == tenantId) {
|
||||
return Result.error("未找到当前租户信息");
|
||||
}
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getTenantId,tenantId);
|
||||
query.eq(SysUserTenant::getStatus,status);
|
||||
long count = relationService.count(query);
|
||||
return Result.ok(count);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户取消租户申请【低代码应用专用接口】
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/cancelApplyTenant")
|
||||
public Result<String> cancelApplyTenant(@RequestParam("tenantId") String tenantId){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
sysTenantService.leaveTenant(sysUser.getId(),tenantId);
|
||||
return Result.ok("取消申请成功");
|
||||
}
|
||||
|
||||
//===========【低代码应用,前端专用接口 —— 加入限制只能维护和查看自己拥有的租户】==========================================================
|
||||
|
||||
/**
|
||||
* 彻底删除租户
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/deleteLogicDeleted")
|
||||
@RequiresPermissions("system:tenant:deleteTenantLogic")
|
||||
public Result<String> deleteTenantLogic(@RequestParam("ids") String ids){
|
||||
sysTenantService.deleteTenantLogic(ids);
|
||||
return Result.ok("彻底删除成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原删除的租户
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/revertTenantLogic")
|
||||
@RequiresPermissions("system:tenant:revertTenantLogic")
|
||||
public Result<String> revertTenantLogic(@RequestParam("ids") String ids){
|
||||
sysTenantService.revertTenantLogic(ids);
|
||||
return Result.ok("还原成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出租户【低代码应用专用接口】
|
||||
* @param sysTenant
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/exitUserTenant")
|
||||
public Result<String> exitUserTenant(@RequestBody SysTenant sysTenant,HttpServletRequest request){
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
//验证用户是否已存在
|
||||
Integer count = relationService.userTenantIzExist(sysUser.getId(),sysTenant.getId());
|
||||
if (count == 0) {
|
||||
return Result.error("此租户下没有当前用户");
|
||||
}
|
||||
//验证密码
|
||||
String loginPassword = request.getParameter("loginPassword");
|
||||
SysUser userById = sysUserService.getById(sysUser.getId());
|
||||
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(),loginPassword, userById.getSalt());
|
||||
if (!passwordEncode.equals(userById.getPassword())) {
|
||||
return Result.error("密码不正确");
|
||||
}
|
||||
//退出登录
|
||||
sysTenantService.exitUserTenant(sysUser.getId(),sysUser.getUsername(),String.valueOf(sysTenant.getId()));
|
||||
return Result.ok("退出租户成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更租户拥有者【低代码应用专用接口】
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/changeOwenUserTenant")
|
||||
public Result<String> changeOwenUserTenant(@RequestParam("userId") String userId){
|
||||
sysTenantService.changeOwenUserTenant(userId);
|
||||
return Result.ok("退出租户成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 邀请用户到租户,通过手机号匹配 【低代码应用专用接口】
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/invitationUser")
|
||||
public Result<String> invitationUser(@RequestParam(name="phone") String phone){
|
||||
return sysTenantService.invitationUser(phone);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取 租户产品包-3个默认admin的人员数量
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadAdminPackCount")
|
||||
public Result<List<TenantPackUserCount>> loadAdminPackCount(@RequestParam("tenantId") Integer tenantId){
|
||||
List<TenantPackUserCount> list = sysTenantService.queryTenantPackUserCount(tenantId);
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询租户产品包信息
|
||||
* @param packModel
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getTenantPackInfo")
|
||||
public Result<TenantPackModel> getTenantPackInfo(TenantPackModel packModel){
|
||||
TenantPackModel tenantPackModel = sysTenantService.queryTenantPack(packModel);
|
||||
return Result.ok(tenantPackModel);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加用户和产品包的关系数据
|
||||
* @param sysTenantPackUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/addTenantPackUser")
|
||||
public Result<?> addTenantPackUser(@RequestBody SysTenantPackUser sysTenantPackUser){
|
||||
sysTenantService.addBatchTenantPackUser(sysTenantPackUser);
|
||||
return Result.ok("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 从产品包移除用户
|
||||
* @param sysTenantPackUser
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/deleteTenantPackUser")
|
||||
public Result<?> deleteTenantPackUser(@RequestBody SysTenantPackUser sysTenantPackUser){
|
||||
sysTenantService.deleteTenantPackUser(sysTenantPackUser);
|
||||
return Result.ok("操作成功!");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改申请状态
|
||||
* @param sysTenant
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/updateApplyStatus")
|
||||
public Result<?> updateApplyStatus(@RequestBody SysTenant sysTenant){
|
||||
SysTenant entity = this.sysTenantService.getById(sysTenant.getId());
|
||||
if(entity==null){
|
||||
return Result.error("租户不存在!");
|
||||
}
|
||||
entity.setApplyStatus(sysTenant.getApplyStatus());
|
||||
sysTenantService.updateById(entity);
|
||||
return Result.ok("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取产品包人员申请列表
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getTenantPackApplyUsers")
|
||||
public Result<?> getTenantPackApplyUsers(@RequestParam("tenantId") Integer tenantId){
|
||||
List<TenantPackUser> list = sysTenantService.getTenantPackApplyUsers(tenantId);
|
||||
return Result.ok(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 个人 申请成为管理员
|
||||
* @param sysTenantPackUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/doApplyTenantPackUser")
|
||||
public Result<?> doApplyTenantPackUser(@RequestBody SysTenantPackUser sysTenantPackUser){
|
||||
sysTenantService.doApplyTenantPackUser(sysTenantPackUser);
|
||||
return Result.ok("申请成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 申请通过 成为管理员
|
||||
* @param sysTenantPackUser
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/passApply")
|
||||
public Result<?> passApply(@RequestBody SysTenantPackUser sysTenantPackUser){
|
||||
sysTenantService.passApply(sysTenantPackUser);
|
||||
return Result.ok("操作成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 拒绝申请 成为管理员
|
||||
* @param sysTenantPackUser
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/deleteApply")
|
||||
public Result<?> deleteApply(@RequestBody SysTenantPackUser sysTenantPackUser){
|
||||
sysTenantService.deleteApply(sysTenantPackUser);
|
||||
return Result.ok("");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 进入应用组织页面 查询租户信息及当前用户是否有 管理员的权限--
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTenantAuthInfo", method = RequestMethod.GET)
|
||||
public Result<TenantDepartAuthInfo> queryTenantAuthInfo(@RequestParam(name="id",required=true) String id) {
|
||||
TenantDepartAuthInfo info = sysTenantService.getTenantDepartAuthInfo(Integer.parseInt(id));
|
||||
return Result.ok(info);
|
||||
}
|
||||
}
|
||||
|
||||
@ -17,9 +17,10 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.PermissionData;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
@ -31,6 +32,8 @@ import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.vo.SysDepartUsersVO;
|
||||
import org.jeecg.modules.system.vo.SysUserRoleVO;
|
||||
import org.jeecg.modules.system.vo.lowapp.DepartAndUserInfo;
|
||||
import org.jeecg.modules.system.vo.lowapp.UpdateDepartInfo;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
@ -74,9 +77,6 @@ public class SysUserController {
|
||||
@Autowired
|
||||
private ISysUserDepartService sysUserDepartService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserRoleService userRoleService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRoleUserService departRoleUserService;
|
||||
|
||||
@ -92,8 +92,17 @@ public class SysUserController {
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserAgentService sysUserAgentService;
|
||||
|
||||
@Autowired
|
||||
private ISysPositionService sysPositionService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserTenantService userTenantService;
|
||||
|
||||
/**
|
||||
* 获取用户列表数据
|
||||
* 获取租户下用户数据(支持租户隔离)
|
||||
* @param user
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
@ -104,63 +113,42 @@ public class SysUserController {
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
|
||||
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
|
||||
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
|
||||
|
||||
//update-begin-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id
|
||||
//部门ID
|
||||
String departId = req.getParameter("departId");
|
||||
if(oConvertUtils.isNotEmpty(departId)){
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserDepart::getDepId,departId);
|
||||
List<SysUserDepart> list = sysUserDepartService.list(query);
|
||||
List<String> userIds = list.stream().map(SysUserDepart::getUserId).collect(Collectors.toList());
|
||||
//update-begin---author:wangshuai ---date:20220322 for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------
|
||||
if(oConvertUtils.listIsNotEmpty(userIds)){
|
||||
queryWrapper.in("id",userIds);
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
String tenantId = oConvertUtils.getString(TenantContext.getTenant(), "0");
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
List<String> userIds = userTenantService.getUserIdsByTenantId(Integer.valueOf(tenantId));
|
||||
if (oConvertUtils.listIsNotEmpty(userIds)) {
|
||||
queryWrapper.in("id", userIds);
|
||||
}else{
|
||||
return Result.OK();
|
||||
queryWrapper.eq("id", "通过租户查询不到任何用户");
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20220322 for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
}
|
||||
//用户ID
|
||||
String code = req.getParameter("code");
|
||||
if(oConvertUtils.isNotEmpty(code)){
|
||||
queryWrapper.in("id",Arrays.asList(code.split(",")));
|
||||
pageSize = code.split(",").length;
|
||||
}
|
||||
//update-end-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id
|
||||
|
||||
//update-begin-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户
|
||||
String status = req.getParameter("status");
|
||||
if(oConvertUtils.isNotEmpty(status)){
|
||||
queryWrapper.eq("status", Integer.parseInt(status));
|
||||
}
|
||||
//update-end-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户
|
||||
|
||||
//TODO 外部模拟登陆临时账号,列表不显示
|
||||
queryWrapper.ne("username","_reserve_user_external");
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
IPage<SysUser> pageList = sysUserService.page(page, queryWrapper);
|
||||
|
||||
//批量查询用户的所属部门
|
||||
//step.1 先拿到全部的 useids
|
||||
//step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
Map<String,String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
pageList.getRecords().forEach(item->{
|
||||
item.setOrgCodeTxt(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
log.info(pageList.toString());
|
||||
return result;
|
||||
//------------------------------------------------------------------------------------------------
|
||||
return sysUserService.queryPageList(req, queryWrapper, pageSize, pageNo);
|
||||
}
|
||||
|
||||
//@RequiresRoles({"admin"})
|
||||
//@RequiresPermissions("system:user:add")
|
||||
/**
|
||||
* 获取系统用户数据(查询全部用户,不做租户隔离)
|
||||
*
|
||||
* @param user
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("system:user:listAll")
|
||||
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
|
||||
public Result<IPage<SysUser>> queryAllPageList(SysUser user, @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest req) {
|
||||
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
|
||||
return sysUserService.queryPageList(req, queryWrapper, pageSize, pageNo);
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:add")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<SysUser> add(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
@ -178,7 +166,9 @@ public class SysUserController {
|
||||
//用户表字段org_code不能在这里设置他的值
|
||||
user.setOrgCode(null);
|
||||
// 保存用户走一个service 保证事务
|
||||
sysUserService.saveUser(user, selectedRoles, selectedDeparts);
|
||||
//获取租户ids
|
||||
String relTenantIds = jsonObject.getString("realTenantIds");
|
||||
sysUserService.saveUser(user, selectedRoles, selectedDeparts, relTenantIds);
|
||||
baseCommonService.addLog("添加用户,username: " +user.getUsername() ,CommonConstant.LOG_TYPE_2, 2);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
@ -188,8 +178,7 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
//@RequiresRoles({"admin"})
|
||||
//@RequiresPermissions("system:user:edit")
|
||||
@RequiresPermissions("system:user:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
@ -212,7 +201,9 @@ public class SysUserController {
|
||||
//用户表字段org_code不能在这里设置他的值
|
||||
user.setOrgCode(null);
|
||||
// 修改用户走一个service 保证事务
|
||||
sysUserService.editUser(user, roles, departs);
|
||||
//获取租户ids
|
||||
String relTenantIds = jsonObject.getString("relTenantIds");
|
||||
sysUserService.editUser(user, roles, departs, relTenantIds);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -225,7 +216,7 @@ public class SysUserController {
|
||||
/**
|
||||
* 删除用户
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:delete")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
baseCommonService.addLog("删除用户,id: " +id ,CommonConstant.LOG_TYPE_2, 3);
|
||||
@ -236,7 +227,7 @@ public class SysUserController {
|
||||
/**
|
||||
* 批量删除用户
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:deleteBatch")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
baseCommonService.addLog("批量删除用户, ids: " +ids ,CommonConstant.LOG_TYPE_2, 3);
|
||||
@ -249,7 +240,7 @@ public class SysUserController {
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:frozenBatch")
|
||||
@RequestMapping(value = "/frozenBatch", method = RequestMethod.PUT)
|
||||
public Result<SysUser> frozenBatch(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
@ -272,6 +263,7 @@ public class SysUserController {
|
||||
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:queryById")
|
||||
@RequestMapping(value = "/queryById", method = RequestMethod.GET)
|
||||
public Result<SysUser> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
@ -285,6 +277,7 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:user:queryUserRole")
|
||||
@RequestMapping(value = "/queryUserRole", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryUserRole(@RequestParam(name = "userid", required = true) String userid) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
@ -337,7 +330,7 @@ public class SysUserController {
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:changepwd")
|
||||
@RequestMapping(value = "/changePassword", method = RequestMethod.PUT)
|
||||
public Result<?> changePassword(@RequestBody SysUser sysUser) {
|
||||
SysUser u = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, sysUser.getUsername()));
|
||||
@ -460,8 +453,7 @@ public class SysUserController {
|
||||
* @param request
|
||||
* @param sysUser
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
//@RequiresPermissions("system:user:export")
|
||||
@RequiresPermissions("system:user:export")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysUser sysUser,HttpServletRequest request) {
|
||||
// Step.1 组装查询条件
|
||||
@ -494,8 +486,7 @@ public class SysUserController {
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
//@RequiresPermissions("system:user:import")
|
||||
@RequiresPermissions("system:user:import")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response)throws IOException {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@ -588,10 +579,28 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @功能:根据id 批量查询
|
||||
* @param userNames
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryByNames", method = RequestMethod.GET)
|
||||
public Result<Collection<SysUser>> queryByNames(@RequestParam String userNames) {
|
||||
Result<Collection<SysUser>> result = new Result<>();
|
||||
String[] names = userNames.split(",");
|
||||
QueryWrapper<SysUser> queryWrapper=new QueryWrapper();
|
||||
queryWrapper.lambda().in(true,SysUser::getUsername,names);
|
||||
Collection<SysUser> userRole = sysUserService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(userRole);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 首页用户重置密码
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:updatepwd")
|
||||
@RequestMapping(value = "/updatePassword", method = RequestMethod.PUT)
|
||||
public Result<?> updatePassword(@RequestBody JSONObject json) {
|
||||
String username = json.getString("username");
|
||||
@ -632,7 +641,7 @@ public class SysUserController {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:addUserRole")
|
||||
@RequestMapping(value = "/addSysUserRole", method = RequestMethod.POST)
|
||||
public Result<String> addSysUserRole(@RequestBody SysUserRoleVO sysUserRoleVO) {
|
||||
Result<String> result = new Result<String>();
|
||||
@ -663,7 +672,7 @@ public class SysUserController {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:deleteRole")
|
||||
@RequestMapping(value = "/deleteUserRole", method = RequestMethod.DELETE)
|
||||
public Result<SysUserRole> deleteUserRole(@RequestParam(name="roleId") String roleId,
|
||||
@RequestParam(name="userId",required=true) String userId
|
||||
@ -687,7 +696,7 @@ public class SysUserController {
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:deleteRoleBatch")
|
||||
@RequestMapping(value = "/deleteUserRoleBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysUserRole> deleteUserRoleBatch(
|
||||
@RequestParam(name="roleId") String roleId,
|
||||
@ -740,6 +749,10 @@ public class SysUserController {
|
||||
item.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
//设置租户id
|
||||
page.setRecords(userTenantService.setUserTenantIds(page.getRecords()));
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
}else{
|
||||
@ -814,7 +827,7 @@ public class SysUserController {
|
||||
/**
|
||||
* 给指定部门添加对应的用户
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:editDepartWithUser")
|
||||
@RequestMapping(value = "/editSysDepartWithUser", method = RequestMethod.POST)
|
||||
public Result<String> editSysDepartWithUser(@RequestBody SysDepartUsersVO sysDepartUsersVO) {
|
||||
Result<String> result = new Result<String>();
|
||||
@ -843,7 +856,7 @@ public class SysUserController {
|
||||
/**
|
||||
* 删除指定机构的用户关系
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:deleteUserInDepart")
|
||||
@RequestMapping(value = "/deleteUserInDepart", method = RequestMethod.DELETE)
|
||||
public Result<SysUserDepart> deleteUserInDepart(@RequestParam(name="depId") String depId,
|
||||
@RequestParam(name="userId",required=true) String userId
|
||||
@ -875,7 +888,7 @@ public class SysUserController {
|
||||
/**
|
||||
* 批量删除指定机构的用户关系
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:deleteUserInDepartBatch")
|
||||
@RequestMapping(value = "/deleteUserInDepartBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysUserDepart> deleteUserInDepartBatch(
|
||||
@RequestParam(name="depId") String depId,
|
||||
@ -982,13 +995,18 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
String realname = jsonObject.getString("realname");
|
||||
if(oConvertUtils.isEmpty(realname)){
|
||||
realname = username;
|
||||
}
|
||||
|
||||
try {
|
||||
user.setCreateTime(new Date());// 设置创建时间
|
||||
String salt = oConvertUtils.randomGen(8);
|
||||
String passwordEncode = PasswordUtil.encrypt(username, password, salt);
|
||||
user.setSalt(salt);
|
||||
user.setUsername(username);
|
||||
user.setRealname(username);
|
||||
user.setRealname(realname);
|
||||
user.setPassword(passwordEncode);
|
||||
user.setEmail(email);
|
||||
user.setPhone(phone);
|
||||
@ -1065,6 +1083,12 @@ public class SysUserController {
|
||||
SysUser user = sysUserService.getOne(query);
|
||||
Map<String,String> map = new HashMap(5);
|
||||
map.put("smscode",smscode);
|
||||
if(null == user){
|
||||
//前端根据文字做判断用户是否存在判断,不能修改
|
||||
result.setMessage("用户信息不存在");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
map.put("username",user.getUsername());
|
||||
result.setResult(map);
|
||||
result.setSuccess(true);
|
||||
@ -1239,7 +1263,7 @@ public class SysUserController {
|
||||
* @param userIds 被删除的用户ID,多个id用半角逗号分割
|
||||
* @return
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequiresPermissions("system:user:deleteRecycleBin")
|
||||
@RequestMapping(value = "/deleteRecycleBin", method = RequestMethod.DELETE)
|
||||
public Result deleteRecycleBin(@RequestParam("userIds") String userIds) {
|
||||
if (StringUtils.isNotBlank(userIds)) {
|
||||
@ -1254,6 +1278,7 @@ public class SysUserController {
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/appEdit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<SysUser> appEdit(HttpServletRequest request,@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
@ -1466,5 +1491,255 @@ public class SysUserController {
|
||||
}
|
||||
return ls;
|
||||
}
|
||||
|
||||
/**
|
||||
* 聊天 创建聊天组件专用 根据用户账号、用户姓名、部门id分页查询
|
||||
* @param departId 部门id
|
||||
* @param keyword 搜索值
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getUserInformation")
|
||||
public Result<IPage<SysUser>> getUserInformation(
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name="keyword",required=false) String keyword) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Integer tenantId = null;
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
tenantId = oConvertUtils.getInt(TenantContext.getTenant(),0);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
IPage<SysUser> pageList = sysUserDepartService.getUserInformation(tenantId,departId, keyword, pageSize, pageNo);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 简版流程用户选择组件
|
||||
* @param departId 部门id
|
||||
* @param roleId 角色id
|
||||
* @param keyword 搜索值
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/selectUserList")
|
||||
public Result<IPage<SysUser>> selectUserList(
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name = "roleId", required = false) String roleId,
|
||||
@RequestParam(name="keyword",required=false) String keyword) {
|
||||
//------------------------------------------------------------------------------------------------
|
||||
Integer tenantId = null;
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
String tenantStr = TenantContext.getTenant();
|
||||
if(oConvertUtils.isNotEmpty(tenantStr)){
|
||||
tenantId = Integer.parseInt(tenantStr);
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
IPage<SysUser> pageList = sysUserDepartService.getUserInformation(tenantId, departId,roleId, keyword, pageSize, pageNo);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户离职(新增代理人和用户状态变更操作)【低代码应用专用接口】
|
||||
* @param sysUserAgent
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/userQuitAgent")
|
||||
public Result<String> userQuitAgent(@RequestBody SysUserAgent sysUserAgent){
|
||||
//判断id是否为空
|
||||
if(oConvertUtils.isNotEmpty(sysUserAgent.getId())){
|
||||
sysUserAgentService.updateById(sysUserAgent);
|
||||
}else{
|
||||
sysUserAgentService.save(sysUserAgent);
|
||||
}
|
||||
sysUserService.userQuit(sysUserAgent.getUserName());
|
||||
return Result.ok("离职成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取被逻辑删除的用户列表,无分页【低代码应用专用接口】
|
||||
*
|
||||
* @return List<SysUser>
|
||||
*/
|
||||
@GetMapping("/getQuitList")
|
||||
public Result<List<SysUser>> getQuitList(HttpServletRequest req) {
|
||||
Integer tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(req),0);
|
||||
List<SysUser> quitList = sysUserService.getQuitList(tenantId);
|
||||
if (null != quitList && quitList.size() > 0) {
|
||||
// 批量查询用户的所属部门
|
||||
// step.1 先拿到全部的 userIds
|
||||
List<String> userIds = quitList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
// step.2 通过 userIds,一次性查询用户的所属部门名字
|
||||
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
quitList.forEach(item -> item.setOrgCode(useDepNames.get(item.getId())));
|
||||
}
|
||||
return Result.ok(quitList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新刪除状态和离职状态【低代码应用专用接口】
|
||||
* @param jsonObject
|
||||
* @return Result<String>
|
||||
*/
|
||||
@PutMapping("/putCancelQuit")
|
||||
public Result<String> putCancelQuit(@RequestBody JSONObject jsonObject, HttpServletRequest request){
|
||||
String userIds = jsonObject.getString("userIds");
|
||||
String usernames = jsonObject.getString("usernames");
|
||||
Integer tenantId = oConvertUtils.getInt(TokenUtils.getTenantIdByRequest(request),0);
|
||||
//将状态改成未删除
|
||||
if (StringUtils.isNotBlank(userIds)) {
|
||||
userTenantService.putCancelQuit(Arrays.asList(userIds.split(SymbolConstant.COMMA)),tenantId);
|
||||
}
|
||||
if(StringUtils.isNotEmpty(usernames)){
|
||||
//根据用户名删除代理人
|
||||
LambdaQueryWrapper<SysUserAgent> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysUserAgent::getUserName,Arrays.asList(usernames.split(SymbolConstant.COMMA)));
|
||||
sysUserAgentService.remove(query);
|
||||
}
|
||||
return Result.ok("取消离职成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户信息(vue3用户设置专用)【低代码应用专用接口】
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/login/setting/getUserData")
|
||||
public Result<SysUser> getUserData(HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
SysUser user = sysUserService.getUserByName(username);
|
||||
if(user==null) {
|
||||
return Result.error("未找到该用户数据");
|
||||
}
|
||||
if(oConvertUtils.isNotEmpty(user.getPost())){
|
||||
String post = user.getPost();
|
||||
LambdaQueryWrapper<SysPosition> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysPosition::getCode,Arrays.asList(post.split(SymbolConstant.COMMA)));
|
||||
queryWrapper.select(SysPosition::getName);
|
||||
List<SysPosition> sysPositionList = sysPositionService.list(queryWrapper);
|
||||
StringBuilder nameBuilder = new StringBuilder();
|
||||
String verticalBar = " | ";
|
||||
for (SysPosition sysPosition:sysPositionList){
|
||||
nameBuilder.append(sysPosition.getName()).append(verticalBar);
|
||||
}
|
||||
String names = nameBuilder.toString();
|
||||
if(oConvertUtils.isNotEmpty(names)){
|
||||
names = names.substring(0,names.lastIndexOf(verticalBar));
|
||||
user.setPostText(names);
|
||||
}
|
||||
}
|
||||
return Result.ok(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户编辑(vue3用户设置专用)【低代码应用专用接口】
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/login/setting/userEdit")
|
||||
@RequiresPermissions("system:user:setting:edit")
|
||||
public Result<String> userEdit(@RequestBody SysUser sysUser, HttpServletRequest request) {
|
||||
String username = JwtUtil.getUserNameByToken(request);
|
||||
SysUser user = sysUserService.getById(sysUser.getId());
|
||||
if(user==null) {
|
||||
return Result.error("未找到该用户数据");
|
||||
}
|
||||
if(!username.equals(user.getUsername())){
|
||||
return Result.error("只能修改自己的数据");
|
||||
}
|
||||
sysUserService.updateById(sysUser);
|
||||
return Result.ok("更新个人信息成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量修改 【low-app】
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/batchEditUsers")
|
||||
public Result<SysUser> batchEditUsers(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
try {
|
||||
sysUserService.batchEditUsers(jsonObject);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("操作成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据关键词搜索部门和用户【low-app】
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/searchByKeyword")
|
||||
public Result<DepartAndUserInfo> searchByKeyword(@RequestParam(name="keyword",required=false) String keyword) {
|
||||
DepartAndUserInfo info = sysUserService.searchByKeyword(keyword);
|
||||
return Result.ok(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑部门前获取部门相关信息 【low-app】
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getUpdateDepartInfo")
|
||||
public Result<UpdateDepartInfo> getUpdateDepartInfo(@RequestParam(name="id",required=false) String id) {
|
||||
UpdateDepartInfo info = sysUserService.getUpdateDepartInfo(id);
|
||||
return Result.ok(info);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑部门 【low-app】
|
||||
* @param updateDepartInfo
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/doUpdateDepartInfo")
|
||||
public Result<?> doUpdateDepartInfo(@RequestBody UpdateDepartInfo updateDepartInfo) {
|
||||
sysUserService.doUpdateDepartInfo(updateDepartInfo);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置负责人 取消负责人
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/changeDepartChargePerson")
|
||||
public Result<?> changeDepartChargePerson(@RequestBody JSONObject json) {
|
||||
sysUserService.changeDepartChargePerson(json);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户下的用户【低代码应用专用接口】
|
||||
* @param sysUser
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/editTenantUser", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> editTenantUser(@RequestBody SysUser sysUser,HttpServletRequest req){
|
||||
Result<String> result = new Result<>();
|
||||
String tenantId = TokenUtils.getTenantIdByRequest(req);
|
||||
if(oConvertUtils.isEmpty(tenantId)){
|
||||
return result.error500("无权修改他人信息!");
|
||||
}
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getTenantId,Integer.valueOf(tenantId));
|
||||
query.eq(SysUserTenant::getUserId,sysUser.getId());
|
||||
SysUserTenant one = userTenantService.getOne(query);
|
||||
if(null == one){
|
||||
return result.error500("非当前租户下的用户,不允许修改!");
|
||||
}
|
||||
String departs = req.getParameter("selecteddeparts");
|
||||
String roles = req.getParameter("selectedroles");
|
||||
sysUserService.editTenantUser(sysUser,tenantId,departs,roles);
|
||||
return Result.ok("修改成功");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xkcoding.justauth.AuthRequestFactory;
|
||||
@ -12,16 +13,14 @@ import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.config.thirdapp.ThirdAppConfig;
|
||||
import org.jeecg.config.thirdapp.ThirdAppTypeItemVo;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.system.entity.SysThirdAccount;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.ThirdLoginModel;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.service.ISysThirdAccountService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
@ -31,10 +30,12 @@ import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -49,7 +50,8 @@ public class ThirdLoginController {
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private ISysThirdAccountService sysThirdAccountService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictService sysDictService;
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
@Autowired
|
||||
@ -91,8 +93,8 @@ public class ThirdLoginController {
|
||||
//判断有没有这个人
|
||||
//update-begin-author:wangshuai date:20201118 for:修改成查询第三方账户表
|
||||
LambdaQueryWrapper<SysThirdAccount> query = new LambdaQueryWrapper<SysThirdAccount>();
|
||||
query.eq(SysThirdAccount::getThirdUserUuid, uuid);
|
||||
query.eq(SysThirdAccount::getThirdType, source);
|
||||
query.and(q -> q.eq(SysThirdAccount::getThirdUserUuid, uuid).or().eq(SysThirdAccount::getThirdUserId, uuid));
|
||||
List<SysThirdAccount> thridList = sysThirdAccountService.list(query);
|
||||
SysThirdAccount user = null;
|
||||
if(thridList==null || thridList.size()==0) {
|
||||
@ -235,8 +237,12 @@ public class ThirdLoginController {
|
||||
}
|
||||
//update-end-author:wangshuai date:20201118 for:如果真实姓名和头像不存在就取第三方登录的
|
||||
JSONObject obj = new JSONObject();
|
||||
//TODO 第三方登确定登录租户和部门逻辑
|
||||
|
||||
//用户登录信息
|
||||
obj.put("userInfo", sysUser);
|
||||
//获取字典缓存【解决 #jeecg-boot/issues/3998】
|
||||
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
|
||||
//token 信息
|
||||
obj.put("token", token);
|
||||
result.setResult(obj);
|
||||
@ -293,7 +299,7 @@ public class ThirdLoginController {
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping("/oauth2/{source}/login")
|
||||
public String oauth2LoginCallback(@PathVariable("source") String source, @RequestParam("state") String state, HttpServletResponse response) throws Exception {
|
||||
public String oauth2LoginCallback(@PathVariable("source") String source, @RequestParam("state") String state, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
||||
String url;
|
||||
if (ThirdAppConfig.WECHAT_ENTERPRISE.equalsIgnoreCase(source)) {
|
||||
ThirdAppTypeItemVo config = thirdAppConfig.getWechatEnterprise();
|
||||
@ -303,7 +309,7 @@ public class ThirdLoginController {
|
||||
// 企业的CorpID
|
||||
builder.append("?appid=").append(config.getClientId());
|
||||
// 授权后重定向的回调链接地址,请使用urlencode对链接进行处理
|
||||
String redirectUri = RestUtil.getBaseUrl() + "/sys/thirdLogin/oauth2/wechat_enterprise/callback";
|
||||
String redirectUri = CommonUtils.getBaseUrl(request) + "/sys/thirdLogin/oauth2/wechat_enterprise/callback";
|
||||
builder.append("&redirect_uri=").append(URLEncoder.encode(redirectUri, "UTF-8"));
|
||||
// 返回类型,此时固定为:code
|
||||
builder.append("&response_type=code");
|
||||
@ -322,7 +328,7 @@ public class ThirdLoginController {
|
||||
builder.append("https://login.dingtalk.com/oauth2/auth");
|
||||
// 授权通过/拒绝后回调地址。
|
||||
// 注意 需要与注册应用时登记的域名保持一致。
|
||||
String redirectUri = RestUtil.getBaseUrl() + "/sys/thirdLogin/oauth2/dingtalk/callback";
|
||||
String redirectUri = CommonUtils.getBaseUrl(request) + "/sys/thirdLogin/oauth2/dingtalk/callback";
|
||||
builder.append("?redirect_uri=").append(URLEncoder.encode(redirectUri, "UTF-8"));
|
||||
// 固定值为code。
|
||||
// 授权通过后返回authCode。
|
||||
|
||||
@ -162,4 +162,7 @@ public class SysAnnouncement implements Serializable {
|
||||
* 发送记录ID
|
||||
*/
|
||||
private transient String sendId;
|
||||
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
}
|
||||
|
||||
@ -50,6 +50,9 @@ public class SysCategory implements Serializable,Comparable<SysCategory>{
|
||||
@Excel(name = "是否有子节点(1:有)", width = 15)
|
||||
private java.lang.String hasChild;
|
||||
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
@Override
|
||||
public int compareTo(SysCategory o) {
|
||||
//比较条件我们定的是按照code的长度升序
|
||||
|
||||
@ -117,4 +117,8 @@ public class SysDataSource {
|
||||
@Excel(name = "所属部门", width = 15)
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
|
||||
/**租户ID*/
|
||||
@ApiModelProperty(value = "租户ID")
|
||||
private java.lang.Integer tenantId;
|
||||
}
|
||||
|
||||
@ -86,6 +86,11 @@ public class SysDepart implements Serializable {
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
/**是否有叶子节点: 1是0否*/
|
||||
private Integer izLeaf;
|
||||
|
||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段负责人ids和旧的负责人ids
|
||||
/**部门负责人的ids*/
|
||||
@ -130,6 +135,7 @@ public class SysDepart implements Serializable {
|
||||
Objects.equals(createBy, depart.createBy) &&
|
||||
Objects.equals(createTime, depart.createTime) &&
|
||||
Objects.equals(updateBy, depart.updateBy) &&
|
||||
Objects.equals(tenantId, depart.tenantId) &&
|
||||
Objects.equals(updateTime, depart.updateTime);
|
||||
}
|
||||
|
||||
@ -138,10 +144,9 @@ public class SysDepart implements Serializable {
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
|
||||
return Objects.hash(super.hashCode(), id, parentId, departName,
|
||||
departNameEn, departNameAbbr, departOrder, description,orgCategory,
|
||||
orgType, orgCode, mobile, fax, address, memo, status,
|
||||
delFlag, createBy, createTime, updateBy, updateTime);
|
||||
delFlag, createBy, createTime, updateBy, updateTime, tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,5 +81,10 @@ public class SysDict implements Serializable {
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
/** 关联的低代码应用ID */
|
||||
private java.lang.String lowAppId;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@ -9,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import java.util.Date;
|
||||
@ -40,6 +42,7 @@ public class SysFiles {
|
||||
private String url;
|
||||
/**创建人登录名称*/
|
||||
@Excel(name = "创建人登录名称", width = 15)
|
||||
@Dict(dicCode = "username",dicText = "realname",dictTable = "sys_user")
|
||||
@ApiModelProperty(value = "创建人登录名称")
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@ -118,4 +121,22 @@ public class SysFiles {
|
||||
@Excel(name = "删除状态(0-正常,1-删除至回收站)", width = 15)
|
||||
@ApiModelProperty(value = "删除状态(0-正常,1-删除至回收站)")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 文件表不存在的字段:用户数据集合
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
private String userData;
|
||||
|
||||
/**
|
||||
* 文件表不存在的字段:用户真实姓名
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
private String realname;
|
||||
|
||||
/**
|
||||
* 文件表不存在的字段:压缩名称
|
||||
*/
|
||||
@TableField(exist=false)
|
||||
private String zipName;
|
||||
}
|
||||
|
||||
@ -109,4 +109,9 @@ public class SysLog implements Serializable {
|
||||
@Dict(dicCode = "operate_type")
|
||||
private Integer operateType;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private Integer tenantId;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,59 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 产品包菜单关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_tenant_pack_perms")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="sys_tenant_pack_perms对象", description="产品包菜单关系表")
|
||||
public class SysPackPermission implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键编号*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键编号")
|
||||
private String id;
|
||||
/**租户产品包名称*/
|
||||
@Excel(name = "租户产品包名称", width = 15)
|
||||
@ApiModelProperty(value = "租户产品包名称")
|
||||
private String packId;
|
||||
/**菜单id*/
|
||||
@Excel(name = "菜单id", width = 15)
|
||||
@ApiModelProperty(value = "菜单id")
|
||||
private String permissionId;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**创建时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**更新时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
}
|
||||
@ -85,4 +85,8 @@ public class SysPosition {
|
||||
*/
|
||||
@ApiModelProperty(value = "组织机构编码")
|
||||
private java.lang.String sysOrgCode;
|
||||
|
||||
/**租户ID*/
|
||||
@ApiModelProperty(value = "租户ID")
|
||||
private java.lang.Integer tenantId;
|
||||
}
|
||||
|
||||
@ -78,5 +78,6 @@ public class SysRole implements Serializable {
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
@ -62,4 +63,74 @@ public class SysTenant implements Serializable {
|
||||
@Dict(dicCode = "tenant_status")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 所属行业
|
||||
*/
|
||||
@Dict(dicCode = "trade")
|
||||
private String trade;
|
||||
|
||||
/**
|
||||
* 公司规模
|
||||
*/
|
||||
@Dict(dicCode = "company_size")
|
||||
private String companySize;
|
||||
|
||||
/**
|
||||
* 公司地址
|
||||
*/
|
||||
private String companyAddress;
|
||||
|
||||
/**
|
||||
* 公司logo
|
||||
*/
|
||||
private String companyLogo;
|
||||
|
||||
/**
|
||||
* 门牌号
|
||||
*/
|
||||
private String houseNumber;
|
||||
|
||||
/**
|
||||
* 工作地点
|
||||
*/
|
||||
private String workPlace;
|
||||
|
||||
/**
|
||||
* 二级域名(暂时无用,预留字段)
|
||||
*/
|
||||
private String secondaryDomain;
|
||||
|
||||
/**
|
||||
* 登录背景图片(暂时无用,预留字段)
|
||||
*/
|
||||
private String loginBkgdImg;
|
||||
|
||||
/**
|
||||
* 职级
|
||||
*/
|
||||
@Dict(dicCode = "company_rank")
|
||||
private String position;
|
||||
|
||||
/**
|
||||
* 部门
|
||||
*/
|
||||
@Dict(dicCode = "company_department")
|
||||
private String department;
|
||||
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
/**更新人登录名称*/
|
||||
private String updateBy;
|
||||
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 允许申请管理员 1允许 0不允许
|
||||
*/
|
||||
private Integer applyStatus;
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,87 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 租户产品包
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_tenant_pack")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="sys_tenant_pack对象", description="租户产品包")
|
||||
public class SysTenantPack implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
/**租户id*/
|
||||
@Excel(name = "租户id", width = 15)
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
/**产品包名*/
|
||||
@Excel(name = "产品包名", width = 15)
|
||||
@ApiModelProperty(value = "产品包名")
|
||||
private String packName;
|
||||
/**开启状态(0 未开启 1开启)*/
|
||||
@Excel(name = "开启状态(0 未开启 1开启)", width = 15)
|
||||
@ApiModelProperty(value = "开启状态(0 未开启 1开启)")
|
||||
private String status;
|
||||
/**备注*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private String remarks;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**创建时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**更新时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**菜单id 临时字段用于新增编辑菜单id传递*/
|
||||
@TableField(exist = false)
|
||||
private String permissionIds;
|
||||
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String packCode;
|
||||
|
||||
public SysTenantPack(){
|
||||
|
||||
}
|
||||
|
||||
public SysTenantPack(Integer tenantId, String packName, String packCode){
|
||||
this.tenantId = tenantId;
|
||||
this.packCode = packCode;
|
||||
this.packName = packName;
|
||||
this.status = "1";
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,93 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Description: 租户产品包用户关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-02-16
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_tenant_pack_user")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="sys_tenant_pack_user对象", description="租户产品包用户关系表")
|
||||
public class SysTenantPackUser implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**租户产品包ID*/
|
||||
@Excel(name = "租户产品包ID", width = 15)
|
||||
@ApiModelProperty(value = "租户产品包ID")
|
||||
private java.lang.String packId;
|
||||
/**用户ID*/
|
||||
@Excel(name = "用户ID", width = 15)
|
||||
@ApiModelProperty(value = "用户ID")
|
||||
private java.lang.String userId;
|
||||
/**租户ID*/
|
||||
@Excel(name = "租户ID", width = 15)
|
||||
@ApiModelProperty(value = "租户ID")
|
||||
private java.lang.Integer tenantId;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新时间*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
private transient String realname;
|
||||
|
||||
private transient String packName;
|
||||
|
||||
private transient String packCode;
|
||||
|
||||
/**
|
||||
* 状态 正常状态1 申请状态0
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
public SysTenantPackUser(){
|
||||
|
||||
}
|
||||
public SysTenantPackUser(Integer tenantId, String packId, String userId) {
|
||||
this.packId = packId;
|
||||
this.userId = userId;
|
||||
this.tenantId = tenantId;
|
||||
this.status = 1;
|
||||
}
|
||||
|
||||
public SysTenantPackUser(SysTenantPackUser param, String userId, String realname) {
|
||||
this.userId = userId;
|
||||
this.realname = realname;
|
||||
this.packId = param.getPackId();
|
||||
this.tenantId = param.getTenantId();
|
||||
this.packName = param.getPackName();
|
||||
this.status = 1;
|
||||
}
|
||||
}
|
||||
@ -4,7 +4,6 @@ import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
@ -99,9 +98,13 @@ public class SysUser implements Serializable {
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 部门code(当前选择登录部门)
|
||||
* 登录选择部门编码
|
||||
*/
|
||||
private String orgCode;
|
||||
/**
|
||||
* 登录选择租户ID
|
||||
*/
|
||||
private Integer loginTenantId;
|
||||
|
||||
/**部门名称*/
|
||||
private transient String orgCodeTxt;
|
||||
@ -177,8 +180,9 @@ public class SysUser implements Serializable {
|
||||
private String departIds;
|
||||
|
||||
/**
|
||||
* 多租户id配置,编辑用户的时候设置
|
||||
* 多租户ids临时用,不持久化数据库(数据库字段不存在)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String relTenantIds;
|
||||
|
||||
/**设备id uniapp推送用*/
|
||||
@ -189,4 +193,15 @@ public class SysUser implements Serializable {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String homePath;
|
||||
|
||||
/**
|
||||
* 职位名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String postText;
|
||||
|
||||
/**
|
||||
* 流程状态
|
||||
*/
|
||||
private String bpmStatus;
|
||||
}
|
||||
|
||||
@ -36,7 +36,10 @@ public class SysUserRole implements Serializable {
|
||||
* 角色id
|
||||
*/
|
||||
private String roleId;
|
||||
|
||||
|
||||
/**租户ID*/
|
||||
private java.lang.Integer tenantId;
|
||||
|
||||
public SysUserRole() {
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: sys_user_tenant_relation
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_user_tenant")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="sys_user_tenant对象", description="sys_user_tenant")
|
||||
public class SysUserTenant implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
/**用户id*/
|
||||
@Excel(name = "用户id", width = 15)
|
||||
@ApiModelProperty(value = "用户id")
|
||||
private String userId;
|
||||
/**租户id*/
|
||||
@Excel(name = "租户id", width = 15)
|
||||
@ApiModelProperty(value = "租户id")
|
||||
private Integer tenantId;
|
||||
/**状态(1 正常 2 冻结 3 待审核 4 拒绝)*/
|
||||
@Excel(name = "状态(1 正常 2 冻结 3 待审核 4 拒绝)", width = 15)
|
||||
@ApiModelProperty(value = "状态(1 正常 2 冻结 3 待审核 4 拒绝)")
|
||||
private String status;
|
||||
/**创建人登录名称*/
|
||||
@ApiModelProperty(value = "创建人登录名称")
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private Date createTime;
|
||||
/**更新人登录名称*/
|
||||
@ApiModelProperty(value = "更新人登录名称")
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private Date updateTime;
|
||||
}
|
||||
@ -1,7 +1,10 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
@ -90,4 +93,29 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
|
||||
*/
|
||||
@Select("SELECT * FROM sys_depart where del_flag ='0' AND parent_id = #{parentId,jdbcType=VARCHAR}")
|
||||
List<SysDepart> queryDeptByPid(@Param("parentId")String parentId);
|
||||
|
||||
/**
|
||||
* 通过父级id和租户id查询部门
|
||||
* @param parentId
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<SysDepart> queryBookDepTreeSync(@Param("parentId") String parentId, @Param("tenantId") Integer tenantId, @Param("departName") String departName);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
@Select("SELECT * FROM sys_depart where id = #{id,jdbcType=VARCHAR}")
|
||||
SysDepart getDepartById(@Param("id") String id);
|
||||
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<SysDepart> getMaxCodeDepart(@Param("page") Page<SysDepart> page, @Param("parentId") String parentId);
|
||||
|
||||
/**
|
||||
* 修改部门状态字段: 是否子节点
|
||||
* @param id 部门id
|
||||
* @param leaf 叶子节点
|
||||
* @return int
|
||||
*/
|
||||
@Update("UPDATE sys_depart SET iz_leaf=#{leaf} WHERE id = #{id}")
|
||||
int setMainLeaf(@Param("id") String id, @Param("leaf") Integer leaf);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -261,6 +262,14 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* @param codeValues 存储字段值 作为查询条件in
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
List<DictModel> queryTableDictByKeysAndFilterSql(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql, @Param("codeValues") List<String> codeValues);
|
||||
|
||||
/**
|
||||
* 根据应用id获取字典列表和详情
|
||||
* @param lowAppId
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
@InterceptorIgnore(tenantLine = "true")
|
||||
List<SysDict> getDictListByLowAppId(@Param("lowAppId") String lowAppId, @Param("tenantId") Integer tenantId);
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysPackPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 产品包菜单关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysPackPermissionMapper extends BaseMapper<SysPackPermission> {
|
||||
|
||||
/**
|
||||
* 通过产品包id获取菜单id
|
||||
* @param packId
|
||||
* @return
|
||||
*/
|
||||
List<String> getPermissionsByPackId(@Param("packId") String packId);
|
||||
}
|
||||
@ -1,7 +1,16 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackUser;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackUserCount;
|
||||
import org.jeecg.modules.system.vo.tenant.UserDepart;
|
||||
import org.jeecg.modules.system.vo.tenant.UserPosition;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 租户mapper接口
|
||||
@ -9,4 +18,77 @@ import org.jeecg.modules.system.entity.SysTenant;
|
||||
*/
|
||||
public interface SysTenantMapper extends BaseMapper<SysTenant> {
|
||||
|
||||
/**
|
||||
* 获取最大值id
|
||||
*/
|
||||
@Select("select MAX(id) id FROM sys_tenant")
|
||||
int getMaxTenantId();
|
||||
|
||||
/**
|
||||
* 获取租户回收站的数据假删除
|
||||
* @param page
|
||||
* @param sysTenant
|
||||
* @return
|
||||
*/
|
||||
List<SysTenant> getRecycleBinPageList(@Param("page") Page<SysTenant> page, @Param("sysTenant") SysTenant sysTenant);
|
||||
|
||||
/**
|
||||
* 彻底删除租户
|
||||
* @param tenantId
|
||||
*/
|
||||
Integer deleteByTenantId(@Param("tenantIds") List<Integer> tenantId);
|
||||
|
||||
/**
|
||||
* 租户还原
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
Integer revertTenantLogic(@Param("tenantIds")List<Integer> list);
|
||||
|
||||
/**
|
||||
* 用于统计 租户产品包的人员数量
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<TenantPackUserCount> queryTenantPackUserCount(@Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 查询人员是不是租户产品包的 超级管理员
|
||||
* @param tenantId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Integer querySuperAdminCount(@Param("tenantId") Integer tenantId, @Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* 查询人员的产品包编码
|
||||
* @param tenantId
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<String> queryUserPackCode(@Param("tenantId") Integer tenantId, @Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* 查询产品包关联的用户列表
|
||||
* @param tenantId
|
||||
* @param packId
|
||||
* @param packUserStatus
|
||||
* @return
|
||||
*/
|
||||
List<TenantPackUser> queryPackUserList(@Param("tenantId") Integer tenantId, @Param("packId") String packId, @Param("packUserStatus") Integer packUserStatus);
|
||||
|
||||
|
||||
/**
|
||||
* 根据用户ID 查询部门
|
||||
* @param userIdList
|
||||
* @return
|
||||
*/
|
||||
List<UserDepart> queryUserDepartList(@Param("userIdList") List<String> userIdList);
|
||||
|
||||
/**
|
||||
* 根据用户ID 查询职位
|
||||
* @param userIdList
|
||||
* @return
|
||||
*/
|
||||
List<UserPosition> queryUserPositionList(@Param("userIdList") List<String> userIdList);
|
||||
}
|
||||
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysTenantPack;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 租户产品包
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysTenantPackMapper extends BaseMapper<SysTenantPack> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.entity.SysTenantPackUser;
|
||||
|
||||
/**
|
||||
* @Description: 租户产品包用户关系
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2023-02-16
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysTenantPackUserMapper extends BaseMapper<SysTenantPackUser> {
|
||||
|
||||
}
|
||||
@ -47,4 +47,37 @@ public interface SysUserDepartMapper extends BaseMapper<SysUserDepart>{
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getUserInformation(Page<SysUser> page, @Param("orgCode") String orgCode, @Param("keyword") String keyword,@Param("userId") String userId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param page
|
||||
* @param orgCode
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getProcessUserList(Page<SysUser> page, @Param("orgCode") String orgCode, @Param("keyword") String keyword, @Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 获取租户下的部门通过前台传过来的部门id
|
||||
* @param departIds
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<String> getTenantDepart(@Param("departIds") List<String> departIds, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据当前租户和用户id查询用户部门数据
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<SysUserDepart> getTenantUserDepart(@Param("userId") String userId, @Param("tenantId") String tenantId);
|
||||
|
||||
/**
|
||||
* 根据用户id和租户id,删除用户部门数据
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
*/
|
||||
void deleteUserDepart(@Param("userId") String userId, @Param("tenantId") String tenantId);
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Constants;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.vo.SysUserDepVo;
|
||||
|
||||
@ -67,7 +67,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @param username
|
||||
* @param orgCode
|
||||
*/
|
||||
void updateUserDepart(@Param("username") String username,@Param("orgCode") String orgCode);
|
||||
void updateUserDepart(@Param("username") String username,@Param("orgCode") String orgCode, @Param("loginTenantId") Integer loginTenantId);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户信息
|
||||
@ -157,4 +157,28 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryByDepIds(@Param("departIds")List<String> departIds,@Param("username") String username);
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param page
|
||||
* @param roleId
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> selectUserListByRoleId(Page<SysUser> page, @Param("roleId") String roleId, @Param("keyword") String keyword, @Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 更新刪除状态和离职状态
|
||||
* @param userIds 存放用户id集合
|
||||
* @param sysUser
|
||||
* @return boolean
|
||||
*/
|
||||
void updateStatusAndFlag(@Param("userIds") List<String> userIds, @Param("sysUser") SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 获取租户下的离职列表信息
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> getTenantQuitList(@Param("tenantId") Integer tenantId);
|
||||
}
|
||||
|
||||
@ -0,0 +1,99 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserTenant;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.vo.SysUserTenantVo;
|
||||
|
||||
/**
|
||||
* @Description: sys_user_tenant_relation
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysUserTenantMapper extends BaseMapper<SysUserTenant> {
|
||||
|
||||
/**
|
||||
* 通过租户id获取数据
|
||||
* @param page
|
||||
* @param userTenantId
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> getPageUserList(@Param("page") Page<SysUser> page,@Param("userTenantId") Integer userTenantId,@Param("user") SysUser user);
|
||||
|
||||
/**
|
||||
* 根据租户id获取用户ids
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<String> getUserIdsByTenantId(@Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 通过用户id获取租户ids
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<Integer> getTenantIdsByUserId(@Param("userId") String userId);
|
||||
|
||||
|
||||
|
||||
//==============================================================================================================================
|
||||
/**
|
||||
* 通过用户id获取租户列表
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<SysUserTenantVo> getTenantListByUserId(@Param("userId") String userId, @Param("userTenantStatus") List<String> userTenantStatus);
|
||||
|
||||
/**
|
||||
* 通过状态、当前登录人的用户名,租户id,查询用户id
|
||||
* @param tenantId
|
||||
* @param statusList
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
List<String> getUserIdsByCreateBy(@Param("tenantId") Integer tenantId, @Param("userTenantStatus") List<String> statusList, @Param("username") String username);
|
||||
|
||||
/**
|
||||
* 联查用户和租户审核状态
|
||||
* @param page
|
||||
* @param status
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<SysUserTenantVo> getUserTenantPageList(@Param("page") Page<SysUserTenantVo> page, @Param("status") List<String> status, @Param("user") SysUser user, @Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 根据用户id获取租户id,没有状态值(如获取租户已经存在,只不过是被拒绝或者审批中)
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<Integer> getTenantIdsNoStatus(@Param("userId") String userId);
|
||||
//==============================================================================================================================
|
||||
|
||||
/**
|
||||
* 统计一个人创建了多少个租户
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Integer countCreateTenantNum(String userId);
|
||||
|
||||
/**
|
||||
* 取消离职
|
||||
* @param userIds
|
||||
* @param tenantId
|
||||
*/
|
||||
void putCancelQuit(@Param("userIds") List<String> userIds, @Param("tenantId") Integer tenantId);
|
||||
|
||||
/**
|
||||
* 判断当前用户是否已在该租户下面
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
*/
|
||||
Integer userTenantIzExist(@Param("userId") String userId, @Param("tenantId") int tenantId);
|
||||
}
|
||||
@ -72,7 +72,7 @@
|
||||
<select id="queryUserAvatarList" resultType="org.jeecg.modules.system.vo.UserAvatar">
|
||||
select id, avatar, realname from sys_user
|
||||
WHERE id IN
|
||||
<foreach item="id" collection="idSet" open="(" separator="or" close=")">
|
||||
<foreach item="id" collection="idSet" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
@ -51,4 +51,44 @@
|
||||
<select id="queryCompByOrgCode" resultType="org.jeecg.modules.system.entity.SysDepart">
|
||||
select * from sys_depart where del_flag = '0' and org_category='1' and org_code= #{orgCode,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<!--通过父级id和租户id查询部门-->
|
||||
<select id="queryBookDepTreeSync" resultType="org.jeecg.modules.system.entity.SysDepart">
|
||||
SELECT * FROM sys_depart
|
||||
WHERE
|
||||
del_flag = '0'
|
||||
<if test="tenantId != null">
|
||||
AND tenant_id = #{tenantId}
|
||||
</if>
|
||||
<choose>
|
||||
<when test="parentId != null and parentId != ''">
|
||||
AND parent_id = #{parentId}
|
||||
</when>
|
||||
<otherwise>
|
||||
<if test="departName == null or departName == ''">
|
||||
AND (parent_id is null or parent_id='')
|
||||
</if>
|
||||
</otherwise>
|
||||
</choose>
|
||||
<if test="departName != null and departName != ''">
|
||||
<bind name="bindName" value="'%'+departName+'%'"/>
|
||||
AND depart_name LIKE #{bindName}
|
||||
</if>
|
||||
ORDER BY depart_order DESC
|
||||
</select>
|
||||
|
||||
<!--获取部门orgCode最大值的部门信息-->
|
||||
<select id="getMaxCodeDepart" resultType="org.jeecg.modules.system.entity.SysDepart">
|
||||
SELECT * FROM sys_depart
|
||||
WHERE
|
||||
<choose>
|
||||
<when test="parentId != null and parentId != ''">
|
||||
parent_id = #{parentId}
|
||||
</when>
|
||||
<otherwise>
|
||||
parent_id IS NULL OR parent_id=''
|
||||
</otherwise>
|
||||
</choose>
|
||||
ORDER BY org_code DESC
|
||||
</select>
|
||||
</mapper>
|
||||
@ -6,7 +6,7 @@
|
||||
<select id="queryDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select s.item_value as "value",s.item_text as "text" from sys_dict_item s
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
order by s.sort_order asc
|
||||
order by s.sort_order asc, s.create_time DESC;
|
||||
</select>
|
||||
|
||||
<!-- 通过字典code获取有效的字典数据项 -->
|
||||
@ -14,7 +14,7 @@
|
||||
select s.item_value as "value",s.item_text as "text" from sys_dict_item s
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
and s.status = 1
|
||||
order by s.sort_order asc
|
||||
order by s.sort_order asc, s.create_time DESC;
|
||||
</select>
|
||||
|
||||
<!-- 通过多个字典code获取字典数据 -->
|
||||
@ -155,7 +155,14 @@
|
||||
<if test="query!= null">
|
||||
1 = 1
|
||||
<foreach collection="query.entrySet()" item="value" index="key" >
|
||||
and ${key} LIKE #{value}
|
||||
<choose>
|
||||
<when test="key == 'tenant_id'">
|
||||
and tenant_id = #{value}
|
||||
</when>
|
||||
<otherwise>
|
||||
and ${key} LIKE #{value}
|
||||
</otherwise>
|
||||
</choose>
|
||||
</foreach>
|
||||
<!-- udapte-end-author:sunjianlei date:20220615 for: 【issues/3709】自定义树查询条件没有处理父ID,没有树状结构了 -->
|
||||
<choose>
|
||||
@ -214,6 +221,14 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--根据应用id获取字典列表和详情-->
|
||||
<select id="getDictListByLowAppId" resultType="org.jeecg.modules.system.entity.SysDict">
|
||||
select id,dict_name,dict_code from sys_dict
|
||||
where
|
||||
del_flag = 0
|
||||
and low_app_id = #{lowAppId}
|
||||
and tenant_id = #{tenantId}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysPackPermissionMapper">
|
||||
|
||||
<select id="getPermissionsByPackId" resultType="java.lang.String">
|
||||
select permission_id from sys_tenant_pack_perms
|
||||
where
|
||||
pack_id = #{packId}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -2,4 +2,111 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysTenantMapper">
|
||||
|
||||
<!--获取租户回收站的数据假删除-->
|
||||
<select id="getRecycleBinPageList" resultType="org.jeecg.modules.system.entity.SysTenant">
|
||||
SELECT id,name,company_logo,house_number,status FROM sys_tenant
|
||||
WHERE
|
||||
del_flag = 1
|
||||
<if test="sysTenant.name!='' and sysTenant.name!=null">
|
||||
<bind name="name" value="'%'+sysTenant.name+'%'"/>
|
||||
AND name like #{name}
|
||||
</if>
|
||||
<if test="sysTenant.houseNumber!='' and sysTenant.houseNumber!=null">
|
||||
<bind name="houseNumber" value="'%'+sysTenant.houseNumber+'%'"/>
|
||||
AND house_number like #{houseNumber}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--彻底删除租户信息-->
|
||||
<delete id="deleteByTenantId">
|
||||
DELETE FROM sys_tenant
|
||||
WHERE
|
||||
del_flag = 1
|
||||
AND id in
|
||||
<foreach collection="tenantIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!--租户还原-->
|
||||
<update id="revertTenantLogic">
|
||||
UPDATE sys_tenant set del_flag = 0
|
||||
WHERE
|
||||
del_flag = 1
|
||||
AND id in
|
||||
<foreach collection="tenantIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 用于统计 租户产品包的人员数量 -->
|
||||
<select id="queryTenantPackUserCount" resultType="org.jeecg.modules.system.vo.tenant.TenantPackUserCount">
|
||||
SELECT pack_code, count(*) as user_count FROM sys_tenant_pack a
|
||||
join sys_tenant_pack_user b on a.id = b.pack_id
|
||||
where a.tenant_id = #{tenantId}
|
||||
and a.pack_code in ('superAdmin', 'accountAdmin', 'appAdmin')
|
||||
and b.status = 1
|
||||
group by a.pack_code
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 查询人员的产品包编码 -->
|
||||
<select id="queryUserPackCode" resultType="java.lang.String">
|
||||
SELECT a.pack_code FROM sys_tenant_pack a
|
||||
join sys_tenant_pack_user b on a.id = b.pack_id
|
||||
where a.tenant_id = #{tenantId}
|
||||
and b.user_id = #{userId}
|
||||
and b.status = 1
|
||||
</select>
|
||||
|
||||
<!-- 查询人员是不是租户产品包的 超级管理员 -->
|
||||
<select id="querySuperAdminCount" resultType="java.lang.Integer">
|
||||
SELECT count(*) FROM sys_tenant_pack a
|
||||
join sys_tenant_pack_user b on a.id = b.pack_id
|
||||
where a.pack_code = 'superAdmin'
|
||||
and a.tenant_id = #{tenantId}
|
||||
and b.user_id = #{userId}
|
||||
and b.status = 1
|
||||
</select>
|
||||
|
||||
<!-- 查询产品包关联的用户列表 -->
|
||||
<select id="queryPackUserList" resultType="org.jeecg.modules.system.vo.tenant.TenantPackUser">
|
||||
SELECT c.id, c.username, c.realname, c.phone, c.avatar, a.pack_name, a.id as pack_id FROM sys_user c
|
||||
join sys_tenant_pack_user b on c.id = b.user_id
|
||||
join sys_tenant_pack a on a.id = b.pack_id
|
||||
where c.status = 1
|
||||
and c.del_flag = 0
|
||||
and b.status = #{packUserStatus}
|
||||
and a.tenant_id = #{tenantId}
|
||||
<if test="packId!='' and packId!=null">
|
||||
and a.id = #{packId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 根据用户ID 查询部门 -->
|
||||
<select id="queryUserDepartList" resultType="org.jeecg.modules.system.vo.tenant.UserDepart">
|
||||
SELECT c.id as user_id,a.depart_name FROM sys_user c
|
||||
join sys_user_depart b on c.id = b.user_id
|
||||
join sys_depart a on a.id = b.dep_id
|
||||
where c.status = 1 and c.del_flag = 0
|
||||
and c.id in
|
||||
<foreach collection="userIdList" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID 查询职位 -->
|
||||
<select id="queryUserPositionList" resultType="org.jeecg.modules.system.vo.tenant.UserPosition">
|
||||
SELECT c.id as user_id, name as position_name FROM sys_user c
|
||||
join sys_user_position b on c.id = b.user_id
|
||||
join sys_position a on a.code = b.position_code
|
||||
where c.status = 1 and c.del_flag = 0
|
||||
and c.id in
|
||||
<foreach collection="userIdList" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysTenantPackMapper">
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysTenantPackUserMapper">
|
||||
|
||||
</mapper>
|
||||
@ -54,4 +54,56 @@
|
||||
and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--获取用户信息(简版流程专用)-->
|
||||
<select id="getProcessUserList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select DISTINCT a.* from sys_user a
|
||||
left join sys_user_depart b on b.user_id = a.id
|
||||
left join sys_depart c on b.dep_id = c.id
|
||||
<bind name="bindOrgCode" value="orgCode+'%'"/>
|
||||
where
|
||||
a.del_flag = 0 and a.status = 1
|
||||
and c.org_code like #{bindOrgCode}
|
||||
and a.username!='_reserve_user_external'
|
||||
<if test="keyword!=null and keyword!=''">
|
||||
<bind name="bindKeyword" value="'%'+keyword+'%'"/>
|
||||
and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
|
||||
</if>
|
||||
<if test="tenantId!=null">
|
||||
and a.id in (
|
||||
select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--获取租户下的部门-通过前台传过来的部门id-->
|
||||
<select id="getTenantDepart" resultType="java.lang.String">
|
||||
select id from sys_depart
|
||||
where
|
||||
id in
|
||||
<foreach collection="departIds" item="departId" open="(" close=")" separator="," >
|
||||
#{departId}
|
||||
</foreach>
|
||||
and tenant_id = #{tenantId}
|
||||
</select>
|
||||
|
||||
<!--根据当前租户和用户id查询用户部门数据-->
|
||||
<select id="getTenantUserDepart" resultType="org.jeecg.modules.system.entity.SysUserDepart">
|
||||
select * from sys_user_depart
|
||||
where
|
||||
user_id = #{userId}
|
||||
and dep_id in(
|
||||
select id from sys_depart where tenant_id = #{tenantId}
|
||||
)
|
||||
</select>
|
||||
|
||||
<!--根据用户id和租户id,删除用户部门数据-->
|
||||
<delete id="deleteUserDepart">
|
||||
delete from sys_user_depart
|
||||
where
|
||||
user_id = #{userId}
|
||||
and dep_id in(
|
||||
select id from sys_depart where tenant_id = #{tenantId}
|
||||
)
|
||||
</delete>
|
||||
</mapper>
|
||||
@ -48,7 +48,18 @@
|
||||
|
||||
<!-- 修改用户部门code -->
|
||||
<update id="updateUserDepart">
|
||||
UPDATE sys_user SET org_code = #{orgCode} where username = #{username}
|
||||
UPDATE sys_user SET
|
||||
<if test="orgCode!=null and loginTenantId!=null">
|
||||
org_code = #{orgCode}
|
||||
,login_tenant_id = #{loginTenantId}
|
||||
</if>
|
||||
<if test="orgCode==null and loginTenantId!=null">
|
||||
login_tenant_id = #{loginTenantId}
|
||||
</if>
|
||||
<if test="orgCode!=null and loginTenantId==null">
|
||||
org_code = #{orgCode}
|
||||
</if>
|
||||
where username = #{username}
|
||||
</update>
|
||||
|
||||
<!-- 根据手机号查询 -->
|
||||
@ -182,4 +193,53 @@
|
||||
and username != #{username}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--根据角色查询用户-->
|
||||
<select id="selectUserListByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select DISTINCT a.* from sys_user a
|
||||
left join sys_user_role ur on ur.user_id = a.id
|
||||
where
|
||||
a.del_flag = 0 and a.status = 1
|
||||
and a.username!='_reserve_user_external'
|
||||
and ur.role_id=#{roleId}
|
||||
<if test="keyword!=null and keyword!=''">
|
||||
<bind name="bindKeyword" value="'%'+keyword+'%'"/>
|
||||
and (a.username like #{bindKeyword} or a.realname like #{bindKeyword})
|
||||
</if>
|
||||
|
||||
<if test="tenantId!=null">
|
||||
and a.id in (
|
||||
select user_id from sys_user_tenant where tenant_id = #{tenantId} and status = '1'
|
||||
)
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--获取租户下的用户离职列表信息-->
|
||||
<select id="getTenantQuitList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select su.id,su.username,su.realname,su.sex from sys_user su
|
||||
join sys_user_tenant sut on sut.user_id = su.id and sut.status = '2'
|
||||
where
|
||||
su.status = 1
|
||||
and su.del_flag = 0
|
||||
<if test="tenantId != 0">
|
||||
and sut.tenant_id = #{tenantId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--更新刪除状态和离职状态-->
|
||||
<update id="updateStatusAndFlag">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
del_flag = 0,
|
||||
update_by = #{sysUser.updateBy},
|
||||
update_time = #{sysUser.updateTime},
|
||||
status = 1
|
||||
WHERE
|
||||
del_flag = 1
|
||||
AND id IN
|
||||
<foreach collection="userIds" item="userId" open="(" close=")" separator="," >
|
||||
#{userId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.jeecg.modules.system.mapper.SysUserTenantMapper">
|
||||
|
||||
<!-- 通过租户id获取数据 -->
|
||||
<select id="getPageUserList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
SELECT su.id,su.username,su.realname,su.sex,su.phone FROM sys_user su
|
||||
JOIN sys_user_tenant str ON str.user_id = su.id and str.status = '1'
|
||||
WHERE su.del_flag = 0
|
||||
<if test="userTenantId!=null">
|
||||
AND str.tenant_id = #{userTenantId}
|
||||
</if>
|
||||
<if test="user.username!='' and user.username!=null">
|
||||
<bind name="bindKeyword" value="'%'+user.username+'%'"/>
|
||||
AND su.username like #{bindKeyword}
|
||||
</if>
|
||||
<if test="user.realname!='' and user.realname!=null">
|
||||
<bind name="bindRealName" value="'%'+user.realname+'%'"/>
|
||||
AND su.realname like #{bindRealName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--根据租户id获取用户ids-->
|
||||
<select id="getUserIdsByTenantId" resultType="java.lang.String">
|
||||
SELECT user_id FROM sys_user_tenant
|
||||
WHERE
|
||||
status = '1'
|
||||
and
|
||||
tenant_id = #{tenantId}
|
||||
</select>
|
||||
|
||||
<!--通过用户id获取租户ids-->
|
||||
<select id="getTenantIdsByUserId" resultType="java.lang.Integer">
|
||||
SELECT tenant_id FROM sys_user_tenant
|
||||
WHERE status = '1'
|
||||
and user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!--通过用户id获取租户列表-->
|
||||
<select id="getTenantListByUserId" resultType="org.jeecg.modules.system.vo.SysUserTenantVo">
|
||||
SELECT st.id as tenantUserId,st.name,st.trade,st.house_number,st.create_by,sut.status as userTenantStatus
|
||||
FROM sys_user_tenant sut
|
||||
JOIN sys_tenant st ON sut.tenant_id = st.id
|
||||
WHERE st.status = 1
|
||||
AND st.del_flag = 0
|
||||
AND sut.user_id = #{userId}
|
||||
<if test="userTenantStatus!=null">
|
||||
AND sut.status in
|
||||
<foreach collection="userTenantStatus" index="index" item="status" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--通过状态、当前登录人的用户名,租户id,查询用户id-->
|
||||
<select id="getUserIdsByCreateBy" resultType="java.lang.String">
|
||||
SELECT sut.user_id
|
||||
FROM sys_user_tenant sut
|
||||
JOIN sys_tenant st on sut.tenant_id = st.id
|
||||
WHERE sut.tenant_id = #{tenantId}
|
||||
AND st.del_flag = 0
|
||||
<if test="userTenantStatus!=null">
|
||||
AND sut.status in
|
||||
<foreach collection="userTenantStatus" index="index" item="status" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--联查用户和租户审核状态-->
|
||||
<select id="getUserTenantPageList" resultType="org.jeecg.modules.system.vo.SysUserTenantVo">
|
||||
SELECT su.id,su.realname,su.username,su.email,su.phone,su.avatar,su.work_no,su.post,su.org_code,sut.status,st.create_by
|
||||
FROM sys_user_tenant sut
|
||||
LEFT JOIN sys_user su on sut.user_id = su.id
|
||||
JOIN sys_tenant st ON sut.tenant_id = st.id
|
||||
WHERE sut.tenant_id = #{tenantId}
|
||||
AND st.del_flag = 0
|
||||
<if test="user.createBy!='' and user.createBy!=null">
|
||||
AND st.create_by = #{user.createBy}
|
||||
</if>
|
||||
<if test="user.username!='' and user.username!=null">
|
||||
<bind name="bindUserName" value="'%'+user.username+'%'"/>
|
||||
AND su.username like #{bindUserName}
|
||||
</if>
|
||||
<if test="user.realname!='' and user.realname!=null">
|
||||
<bind name="bindRealName" value="'%'+user.realname+'%'"/>
|
||||
AND su.realname like #{bindRealName}
|
||||
</if>
|
||||
<if test="user.sex!='' and user.sex!=null">
|
||||
AND su.sex = #{user.sex}
|
||||
</if>
|
||||
AND sut.status in
|
||||
<foreach collection="status" index="index" item="status" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!--根据用户id获取租户id,没有状态-->
|
||||
<select id="getTenantIdsNoStatus" resultType="java.lang.Integer">
|
||||
SELECT tenant_id FROM sys_user_tenant
|
||||
WHERE
|
||||
user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 统计一个人创建了多少个租户 -->
|
||||
<select id="countCreateTenantNum" resultType="java.lang.Integer">
|
||||
select count(*) count from sys_tenant where create_by = #{userId} and del_flag = 0 and status = 1
|
||||
</select>
|
||||
|
||||
<!--判断当前用户是否已在该租户下面-->
|
||||
<select id="userTenantIzExist" resultType="java.lang.Integer">
|
||||
select count(*) count from sys_user_tenant
|
||||
where
|
||||
user_id = #{userId}
|
||||
and tenant_id = #{tenantId}
|
||||
</select>
|
||||
|
||||
<!--用户租户取消离职-->
|
||||
<update id="putCancelQuit">
|
||||
update sys_user_tenant set status='1'
|
||||
where
|
||||
tenant_id = #{tenantId}
|
||||
AND user_id in
|
||||
<foreach collection="userIds" index="index" item="userId" open="(" separator="," close=")">
|
||||
#{userId}
|
||||
</foreach>
|
||||
</update>
|
||||
</mapper>
|
||||
@ -113,6 +113,11 @@ public class SysDepartTreeModel implements Serializable{
|
||||
this.updateBy = sysDepart.getUpdateBy();
|
||||
this.updateTime = sysDepart.getUpdateTime();
|
||||
this.directorUserIds = sysDepart.getDirectorUserIds();
|
||||
if(0 == sysDepart.getIzLeaf()){
|
||||
this.isLeaf = false;
|
||||
}else{
|
||||
this.isLeaf = true;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getIsLeaf() {
|
||||
|
||||
@ -22,5 +22,7 @@ public class SysUserSysDepartModel {
|
||||
private String departId;
|
||||
private String departName;
|
||||
private String avatar;
|
||||
private String sex;
|
||||
private String birthday;
|
||||
|
||||
}
|
||||
|
||||
@ -2,6 +2,8 @@ package org.jeecg.modules.system.rule;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.jeecg.common.handler.IFillRuleHandler;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
@ -53,39 +55,42 @@ public class OrgCodeRule implements IFillRuleHandler {
|
||||
//如果是最高级,则查询出同级的org_code, 调用工具类生成编码并返回
|
||||
if (StringUtil.isNullOrEmpty(parentId)) {
|
||||
// 线判断数据库中的表是否为空,空则直接返回初始编码
|
||||
query1.eq(SysDepart::getParentId, "").or().isNull(SysDepart::getParentId);
|
||||
query1.orderByDesc(SysDepart::getOrgCode);
|
||||
departList = sysDepartService.list(query1);
|
||||
if (departList == null || departList.size() == 0) {
|
||||
//获取最大值code的部门信息
|
||||
//update-begin---author:wangshuai ---date:20230211 for:[QQYUN-4209]租户隔离下部门新建不了------------
|
||||
Page<SysDepart> page = new Page<>(1,1);
|
||||
IPage<SysDepart> pageList = sysDepartService.getMaxCodeDepart(page,"");
|
||||
List<SysDepart> records = pageList.getRecords();
|
||||
if (null==records || records.size()==0) {
|
||||
//update-end---author:wangshuai ---date:20230211 for:[QQYUN-4209]租户隔离下部门新建不了------------
|
||||
strArray[0] = YouBianCodeUtil.getNextYouBianCode(null);
|
||||
strArray[1] = "1";
|
||||
return strArray;
|
||||
} else {
|
||||
SysDepart depart = departList.get(0);
|
||||
SysDepart depart = records.get(0);
|
||||
oldOrgCode = depart.getOrgCode();
|
||||
orgType = depart.getOrgType();
|
||||
newOrgCode = YouBianCodeUtil.getNextYouBianCode(oldOrgCode);
|
||||
}
|
||||
} else {//反之则查询出所有同级的部门,获取结果后有两种情况,有同级和没有同级
|
||||
// 封装查询同级的条件
|
||||
query.eq(SysDepart::getParentId, parentId);
|
||||
// 降序排序
|
||||
query.orderByDesc(SysDepart::getOrgCode);
|
||||
// 查询出同级部门的集合
|
||||
List<SysDepart> parentList = sysDepartService.list(query);
|
||||
//获取自己部门最大值orgCode部门信息
|
||||
//update-begin---author:wangshuai ---date:20230211 for:[QQYUN-4209]租户隔离下部门新建不了------------
|
||||
Page<SysDepart> page = new Page<>(1,1);
|
||||
IPage<SysDepart> pageList = sysDepartService.getMaxCodeDepart(page,parentId);
|
||||
List<SysDepart> records = pageList.getRecords();
|
||||
// 查询出父级部门
|
||||
SysDepart depart = sysDepartService.getById(parentId);
|
||||
SysDepart depart = sysDepartService.getDepartById(parentId);
|
||||
//update-end---author:wangshuai ---date:20230211 for:[QQYUN-4209]租户隔离下部门新建不了------------
|
||||
// 获取父级部门的Code
|
||||
String parentCode = depart.getOrgCode();
|
||||
// 根据父级部门类型算出当前部门的类型
|
||||
orgType = String.valueOf(Integer.valueOf(depart.getOrgType()) + 1);
|
||||
// 处理同级部门为null的情况
|
||||
if (parentList == null || parentList.size() == 0) {
|
||||
if (null == records || records.size()==0) {
|
||||
// 直接生成当前的部门编码并返回
|
||||
newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, null);
|
||||
} else { //处理有同级部门的情况
|
||||
// 获取同级部门的编码,利用工具类
|
||||
String subCode = parentList.get(0).getOrgCode();
|
||||
String subCode = records.get(0).getOrgCode();
|
||||
// 返回生成的当前部门编码
|
||||
newOrgCode = YouBianCodeUtil.getSubYouBianCode(parentCode, subCode);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.system.security;
|
||||
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.security.AbstractQueryBlackListHandler;
|
||||
|
||||
@ -1,10 +1,14 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -159,4 +163,39 @@ public interface ISysDepartService extends IService<SysDepart>{
|
||||
* @return
|
||||
*/
|
||||
List<SysDepart> queryDeptByPid(String pid);
|
||||
|
||||
/**
|
||||
* 获取我的部门已加入的公司
|
||||
* @return
|
||||
*/
|
||||
List<SysDepart> getMyDepartList();
|
||||
|
||||
/**
|
||||
* 删除部门
|
||||
* @param id
|
||||
*/
|
||||
void deleteDepart(String id);
|
||||
|
||||
/**
|
||||
* 通讯录通过租户id查询部门数据
|
||||
* @param parentId
|
||||
* @param tenantId
|
||||
* @param departName
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeModel> queryBookDepTreeSync(String parentId, Integer tenantId, String departName);
|
||||
|
||||
/**
|
||||
* 根据id查询部门信息
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
SysDepart getDepartById(String parentId);
|
||||
|
||||
/**
|
||||
* 根据id查询部门信息
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
IPage<SysDepart> getMaxCodeDepart(Page<SysDepart> page, String parentId);
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import org.jeecg.common.system.vo.DictQuery;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.vo.lowapp.SysDictVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -255,4 +256,22 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
*/
|
||||
List<DictModel> loadDict(String dictCode, String keyword, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 根据应用id获取字典列表和详情
|
||||
* @param lowAppId
|
||||
* @return
|
||||
*/
|
||||
List<SysDictVo> getDictListByLowAppId(String lowAppId);
|
||||
|
||||
/**
|
||||
* 创建字典
|
||||
* @param sysDictVo
|
||||
*/
|
||||
void addDictByLowAppId(SysDictVo sysDictVo);
|
||||
|
||||
/**
|
||||
* 编辑字典
|
||||
* @param sysDictVo
|
||||
*/
|
||||
void editDictByLowAppId(SysDictVo sysDictVo);
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysPackPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 产品包菜单关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysPackPermissionService extends IService<SysPackPermission> {
|
||||
|
||||
}
|
||||
@ -1,11 +1,13 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@ -0,0 +1,75 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysTenantPack;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysTenantPackUser;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 租户产品包
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysTenantPackService extends IService<SysTenantPack> {
|
||||
|
||||
/**
|
||||
* 新增产品包并将菜单插入关系表
|
||||
* @param sysTenantPack
|
||||
*/
|
||||
void addPackPermission(SysTenantPack sysTenantPack);
|
||||
|
||||
/**
|
||||
* 设置菜单id
|
||||
* @param records
|
||||
* @return
|
||||
*/
|
||||
List<SysTenantPack> setPermissions(List<SysTenantPack> records);
|
||||
|
||||
/**
|
||||
* 编辑产品包并将菜单插入关系表
|
||||
* @param sysTenantPack
|
||||
*/
|
||||
void editPackPermission(SysTenantPack sysTenantPack);
|
||||
|
||||
/**
|
||||
* 删除租户产品包
|
||||
* @param ids
|
||||
*/
|
||||
void deletePackPermissions(String ids);
|
||||
|
||||
/**
|
||||
* 退出租户
|
||||
* @param tenantId
|
||||
* @param s
|
||||
*/
|
||||
void exitTenant(String tenantId, String s);
|
||||
|
||||
/**
|
||||
* 创建租户的时候默认创建3个 产品包
|
||||
* @param tenantId
|
||||
*/
|
||||
void addDefaultTenantPack(Integer tenantId);
|
||||
|
||||
/**
|
||||
* 保存产品包
|
||||
* @param sysTenantPack
|
||||
*/
|
||||
String saveOne(SysTenantPack sysTenantPack);
|
||||
|
||||
|
||||
/**
|
||||
* 保存产品包和人员的关系
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void savePackUser(SysTenantPackUser sysTenantPackUser);
|
||||
|
||||
/**
|
||||
* 根据租户ID和编码查询
|
||||
* @param tenantId
|
||||
* @param packCode
|
||||
* @return
|
||||
*/
|
||||
SysTenantPack getSysTenantPack(Integer tenantId ,String packCode);
|
||||
}
|
||||
@ -1,7 +1,15 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.entity.SysTenantPackUser;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantDepartAuthInfo;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackModel;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackUser;
|
||||
import org.jeecg.modules.system.vo.tenant.TenantPackUserCount;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -36,4 +44,150 @@ public interface ISysTenantService extends IService<SysTenant> {
|
||||
*/
|
||||
boolean removeTenantById(String id);
|
||||
|
||||
/**
|
||||
* 邀请用户加入租户
|
||||
* @param ids
|
||||
* @param userIds
|
||||
*/
|
||||
void invitationUserJoin(String ids, String userIds);
|
||||
|
||||
/**
|
||||
* 请离用户(租户)
|
||||
* @param userIds
|
||||
* @param tenantId
|
||||
*/
|
||||
void leaveTenant(String userIds, String tenantId);
|
||||
|
||||
/**
|
||||
* 添加租户,并将创建的用户加入关系表
|
||||
* @param sysTenant
|
||||
* @param userId
|
||||
*/
|
||||
Integer saveTenantJoinUser(SysTenant sysTenant, String userId);
|
||||
|
||||
/**
|
||||
* 保存租户
|
||||
* @param sysTenant
|
||||
*/
|
||||
void saveTenant(SysTenant sysTenant);
|
||||
|
||||
/**
|
||||
* 通过门牌号加入租户
|
||||
* @param sysTenant
|
||||
* @param userId
|
||||
*/
|
||||
Integer joinTenantByHouseNumber(SysTenant sysTenant, String userId);
|
||||
|
||||
/**
|
||||
* 统计一个人创建了多少个租户
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
Integer countCreateTenantNum(String userId);
|
||||
|
||||
/**
|
||||
* 获取租户回收站的数据
|
||||
* @param page
|
||||
* @param sysTenant
|
||||
* @return
|
||||
*/
|
||||
IPage<SysTenant> getRecycleBinPageList(Page<SysTenant> page, SysTenant sysTenant);
|
||||
|
||||
/**
|
||||
* 彻底删除租户
|
||||
* @param ids
|
||||
*/
|
||||
void deleteTenantLogic(String ids);
|
||||
|
||||
/**
|
||||
* 还原租户
|
||||
* @param ids
|
||||
*/
|
||||
void revertTenantLogic(String ids);
|
||||
|
||||
/**
|
||||
* 退出租户
|
||||
* @param userId
|
||||
* @param userId
|
||||
* @param username
|
||||
*/
|
||||
void exitUserTenant(String userId, String username, String tenantId);
|
||||
|
||||
/**
|
||||
* 变更租户拥有者
|
||||
* @param userId
|
||||
*/
|
||||
void changeOwenUserTenant(String userId);
|
||||
|
||||
/**
|
||||
* 邀请用户到租户。通过手机号匹配
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
Result<String> invitationUser(String phone);
|
||||
|
||||
/**
|
||||
* 进入应用组织页面 查询用户是否有 超级管理员的权限
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
TenantDepartAuthInfo getTenantDepartAuthInfo(Integer tenantId);
|
||||
|
||||
|
||||
/**
|
||||
* 获取 租户产品包-3个默认admin的人员数量
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<TenantPackUserCount> queryTenantPackUserCount(Integer tenantId);
|
||||
|
||||
/**
|
||||
* 查询租户产品包信息
|
||||
* @param model
|
||||
* @return
|
||||
*/
|
||||
TenantPackModel queryTenantPack(TenantPackModel model);
|
||||
|
||||
/**
|
||||
* 添加多个用户和产品包的关系数据
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void addBatchTenantPackUser(SysTenantPackUser sysTenantPackUser);
|
||||
|
||||
/**
|
||||
* 添加用户和产品包的关系数据 带日志记录的
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void addTenantPackUser(SysTenantPackUser sysTenantPackUser);
|
||||
|
||||
/**
|
||||
* 移除用户和产品包的关系数据 带日志记录的
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void deleteTenantPackUser(SysTenantPackUser sysTenantPackUser);
|
||||
|
||||
|
||||
/**
|
||||
* 查询申请的用户列表
|
||||
*/
|
||||
List<TenantPackUser> getTenantPackApplyUsers(Integer tenantId);
|
||||
|
||||
/**
|
||||
* 个人 申请成为管理员
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void doApplyTenantPackUser(SysTenantPackUser sysTenantPackUser);
|
||||
|
||||
/**
|
||||
* 申请通过 成为管理员
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void passApply(SysTenantPackUser sysTenantPackUser);
|
||||
|
||||
/**
|
||||
* 拒绝申请 成为管理员
|
||||
* @param sysTenantPackUser
|
||||
*/
|
||||
void deleteApply(SysTenantPackUser sysTenantPackUser);
|
||||
}
|
||||
|
||||
@ -57,11 +57,24 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param tenantId
|
||||
* @param departId
|
||||
* @param keyword
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getUserInformation(String departId, String keyword, Integer pageSize, Integer pageNo);
|
||||
IPage<SysUser> getUserInformation(Integer tenantId, String departId, String keyword, Integer pageSize, Integer pageNo);
|
||||
|
||||
/**
|
||||
* 获取用户信息
|
||||
* @param tenantId
|
||||
* @param departId
|
||||
* @param roleId
|
||||
* @param keyword
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getUserInformation(Integer tenantId,String departId,String roleId, String keyword, Integer pageSize, Integer pageNo);
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@ -11,8 +12,11 @@ import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.modules.system.entity.SysRoleIndex;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.vo.lowapp.DepartAndUserInfo;
|
||||
import org.jeecg.modules.system.vo.lowapp.UpdateDepartInfo;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -28,6 +32,17 @@ import java.util.Set;
|
||||
*/
|
||||
public interface ISysUserService extends IService<SysUser> {
|
||||
|
||||
/**
|
||||
* 查询用户数据列表
|
||||
*
|
||||
* @param req
|
||||
* @param queryWrapper
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @return
|
||||
*/
|
||||
Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo);
|
||||
|
||||
/**
|
||||
* 重置密码
|
||||
*
|
||||
@ -184,7 +199,7 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @param username
|
||||
* @param orgCode
|
||||
*/
|
||||
void updateUserDepart(String username,String orgCode);
|
||||
void updateUserDepart(String username,String orgCode,Integer loginTenantId);
|
||||
|
||||
/**
|
||||
* 根据手机号获取用户名和密码
|
||||
@ -277,16 +292,18 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @param user 用户
|
||||
* @param selectedRoles 选择的角色id,多个以逗号隔开
|
||||
* @param selectedDeparts 选择的部门id,多个以逗号隔开
|
||||
* @param relTenantIds 多个租户id
|
||||
*/
|
||||
void saveUser(SysUser user, String selectedRoles, String selectedDeparts);
|
||||
void saveUser(SysUser user, String selectedRoles, String selectedDeparts, String relTenantIds);
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
* @param user 用户
|
||||
* @param roles 选择的角色id,多个以逗号隔开
|
||||
* @param departs 选择的部门id,多个以逗号隔开
|
||||
* @param relTenantIds 多个租户id
|
||||
*/
|
||||
void editUser(SysUser user, String roles, String departs);
|
||||
void editUser(SysUser user, String roles, String departs, String relTenantIds);
|
||||
|
||||
/**
|
||||
* userId转为username
|
||||
@ -303,4 +320,73 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
*/
|
||||
LoginUser getEncodeUserInfo(String username);
|
||||
|
||||
/**
|
||||
* 用户离职
|
||||
* @param username
|
||||
*/
|
||||
void userQuit(String username);
|
||||
|
||||
/**
|
||||
* 获取离职人员列表
|
||||
* @param tenantId 租户id
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> getQuitList(Integer tenantId);
|
||||
|
||||
/**
|
||||
* 更新刪除状态和离职状态
|
||||
* @param userIds 存放用户id集合
|
||||
* @param sysUser
|
||||
* @return boolean
|
||||
*/
|
||||
void updateStatusAndFlag(List<String> userIds, SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 设置登录租户
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
Result<JSONObject> setLoginTenant(SysUser sysUser, JSONObject obj, String username, Result<JSONObject> result);
|
||||
|
||||
//--- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能,细节实现 ---
|
||||
/**
|
||||
* 批量编辑用户信息
|
||||
* @param json
|
||||
*/
|
||||
void batchEditUsers(JSONObject json);
|
||||
|
||||
/**
|
||||
* 根据关键词查询用户和部门
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
DepartAndUserInfo searchByKeyword(String keyword);
|
||||
|
||||
/**
|
||||
* 查询 部门修改的信息
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
UpdateDepartInfo getUpdateDepartInfo(String departId);
|
||||
|
||||
/**
|
||||
* 修改部门相关信息
|
||||
* @param updateDepartInfo
|
||||
*/
|
||||
void doUpdateDepartInfo(UpdateDepartInfo updateDepartInfo);
|
||||
|
||||
/**
|
||||
* 设置负责人 取消负责人
|
||||
* @param json
|
||||
*/
|
||||
void changeDepartChargePerson(JSONObject json);
|
||||
//--- author:taoyan date:20221231 for: QQYUN-3515【应用】应用下的组织机构管理功能,细节实现 ---
|
||||
|
||||
/**
|
||||
* 编辑租户用户
|
||||
* @param sysUser
|
||||
* @param tenantId
|
||||
* @param departs
|
||||
*/
|
||||
void editTenantUser(SysUser sysUser, String tenantId, String departs, String roles);
|
||||
}
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserTenant;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.vo.SysUserTenantVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: sys_user_tenant_relation
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysUserTenantService extends IService<SysUserTenant> {
|
||||
|
||||
/**
|
||||
* 通过租户id获取数据
|
||||
* @param page
|
||||
* @param userTenantId
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
Page<SysUser> getPageUserList(Page<SysUser> page, Integer userTenantId, SysUser user);
|
||||
|
||||
/**
|
||||
* 设置租户id
|
||||
* @param records
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> setUserTenantIds(List<SysUser> records);
|
||||
|
||||
/**
|
||||
* 获取用户id根据用户id
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
List<String> getUserIdsByTenantId(Integer tenantId);
|
||||
|
||||
/**
|
||||
* 通过用户id获取租户ids
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
List<Integer> getTenantIdsByUserId(String userId);
|
||||
|
||||
/**
|
||||
* 通过用户id获取租户列表
|
||||
* @param userId
|
||||
* @param userTenantStatus
|
||||
* @return
|
||||
*/
|
||||
List<SysUserTenantVo> getTenantListByUserId(String userId, List<String> userTenantStatus);
|
||||
|
||||
/**
|
||||
* 更新用户租户状态
|
||||
* @param id
|
||||
* @param tenantId
|
||||
* @param userTenantStatus
|
||||
*/
|
||||
void updateUserTenantStatus(String id, String tenantId, String userTenantStatus);
|
||||
|
||||
/**
|
||||
* 联查用户和租户审核状态
|
||||
* @param page
|
||||
* @param status 租户用户状态,默认为1正常
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUserTenantVo> getUserTenantPageList(Page<SysUserTenantVo> page, List<String> status, SysUser user, Integer tenantId);
|
||||
|
||||
/**
|
||||
* 取消离职
|
||||
* @param userIds
|
||||
* @param tenantId
|
||||
*/
|
||||
void putCancelQuit(List<String> userIds, Integer tenantId);
|
||||
|
||||
/**
|
||||
* 验证用户是否已存在
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
* @return
|
||||
*/
|
||||
Integer userTenantIzExist(String userId, Integer tenantId);
|
||||
}
|
||||
@ -4,17 +4,22 @@ import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.netty.util.internal.StringUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.FillRuleConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.FillRuleUtil;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
@ -53,6 +58,8 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
private SysDepartRoleUserMapper departRoleUserMapper;
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private SysDepartMapper departMapper;
|
||||
|
||||
@Override
|
||||
public List<SysDepartTreeModel> queryMyDeptTreeList(String departIds) {
|
||||
@ -63,6 +70,14 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
query.or().likeRight(SysDepart::getOrgCode,codeArr[i]);
|
||||
}
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的 SASS 控制
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query.eq(SysDepart::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
query.orderByAsc(SysDepart::getDepartOrder);
|
||||
//将父节点ParentId设为null
|
||||
List<SysDepart> listDepts = this.list(query);
|
||||
@ -82,9 +97,15 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
* queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DEPARTS_CACHE)
|
||||
//@Cacheable(value = CacheConstant.SYS_DEPARTS_CACHE)
|
||||
public List<SysDepartTreeModel> queryTreeList() {
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query.eq(SysDepart::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
query.orderByAsc(SysDepart::getDepartOrder);
|
||||
List<SysDepart> list = this.list(query);
|
||||
@ -108,6 +129,12 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
if(oConvertUtils.isNotEmpty(ids)){
|
||||
query.in(true,SysDepart::getId,ids.split(","));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query.eq(SysDepart::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
query.orderByAsc(SysDepart::getDepartOrder);
|
||||
List<SysDepart> list= this.list(query);
|
||||
for (SysDepart depart : list) {
|
||||
@ -117,11 +144,17 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
|
||||
}
|
||||
|
||||
@Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
|
||||
//@Cacheable(value = CacheConstant.SYS_DEPART_IDS_CACHE)
|
||||
@Override
|
||||
public List<DepartIdModel> queryDepartIdTreeList() {
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query.eq(SysDepart::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
query.orderByAsc(SysDepart::getDepartOrder);
|
||||
List<SysDepart> list = this.list(query);
|
||||
// 调用wrapTreeDataToTreeList方法生成树状数据
|
||||
@ -136,9 +169,14 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveDepartData(SysDepart sysDepart, String username) {
|
||||
if (sysDepart != null && username != null) {
|
||||
if (sysDepart.getParentId() == null) {
|
||||
//update-begin---author:wangshuai ---date:20230216 for:[QQYUN-4163]给部门表加个是否有子节点------------
|
||||
if (oConvertUtils.isEmpty(sysDepart.getParentId())) {
|
||||
sysDepart.setParentId("");
|
||||
}else{
|
||||
//将父部门的设成不是叶子结点
|
||||
departMapper.setMainLeaf(sysDepart.getParentId(),CommonConstant.NOT_LEAF);
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20230216 for:[QQYUN-4163]给部门表加个是否有子节点------------
|
||||
//String s = UUID.randomUUID().toString().replace("-", "");
|
||||
sysDepart.setId(IdWorker.getIdStr(sysDepart));
|
||||
// 先判断该对象有无父级ID,有则意味着不是最高级,否则意味着是最高级
|
||||
@ -272,6 +310,8 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
for(String id: ids) {
|
||||
idList.add(id);
|
||||
this.checkChildrenExists(id, idList);
|
||||
//删除部门设置父级的叶子结点
|
||||
this.setIzLeaf(id);
|
||||
}
|
||||
this.removeByIds(idList);
|
||||
//根据部门id获取部门角色id
|
||||
@ -427,6 +467,12 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
query.in(SysDepart::getId, Arrays.asList(departIds.split(",")));
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query.eq(SysDepart::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
query.orderByAsc(SysDepart::getOrgCode);
|
||||
List<SysDepart> list = this.list(query);
|
||||
//查找根部门
|
||||
@ -527,6 +573,12 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
};
|
||||
LambdaQueryWrapper<SysDepart> lqw=new LambdaQueryWrapper<>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的 SASS 控制
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
lqw.eq(SysDepart::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0));
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
lqw.eq(true,SysDepart::getDelFlag,CommonConstant.DEL_FLAG_0.toString());
|
||||
lqw.func(square);
|
||||
//update-begin---author:wangshuai ---date:20220527 for:[VUEN-1143]排序不对,vue3和2应该都有问题,应该按照升序排------------
|
||||
@ -543,13 +595,6 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
SysDepartTreeModel treeModel = new SysDepartTreeModel(depart);
|
||||
//TODO 异步树加载key拼接__+时间戳,以便于每次展开节点会刷新数据
|
||||
//treeModel.setKey(treeModel.getKey()+"__"+System.currentTimeMillis());
|
||||
treeModel.setKey(treeModel.getKey());
|
||||
Integer count=this.baseMapper.queryCountByPid(depart.getId());
|
||||
if(count>0){
|
||||
treeModel.setIsLeaf(false);
|
||||
}else{
|
||||
treeModel.setIsLeaf(true);
|
||||
}
|
||||
records.add(treeModel);
|
||||
}
|
||||
return records;
|
||||
@ -764,4 +809,85 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增方法添加部门负责人、删除负责部门负责人、查询部门对应的负责人
|
||||
|
||||
/**
|
||||
* 获取我的部门已加入的公司
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<SysDepart> getMyDepartList() {
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = user.getId();
|
||||
//字典code集合
|
||||
List<String> list = new ArrayList<>();
|
||||
//查询我加入的部门
|
||||
List<SysDepart> sysDepartList = this.baseMapper.queryUserDeparts(userId);
|
||||
for (SysDepart sysDepart : sysDepartList) {
|
||||
//获取一级部门编码
|
||||
String orgCode = sysDepart.getOrgCode();
|
||||
if (YouBianCodeUtil.ZHANWEI_LENGTH <= orgCode.length()) {
|
||||
int length = YouBianCodeUtil.ZHANWEI_LENGTH;
|
||||
String companyOrgCode = orgCode.substring(0, length);
|
||||
list.add(companyOrgCode);
|
||||
}
|
||||
}
|
||||
//字典code集合不为空
|
||||
if (oConvertUtils.isNotEmpty(list)) {
|
||||
//查询一级部门的数据
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<>();
|
||||
query.select(SysDepart::getDepartName, SysDepart::getId, SysDepart::getOrgCode);
|
||||
query.eq(SysDepart::getDelFlag, String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
query.in(SysDepart::getOrgCode, list);
|
||||
return this.baseMapper.selectList(query);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteDepart(String id) {
|
||||
//删除部门设置父级的叶子结点
|
||||
this.setIzLeaf(id);
|
||||
this.delete(id);
|
||||
//删除部门用户关系表
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>()
|
||||
.eq(SysUserDepart::getDepId, id);
|
||||
this.userDepartMapper.delete(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDepartTreeModel> queryBookDepTreeSync(String parentId, Integer tenantId, String departName) {
|
||||
List<SysDepart> list = departMapper.queryBookDepTreeSync(parentId,tenantId,departName);
|
||||
List<SysDepartTreeModel> records = new ArrayList<>();
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
SysDepart depart = list.get(i);
|
||||
SysDepartTreeModel treeModel = new SysDepartTreeModel(depart);
|
||||
records.add(treeModel);
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDepart getDepartById(String id) {
|
||||
return departMapper.getDepartById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysDepart> getMaxCodeDepart(Page<SysDepart> page, String parentId) {
|
||||
return page.setRecords(departMapper.getMaxCodeDepart(page,parentId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置父级节点是否存在叶子结点
|
||||
* @param id
|
||||
*/
|
||||
private void setIzLeaf(String id) {
|
||||
SysDepart depart = this.getDepartById(id);
|
||||
String parentId = depart.getParentId();
|
||||
if(oConvertUtils.isNotEmpty(parentId)){
|
||||
Long count = this.count(new QueryWrapper<SysDepart>().lambda().eq(SysDepart::getParentId, parentId));
|
||||
if(count == 1){
|
||||
//若父节点无其他子节点,则该父节点是叶子节点
|
||||
departMapper.setMainLeaf(parentId, CommonConstant.IS_LEAF);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,27 +1,34 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DataBaseConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.util.ResourceUtil;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.DictModelMany;
|
||||
import org.jeecg.common.system.vo.DictQuery;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.mapper.SysDictItemMapper;
|
||||
import org.jeecg.modules.system.mapper.SysDictMapper;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.vo.lowapp.SysDictVo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -81,7 +88,16 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
@Override
|
||||
public Map<String, List<DictModel>> queryAllDictItems() {
|
||||
Map<String, List<DictModel>> res = new HashMap(5);
|
||||
List<SysDict> ls = sysDictMapper.selectList(null);
|
||||
LambdaQueryWrapper<SysDict> sysDictQueryWrapper = new LambdaQueryWrapper<SysDict>();
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
sysDictQueryWrapper.eq(SysDict::getTenantId, oConvertUtils.getInt(TenantContext.getTenant(), 0))
|
||||
.or().eq(SysDict::getTenantId,0);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
|
||||
List<SysDict> ls = sysDictMapper.selectList(sysDictQueryWrapper);
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<SysDictItem>();
|
||||
queryWrapper.eq(SysDictItem::getStatus, 1);
|
||||
queryWrapper.orderByAsc(SysDictItem::getSortOrder);
|
||||
@ -475,4 +491,89 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysDictVo> getDictListByLowAppId(String lowAppId) {
|
||||
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
List<SysDict> list = baseMapper.getDictListByLowAppId(lowAppId,tenantId);
|
||||
//查询字典下面的字典项
|
||||
List<SysDictVo> dictVoList = new ArrayList<>();
|
||||
for (SysDict dict:list) {
|
||||
SysDictVo dictVo = new SysDictVo();
|
||||
BeanUtils.copyProperties(dict,dictVo);
|
||||
List<SysDictItem> sysDictItems = sysDictItemMapper.selectItemsByMainId(dict.getId());
|
||||
dictVo.setDictItemsList(sysDictItems);
|
||||
dictVoList.add(dictVo);
|
||||
}
|
||||
return dictVoList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDictByLowAppId(SysDictVo sysDictVo) {
|
||||
String id = this.addDict(sysDictVo.getDictName(),sysDictVo.getLowAppId());
|
||||
this.addDictItem(id,sysDictVo.getDictItemsList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editDictByLowAppId(SysDictVo sysDictVo) {
|
||||
String id = sysDictVo.getId();
|
||||
SysDict dict = baseMapper.selectById(id);
|
||||
if(null == dict){
|
||||
throw new JeecgBootException("字典数据不存在");
|
||||
}
|
||||
//判断应用id和数据库中的是否一致,不一致不让修改
|
||||
if(!dict.getLowAppId().equals(sysDictVo.getLowAppId())){
|
||||
throw new JeecgBootException("字典数据不存在");
|
||||
}
|
||||
SysDict sysDict = new SysDict();
|
||||
sysDict.setDictName(sysDictVo.getDictName());
|
||||
sysDict.setId(id);
|
||||
baseMapper.updateById(sysDict);
|
||||
this.updateDictItem(id,sysDictVo.getDictItemsList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字典
|
||||
* @param dictName
|
||||
*/
|
||||
private String addDict(String dictName,String lowAppId) {
|
||||
SysDict dict = new SysDict();
|
||||
dict.setDictName(dictName);
|
||||
dict.setDictCode(RandomUtil.randomString(10));
|
||||
dict.setDelFlag(Integer.valueOf(CommonConstant.STATUS_0));
|
||||
dict.setLowAppId(lowAppId);
|
||||
baseMapper.insert(dict);
|
||||
return dict.getId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加字典子项
|
||||
* @param id
|
||||
* @param dictItemList
|
||||
*/
|
||||
private void addDictItem(String id,List<SysDictItem> dictItemList) {
|
||||
if(null!=dictItemList && dictItemList.size()>0){
|
||||
for (SysDictItem dictItem:dictItemList) {
|
||||
SysDictItem sysDictItem = new SysDictItem();
|
||||
BeanUtils.copyProperties(dictItem,sysDictItem);
|
||||
sysDictItem.setDictId(id);
|
||||
sysDictItem.setId("");
|
||||
sysDictItem.setStatus(Integer.valueOf(CommonConstant.STATUS_1));
|
||||
sysDictItemMapper.insert(sysDictItem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新字典子项
|
||||
* @param id
|
||||
* @param dictItemList
|
||||
*/
|
||||
private void updateDictItem(String id,List<SysDictItem> dictItemList){
|
||||
//先删除在新增 因为排序可能不一致
|
||||
LambdaQueryWrapper<SysDictItem> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysDictItem::getDictId,id);
|
||||
sysDictItemMapper.delete(query);
|
||||
//新增子项
|
||||
this.addDictItem(id,dictItemList);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,19 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysPackPermission;
|
||||
import org.jeecg.modules.system.mapper.SysPackPermissionMapper;
|
||||
import org.jeecg.modules.system.service.ISysPackPermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 产品包菜单关系表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysPackPermissionServiceImpl extends ServiceImpl<SysPackPermissionMapper, SysPackPermission> implements ISysPackPermissionService {
|
||||
|
||||
}
|
||||
@ -1,8 +1,12 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
@ -21,11 +25,9 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -278,7 +280,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
||||
@Override
|
||||
public boolean checkPermDuplication(String id, String url,Boolean alwaysShow) {
|
||||
QueryWrapper<SysPermission> qw=new QueryWrapper();
|
||||
qw.lambda().eq(true, SysPermission::getUrl,url).ne(oConvertUtils.isNotEmpty(id), SysPermission::getId,id).eq(true, SysPermission::isAlwaysShow,alwaysShow);
|
||||
qw.lambda().eq(true,SysPermission::getUrl,url).ne(oConvertUtils.isNotEmpty(id),SysPermission::getId,id).eq(true,SysPermission::isAlwaysShow,alwaysShow);
|
||||
return count(qw)==0;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,204 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.constant.TenantConstant;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.aop.TenantLog;
|
||||
import org.jeecg.modules.system.entity.SysPackPermission;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.entity.SysTenantPack;
|
||||
import org.jeecg.modules.system.entity.SysTenantPackUser;
|
||||
import org.jeecg.modules.system.mapper.SysPackPermissionMapper;
|
||||
import org.jeecg.modules.system.mapper.SysTenantPackMapper;
|
||||
import org.jeecg.modules.system.mapper.SysTenantPackUserMapper;
|
||||
import org.jeecg.modules.system.service.ISysTenantPackService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 租户产品包
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-31
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysTenantPackServiceImpl extends ServiceImpl<SysTenantPackMapper, SysTenantPack> implements ISysTenantPackService {
|
||||
|
||||
@Autowired
|
||||
private SysTenantPackMapper sysTenantPackMapper;
|
||||
|
||||
@Autowired
|
||||
private SysTenantPackUserMapper sysTenantPackUserMapper;
|
||||
|
||||
@Autowired
|
||||
private SysPackPermissionMapper sysPackPermissionMapper;
|
||||
|
||||
@Override
|
||||
public void addPackPermission(SysTenantPack sysTenantPack) {
|
||||
sysTenantPackMapper.insert(sysTenantPack);
|
||||
String permissionIds = sysTenantPack.getPermissionIds();
|
||||
if (oConvertUtils.isNotEmpty(permissionIds)) {
|
||||
String packId = sysTenantPack.getId();
|
||||
String[] permissionIdArray = permissionIds.split(SymbolConstant.COMMA);
|
||||
for (String permissionId : permissionIdArray) {
|
||||
this.addPermission(packId, permissionId);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysTenantPack> setPermissions(List<SysTenantPack> records) {
|
||||
for (SysTenantPack pack : records) {
|
||||
List<String> permissionIds = sysPackPermissionMapper.getPermissionsByPackId(pack.getId());
|
||||
if (null != permissionIds && permissionIds.size() > 0) {
|
||||
String ids = String.join(SymbolConstant.COMMA, permissionIds);
|
||||
pack.setPermissionIds(ids);
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editPackPermission(SysTenantPack sysTenantPack) {
|
||||
//数据库汇总的id
|
||||
List<String> oldPermissionIds = sysPackPermissionMapper.getPermissionsByPackId(sysTenantPack.getId());
|
||||
//前台传过来的需要修改的id
|
||||
String permissionIds = sysTenantPack.getPermissionIds();
|
||||
//如果传过来的菜单id为空,那么就删除数据库中所有菜单
|
||||
if (oConvertUtils.isEmpty(permissionIds)) {
|
||||
this.deletePackPermission(sysTenantPack.getId(), null);
|
||||
} else if (oConvertUtils.isNotEmpty(permissionIds) && oConvertUtils.isEmpty(oldPermissionIds)) {
|
||||
//如果传过来的菜单id不为空但是数据库的菜单id为空,那么就新增
|
||||
this.addPermission(sysTenantPack.getId(), permissionIds);
|
||||
} else {
|
||||
//都不为空,需要比较,进行添加或删除
|
||||
if (oConvertUtils.isNotEmpty(oldPermissionIds)) {
|
||||
//找到新的租户id与原来的租户id不同之处,进行删除
|
||||
List<String> permissionList = oldPermissionIds.stream().filter(item -> !permissionIds.contains(item)).collect(Collectors.toList());
|
||||
if (permissionList.size() > 0) {
|
||||
for (String permission : permissionList) {
|
||||
this.deletePackPermission(sysTenantPack.getId(), permission);
|
||||
}
|
||||
}
|
||||
|
||||
//找到原来菜单id与新的菜单id不同之处,进行新增
|
||||
List<String> permissionAddList = Arrays.stream(permissionIds.split(SymbolConstant.COMMA)).filter(item -> !oldPermissionIds.contains(item)).collect(Collectors.toList());
|
||||
if (permissionAddList.size() > 0) {
|
||||
for (String permission : permissionAddList) {
|
||||
this.addPermission(sysTenantPack.getId(), permission);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
sysTenantPackMapper.updateById(sysTenantPack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deletePackPermissions(String ids) {
|
||||
String[] idsArray = ids.split(SymbolConstant.COMMA);
|
||||
for (String id : idsArray) {
|
||||
this.deletePackPermission(id,null);
|
||||
sysTenantPackMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exitTenant(String tenantId, String userId) {
|
||||
this.getById(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDefaultTenantPack(Integer tenantId) {
|
||||
// 创建超级管理员
|
||||
SysTenantPack superAdminPack = new SysTenantPack(tenantId, "超级管理员", TenantConstant.SUPER_ADMIN);
|
||||
ISysTenantPackService currentService = SpringContextUtils.getApplicationContext().getBean(ISysTenantPackService.class);
|
||||
String packId = currentService.saveOne(superAdminPack);
|
||||
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
SysTenantPackUser packUser = new SysTenantPackUser(tenantId, packId, sysUser.getId());
|
||||
packUser.setRealname(sysUser.getRealname());
|
||||
packUser.setPackName(superAdminPack.getPackName());
|
||||
//添加人员和管理员的关系数据
|
||||
currentService.savePackUser(packUser);
|
||||
|
||||
// 创建超级管理员
|
||||
SysTenantPack accountAdminPack = new SysTenantPack(tenantId, "组织账户管理员", TenantConstant.ACCOUNT_ADMIN);
|
||||
currentService.saveOne(accountAdminPack);
|
||||
|
||||
// 创建超级管理员
|
||||
SysTenantPack appAdminPack = new SysTenantPack(tenantId, "组织应用管理员", TenantConstant.APP_ADMIN);
|
||||
currentService.saveOne(appAdminPack);
|
||||
|
||||
}
|
||||
|
||||
@TenantLog(2)
|
||||
@Override
|
||||
public String saveOne(SysTenantPack sysTenantPack) {
|
||||
sysTenantPackMapper.insert(sysTenantPack);
|
||||
return sysTenantPack.getId();
|
||||
}
|
||||
|
||||
@TenantLog(2)
|
||||
@Override
|
||||
public void savePackUser(SysTenantPackUser sysTenantPackUser) {
|
||||
sysTenantPackUser.setStatus(1);
|
||||
sysTenantPackUserMapper.insert(sysTenantPackUser);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysTenantPack getSysTenantPack(Integer tenantId, String packCode) {
|
||||
LambdaQueryWrapper<SysTenantPack> query = new LambdaQueryWrapper<SysTenantPack>()
|
||||
.eq(SysTenantPack::getPackCode, packCode)
|
||||
.eq(SysTenantPack::getTenantId, tenantId);
|
||||
List<SysTenantPack> list = baseMapper.selectList(query);
|
||||
if(list!=null && list.size()>0){
|
||||
SysTenantPack pack = list.get(0);
|
||||
if(pack!=null && pack.getId()!=null){
|
||||
return pack;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加菜单
|
||||
*
|
||||
* @param packId
|
||||
* @param permissionId
|
||||
*/
|
||||
public void addPermission(String packId, String permissionId) {
|
||||
SysPackPermission permission = new SysPackPermission();
|
||||
permission.setPermissionId(permissionId);
|
||||
permission.setPackId(packId);
|
||||
sysPackPermissionMapper.insert(permission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据包名id和菜单id删除关系表
|
||||
*
|
||||
* @param packId
|
||||
* @param permissionId
|
||||
*/
|
||||
public void deletePackPermission(String packId, String permissionId) {
|
||||
LambdaQueryWrapper<SysPackPermission> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysPackPermission::getPackId, packId);
|
||||
if (oConvertUtils.isNotEmpty(permissionId)) {
|
||||
query.eq(SysPackPermission::getPermissionId, permissionId);
|
||||
}
|
||||
sysPackPermissionMapper.delete(query);
|
||||
}
|
||||
}
|
||||
@ -1,20 +1,41 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.aop.TenantLog;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.SysTenantMapper;
|
||||
import org.jeecg.modules.system.mapper.SysTenantPackUserMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserTenantMapper;
|
||||
import org.jeecg.modules.system.service.ISysTenantPackService;
|
||||
import org.jeecg.modules.system.service.ISysTenantService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.vo.tenant.*;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 租户实现类
|
||||
@ -26,9 +47,22 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
|
||||
@Autowired
|
||||
ISysUserService userService;
|
||||
@Autowired
|
||||
private SysUserTenantMapper userTenantMapper;
|
||||
@Autowired
|
||||
private SysTenantMapper tenantMapper;
|
||||
@Autowired
|
||||
private ISysTenantPackService sysTenantPackService;
|
||||
|
||||
@Autowired
|
||||
private SysTenantPackUserMapper sysTenantPackUserMapper;
|
||||
|
||||
@Override
|
||||
public List<SysTenant> queryEffectiveTenant(Collection<Integer> idList) {
|
||||
if(oConvertUtils.listIsEmpty(idList)){
|
||||
return null;
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysTenant> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysTenant::getId, idList);
|
||||
queryWrapper.eq(SysTenant::getStatus, Integer.valueOf(CommonConstant.STATUS_1));
|
||||
@ -38,13 +72,11 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
|
||||
@Override
|
||||
public Long countUserLinkTenant(String id) {
|
||||
LambdaQueryWrapper<SysUser> userQueryWrapper = new LambdaQueryWrapper<>();
|
||||
userQueryWrapper.eq(SysUser::getRelTenantIds, id);
|
||||
userQueryWrapper.or().like(SysUser::getRelTenantIds, "%," + id);
|
||||
userQueryWrapper.or().like(SysUser::getRelTenantIds, id + ",%");
|
||||
userQueryWrapper.or().like(SysUser::getRelTenantIds, "%," + id + ",%");
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getTenantId,id);
|
||||
query.eq(SysUserTenant::getStatus,CommonConstant.STATUS_1);
|
||||
// 查找出已被关联的用户数量
|
||||
return userService.count(userQueryWrapper);
|
||||
return userTenantMapper.selectCount(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -57,4 +89,486 @@ public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant
|
||||
return super.removeById(Integer.parseInt(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void invitationUserJoin(String ids, String userIds) {
|
||||
String[] idArray = ids.split(SymbolConstant.COMMA);
|
||||
String[] userIdArray = userIds.split(SymbolConstant.COMMA);
|
||||
//先循环用户id,避免多次查询
|
||||
for (String userId : userIdArray) {
|
||||
//循环租户id
|
||||
for (String id:idArray) {
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getTenantId,id);
|
||||
query.eq(SysUserTenant::getUserId,userId);
|
||||
long count = userTenantMapper.selectCount(query);
|
||||
if(count == 0){
|
||||
SysUserTenant relation = new SysUserTenant();
|
||||
relation.setUserId(userId);
|
||||
relation.setTenantId(Integer.valueOf(id));
|
||||
relation.setStatus(CommonConstant.USER_TENANT_UNDER_REVIEW);
|
||||
userTenantMapper.insert(relation);
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void leaveTenant(String userIds, String tenantId) {
|
||||
String[] userIdArray = userIds.split(SymbolConstant.COMMA);
|
||||
for (String userId:userIdArray) {
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getTenantId,tenantId);
|
||||
query.eq(SysUserTenant::getUserId,userId);
|
||||
userTenantMapper.delete(query);
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public Integer saveTenantJoinUser(SysTenant sysTenant, String userId) {
|
||||
//添加租户
|
||||
this.saveTenant(sysTenant);
|
||||
|
||||
// 添加租户产品包
|
||||
Integer tenantId = sysTenant.getId();
|
||||
sysTenantPackService.addDefaultTenantPack(tenantId);
|
||||
|
||||
//添加租户到关系表
|
||||
return this.saveTenantRelation(sysTenant.getId(), userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveTenant(SysTenant sysTenant){
|
||||
//获取租户id
|
||||
sysTenant.setId(this.tenantIdGenerate());
|
||||
sysTenant.setHouseNumber(RandomUtil.randomStringUpper(6));
|
||||
this.save(sysTenant);
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public Integer joinTenantByHouseNumber(SysTenant sysTenant, String userId) {
|
||||
LambdaQueryWrapper<SysTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysTenant::getHouseNumber,sysTenant.getHouseNumber());
|
||||
SysTenant one = this.getOne(query);
|
||||
//需要返回租户id(用于前台更新缓存),返回0则代表当前租户门牌号不存在
|
||||
if(null == one){
|
||||
return 0;
|
||||
}else{
|
||||
LambdaQueryWrapper<SysUserTenant> relationQuery = new LambdaQueryWrapper<>();
|
||||
relationQuery.eq(SysUserTenant::getTenantId,one.getId());
|
||||
relationQuery.eq(SysUserTenant::getUserId,userId);
|
||||
SysUserTenant relation = userTenantMapper.selectOne(relationQuery);
|
||||
if(relation != null){
|
||||
String msg = "";
|
||||
if(CommonConstant.USER_TENANT_UNDER_REVIEW.equals(relation.getStatus())){
|
||||
msg = ",状态:审核中";
|
||||
}else if(CommonConstant.USER_TENANT_REFUSE.equals(relation.getStatus())){
|
||||
throw new JeecgBootException("管理员已拒绝您加入租户,请联系租户管理员");
|
||||
}else if(CommonConstant.USER_TENANT_QUIT.equals(relation.getStatus())){
|
||||
msg = ",状态:已离职";
|
||||
}
|
||||
throw new JeecgBootException("您已是该租户成员"+msg);
|
||||
}
|
||||
//用户加入门牌号审核中状态
|
||||
SysUserTenant tenant = new SysUserTenant();
|
||||
tenant.setTenantId(one.getId());
|
||||
tenant.setUserId(userId);
|
||||
tenant.setStatus(CommonConstant.USER_TENANT_UNDER_REVIEW);
|
||||
userTenantMapper.insert(tenant);
|
||||
return tenant.getTenantId();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer countCreateTenantNum(String userId) {
|
||||
return this.userTenantMapper.countCreateTenantNum(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysTenant> getRecycleBinPageList(Page<SysTenant> page, SysTenant sysTenant) {
|
||||
return page.setRecords(tenantMapper.getRecycleBinPageList(page,sysTenant));
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void deleteTenantLogic(String ids) {
|
||||
String[] idArray = ids.split(SymbolConstant.COMMA);
|
||||
List<Integer> list = new ArrayList<>();
|
||||
//转成int类型
|
||||
for (String id:idArray) {
|
||||
list.add(Integer.valueOf(id));
|
||||
}
|
||||
//删除租户
|
||||
tenantMapper.deleteByTenantId(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void revertTenantLogic(String ids) {
|
||||
String[] idArray = ids.split(SymbolConstant.COMMA);
|
||||
List<Integer> list = new ArrayList<>();
|
||||
//转成int类型
|
||||
for (String id:idArray) {
|
||||
list.add(Integer.valueOf(id));
|
||||
}
|
||||
//还原租户
|
||||
tenantMapper.revertTenantLogic(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加租户到关系表
|
||||
* @param tenantId
|
||||
* @param userId
|
||||
*/
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public Integer saveTenantRelation(Integer tenantId,String userId) {
|
||||
SysUserTenant relation = new SysUserTenant();
|
||||
relation.setTenantId(tenantId);
|
||||
relation.setUserId(userId);
|
||||
relation.setStatus(CommonConstant.USER_TENANT_NORMAL);
|
||||
userTenantMapper.insert(relation);
|
||||
return relation.getTenantId();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户id
|
||||
* @return
|
||||
*/
|
||||
public int tenantIdGenerate(){
|
||||
synchronized (this){
|
||||
//获取最大值id
|
||||
int maxTenantId = tenantMapper.getMaxTenantId();
|
||||
if(maxTenantId >= 1000){
|
||||
return maxTenantId + 1;
|
||||
}else{
|
||||
return 1000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void exitUserTenant(String userId, String username, String tenantId) {
|
||||
int tId = Integer.parseInt(tenantId);
|
||||
//获取所有租户信息
|
||||
List<String> userIdsByTenantId = userTenantMapper.getUserIdsByTenantId(tId);
|
||||
//查询当前租户是否为拥有者
|
||||
SysTenant sysTenant = tenantMapper.selectById(tId);
|
||||
//如果是拥有着
|
||||
if (username.equals(sysTenant.getCreateBy())) {
|
||||
//判断当前租户信息位数
|
||||
if (null != userIdsByTenantId && userIdsByTenantId.size() > 1) {
|
||||
//需要指配拥有者
|
||||
throw new JeecgBootException("assignedOwen");
|
||||
} else if (null != userIdsByTenantId && userIdsByTenantId.size() == 1) {
|
||||
//最后一位直接退出租户即可
|
||||
//逻辑删除,不删除关系表租户一个户最后一位,保证回收站取回还有管理员
|
||||
tenantMapper.deleteById(tenantId);
|
||||
this.leveUserProcess(userId, tenantId);
|
||||
} else {
|
||||
throw new JeecgBootException("退出租户失败,租户信息已不存在");
|
||||
}
|
||||
} else {
|
||||
//不是拥有者直接删除
|
||||
this.leaveTenant(userId, tenantId);
|
||||
this.leveUserProcess(userId, tenantId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeOwenUserTenant(String userId) {
|
||||
//查询当前用户是否存在该租户下
|
||||
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
Integer count = userTenantMapper.userTenantIzExist(userId, tenantId);
|
||||
if (count == 0) {
|
||||
throw new JeecgBootException("退出租户失败,此租户下没有该用户");
|
||||
}
|
||||
//获取用户信息
|
||||
SysUser user = userService.getById(userId);
|
||||
//变更拥有者
|
||||
SysTenant tenant = new SysTenant();
|
||||
tenant.setCreateBy(user.getUsername());
|
||||
tenant.setId(tenantId);
|
||||
tenantMapper.updateById(tenant);
|
||||
//删除当前登录用户的租户信息
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
this.leaveTenant(loginUser.getId(), String.valueOf(tenantId));
|
||||
//离职流程
|
||||
this.leveUserProcess(userId, String.valueOf(tenantId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发离职流程
|
||||
*
|
||||
* @param userId
|
||||
* @param tenantId
|
||||
* @param tenantId
|
||||
*/
|
||||
private void leveUserProcess(String userId, String tenantId) {
|
||||
LoginUser userInfo = new LoginUser();
|
||||
SysUser user = userService.getById(userId);
|
||||
//触发入职流程
|
||||
BeanUtils.copyProperties(user, userInfo);
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> invitationUser(String phone) {
|
||||
Result<String> result = new Result<>();
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
|
||||
//1、查询用户信息,判断用户是否存在
|
||||
SysUser userByPhone = userService.getUserByPhone(phone);
|
||||
if(null == userByPhone){
|
||||
result.setSuccess(false);
|
||||
result.setMessage("用户不存在");
|
||||
return result;
|
||||
}
|
||||
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
|
||||
//2.判断当前邀请人是否存在租户列表中
|
||||
Integer userCount = userTenantMapper.userTenantIzExist(sysUser.getId(), tenantId);
|
||||
if(userCount == 0){
|
||||
result.setSuccess(false);
|
||||
result.setMessage("当前管理员没有邀请权限");
|
||||
return result;
|
||||
}
|
||||
|
||||
//3.插入到租户信息,已存在的不予许插入
|
||||
//获取被邀请人是否已存在
|
||||
Integer count = userTenantMapper.userTenantIzExist(userByPhone.getId(), tenantId);
|
||||
//用户已存在
|
||||
if(count>0){
|
||||
result.setSuccess(false);
|
||||
result.setMessage("用户名(" + userByPhone.getRealname() + ")" + "手机号(" + userByPhone.getPhone() + ")" + "已存在该租户中,不能重复邀请");
|
||||
return result;
|
||||
}
|
||||
|
||||
//4.查询当前租户是否是拥有者,拥有者直接可以邀请,否则需要审核
|
||||
LambdaQueryWrapper<SysTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysTenant::getCreateBy, sysUser.getUsername());
|
||||
query.eq(SysTenant::getId, tenantId);
|
||||
Long tenantCount = tenantMapper.selectCount(query);
|
||||
//默认审核中
|
||||
String status = CommonConstant.USER_TENANT_UNDER_REVIEW;
|
||||
if (tenantCount > 0) {
|
||||
//是拥有者直接通过审核
|
||||
status = CommonConstant.USER_TENANT_NORMAL;
|
||||
}
|
||||
|
||||
//5.当前用户不存在租户中,就需要将用户添加到租户中
|
||||
SysUserTenant tenant = new SysUserTenant();
|
||||
tenant.setTenantId(tenantId);
|
||||
tenant.setUserId(userByPhone.getId());
|
||||
tenant.setStatus(status);
|
||||
userTenantMapper.insert(tenant);
|
||||
this.addUserProcess(userByPhone, sysUser, tenantId);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("邀请成员成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TenantDepartAuthInfo getTenantDepartAuthInfo(Integer tenantId) {
|
||||
SysTenant sysTenant = this.getById(tenantId);
|
||||
if(sysTenant==null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
TenantDepartAuthInfo info = new TenantDepartAuthInfo();
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = sysUser.getId();
|
||||
boolean superAdmin = false;
|
||||
// 查询pack表
|
||||
List<String> packCodeList = baseMapper.queryUserPackCode(tenantId, userId);
|
||||
if(packCodeList==null || packCodeList.size()==0){
|
||||
//如果没有数据 判断租户创建人是不是当前用户
|
||||
if(sysTenant.getCreateBy().equals(sysUser.getUsername())){
|
||||
sysTenantPackService.addDefaultTenantPack(tenantId);
|
||||
superAdmin = true;
|
||||
}else{
|
||||
superAdmin = false;
|
||||
}
|
||||
}
|
||||
if(superAdmin == false){
|
||||
List<TenantPackUserCount> packCountList = baseMapper.queryTenantPackUserCount(tenantId);
|
||||
info.setPackCountList(packCountList);
|
||||
}
|
||||
info.setSysTenant(sysTenant);
|
||||
info.setSuperAdmin(superAdmin);
|
||||
info.setPackCodes(packCodeList);
|
||||
return info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenantPackUserCount> queryTenantPackUserCount(Integer tenantId) {
|
||||
return baseMapper.queryTenantPackUserCount(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TenantPackModel queryTenantPack(TenantPackModel model) {
|
||||
Integer tenantId = model.getTenantId();
|
||||
String packCode = model.getPackCode();
|
||||
|
||||
SysTenantPack sysTenantPack = sysTenantPackService.getSysTenantPack(tenantId, packCode);
|
||||
if(sysTenantPack!=null){
|
||||
TenantPackModel tenantPackModel = new TenantPackModel();
|
||||
tenantPackModel.setPackName(sysTenantPack.getPackName());
|
||||
tenantPackModel.setPackId(sysTenantPack.getId());
|
||||
// 查询用户
|
||||
List<TenantPackUser> userList = getTenantPackUserList(tenantId, sysTenantPack.getId(), 1);
|
||||
tenantPackModel.setUserList(userList);
|
||||
return tenantPackModel;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addBatchTenantPackUser(SysTenantPackUser sysTenantPackUser) {
|
||||
String userIds = sysTenantPackUser.getUserId();
|
||||
if(oConvertUtils.isNotEmpty(userIds)){
|
||||
ISysTenantService currentService = SpringContextUtils.getApplicationContext().getBean(ISysTenantService.class);
|
||||
String realNames = sysTenantPackUser.getRealname();
|
||||
String[] userIdArray = userIds.split(",");
|
||||
String[] realNameArray = realNames.split(",");
|
||||
for(int i=0;i<userIdArray.length;i++){
|
||||
String userId = userIdArray[i];
|
||||
String realName = realNameArray[i];
|
||||
SysTenantPackUser entity = new SysTenantPackUser(sysTenantPackUser, userId, realName);
|
||||
LambdaQueryWrapper<SysTenantPackUser> query = new LambdaQueryWrapper<SysTenantPackUser>()
|
||||
.eq(SysTenantPackUser::getTenantId, entity.getTenantId())
|
||||
.eq(SysTenantPackUser::getPackId, entity.getPackId())
|
||||
.eq(SysTenantPackUser::getUserId, entity.getUserId());
|
||||
SysTenantPackUser packUser = sysTenantPackUserMapper.selectOne(query);
|
||||
if(packUser==null || packUser.getId()==null){
|
||||
currentService.addTenantPackUser(entity);
|
||||
}else{
|
||||
if(packUser.getStatus()==0){
|
||||
packUser.setPackName(entity.getPackName());
|
||||
packUser.setRealname(realName);
|
||||
currentService.addTenantPackUser(packUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TenantLog(2)
|
||||
@Override
|
||||
public void addTenantPackUser(SysTenantPackUser sysTenantPackUser) {
|
||||
if(sysTenantPackUser.getId()==null){
|
||||
sysTenantPackUserMapper.insert(sysTenantPackUser);
|
||||
}else{
|
||||
sysTenantPackUser.setStatus(1);
|
||||
sysTenantPackUserMapper.updateById(sysTenantPackUser);
|
||||
}
|
||||
}
|
||||
|
||||
@TenantLog(4)
|
||||
@Override
|
||||
public void deleteTenantPackUser(SysTenantPackUser sysTenantPackUser) {
|
||||
LambdaQueryWrapper<SysTenantPackUser> query = new LambdaQueryWrapper<SysTenantPackUser>()
|
||||
.eq(SysTenantPackUser::getUserId, sysTenantPackUser.getUserId())
|
||||
.eq(SysTenantPackUser::getPackId, sysTenantPackUser.getPackId());
|
||||
sysTenantPackUserMapper.delete(query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenantPackUser> getTenantPackApplyUsers(Integer tenantId) {
|
||||
return getTenantPackUserList(tenantId, null, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取租户下 某个产品包的用户
|
||||
* 或者是 租户下产品包的申请用户
|
||||
* @param tenantId
|
||||
* @param packId
|
||||
* @param packUserStatus
|
||||
* @return
|
||||
*/
|
||||
private List<TenantPackUser> getTenantPackUserList(Integer tenantId, String packId, Integer packUserStatus){
|
||||
// 查询用户
|
||||
List<TenantPackUser> userList = baseMapper.queryPackUserList(tenantId, packId, packUserStatus);
|
||||
if(userList!=null && userList.size()>0){
|
||||
List<String> userIdList = userList.stream().map(i->i.getId()).collect(Collectors.toList());
|
||||
// 部门
|
||||
List<UserDepart> depList = baseMapper.queryUserDepartList(userIdList);
|
||||
// 职位 TODO
|
||||
// 遍历用户 往用户中添加 部门信息和职位信息
|
||||
for(TenantPackUser user: userList){
|
||||
for(UserDepart dep: depList){
|
||||
if(user.getId().equals(dep.getUserId())){
|
||||
user.addDepart(dep.getDepartName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return userList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doApplyTenantPackUser(SysTenantPackUser sysTenantPackUser) {
|
||||
LambdaQueryWrapper<SysTenantPack> query1 = new LambdaQueryWrapper<SysTenantPack>()
|
||||
.eq(SysTenantPack::getTenantId, sysTenantPackUser.getTenantId())
|
||||
.eq(SysTenantPack::getPackCode, sysTenantPackUser.getPackCode());
|
||||
SysTenantPack pack = sysTenantPackService.getOne(query1);
|
||||
if(pack!=null){
|
||||
sysTenantPackUser.setStatus(0);
|
||||
sysTenantPackUser.setPackId(pack.getId());
|
||||
LambdaQueryWrapper<SysTenantPackUser> query = new LambdaQueryWrapper<SysTenantPackUser>()
|
||||
.eq(SysTenantPackUser::getTenantId, sysTenantPackUser.getTenantId())
|
||||
.eq(SysTenantPackUser::getPackId, sysTenantPackUser.getPackId())
|
||||
.eq(SysTenantPackUser::getUserId, sysTenantPackUser.getUserId());
|
||||
Long count = sysTenantPackUserMapper.selectCount(query);
|
||||
if(count==null || count==0){
|
||||
sysTenantPackUserMapper.insert(sysTenantPackUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void passApply(SysTenantPackUser sysTenantPackUser) {
|
||||
LambdaQueryWrapper<SysTenantPackUser> query = new LambdaQueryWrapper<SysTenantPackUser>()
|
||||
.eq(SysTenantPackUser::getTenantId, sysTenantPackUser.getTenantId())
|
||||
.eq(SysTenantPackUser::getPackId, sysTenantPackUser.getPackId())
|
||||
.eq(SysTenantPackUser::getUserId, sysTenantPackUser.getUserId());
|
||||
SysTenantPackUser packUser = sysTenantPackUserMapper.selectOne(query);
|
||||
if(packUser!=null && packUser.getId()!=null && packUser.getStatus()==0){
|
||||
ISysTenantService currentService = SpringContextUtils.getApplicationContext().getBean(ISysTenantService.class);
|
||||
packUser.setPackName(sysTenantPackUser.getPackName());
|
||||
packUser.setRealname(sysTenantPackUser.getRealname());
|
||||
currentService.addTenantPackUser(packUser);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteApply(SysTenantPackUser sysTenantPackUser) {
|
||||
LambdaQueryWrapper<SysTenantPackUser> query = new LambdaQueryWrapper<SysTenantPackUser>()
|
||||
.eq(SysTenantPackUser::getTenantId, sysTenantPackUser.getTenantId())
|
||||
.eq(SysTenantPackUser::getPackId, sysTenantPackUser.getPackId())
|
||||
.eq(SysTenantPackUser::getUserId, sysTenantPackUser.getUserId());
|
||||
SysTenantPackUser packUser = sysTenantPackUserMapper.selectOne(query);
|
||||
if(packUser!=null && packUser.getId()!=null && packUser.getStatus()==0){
|
||||
sysTenantPackUserMapper.deleteById(packUser.getId());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 触发入职流程
|
||||
*
|
||||
* @param user
|
||||
* @param loginUser
|
||||
* @param tenantId
|
||||
*/
|
||||
private void addUserProcess(SysUser user, LoginUser loginUser, Integer tenantId) {
|
||||
LoginUser userInfo = new LoginUser();
|
||||
//触发入职流程
|
||||
BeanUtils.copyProperties(user, userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@ -4,20 +4,27 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserDepart;
|
||||
import org.jeecg.modules.system.mapper.SysUserDepartMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserTenantMapper;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysUserDepartService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.vo.SysUserDepVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -37,8 +44,13 @@ import java.util.stream.Collectors;
|
||||
public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, SysUserDepart> implements ISysUserDepartService {
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private SysUserMapper sysUserMapper;
|
||||
@Autowired
|
||||
private SysUserTenantMapper userTenantMapper;
|
||||
|
||||
|
||||
/**
|
||||
@ -57,6 +69,14 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
for(SysUserDepart userDepart : userDepList) {
|
||||
depIdList.add(userDepart.getDepId());
|
||||
}
|
||||
|
||||
//update-begin---author:wangshuai ---date:20230112 for:判断是否开启租户saas模式,开启需要根据当前租户查询------------
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
Integer tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
queryDep.eq(SysDepart::getTenantId,tenantId);
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20230112 for:判断是否开启租户saas模式,开启需要根据当前租户查询------------
|
||||
|
||||
queryDep.in(SysDepart::getId, depIdList);
|
||||
List<SysDepart> depList = sysDepartService.list(queryDep);
|
||||
//jeecg-boot/issues/3906
|
||||
@ -144,7 +164,20 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
//update-begin---author:wangshuai ---date:20220902 for:[VUEN-2121]临时用户不能直接显示------------
|
||||
query.ne(SysUser::getUsername,"_reserve_user_external");
|
||||
//update-end---author:wangshuai ---date:20220902 for:[VUEN-2121]临时用户不能直接显示------------
|
||||
pageList = sysUserMapper.selectPage(page, query);
|
||||
|
||||
//------------------------------------------------------------------------------------------------
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
String tenantId = oConvertUtils.getString(TenantContext.getTenant(), "0");
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
List<String> userIdList = userTenantMapper.getUserIdsByTenantId(Integer.valueOf(tenantId));
|
||||
if(null!=userIdList && userIdList.size()>0){
|
||||
query.in(SysUser::getId,userIdList);
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------
|
||||
pageList = sysUserMapper.selectPage(page, query);
|
||||
}else{
|
||||
// 有部门ID 需要走自定义sql
|
||||
SysDepart sysDepart = sysDepartService.getById(departId);
|
||||
@ -172,7 +205,7 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> getUserInformation(String departId, String keyword, Integer pageSize, Integer pageNo) {
|
||||
public IPage<SysUser> getUserInformation(Integer tenantId, String departId, String keyword, Integer pageSize, Integer pageNo) {
|
||||
IPage<SysUser> pageList = null;
|
||||
// 部门ID不存在 直接查询用户表即可
|
||||
Page<SysUser> page = new Page<>(pageNo, pageSize);
|
||||
@ -181,10 +214,23 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUser::getStatus,Integer.parseInt(CommonConstant.STATUS_1));
|
||||
query.ne(SysUser::getUsername,"_reserve_user_external");
|
||||
|
||||
// 支持租户隔离
|
||||
if (tenantId != null) {
|
||||
List<String> userIds = userTenantMapper.getUserIdsByTenantId(tenantId);
|
||||
if(oConvertUtils.listIsNotEmpty(userIds)){
|
||||
query.in(SysUser::getId, userIds);
|
||||
}else{
|
||||
query.eq(SysUser::getId,"通过租户ID查不到用户");
|
||||
}
|
||||
}
|
||||
|
||||
//排除自己
|
||||
query.ne(SysUser::getId,sysUser.getId());
|
||||
//这个语法可以将or用括号包起来,避免数据查不到
|
||||
query.and((wrapper) -> wrapper.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname,keyword));
|
||||
if(StringUtils.isNotEmpty(keyword)){
|
||||
//这个语法可以将or用括号包起来,避免数据查不到
|
||||
query.and((wrapper) -> wrapper.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname,keyword));
|
||||
}
|
||||
pageList = sysUserMapper.selectPage(page, query);
|
||||
}else{
|
||||
// 有部门ID 需要走自定义sql
|
||||
@ -196,6 +242,52 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
return pageList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> getUserInformation(Integer tenantId, String departId,String roleId, String keyword, Integer pageSize, Integer pageNo) {
|
||||
IPage<SysUser> pageList = null;
|
||||
// 部门ID不存在 直接查询用户表即可
|
||||
Page<SysUser> page = new Page<>(pageNo, pageSize);
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
if(oConvertUtils.isNotEmpty(departId)){
|
||||
// 有部门ID 需要走自定义sql
|
||||
SysDepart sysDepart = sysDepartService.getById(departId);
|
||||
//update-begin-author:taoyan date:2023-1-3 for: 用户选择组件 加载用户需要根据租户ID过滤
|
||||
pageList = this.baseMapper.getProcessUserList(page, sysDepart.getOrgCode(), keyword, tenantId);
|
||||
} else if (oConvertUtils.isNotEmpty(roleId)) {
|
||||
pageList = this.sysUserMapper.selectUserListByRoleId(page, roleId, keyword, tenantId);
|
||||
//update-end-author:taoyan date:2023-1-3 for: 用户选择组件 加载用户需要根据租户ID过滤
|
||||
} else{
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUser::getStatus,Integer.parseInt(CommonConstant.STATUS_1));
|
||||
query.ne(SysUser::getUsername,"_reserve_user_external");
|
||||
|
||||
// 支持租户隔离
|
||||
if (tenantId != null) {
|
||||
List<String> userIds = userTenantMapper.getUserIdsByTenantId(tenantId);
|
||||
if(oConvertUtils.listIsNotEmpty(userIds)){
|
||||
query.in(SysUser::getId, userIds);
|
||||
}else{
|
||||
query.eq(SysUser::getId,"通过租户ID查不到用户");
|
||||
}
|
||||
}
|
||||
|
||||
if(StringUtils.isNotEmpty(keyword)){
|
||||
//这个语法可以将or用括号包起来,避免数据查不到
|
||||
query.and((wrapper) -> wrapper.like(SysUser::getUsername, keyword).or().like(SysUser::getRealname,keyword));
|
||||
}
|
||||
pageList = sysUserMapper.selectPage(page, query);
|
||||
}
|
||||
// 批量查询用户的所属部门
|
||||
// step.1 先拿到全部的 useids
|
||||
// step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if (userIds.size() > 0) {
|
||||
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
pageList.getRecords().forEach(item -> item.setOrgCodeTxt(useDepNames.get(item.getId())));
|
||||
}
|
||||
return pageList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 升级SpringBoot2.6.6,不允许循环依赖
|
||||
* @param userIds
|
||||
|
||||
@ -1,35 +1,53 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.config.TenantContext;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.FillRuleConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.constant.enums.RoleIndexConfigEnum;
|
||||
import org.jeecg.common.desensitization.annotation.SensitiveEncode;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.UUIDGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.config.mybatis.MybatisPlusSaasConfig;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.vo.SysUserDepVo;
|
||||
import org.jeecg.modules.system.vo.UserAvatar;
|
||||
import org.jeecg.modules.system.vo.lowapp.DepartAndUserInfo;
|
||||
import org.jeecg.modules.system.vo.lowapp.DepartInfo;
|
||||
import org.jeecg.modules.system.vo.lowapp.UpdateDepartInfo;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@ -71,6 +89,76 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
@Autowired
|
||||
SysRoleIndexMapper sysRoleIndexMapper;
|
||||
@Autowired
|
||||
SysTenantMapper sysTenantMapper;
|
||||
@Autowired
|
||||
private SysUserTenantMapper relationMapper;
|
||||
@Autowired
|
||||
private SysUserTenantMapper userTenantMapper;
|
||||
|
||||
@Override
|
||||
public Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo) {
|
||||
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
|
||||
//update-begin-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id
|
||||
//部门ID
|
||||
String departId = req.getParameter("departId");
|
||||
if (oConvertUtils.isNotEmpty(departId)) {
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserDepart::getDepId, departId);
|
||||
List<SysUserDepart> list = sysUserDepartMapper.selectList(query);
|
||||
List<String> userIds = list.stream().map(SysUserDepart::getUserId).collect(Collectors.toList());
|
||||
//update-begin---author:wangshuai ---date:20220322 for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------
|
||||
if (oConvertUtils.listIsNotEmpty(userIds)) {
|
||||
queryWrapper.in("id", userIds);
|
||||
} else {
|
||||
return Result.OK();
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20220322 for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------
|
||||
}
|
||||
//用户ID
|
||||
String code = req.getParameter("code");
|
||||
if (oConvertUtils.isNotEmpty(code)) {
|
||||
queryWrapper.in("id", Arrays.asList(code.split(",")));
|
||||
pageSize = code.split(",").length;
|
||||
}
|
||||
//update-end-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id
|
||||
|
||||
//update-begin-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户
|
||||
String status = req.getParameter("status");
|
||||
if (oConvertUtils.isNotEmpty(status)) {
|
||||
queryWrapper.eq("status", Integer.parseInt(status));
|
||||
}
|
||||
//update-end-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户
|
||||
|
||||
//TODO 外部模拟登陆临时账号,列表不显示
|
||||
queryWrapper.ne("username", "_reserve_user_external");
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
IPage<SysUser> pageList = this.page(page, queryWrapper);
|
||||
|
||||
//批量查询用户的所属部门
|
||||
//step.1 先拿到全部的 useids
|
||||
//step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if (userIds != null && userIds.size() > 0) {
|
||||
Map<String, String> useDepNames = this.getDepNamesByUserIds(userIds);
|
||||
pageList.getRecords().forEach(item -> {
|
||||
item.setOrgCodeTxt(useDepNames.get(item.getId()));
|
||||
//查询用户的租户ids
|
||||
List<Integer> list = userTenantMapper.getTenantIdsByUserId(item.getId());
|
||||
if (oConvertUtils.isNotEmpty(list)) {
|
||||
item.setRelTenantIds(StringUtils.join(list.toArray(), SymbolConstant.COMMA));
|
||||
} else {
|
||||
item.setRelTenantIds("");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
//log.info(pageList.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = {CacheConstant.SYS_USERS_CACHE}, allEntries = true)
|
||||
@ -123,7 +211,17 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
@Override
|
||||
public SysUser getUserByName(String username) {
|
||||
return userMapper.getUserByName(username);
|
||||
SysUser sysUser = userMapper.getUserByName(username);
|
||||
//查询用户的租户ids
|
||||
if(sysUser!=null){
|
||||
List<Integer> list = userTenantMapper.getTenantIdsByUserId(sysUser.getId());
|
||||
if (oConvertUtils.isNotEmpty(list)) {
|
||||
sysUser.setRelTenantIds(StringUtils.join(list.toArray(), SymbolConstant.COMMA));
|
||||
} else {
|
||||
sysUser.setRelTenantIds("");
|
||||
}
|
||||
}
|
||||
return sysUser;
|
||||
}
|
||||
|
||||
|
||||
@ -344,8 +442,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
@Override
|
||||
@CacheEvict(value= {CacheConstant.SYS_USERS_CACHE}, key="#username")
|
||||
public void updateUserDepart(String username,String orgCode) {
|
||||
baseMapper.updateUserDepart(username, orgCode);
|
||||
public void updateUserDepart(String username,String orgCode,Integer loginTenantId) {
|
||||
baseMapper.updateUserDepart(username, orgCode,loginTenantId);
|
||||
}
|
||||
|
||||
|
||||
@ -444,8 +542,12 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
@Override
|
||||
public List<SysUser> queryLogicDeleted() {
|
||||
return this.queryLogicDeleted(null);
|
||||
}
|
||||
//update-begin---author:wangshuai ---date:20221116 for:回收站查询未离职的------------
|
||||
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.ne(SysUser::getStatus, CommonConstant.USER_QUIT);
|
||||
return this.queryLogicDeleted(wrapper);
|
||||
//update-end---author:wangshuai ---date:20221116 for:回收站查询未离职的--------------
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> queryLogicDeleted(LambdaQueryWrapper<SysUser> wrapper) {
|
||||
@ -481,6 +583,9 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
//5. 删除第三方用户表(因为第4步需要用到第三方用户表,所以在他之后删)
|
||||
line += sysThirdAccountMapper.delete(new LambdaQueryWrapper<SysThirdAccount>().in(SysThirdAccount::getSysUserId, userIds));
|
||||
|
||||
//6. 删除租户用户中间表的数据
|
||||
line += userTenantMapper.delete(new LambdaQueryWrapper<SysUserTenant>().in(SysUserTenant::getUserId,userIds));
|
||||
|
||||
return line != 0;
|
||||
}
|
||||
|
||||
@ -514,9 +619,11 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) {
|
||||
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts, String relTenantIds) {
|
||||
//step.1 保存用户
|
||||
this.save(user);
|
||||
//获取用户保存前台传过来的租户id并添加到租户
|
||||
this.saveUserTenant(user.getId(),relTenantIds);
|
||||
//step.2 保存角色
|
||||
if(oConvertUtils.isNotEmpty(selectedRoles)) {
|
||||
String[] arr = selectedRoles.split(",");
|
||||
@ -525,6 +632,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
|
||||
//update-begin---author:wangshuai ---date:20230112 for:用户创建的时候增加临时角色 test------------
|
||||
//开启租户saas模式
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
String testRoleId = "ee8626f80f7c2619917b6236f3a7f02b";
|
||||
//如果前台没有传递角色或者传过来的劫色没有临时角色,那么默认临时角色 test
|
||||
if (oConvertUtils.isEmpty(selectedRoles) || !selectedRoles.contains(testRoleId)) {
|
||||
SysUserRole userRole = new SysUserRole(user.getId(), testRoleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
//update-end---author:wangshuai ---date:20230112 for:用户创建的时候增加临时角色 test------------
|
||||
|
||||
//step.3 保存所属部门
|
||||
if(oConvertUtils.isNotEmpty(selectedDeparts)) {
|
||||
String[] arr = selectedDeparts.split(",");
|
||||
@ -533,12 +653,19 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
sysUserDepartMapper.insert(userDeaprt);
|
||||
}
|
||||
}
|
||||
|
||||
//触发入职流程
|
||||
LoginUser userInfo=new LoginUser();
|
||||
BeanUtils.copyProperties(user,userInfo);
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void editUser(SysUser user, String roles, String departs) {
|
||||
public void editUser(SysUser user, String roles, String departs, String relTenantIds) {
|
||||
//获取用户编辑前台传过来的租户id
|
||||
this.editUserTenants(user.getId(),relTenantIds);
|
||||
//step.1 修改用户基础信息
|
||||
this.updateById(user);
|
||||
//step.2 修改角色
|
||||
@ -605,10 +732,527 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
LoginUser loginUser = new LoginUser();
|
||||
SysUser sysUser = userMapper.getUserByName(username);
|
||||
//查询用户的租户ids
|
||||
this.setUserTenantIds(sysUser);
|
||||
if(sysUser==null) {
|
||||
return null;
|
||||
}
|
||||
BeanUtils.copyProperties(sysUser, loginUser);
|
||||
return loginUser;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void userQuit(String username) {
|
||||
SysUser sysUser = userMapper.getUserByName(username);
|
||||
if(null == sysUser){
|
||||
throw new JeecgBootException("离职失败,该用户已不存在");
|
||||
}
|
||||
//update-begin---author:wangshuai ---date:20230111 for:[QQYUN-3951]租户用户离职重构------------
|
||||
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
//更新用户租户表的状态为离职状态
|
||||
if(tenantId==0){
|
||||
throw new JeecgBootException("离职失败,租户不存在");
|
||||
}
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getUserId,sysUser.getId());
|
||||
query.eq(SysUserTenant::getTenantId,tenantId);
|
||||
SysUserTenant userTenant = new SysUserTenant();
|
||||
userTenant.setStatus(CommonConstant.USER_TENANT_QUIT);
|
||||
userTenantMapper.update(userTenant,query);
|
||||
//update-end---author:wangshuai ---date:20230111 for:[QQYUN-3951]租户用户离职重构------------
|
||||
//触发离职流程
|
||||
LoginUser userInfo=new LoginUser();
|
||||
BeanUtils.copyProperties(sysUser,userInfo);
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> getQuitList(Integer tenantId) {
|
||||
return userMapper.getTenantQuitList(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStatusAndFlag(List<String> userIds, SysUser sysUser) {
|
||||
userMapper.updateStatusAndFlag(userIds,sysUser);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置登录租户
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<JSONObject> setLoginTenant(SysUser sysUser, JSONObject obj, String username, Result<JSONObject> result){
|
||||
// update-begin--Author:sunjianlei Date:20210802 for:获取用户租户信息
|
||||
//用户有哪些租户
|
||||
List<SysTenant> tenantList = null;
|
||||
//update-begin---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表------------
|
||||
List<Integer> tenantIdList = relationMapper.getTenantIdsNoStatus(sysUser.getId());
|
||||
if (null!=tenantIdList && tenantIdList.size()>0) {
|
||||
//update-end---author:wangshuai ---date:20221223 for:[QQYUN-3371]租户逻辑改造,改成关系表--------------
|
||||
//-------------------------------------------------------------------------------------
|
||||
//查询有效的租户集合
|
||||
LambdaQueryWrapper<SysTenant> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysTenant::getId, tenantIdList);
|
||||
queryWrapper.eq(SysTenant::getStatus, Integer.valueOf(CommonConstant.STATUS_1));
|
||||
tenantList = sysTenantMapper.selectList(queryWrapper);
|
||||
//-------------------------------------------------------------------------------------
|
||||
|
||||
if (tenantList.size() == 0) {
|
||||
return result.error500("与该用户关联的租户均已被冻结,无法登录!");
|
||||
} else {
|
||||
obj.put("tenantList", tenantList);
|
||||
}
|
||||
}
|
||||
// update-end--Author:sunjianlei Date:20210802 for:获取用户租户信息
|
||||
|
||||
|
||||
//登录会话租户ID,有效性重置
|
||||
if (tenantList != null && tenantList.size() > 0) {
|
||||
if (tenantList.size() == 1) {
|
||||
sysUser.setLoginTenantId(tenantList.get(0).getId());
|
||||
} else {
|
||||
List<SysTenant> listAfterFilter = tenantList.stream().filter(s -> s.getId().equals(sysUser.getLoginTenantId())).collect(Collectors.toList());
|
||||
if (listAfterFilter == null || listAfterFilter.size() == 0) {
|
||||
//如果上次登录租户ID,在用户拥有的租户集合里面没有了,则随机取用户拥有的第一个租户ID
|
||||
sysUser.setLoginTenantId(tenantList.get(0).getId());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//无租户的时候,设置为 0
|
||||
sysUser.setLoginTenantId(0);
|
||||
}
|
||||
//设置用户登录缓存租户
|
||||
this.updateUserDepart(username, null,sysUser.getLoginTenantId());
|
||||
log.info(" 登录接口用户的租户ID = {}", sysUser.getLoginTenantId());
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取租户id
|
||||
* @param sysUser
|
||||
*/
|
||||
private void setUserTenantIds(SysUser sysUser) {
|
||||
if(ObjectUtils.isNotEmpty(sysUser)) {
|
||||
List<Integer> list = relationMapper.getTenantIdsNoStatus(sysUser.getId());
|
||||
if(null!=list && list.size()>0){
|
||||
sysUser.setRelTenantIds(StringUtils.join(list.toArray(), ","));
|
||||
}else{
|
||||
sysUser.setRelTenantIds("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存租户
|
||||
* @param userId
|
||||
* @param relTenantIds
|
||||
*/
|
||||
private void saveUserTenant(String userId, String relTenantIds) {
|
||||
if (oConvertUtils.isNotEmpty(relTenantIds)) {
|
||||
String[] tenantIds = relTenantIds.split(SymbolConstant.COMMA);
|
||||
for (String tenantId : tenantIds) {
|
||||
SysUserTenant relation = new SysUserTenant();
|
||||
relation.setUserId(userId);
|
||||
relation.setTenantId(Integer.valueOf(tenantId));
|
||||
relation.setStatus(CommonConstant.STATUS_1);
|
||||
relationMapper.insert(relation);
|
||||
}
|
||||
}else{
|
||||
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
||||
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) {
|
||||
SysUserTenant relation = new SysUserTenant();
|
||||
relation.setUserId(userId);
|
||||
String tenantId = oConvertUtils.getString(TenantContext.getTenant(), "0");
|
||||
relation.setTenantId(Integer.valueOf(tenantId));
|
||||
relation.setStatus(CommonConstant.STATUS_1);
|
||||
relationMapper.insert(relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑租户
|
||||
* @param userId
|
||||
* @param relTenantIds
|
||||
*/
|
||||
private void editUserTenants(String userId, String relTenantIds) {
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getUserId, userId);
|
||||
//数据库的租户id
|
||||
List<Integer> oldTenantIds = relationMapper.getTenantIdsNoStatus(userId);
|
||||
//如果传过来的租户id为空,那么就删除租户
|
||||
if (oConvertUtils.isEmpty(relTenantIds)) {
|
||||
this.deleteTenantByUserId(userId, null);
|
||||
} else if (oConvertUtils.isNotEmpty(relTenantIds) && oConvertUtils.isEmpty(oldTenantIds)) {
|
||||
//如果传过来的租户id不为空但是数据库的租户id为空,那么就新增
|
||||
this.saveUserTenant(userId, relTenantIds);
|
||||
} else {
|
||||
//都不为空,需要比较,进行添加或删除
|
||||
if(oConvertUtils.isNotEmpty(oldTenantIds)){
|
||||
//找到新的租户id与原来的租户id不同之处,进行删除
|
||||
List<Integer> tenantIdList = oldTenantIds.stream().filter(item -> !relTenantIds.contains(item.toString())).collect(Collectors.toList());
|
||||
for (Integer tenantId : tenantIdList) {
|
||||
this.deleteTenantByUserId(userId, tenantId);
|
||||
}
|
||||
//找到原来租户的用户id与新的租户id不同之处,进行新增
|
||||
String tenantIds = Arrays.stream(relTenantIds.split(SymbolConstant.COMMA)).filter(item -> !oldTenantIds.contains(Integer.valueOf(item))).collect(Collectors.joining(","));
|
||||
this.saveUserTenant(userId, tenantIds);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除租户通过用户id
|
||||
* @param tenantId
|
||||
* @param userId
|
||||
*/
|
||||
private void deleteTenantByUserId(String userId,Integer tenantId){
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getUserId, userId);
|
||||
if(oConvertUtils.isNotEmpty(tenantId)){
|
||||
query.eq(SysUserTenant::getTenantId, tenantId);
|
||||
}
|
||||
relationMapper.delete(query);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void batchEditUsers(JSONObject json) {
|
||||
String userIds = json.getString("userIds");
|
||||
List<String> idList = JSONArray.parseArray(userIds, String.class);
|
||||
//部门
|
||||
String selecteddeparts = json.getString("selecteddeparts");
|
||||
//职位
|
||||
String post = json.getString("post");
|
||||
//工作地点? 没有这个字段
|
||||
String workAddress = json.getString("workAddress");
|
||||
if(oConvertUtils.isNotEmpty(post)) {
|
||||
LambdaUpdateWrapper<SysUser> updateWrapper = new UpdateWrapper<SysUser>().lambda()
|
||||
.in(SysUser::getId, idList)
|
||||
.set(SysUser::getPost, post);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
if(oConvertUtils.isNotEmpty(selecteddeparts)) {
|
||||
//查询当前租户的部门列表
|
||||
Integer currentTenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);
|
||||
LambdaQueryWrapper<SysDepart> departQuery = new LambdaQueryWrapper<SysDepart>()
|
||||
.eq(SysDepart::getTenantId, currentTenantId);
|
||||
List<SysDepart> departList = sysDepartMapper.selectList(departQuery);
|
||||
if(departList==null || departList.size()==0){
|
||||
log.error("batchEditUsers 根据租户ID没有找到部门>"+currentTenantId);
|
||||
return;
|
||||
}
|
||||
List<String> departIdList = new ArrayList<String>();
|
||||
for(SysDepart depart: departList){
|
||||
if(depart!=null){
|
||||
String id = depart.getId();
|
||||
if(oConvertUtils.isNotEmpty(id)){
|
||||
departIdList.add(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
//删除人员的部门关联
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>()
|
||||
.in(SysUserDepart::getUserId, idList)
|
||||
.in(SysUserDepart::getDepId, departIdList);
|
||||
sysUserDepartMapper.delete(query);
|
||||
|
||||
String[] arr = selecteddeparts.split(",");
|
||||
|
||||
//再新增
|
||||
for (String deaprtId : arr) {
|
||||
for(String userId: idList){
|
||||
SysUserDepart userDepart = new SysUserDepart(userId, deaprtId);
|
||||
sysUserDepartMapper.insert(userDepart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DepartAndUserInfo searchByKeyword(String keyword) {
|
||||
DepartAndUserInfo departAndUserInfo = new DepartAndUserInfo();
|
||||
if(oConvertUtils.isNotEmpty(keyword)){
|
||||
LambdaQueryWrapper<SysUser> query1 = new LambdaQueryWrapper<SysUser>()
|
||||
.like(SysUser::getRealname, keyword);
|
||||
String str = oConvertUtils.getString(TenantContext.getTenant(), "0");
|
||||
Integer tenantId = Integer.valueOf(str);
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
List<String> userIds = userTenantMapper.getUserIdsByTenantId(tenantId);
|
||||
if (oConvertUtils.listIsNotEmpty(userIds)) {
|
||||
query1.in(SysUser::getId, userIds);
|
||||
}else{
|
||||
query1.eq(SysUser::getId, "");
|
||||
}
|
||||
}
|
||||
List<SysUser> list1 = this.baseMapper.selectList(query1);
|
||||
if(list1!=null && list1.size()>0){
|
||||
List<UserAvatar> userList = list1.stream().map(v -> new UserAvatar(v)).collect(Collectors.toList());
|
||||
departAndUserInfo.setUserList(userList);
|
||||
}
|
||||
|
||||
LambdaQueryWrapper<SysDepart> query2 = new LambdaQueryWrapper<SysDepart>()
|
||||
.like(SysDepart::getDepartName, keyword);
|
||||
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){
|
||||
query2.eq(SysDepart::getTenantId, tenantId);
|
||||
}
|
||||
List<SysDepart> list2 = sysDepartMapper.selectList(query2);
|
||||
if(list2!=null && list2.size()>0){
|
||||
List<DepartInfo> departList = new ArrayList<>();
|
||||
for(SysDepart depart: list2){
|
||||
List<String> orgName = new ArrayList<>();
|
||||
List<String> orgId = new ArrayList<>();
|
||||
getParentDepart(depart, orgName, orgId);
|
||||
DepartInfo departInfo = new DepartInfo();
|
||||
departInfo.setId(depart.getId());
|
||||
departInfo.setOrgId(orgId);
|
||||
departInfo.setOrgName(orgName);
|
||||
departList.add(departInfo);
|
||||
}
|
||||
departAndUserInfo.setDepartList(departList);
|
||||
}
|
||||
}
|
||||
return departAndUserInfo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UpdateDepartInfo getUpdateDepartInfo(String departId) {
|
||||
SysDepart depart = sysDepartMapper.selectById(departId);
|
||||
if(depart!=null){
|
||||
UpdateDepartInfo info = new UpdateDepartInfo(depart);
|
||||
List<SysDepart> subList = sysDepartMapper.queryDeptByPid(departId);
|
||||
if(subList!=null && subList.size()>0){
|
||||
info.setHasSub(true);
|
||||
}
|
||||
//获取部门负责人信息
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<SysUser>()
|
||||
.eq(SysUser::getUserIdentity, 2)
|
||||
.like(SysUser::getDepartIds, depart.getId());
|
||||
List<SysUser> userList = this.baseMapper.selectList(query);
|
||||
if(userList!=null && userList.size()>0){
|
||||
List<String> idList = userList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
||||
info.setChargePersonList(idList);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doUpdateDepartInfo(UpdateDepartInfo info) {
|
||||
String departId = info.getDepartId();
|
||||
SysDepart depart = sysDepartMapper.selectById(departId);
|
||||
if(depart!=null){
|
||||
//修改部门信息-上级和部门名称
|
||||
if(!depart.getParentId().equals(info.getParentId())){
|
||||
String pid = info.getParentId();
|
||||
SysDepart parentDepart = sysDepartMapper.selectById(pid);
|
||||
if(parentDepart!=null){
|
||||
String orgCode = getNextOrgCode(pid);
|
||||
depart.setOrgCode(orgCode);
|
||||
depart.setParentId(pid);
|
||||
}
|
||||
}
|
||||
depart.setDepartName(info.getDepartName());
|
||||
sysDepartMapper.updateById(depart);
|
||||
//先查询这个部门的负责人
|
||||
List<SysUser> departChargeUsers = queryDepartChargePersons(departId);
|
||||
List<String> departChargeUserIdList = departChargeUsers.stream().map(i -> i.getId()).collect(Collectors.toList());
|
||||
//修改部门负责人
|
||||
List<String> userIdList = info.getChargePersonList();
|
||||
if(userIdList!=null && userIdList.size()>0){
|
||||
for(String userId: userIdList){
|
||||
SysUser user = this.baseMapper.selectById(userId);
|
||||
if(user!=null){
|
||||
departChargeUserIdList.remove(user.getId());
|
||||
user.setUserIdentity(2);
|
||||
String departIds = user.getDepartIds();
|
||||
if(oConvertUtils.isEmpty(departIds)){
|
||||
user.setDepartIds(departId);
|
||||
}else{
|
||||
List<String> list = new ArrayList<String>(Arrays.asList(departIds.split(",")));
|
||||
if(list.indexOf(departId)>=0){
|
||||
continue;
|
||||
}else{
|
||||
list.add(departId);
|
||||
String newDepartIds = String.join(",", list);
|
||||
user.setDepartIds(newDepartIds);
|
||||
}
|
||||
}
|
||||
this.baseMapper.updateById(user);
|
||||
}
|
||||
}
|
||||
//删除
|
||||
for(String chargeUserId: departChargeUserIdList){
|
||||
for(SysUser chargeUser: departChargeUsers){
|
||||
if(chargeUser.getId().equals(chargeUserId)){
|
||||
String departIds = chargeUser.getDepartIds();
|
||||
List<String> list = new ArrayList<String>(Arrays.asList(departIds.split(",")));
|
||||
list.remove(departId);
|
||||
String newDepartIds = String.join(",", list);
|
||||
chargeUser.setDepartIds(newDepartIds);
|
||||
this.baseMapper.updateById(chargeUser);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<SysUser> queryDepartChargePersons(String departId){
|
||||
List<SysUser> result = new ArrayList<>();
|
||||
LambdaQueryWrapper<SysUserDepart> query1 = new LambdaQueryWrapper<SysUserDepart>()
|
||||
.eq(SysUserDepart::getDepId, departId);
|
||||
List<SysUserDepart> list1 = sysUserDepartMapper.selectList(query1);
|
||||
if(list1!=null && list1.size()>0){
|
||||
List<String> userIdList = list1.stream().map(item -> item.getUserId()).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<SysUser> query2 = new LambdaQueryWrapper<SysUser>()
|
||||
.in(SysUser::getId, userIdList);
|
||||
List<SysUser> userList = this.baseMapper.selectList(query2);
|
||||
if(userList!=null && userList.size()>0){
|
||||
for(SysUser user: userList){
|
||||
Integer identity = user.getUserIdentity();
|
||||
String deps = user.getDepartIds();
|
||||
if(identity!=null && identity==2){
|
||||
if(oConvertUtils.isNotEmpty(deps)){
|
||||
if(deps.indexOf(departId)>=0){
|
||||
result.add(user);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 变更父级部门 修改编码
|
||||
* @param parentId
|
||||
* @return
|
||||
*/
|
||||
private String getNextOrgCode(String parentId){
|
||||
JSONObject formData = new JSONObject();
|
||||
formData.put("parentId",parentId);
|
||||
String[] codeArray = (String[]) FillRuleUtil.executeRule(FillRuleConstant.DEPART, formData);
|
||||
return codeArray[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changeDepartChargePerson(JSONObject json) {
|
||||
String userId = json.getString("userId");
|
||||
String departId = json.getString("departId");
|
||||
boolean status = json.getBoolean("status");
|
||||
SysUser user = this.getById(userId);
|
||||
if(user!=null){
|
||||
String ids = user.getDepartIds();
|
||||
if(status==true){
|
||||
//设置部门负责人
|
||||
if(oConvertUtils.isEmpty(ids)){
|
||||
user.setDepartIds(departId);
|
||||
}else{
|
||||
List<String> list = new ArrayList<String>(Arrays.asList(ids.split(",")));
|
||||
if(list.indexOf(departId)>=0){
|
||||
//啥也不干
|
||||
}else{
|
||||
list.add(departId);
|
||||
String newIds = String.join(",", list);
|
||||
user.setDepartIds(newIds);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
// 取消负责人
|
||||
if(oConvertUtils.isNotEmpty(ids)){
|
||||
List<String> list = new ArrayList<String>();
|
||||
for(String temp: ids.split(",")){
|
||||
if(oConvertUtils.isEmpty(temp)){
|
||||
continue;
|
||||
}
|
||||
if(!temp.equals(departId)){
|
||||
list.add(temp);
|
||||
}
|
||||
}
|
||||
String newIds = "";
|
||||
if(list.size()>0){
|
||||
newIds = String.join(",", list);
|
||||
}
|
||||
user.setDepartIds(newIds);
|
||||
}
|
||||
}
|
||||
this.updateById(user);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 找上级部门
|
||||
* @param depart
|
||||
* @param orgName
|
||||
* @param orgId
|
||||
*/
|
||||
private void getParentDepart(SysDepart depart,List<String> orgName,List<String> orgId){
|
||||
String pid = depart.getParentId();
|
||||
orgName.add(0, depart.getDepartName());
|
||||
orgId.add(0, depart.getId());
|
||||
if(oConvertUtils.isNotEmpty(pid)){
|
||||
SysDepart temp = sysDepartMapper.selectById(pid);
|
||||
getParentDepart(temp, orgName, orgId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void editTenantUser(SysUser sysUser, String tenantId, String departs, String roles) {
|
||||
SysUser user = new SysUser();
|
||||
user.setWorkNo(sysUser.getWorkNo());
|
||||
user.setPost(sysUser.getPost());
|
||||
user.setId(sysUser.getId());
|
||||
this.updateById(user);
|
||||
//修改租户用户下的部门
|
||||
this.updateTenantDepart(user, tenantId, departs);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改租户下的部门
|
||||
* @param departs
|
||||
*/
|
||||
public void updateTenantDepart(SysUser user, String tenantId, String departs) {
|
||||
List<String> departList = new ArrayList<>();
|
||||
if (oConvertUtils.isNotEmpty(departs)) {
|
||||
//获取当前租户下的部门id,根据前台
|
||||
departList = sysUserDepartMapper.getTenantDepart(Arrays.asList(departs.split(SymbolConstant.COMMA)), tenantId);
|
||||
}
|
||||
//查询当前租户下部门和用户已关联的部门
|
||||
List<SysUserDepart> userDepartList = sysUserDepartMapper.getTenantUserDepart(user.getId(), tenantId);
|
||||
if (userDepartList != null && userDepartList.size() > 0 && departList.size() > 0) {
|
||||
for (SysUserDepart depart : userDepartList) {
|
||||
//修改已关联部门删除部门用户角色关系
|
||||
if (!departList.contains(depart.getDepId())) {
|
||||
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList(
|
||||
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId, depart.getDepId()));
|
||||
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList());
|
||||
if (roleIds.size() > 0) {
|
||||
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId())
|
||||
.in(SysDepartRoleUser::getDroleId, roleIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (departList.size() > 0) {
|
||||
//删除用户下的部门
|
||||
sysUserDepartMapper.deleteUserDepart(user.getId(), tenantId);
|
||||
for (String departId : departList) {
|
||||
//添加部门
|
||||
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId);
|
||||
sysUserDepartMapper.insert(userDepart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,150 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.SymbolConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserTenant;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserTenantMapper;
|
||||
import org.jeecg.modules.system.service.ISysUserTenantService;
|
||||
import org.jeecg.modules.system.vo.SysUserDepVo;
|
||||
import org.jeecg.modules.system.vo.SysUserTenantVo;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: sys_user_tenant_relation
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2022-12-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysUserTenantServiceImpl extends ServiceImpl<SysUserTenantMapper, SysUserTenant> implements ISysUserTenantService {
|
||||
|
||||
@Autowired
|
||||
private SysUserTenantMapper userTenantMapper;
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
|
||||
@Override
|
||||
public Page<SysUser> getPageUserList(Page<SysUser> page, Integer userTenantId, SysUser user) {
|
||||
return page.setRecords(userTenantMapper.getPageUserList(page,userTenantId,user));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> setUserTenantIds(List<SysUser> records) {
|
||||
if(null == records || records.size() == 0){
|
||||
return records;
|
||||
}
|
||||
for (SysUser sysUser:records) {
|
||||
//查询租户id
|
||||
List<Integer> list = userTenantMapper.getTenantIdsByUserId(sysUser.getId());
|
||||
if(oConvertUtils.isNotEmpty(list)){
|
||||
sysUser.setRelTenantIds(StringUtils.join(list.toArray(), SymbolConstant.COMMA));
|
||||
}else{
|
||||
sysUser.setRelTenantIds("");
|
||||
}
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getUserIdsByTenantId(Integer tenantId) {
|
||||
return userTenantMapper.getUserIdsByTenantId(tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getTenantIdsByUserId(String userId) {
|
||||
return userTenantMapper.getTenantIdsByUserId(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUserTenantVo> getTenantListByUserId(String userId, List<String> userTenantStatus) {
|
||||
return userTenantMapper.getTenantListByUserId(userId, userTenantStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUserTenantStatus(String id, String tenantId, String userTenantStatus) {
|
||||
if (oConvertUtils.isEmpty(tenantId)) {
|
||||
throw new JeecgBootException("租户数据为空");
|
||||
}
|
||||
LambdaQueryWrapper<SysUserTenant> query = new LambdaQueryWrapper<>();
|
||||
query.eq(SysUserTenant::getUserId, id);
|
||||
query.eq(SysUserTenant::getTenantId, Integer.valueOf(tenantId));
|
||||
SysUserTenant userTenant = userTenantMapper.selectOne(query);
|
||||
if (null == userTenant) {
|
||||
throw new JeecgBootException("租户数据为空");
|
||||
}
|
||||
SysUserTenant tenant = new SysUserTenant();
|
||||
tenant.setStatus(userTenantStatus);
|
||||
this.update(tenant, query);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUserTenantVo> getUserTenantPageList(Page<SysUserTenantVo> page, List<String> status, SysUser user, Integer tenantId) {
|
||||
List<SysUserTenantVo> tenantPageList = userTenantMapper.getUserTenantPageList(page, status, user, tenantId);
|
||||
List<String> userIds = tenantPageList.stream().map(SysUserTenantVo::getId).collect(Collectors.toList());
|
||||
if (userIds != null && userIds.size() > 0) {
|
||||
Map<String, String> useDepNames = this.getDepNamesByUserIds(userIds);
|
||||
tenantPageList.forEach(item -> {
|
||||
item.setOrgCodeTxt(useDepNames.get(item.getId()));
|
||||
//查询用户的租户ids
|
||||
List<Integer> list = userTenantMapper.getTenantIdsNoStatus(item.getId());
|
||||
if (oConvertUtils.isNotEmpty(list)) {
|
||||
item.setRelTenantIds(StringUtils.join(list.toArray(), SymbolConstant.COMMA));
|
||||
} else {
|
||||
item.setRelTenantIds("");
|
||||
}
|
||||
});
|
||||
}
|
||||
return page.setRecords(tenantPageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取部门名称
|
||||
*
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
|
||||
List<SysUserDepVo> list = userMapper.getDepNamesByUserIds(userIds);
|
||||
Map<String, String> res = new HashMap(5);
|
||||
list.forEach(item -> {
|
||||
if (res.get(item.getUserId()) == null) {
|
||||
res.put(item.getUserId(), item.getDepartName());
|
||||
} else {
|
||||
res.put(item.getUserId(), res.get(item.getUserId()) + "," + item.getDepartName());
|
||||
}
|
||||
}
|
||||
);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void putCancelQuit(List<String> userIds, Integer tenantId) {
|
||||
userTenantMapper.putCancelQuit(userIds, tenantId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer userTenantIzExist(String userId, Integer tenantId) {
|
||||
return userTenantMapper.userTenantIzExist(userId,tenantId);
|
||||
}
|
||||
}
|
||||
@ -29,6 +29,7 @@ import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.JeecgBaseConfig;
|
||||
import org.jeecg.config.thirdapp.ThirdAppConfig;
|
||||
import org.jeecg.config.thirdapp.ThirdAppTypeItemVo;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
@ -59,6 +60,8 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
|
||||
@Autowired
|
||||
JeecgBaseConfig jeecgBaseConfig;
|
||||
@Autowired
|
||||
ThirdAppConfig thirdAppConfig;
|
||||
@Autowired
|
||||
@ -769,7 +772,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
// 封装钉钉消息
|
||||
String title = message.getTitle();
|
||||
String content = message.getContent();
|
||||
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
|
||||
String agentId = thirdAppConfig.getDingtalk().getAgentId();
|
||||
Message<MarkdownMessage> mdMessage = new Message<>(agentId, new MarkdownMessage(title, content));
|
||||
if (message.getToAll()) {
|
||||
mdMessage.setTo_all_user(true);
|
||||
@ -793,7 +796,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
}
|
||||
// 封装钉钉消息
|
||||
String content = message.getContent();
|
||||
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
|
||||
String agentId = thirdAppConfig.getDingtalk().getAgentId();
|
||||
Message<TextMessage> textMessage = new Message<>(agentId, new TextMessage(content));
|
||||
if (message.getToAll()) {
|
||||
textMessage.setTo_all_user(true);
|
||||
@ -826,7 +829,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
if (accessToken == null) {
|
||||
return null;
|
||||
}
|
||||
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
|
||||
String agentId = thirdAppConfig.getDingtalk().getAgentId();
|
||||
return JdtMessageAPI.recallMessage(agentId, msgTaskId, getAccessToken());
|
||||
}
|
||||
|
||||
@ -845,12 +848,22 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
if (accessToken == null) {
|
||||
return null;
|
||||
}
|
||||
int agentId = thirdAppConfig.getDingtalk().getAgentIdInt();
|
||||
String agentId = thirdAppConfig.getDingtalk().getAgentId();
|
||||
String markdown = "### " + announcement.getTitile() + "\n" + oConvertUtils.getString(announcement.getMsgAbstract(),"空");
|
||||
ActionCardMessage actionCard = new ActionCardMessage(markdown);
|
||||
actionCard.setTitle(announcement.getTitile());
|
||||
actionCard.setSingle_title("详情");
|
||||
actionCard.setSingle_url(RestUtil.getBaseUrl() + "/sys/annountCement/show/" + announcement.getId());
|
||||
String baseUrl = null;
|
||||
//优先通过请求获取basepath,获取不到读取 jeecg.domainUrl.pc
|
||||
try {
|
||||
baseUrl = RestUtil.getBaseUrl();
|
||||
} catch (Exception e) {
|
||||
log.warn(e.getMessage());
|
||||
baseUrl = jeecgBaseConfig.getDomainUrl().getPc();
|
||||
//e.printStackTrace();
|
||||
}
|
||||
|
||||
actionCard.setSingle_url(baseUrl + "/sys/annountCement/show/" + announcement.getId());
|
||||
Message<ActionCardMessage> actionCardMessage = new Message<>(agentId, actionCard);
|
||||
if (CommonConstant.MSG_TYPE_ALL.equals(announcement.getMsgType())) {
|
||||
actionCardMessage.setTo_all_user(true);
|
||||
|
||||
@ -0,0 +1,57 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @author: wangshuai
|
||||
* @date: 2022年09月27日 20:56
|
||||
*/
|
||||
@Data
|
||||
public class SysFileLogVo {
|
||||
/**
|
||||
* 文件id
|
||||
*/
|
||||
private String fileId;
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
/**
|
||||
* 日志内容
|
||||
*/
|
||||
private String dataContent;
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realname;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 日志创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 路径
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 是否为文件夹
|
||||
*/
|
||||
private String izFolder;
|
||||
}
|
||||
@ -0,0 +1,142 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @author: wangshuai
|
||||
* @date: 2022年09月21日 17:27
|
||||
*/
|
||||
@Data
|
||||
public class SysFilesVo {
|
||||
/**
|
||||
* 需要复制的文件夹或者文件id
|
||||
*/
|
||||
private String fileId;
|
||||
|
||||
/**
|
||||
* 需要复制到哪个文件夹下的id
|
||||
*/
|
||||
private String copyToFileId;
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 委托人的用户id
|
||||
*/
|
||||
private String msgTo;
|
||||
|
||||
/**
|
||||
* 权限
|
||||
*/
|
||||
private String authority;
|
||||
|
||||
/**
|
||||
* 文件名称
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
|
||||
/**
|
||||
* 删除状态
|
||||
*/
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 文件大小
|
||||
*/
|
||||
private Double fileSize;
|
||||
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
private String fileUrl;
|
||||
|
||||
/**
|
||||
* 说明(添加到系统日志)
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private String createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private String updateTime;
|
||||
|
||||
/**
|
||||
* 下载数
|
||||
*/
|
||||
private String downCount;
|
||||
|
||||
/**
|
||||
* 阅读数
|
||||
*/
|
||||
private String readCount;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String parentId;
|
||||
|
||||
/**
|
||||
* 分享地址
|
||||
*/
|
||||
private String shareUrl;
|
||||
|
||||
/**
|
||||
* 是否允许下载(1:是 0:否)
|
||||
*/
|
||||
private String enableDown;
|
||||
|
||||
/**
|
||||
* 分享权限(1.关闭分享 2.允许所有联系人查看 3.允许任何人查看)
|
||||
*/
|
||||
private String sharePerms;
|
||||
|
||||
/**
|
||||
* 是否允许修改(1:是 0:否)
|
||||
*/
|
||||
private String enableUpdat;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 真实姓名
|
||||
*/
|
||||
private String realname;
|
||||
|
||||
/**
|
||||
* 权限方式(enableDown:下载,enableUpdat:修改,sharePerms:分享权限,reduction:还原,rename:重命名,newFile:上传新版本)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 最上级的id
|
||||
*/
|
||||
private String rootId;
|
||||
|
||||
/**
|
||||
* 是否为文件夹(0否 1是)
|
||||
*/
|
||||
private String izFolder;
|
||||
|
||||
/**
|
||||
* 是否为一级文件夹(0否 1是)
|
||||
*/
|
||||
private String izRootFolder;
|
||||
}
|
||||
@ -0,0 +1,32 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @author: wangshuai
|
||||
* @date: 2022年12月07日 16:41
|
||||
*/
|
||||
@Data
|
||||
public class SysUserRoleCountVo {
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private String id;
|
||||
/**
|
||||
* 角色名称
|
||||
*/
|
||||
private String roleName;
|
||||
/**
|
||||
* 角色描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 角色编码
|
||||
*/
|
||||
private String roleCode;
|
||||
/**
|
||||
* 角色下的用户数量
|
||||
*/
|
||||
private Long count;
|
||||
}
|
||||
@ -0,0 +1,104 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
|
||||
/**
|
||||
* @Description: 用户租户类(用户数据租户数据)
|
||||
* @author: wangshuai
|
||||
* @date: 2023年01月08日 17:27
|
||||
*/
|
||||
@Data
|
||||
public class SysUserTenantVo {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 用户账号
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String realname;
|
||||
|
||||
/**
|
||||
* 工号
|
||||
*/
|
||||
private String workNo;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 职位
|
||||
*/
|
||||
private String post;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 部门名称
|
||||
*/
|
||||
private String orgCodeTxt;
|
||||
|
||||
/**
|
||||
* 部门code
|
||||
*/
|
||||
private String orgCode;
|
||||
|
||||
/**
|
||||
* 租户id
|
||||
*/
|
||||
private String relTenantIds;
|
||||
|
||||
/**
|
||||
* 租户创建人
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 用户租户状态
|
||||
*/
|
||||
private String userTenantStatus;
|
||||
|
||||
/**
|
||||
* 用户租户id
|
||||
*/
|
||||
private String tenantUserId;
|
||||
|
||||
/**
|
||||
* 租户名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 所属行业
|
||||
*/
|
||||
@Dict(dicCode = "trade")
|
||||
private String trade;
|
||||
|
||||
/**
|
||||
* 门牌号
|
||||
*/
|
||||
private String houseNumber;
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
|
||||
/**
|
||||
* 用户名和头像信息
|
||||
@ -16,4 +17,12 @@ public class UserAvatar {
|
||||
|
||||
private String avatar;
|
||||
|
||||
public UserAvatar(){
|
||||
|
||||
}
|
||||
public UserAvatar(SysUser sysUser){
|
||||
this.id = sysUser.getId();
|
||||
this.realname = sysUser.getRealname();
|
||||
this.avatar = sysUser.getAvatar();
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package org.jeecg.modules.system.vo.lowapp;
|
||||
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.system.vo.UserAvatar;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户或者部门的信息
|
||||
* 用于 成员与部门 的搜索
|
||||
* @Author taoYan
|
||||
* @Date 2022/12/30 10:47
|
||||
**/
|
||||
@Data
|
||||
public class DepartAndUserInfo implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
List<UserAvatar> userList;
|
||||
|
||||
List<DepartInfo> departList;
|
||||
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package org.jeecg.modules.system.vo.lowapp;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author taoYan
|
||||
* @Date 2022/12/30 10:52
|
||||
**/
|
||||
@Data
|
||||
public class DepartInfo {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 上级名称-下级名称
|
||||
*/
|
||||
private List<String> orgName;
|
||||
|
||||
/**
|
||||
* 上级ID-下级ID
|
||||
*/
|
||||
private List<String> orgId;
|
||||
|
||||
}
|
||||
@ -0,0 +1,37 @@
|
||||
package org.jeecg.modules.system.vo.lowapp;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SysDictVo {
|
||||
/**
|
||||
* 字典id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典名称
|
||||
*/
|
||||
private String dictName;
|
||||
|
||||
/**
|
||||
* 字典编码
|
||||
*/
|
||||
private String dictCode;
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
private String lowAppId;
|
||||
|
||||
/**
|
||||
* 字典子项
|
||||
*/
|
||||
private List<SysDictItem> dictItemsList;
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user