mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
Jeecg-Boot 2.1.4 版本发布 | 重构较大,较多新功能
This commit is contained in:
4
jeecg-boot/jeecg-boot-module-system/.gitattributes
vendored
Normal file
4
jeecg-boot/jeecg-boot-module-system/.gitattributes
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
*.js linguist-language=Java
|
||||
*.css linguist-language=Java
|
||||
*.html linguist-language=Java
|
||||
*.vue linguist-language=Java
|
||||
@ -1 +0,0 @@
|
||||
/target/
|
||||
@ -3,12 +3,12 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>jeecg-boot-module-system</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<version>2.1.3</version>
|
||||
<version>2.1.4</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
|
||||
@ -25,17 +25,18 @@ public class JeecgApplication {
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
//System.setProperty("spring.devtools.restart.enabled", "true");
|
||||
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = env.getProperty("server.servlet.context-path");
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"swagger-ui: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
ConfigurableApplicationContext application = SpringApplication.run(JeecgApplication.class, args);
|
||||
Environment env = application.getEnvironment();
|
||||
String ip = InetAddress.getLocalHost().getHostAddress();
|
||||
String port = env.getProperty("server.port");
|
||||
String path = env.getProperty("server.servlet.context-path");
|
||||
log.info("\n----------------------------------------------------------\n\t" +
|
||||
"Application Jeecg-Boot is running! Access URLs:\n\t" +
|
||||
"Local: \t\thttp://localhost:" + port + path + "/\n\t" +
|
||||
"External: \thttp://" + ip + ":" + port + path + "/\n\t" +
|
||||
"swagger-ui: \thttp://" + ip + ":" + port + path + "/swagger-ui.html\n\t" +
|
||||
"Doc: \t\thttp://" + ip + ":" + port + path + "/doc.html\n" +
|
||||
"----------------------------------------------------------");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -61,7 +61,7 @@ public class JeecgOneToMainUtil {
|
||||
|
||||
//第三步:一对多(父子表)数据模型,代码生成
|
||||
try {
|
||||
new CodeGenerateOneToMany(mainTable,subTables).generateCodeFile();
|
||||
new CodeGenerateOneToMany(mainTable,subTables).generateCodeFile(null);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -0,0 +1,38 @@
|
||||
package org.jeecg.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.modules.system.util.MinioUtil;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* Minio文件上传配置文件
|
||||
*/
|
||||
@Slf4j
|
||||
@Configuration
|
||||
public class MinioConfig {
|
||||
@Value(value = "${jeecg.minio.minio_url}")
|
||||
private String minioUrl;
|
||||
@Value(value = "${jeecg.minio.minio_name}")
|
||||
private String minioName;
|
||||
@Value(value = "${jeecg.minio.minio_pass}")
|
||||
private String minioPass;
|
||||
@Value(value = "${jeecg.minio.bucketName}")
|
||||
private String bucketName;
|
||||
|
||||
@Bean
|
||||
public void initMinio(){
|
||||
if(!minioUrl.startsWith("http")){
|
||||
minioUrl = "http://" + minioUrl;
|
||||
}
|
||||
if(!minioUrl.endsWith("/")){
|
||||
minioUrl = minioUrl.concat("/");
|
||||
}
|
||||
MinioUtil.setMinioUrl(minioUrl);
|
||||
MinioUtil.setMinioName(minioName);
|
||||
MinioUtil.setMinioPass(minioPass);
|
||||
MinioUtil.setBucketName(bucketName);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
package org.jeecg.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.http.client.ClientHttpRequestFactory;
|
||||
import org.springframework.http.client.SimpleClientHttpRequestFactory;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
@Configuration
|
||||
public class RestTemplateConfig {
|
||||
|
||||
@Bean
|
||||
public RestTemplate restTemplate(ClientHttpRequestFactory factory) {
|
||||
return new RestTemplate(factory);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public ClientHttpRequestFactory simpleClientHttpRequestFactory() {
|
||||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory();
|
||||
factory.setReadTimeout(5000);//ms
|
||||
factory.setConnectTimeout(15000);//ms
|
||||
return factory;
|
||||
}
|
||||
}
|
||||
@ -66,14 +66,12 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put(url,"anon");
|
||||
}
|
||||
}
|
||||
//大屏请求排除
|
||||
filterChainDefinitionMap.put("/big/screen/**", "anon");
|
||||
filterChainDefinitionMap.put("/bigscreen/**", "anon");
|
||||
|
||||
//cas验证登录
|
||||
filterChainDefinitionMap.put("/cas/client/validateLogin", "anon");
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
filterChainDefinitionMap.put("/sys/getCheckCode", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/randomImage/**", "anon"); //登录验证码接口排除
|
||||
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/mLogin", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/logout", "anon"); //登出接口排除
|
||||
@ -86,8 +84,9 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put("/sys/user/phoneVerification", "anon");//用户忘记密码验证手机号
|
||||
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
|
||||
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
|
||||
filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
|
||||
//filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
|
||||
//filterChainDefinitionMap.put("/sys/common/download/**", "anon");//文件下载不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
|
||||
filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
|
||||
filterChainDefinitionMap.put("/", "anon");
|
||||
@ -104,6 +103,7 @@ public class ShiroConfig {
|
||||
// update-begin--Author:sunjianlei Date:20190813 for:排除字体格式的后缀
|
||||
filterChainDefinitionMap.put("/**/*.ttf", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff", "anon");
|
||||
filterChainDefinitionMap.put("/**/*.woff2", "anon");
|
||||
// update-begin--Author:sunjianlei Date:20190813 for:排除字体格式的后缀
|
||||
|
||||
filterChainDefinitionMap.put("/druid/**", "anon");
|
||||
@ -123,10 +123,13 @@ public class ShiroConfig {
|
||||
|
||||
//排除Online请求
|
||||
filterChainDefinitionMap.put("/auto/cgform/**", "anon");
|
||||
|
||||
|
||||
//websocket排除
|
||||
filterChainDefinitionMap.put("/websocket/**", "anon");
|
||||
|
||||
|
||||
//大屏设计器排除
|
||||
filterChainDefinitionMap.put("/big/screen/**", "anon");
|
||||
|
||||
// 添加自己的过滤器并且取名为jwt
|
||||
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
|
||||
filterMap.put("jwt", new JwtFilter());
|
||||
|
||||
@ -19,8 +19,8 @@ import java.util.List;
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/big/screen")
|
||||
public class BigScreenController extends JeecgController<JeecgDemo, IJeecgDemoService> {
|
||||
@RequestMapping("/big/screen/templat")
|
||||
public class BigScreenTemplatController extends JeecgController<JeecgDemo, IJeecgDemoService> {
|
||||
|
||||
/**
|
||||
* @param modelAndView
|
||||
@ -128,7 +128,6 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@GetMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request,SysMessageTemplate sysMessageTemplate) {
|
||||
|
||||
@ -6,6 +6,7 @@ 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.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.oss.entity.OSSFile;
|
||||
@ -44,6 +45,7 @@ public class OSSFileController {
|
||||
|
||||
@ResponseBody
|
||||
@PostMapping("/upload")
|
||||
@RequiresRoles("admin")
|
||||
public Result upload(@RequestParam("file") MultipartFile multipartFile) {
|
||||
Result result = new Result();
|
||||
try {
|
||||
|
||||
@ -8,6 +8,7 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
@ -83,6 +84,7 @@ public class QuartzJobController {
|
||||
* @param quartzJob
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<?> add(@RequestBody QuartzJob quartzJob) {
|
||||
List<QuartzJob> list = quartzJobService.findByJobClassName(quartzJob.getJobClassName());
|
||||
@ -99,6 +101,7 @@ public class QuartzJobController {
|
||||
* @param quartzJob
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
public Result<?> eidt(@RequestBody QuartzJob quartzJob) {
|
||||
try {
|
||||
@ -116,6 +119,7 @@ public class QuartzJobController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
QuartzJob quartzJob = quartzJobService.getById(id);
|
||||
@ -133,6 +137,7 @@ public class QuartzJobController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
if (ids == null || "".equals(ids.trim())) {
|
||||
@ -148,9 +153,10 @@ public class QuartzJobController {
|
||||
/**
|
||||
* 暂停定时任务
|
||||
*
|
||||
* @param job
|
||||
* @param jobClassName
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@GetMapping(value = "/pause")
|
||||
@ApiOperation(value = "暂停定时任务")
|
||||
public Result<Object> pauseJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
|
||||
@ -172,9 +178,10 @@ public class QuartzJobController {
|
||||
/**
|
||||
* 启动定时任务
|
||||
*
|
||||
* @param job
|
||||
* @param jobClassName
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles("admin")
|
||||
@GetMapping(value = "/resume")
|
||||
@ApiOperation(value = "恢复定时任务")
|
||||
public Result<Object> resumeJob(@RequestParam(name = "jobClassName", required = true) String jobClassName) {
|
||||
@ -203,7 +210,7 @@ public class QuartzJobController {
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @param quartzJob
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, QuartzJob quartzJob) {
|
||||
|
||||
@ -75,15 +75,26 @@ public class PermissionDataAspect {
|
||||
String requestMethod = request.getMethod();
|
||||
String requestPath = request.getRequestURI().substring(request.getContextPath().length());
|
||||
requestPath = filterUrl(requestPath);
|
||||
log.info("拦截请求>>"+requestPath+";请求类型>>"+requestMethod);
|
||||
log.info("拦截请求 >> "+requestPath+";请求类型 >> "+requestMethod);
|
||||
//1.直接通过前端请求地址查询菜单
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getMenuType,2);
|
||||
query.eq(SysPermission::getDelFlag,0);
|
||||
query.eq(SysPermission::getUrl, requestPath);
|
||||
currentSyspermission = sysPermissionService.list(query);
|
||||
//2.未找到 再通过正则匹配获取菜单
|
||||
//2.未找到 再通过自定义匹配URL 获取菜单
|
||||
if(currentSyspermission==null || currentSyspermission.size()==0) {
|
||||
//通过自定义URL匹配规则 获取菜单(实现通过菜单配置数据权限规则,实际上针对获取数据接口进行数据规则控制)
|
||||
String userMatchUrl = UrlMatchEnum.getMatchResultByUrl(requestPath);
|
||||
LambdaQueryWrapper<SysPermission> queryQserMatch = new LambdaQueryWrapper<SysPermission>();
|
||||
queryQserMatch.eq(SysPermission::getMenuType, 1);
|
||||
queryQserMatch.eq(SysPermission::getDelFlag, 0);
|
||||
queryQserMatch.eq(SysPermission::getUrl, userMatchUrl);
|
||||
currentSyspermission = sysPermissionService.list(queryQserMatch);
|
||||
}
|
||||
//3.未找到 再通过正则匹配获取菜单
|
||||
if(currentSyspermission==null || currentSyspermission.size()==0) {
|
||||
//通过正则匹配权限配置
|
||||
String regUrl = getRegexpUrl(requestPath);
|
||||
if(regUrl!=null) {
|
||||
currentSyspermission = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getMenuType,2).eq(SysPermission::getUrl, regUrl).eq(SysPermission::getDelFlag,0));
|
||||
|
||||
@ -0,0 +1,54 @@
|
||||
package org.jeecg.modules.system.aspect;
|
||||
|
||||
/**
|
||||
* @Author scott
|
||||
* @Date 2020/1/14 13:36
|
||||
* @Description: 请求URL与菜单路由URL转换规则(方便于采用菜单路由URL来配置数据权限规则)
|
||||
*/
|
||||
public enum UrlMatchEnum {
|
||||
CGFORM_DATA("/online/cgform/api/getData/", "/online/cgformList/"),
|
||||
CGFORM_TREE_DATA("/online/cgform/api/getTreeData/", "/online/cgformList/");
|
||||
|
||||
UrlMatchEnum(String url, String match_url) {
|
||||
this.url = url;
|
||||
this.match_url = match_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request 请求 URL前缀
|
||||
*/
|
||||
private String url;
|
||||
/**
|
||||
* 菜单路由 URL前缀 (对应菜单路径)
|
||||
*/
|
||||
private String match_url;
|
||||
|
||||
/**
|
||||
* 根据req url 获取到菜单配置路径(前端页面路由URL)
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
public static String getMatchResultByUrl(String url) {
|
||||
//获取到枚举
|
||||
UrlMatchEnum[] values = UrlMatchEnum.values();
|
||||
//加强for循环进行遍历操作
|
||||
for (UrlMatchEnum lr : values) {
|
||||
//如果遍历获取的type和参数type一致
|
||||
if (url.indexOf(lr.url) != -1) {
|
||||
//返回type对象的desc
|
||||
return url.replace(lr.url, lr.match_url);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
/**
|
||||
* 比如request真实请求URL: /online/cgform/api/getData/81fcf7d8922d45069b0d5ba983612d3a
|
||||
* 转换匹配路由URL后(对应配置的菜单路径):/online/cgformList/81fcf7d8922d45069b0d5ba983612d3a
|
||||
*/
|
||||
System.out.println(UrlMatchEnum.getMatchResultByUrl("/online/cgform/api/getData/81fcf7d8922d45069b0d5ba983612d3a"));
|
||||
}
|
||||
}
|
||||
@ -23,6 +23,7 @@ import org.jeecg.modules.system.model.SysLoginModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysLogService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.util.RandImageUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@ -64,12 +65,15 @@ public class LoginController {
|
||||
//update-begin--Author:scott Date:20190805 for:暂时注释掉密码加密逻辑,有点问题
|
||||
|
||||
//update-begin-author:taoyan date:20190828 for:校验验证码
|
||||
Object checkCode = redisUtil.get(sysLoginModel.getCheckKey());
|
||||
if(checkCode==null) {
|
||||
result.error500("验证码失效");
|
||||
return result;
|
||||
}
|
||||
if(!checkCode.equals(sysLoginModel.getCaptcha())) {
|
||||
String captcha = sysLoginModel.getCaptcha();
|
||||
if(captcha==null){
|
||||
result.error500("验证码无效");
|
||||
return result;
|
||||
}
|
||||
String lowerCaseCaptcha = captcha.toLowerCase();
|
||||
String realKey = MD5Util.MD5Encode(lowerCaseCaptcha+sysLoginModel.getCheckKey(), "utf-8");
|
||||
Object checkCode = redisUtil.get(realKey);
|
||||
if(checkCode==null || !checkCode.equals(lowerCaseCaptcha)) {
|
||||
result.error500("验证码错误");
|
||||
return result;
|
||||
}
|
||||
@ -214,8 +218,14 @@ public class LoginController {
|
||||
public Result<String> sms(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<String>();
|
||||
String mobile = jsonObject.get("mobile").toString();
|
||||
//手机号模式 登录模式: "2" 注册模式: "1"
|
||||
String smsmode=jsonObject.get("smsmode").toString();
|
||||
log.info(mobile);
|
||||
log.info(mobile);
|
||||
if(oConvertUtils.isEmpty(mobile)){
|
||||
result.setMessage("手机号不允许为空!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
Object object = redisUtil.get(mobile);
|
||||
if (object != null) {
|
||||
result.setMessage("验证码10分钟内,仍然有效!");
|
||||
@ -375,7 +385,10 @@ public class LoginController {
|
||||
String key = MD5Util.MD5Encode(code+System.currentTimeMillis(), "utf-8");
|
||||
redisUtil.set(key, code, 60);
|
||||
map.put("key", key);
|
||||
map.put("code",code);
|
||||
//update-begin-author:taoyan date:20200210 for:TASK #3391 【bug】安全问题,返回验证码不安全
|
||||
String encode = java.util.Base64.getEncoder().encodeToString(code.getBytes("UTF-8"));
|
||||
map.put("code",encode);
|
||||
//update-end-author:taoyan date:20200210 for:TASK #3391 【bug】安全问题,返回验证码不安全
|
||||
result.setResult(map);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
@ -384,6 +397,30 @@ public class LoginController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 后台生成图形验证码
|
||||
* @param response
|
||||
* @param key
|
||||
*/
|
||||
@ApiOperation("获取验证码2")
|
||||
@GetMapping(value = "/randomImage/{key}")
|
||||
public Result<String> randomImage(HttpServletResponse response,@PathVariable String key){
|
||||
Result<String> res = new Result<String>();
|
||||
try {
|
||||
String code = RandomUtil.randomString(BASE_CHECK_CODES,4);
|
||||
String lowerCaseCode = code.toLowerCase();
|
||||
String realKey = MD5Util.MD5Encode(lowerCaseCode+key, "utf-8");
|
||||
redisUtil.set(realKey, lowerCaseCode, 60);
|
||||
String base64 = RandImageUtil.generate(code);
|
||||
res.setSuccess(true);
|
||||
res.setResult(base64);
|
||||
} catch (Exception e) {
|
||||
res.error500("获取验证码出错"+e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* app登录
|
||||
|
||||
@ -237,10 +237,10 @@ public class SysCategoryController {
|
||||
for (SysCategory sysCategoryExcel : listSysCategorys) {
|
||||
sysCategoryService.save(sysCategoryExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSysCategorys.size());
|
||||
return Result.ok("文件导入成功!数据行数:" + listSysCategorys.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return Result.error("文件导入失败:"+e.getMessage());
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("文件导入失败:"+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
@ -249,7 +249,7 @@ public class SysCategoryController {
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,186 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
import org.jeecg.modules.system.service.ISysCheckRuleService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "编码校验规则")
|
||||
@RestController
|
||||
@RequestMapping("/sys/checkRule")
|
||||
public class SysCheckRuleController extends JeecgController<SysCheckRule, ISysCheckRuleService> {
|
||||
|
||||
@Autowired
|
||||
private ISysCheckRuleService sysCheckRuleService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-分页列表查询")
|
||||
@ApiOperation(value = "编码校验规则-分页列表查询", notes = "编码校验规则-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result queryPageList(
|
||||
SysCheckRule sysCheckRule,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest request
|
||||
) {
|
||||
QueryWrapper<SysCheckRule> queryWrapper = QueryGenerator.initQueryWrapper(sysCheckRule, request.getParameterMap());
|
||||
Page<SysCheckRule> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysCheckRule> pageList = sysCheckRuleService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param ruleCode
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过Code校验传入的值")
|
||||
@ApiOperation(value = "编码校验规则-通过Code校验传入的值", notes = "编码校验规则-通过Code校验传入的值")
|
||||
@GetMapping(value = "/checkByCode")
|
||||
public Result checkByCode(
|
||||
@RequestParam(name = "ruleCode") String ruleCode,
|
||||
@RequestParam(name = "value") String value
|
||||
) throws UnsupportedEncodingException {
|
||||
SysCheckRule sysCheckRule = sysCheckRuleService.getByCode(ruleCode);
|
||||
if (sysCheckRule == null) {
|
||||
return Result.error("该编码不存在");
|
||||
}
|
||||
JSONObject errorResult = sysCheckRuleService.checkValue(sysCheckRule, URLDecoder.decode(value, "UTF-8"));
|
||||
if (errorResult == null) {
|
||||
return Result.ok();
|
||||
} else {
|
||||
Result<Object> r = Result.error(errorResult.getString("message"));
|
||||
r.setResult(errorResult);
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-添加")
|
||||
@ApiOperation(value = "编码校验规则-添加", notes = "编码校验规则-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result add(@RequestBody SysCheckRule sysCheckRule) {
|
||||
sysCheckRuleService.save(sysCheckRule);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysCheckRule
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-编辑")
|
||||
@ApiOperation(value = "编码校验规则-编辑", notes = "编码校验规则-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result edit(@RequestBody SysCheckRule sysCheckRule) {
|
||||
sysCheckRuleService.updateById(sysCheckRule);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过id删除")
|
||||
@ApiOperation(value = "编码校验规则-通过id删除", notes = "编码校验规则-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result delete(@RequestParam(name = "id", required = true) String id) {
|
||||
sysCheckRuleService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-批量删除")
|
||||
@ApiOperation(value = "编码校验规则-批量删除", notes = "编码校验规则-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.sysCheckRuleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "编码校验规则-通过id查询")
|
||||
@ApiOperation(value = "编码校验规则-通过id查询", notes = "编码校验规则-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
SysCheckRule sysCheckRule = sysCheckRuleService.getById(id);
|
||||
return Result.ok(sysCheckRule);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysCheckRule
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCheckRule sysCheckRule) {
|
||||
return super.exportXls(request, sysCheckRule, SysCheckRule.class, "编码校验规则");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysCheckRule.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,178 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
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.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
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.modules.system.entity.SysDataSource;
|
||||
import org.jeecg.modules.system.service.ISysDataSourceService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "多数据源管理")
|
||||
@RestController
|
||||
@RequestMapping("/sys/dataSource")
|
||||
public class SysDataSourceController extends JeecgController<SysDataSource, ISysDataSourceService> {
|
||||
|
||||
@Autowired
|
||||
private ISysDataSourceService sysDataSourceService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysDataSource
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-分页列表查询")
|
||||
@ApiOperation(value = "多数据源管理-分页列表查询", notes = "多数据源管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(
|
||||
SysDataSource sysDataSource,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req
|
||||
) {
|
||||
QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
Page<SysDataSource> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDataSource> pageList = sysDataSourceService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/options")
|
||||
public Result<?> queryOptions(SysDataSource sysDataSource, HttpServletRequest req) {
|
||||
QueryWrapper<SysDataSource> queryWrapper = QueryGenerator.initQueryWrapper(sysDataSource, req.getParameterMap());
|
||||
List<SysDataSource> pageList = sysDataSourceService.list(queryWrapper);
|
||||
JSONArray array = new JSONArray(pageList.size());
|
||||
for (SysDataSource item : pageList) {
|
||||
JSONObject option = new JSONObject(3);
|
||||
option.put("value", item.getCode());
|
||||
option.put("label", item.getName());
|
||||
option.put("text", item.getName());
|
||||
array.add(option);
|
||||
}
|
||||
return Result.ok(array);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysDataSource
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-添加")
|
||||
@ApiOperation(value = "多数据源管理-添加", notes = "多数据源管理-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDataSource sysDataSource) {
|
||||
sysDataSourceService.save(sysDataSource);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysDataSource
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-编辑")
|
||||
@ApiOperation(value = "多数据源管理-编辑", notes = "多数据源管理-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDataSource sysDataSource) {
|
||||
sysDataSourceService.updateById(sysDataSource);
|
||||
DataSourceCachePool.removeCacheById(sysDataSource.getId());
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-通过id删除")
|
||||
@ApiOperation(value = "多数据源管理-通过id删除", notes = "多数据源管理-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name = "id") String id) {
|
||||
sysDataSourceService.removeById(id);
|
||||
DataSourceCachePool.removeCacheById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-批量删除")
|
||||
@ApiOperation(value = "多数据源管理-批量删除", notes = "多数据源管理-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name = "ids") String ids) {
|
||||
List<String> idList = Arrays.asList(ids.split(","));
|
||||
this.sysDataSourceService.removeByIds(idList);
|
||||
idList.forEach(DataSourceCachePool::removeCacheById);
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "多数据源管理-通过id查询")
|
||||
@ApiOperation(value = "多数据源管理-通过id查询", notes = "多数据源管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name = "id") String id) {
|
||||
SysDataSource sysDataSource = sysDataSourceService.getById(id);
|
||||
return Result.ok(sysDataSource);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysDataSource
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDataSource sysDataSource) {
|
||||
return super.exportXls(request, sysDataSource, SysDataSource.class, "多数据源管理");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDataSource.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -14,9 +14,11 @@ 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;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
@ -58,6 +60,31 @@ public class SysDepartController {
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
/**
|
||||
* 查询数据 查出我的部门,并以树结构数据格式响应给前端
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryMyDeptTreeList", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartTreeModel>> queryMyDeptTreeList() {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<>();
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
try {
|
||||
if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){
|
||||
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds());
|
||||
result.setResult(list);
|
||||
result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
|
||||
result.setSuccess(true);
|
||||
}else{
|
||||
result.setMessage(CommonConstant.USER_IDENTITY_1.toString());
|
||||
result.setSuccess(true);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据 查出所有部门,并以树结构数据格式响应给前端
|
||||
*
|
||||
@ -228,20 +255,14 @@ public class SysDepartController {
|
||||
@RequestMapping(value = "/searchBy", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord) {
|
||||
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>();
|
||||
try {
|
||||
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
|
||||
if (treeList.size() == 0 || treeList == null) {
|
||||
throw new Exception();
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(treeList);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
e.fillInStackTrace();
|
||||
List<SysDepartTreeModel> treeList = this.sysDepartService.searhBy(keyWord);
|
||||
if (treeList == null || treeList.size() == 0) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("查询失败或没有您想要的任何数据!");
|
||||
result.setMessage("未查询匹配数据!");
|
||||
return result;
|
||||
}
|
||||
result.setResult(treeList);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -0,0 +1,321 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartPermissionService;
|
||||
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.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.modules.system.service.ISysDepartRolePermissionService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionService;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags="部门权限表")
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysDepartPermission")
|
||||
public class SysDepartPermissionController extends JeecgController<SysDepartPermission, ISysDepartPermissionService> {
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
|
||||
@Autowired
|
||||
private ISysPermissionService sysPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRolePermissionService sysDepartRolePermissionService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysDepartPermission
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-分页列表查询")
|
||||
@ApiOperation(value="部门权限表-分页列表查询", notes="部门权限表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysDepartPermission sysDepartPermission,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDepartPermission> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartPermission, req.getParameterMap());
|
||||
Page<SysDepartPermission> page = new Page<SysDepartPermission>(pageNo, pageSize);
|
||||
IPage<SysDepartPermission> pageList = sysDepartPermissionService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysDepartPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-添加")
|
||||
@ApiOperation(value="部门权限表-添加", notes="部门权限表-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
sysDepartPermissionService.save(sysDepartPermission);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysDepartPermission
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-编辑")
|
||||
@ApiOperation(value="部门权限表-编辑", notes="部门权限表-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDepartPermission sysDepartPermission) {
|
||||
sysDepartPermissionService.updateById(sysDepartPermission);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-通过id删除")
|
||||
@ApiOperation(value="部门权限表-通过id删除", notes="部门权限表-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysDepartPermissionService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-批量删除")
|
||||
@ApiOperation(value="部门权限表-批量删除", notes="部门权限表-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysDepartPermissionService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门权限表-通过id查询")
|
||||
@ApiOperation(value="部门权限表-通过id查询", notes="部门权限表-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getById(id);
|
||||
return Result.ok(sysDepartPermission);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysDepartPermission
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDepartPermission sysDepartPermission) {
|
||||
return super.exportXls(request, sysDepartPermission, SysDepartPermission.class, "部门权限表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDepartPermission.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门管理授权查询数据规则数据
|
||||
*/
|
||||
@GetMapping(value = "/datarule/{permissionId}/{departId}")
|
||||
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId) {
|
||||
List<SysPermissionDataRule> list = sysPermissionDataRuleService.getPermRuleListByPermId(permissionId);
|
||||
if(list==null || list.size()==0) {
|
||||
return Result.error("未找到权限配置信息");
|
||||
}else {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
|
||||
.eq(SysDepartPermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartPermission::getDepartId,departId);
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
|
||||
if(sysDepartPermission==null) {
|
||||
//return Result.error("未找到角色菜单配置信息");
|
||||
}else {
|
||||
String drChecked = sysDepartPermission.getDataRuleIds();
|
||||
if(oConvertUtils.isNotEmpty(drChecked)) {
|
||||
map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
|
||||
}
|
||||
}
|
||||
return Result.ok(map);
|
||||
//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据规则至部门菜单关联表
|
||||
*/
|
||||
@PostMapping(value = "/datarule")
|
||||
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
|
||||
try {
|
||||
String permissionId = jsonObject.getString("permissionId");
|
||||
String departId = jsonObject.getString("departId");
|
||||
String dataRuleIds = jsonObject.getString("dataRuleIds");
|
||||
log.info("保存数据规则>>"+"菜单ID:"+permissionId+"部门ID:"+ departId+"数据权限ID:"+dataRuleIds);
|
||||
LambdaQueryWrapper<SysDepartPermission> query = new LambdaQueryWrapper<SysDepartPermission>()
|
||||
.eq(SysDepartPermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartPermission::getDepartId,departId);
|
||||
SysDepartPermission sysDepartPermission = sysDepartPermissionService.getOne(query);
|
||||
if(sysDepartPermission==null) {
|
||||
return Result.error("请先保存部门菜单权限!");
|
||||
}else {
|
||||
sysDepartPermission.setDataRuleIds(dataRuleIds);
|
||||
this.sysDepartPermissionService.updateById(sysDepartPermission);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("SysDepartPermissionController.saveDatarule()发生异常:" + e.getMessage(),e);
|
||||
return Result.error("保存失败");
|
||||
}
|
||||
return Result.ok("保存成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryDeptRolePermission", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryDeptRolePermission(@RequestParam(name = "roleId", required = true) String roleId) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
List<SysDepartRolePermission> list = sysDepartRolePermissionService.list(new QueryWrapper<SysDepartRolePermission>().lambda().eq(SysDepartRolePermission::getRoleId, roleId));
|
||||
result.setResult(list.stream().map(SysDepartRolePermission -> String.valueOf(SysDepartRolePermission.getPermissionId())).collect(Collectors.toList()));
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存角色授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveDeptRolePermission", method = RequestMethod.POST)
|
||||
public Result<String> saveDeptRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
String roleId = json.getString("roleId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.sysDepartRolePermissionService.saveDeptRolePermission(roleId, permissionIds, lastPermissionIds);
|
||||
result.success("保存成功!");
|
||||
log.info("======部门角色授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户角色授权功能,查询菜单权限树
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryTreeListForDeptRole", method = RequestMethod.GET)
|
||||
public Result<Map<String,Object>> queryTreeListForDeptRole(@RequestParam(name="departId",required=true) String departId,HttpServletRequest request) {
|
||||
Result<Map<String,Object>> result = new Result<>();
|
||||
//全部权限ids
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
query.inSql(SysPermission::getId,"select permission_id from sys_depart_permission where depart_id='"+departId+"'");
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
for(SysPermission sysPer : list) {
|
||||
ids.add(sysPer.getId());
|
||||
}
|
||||
List<TreeModel> treeList = new ArrayList<>();
|
||||
getTreeModelList(treeList, list, null);
|
||||
Map<String,Object> resMap = new HashMap<String,Object>();
|
||||
resMap.put("treeList", treeList); //全部树节点数据
|
||||
resMap.put("ids", ids);//全部树ids
|
||||
result.setResult(resMap);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void getTreeModelList(List<TreeModel> treeList, List<SysPermission> metaList, TreeModel temp) {
|
||||
for (SysPermission permission : metaList) {
|
||||
String tempPid = permission.getParentId();
|
||||
TreeModel tree = new TreeModel(permission.getId(), tempPid, permission.getName(),permission.getRuleFlag(), permission.isLeaf());
|
||||
if(temp==null && oConvertUtils.isEmpty(tempPid)) {
|
||||
treeList.add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}else if(temp!=null && tempPid!=null && tempPid.equals(temp.getKey())){
|
||||
temp.getChildren().add(tree);
|
||||
if(!tree.getIsLeaf()) {
|
||||
getTreeModelList(treeList, metaList, tree);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,285 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
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.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartRole;
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import org.jeecg.modules.system.entity.SysDepartRoleUser;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
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.jeecg.common.system.base.controller.JeecgController;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags="部门角色")
|
||||
@RestController
|
||||
@RequestMapping("/sys/sysDepartRole")
|
||||
public class SysDepartRoleController extends JeecgController<SysDepartRole, ISysDepartRoleService> {
|
||||
@Autowired
|
||||
private ISysDepartRoleService sysDepartRoleService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRoleUserService departRoleUserService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartRolePermissionService sysDepartRolePermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param sysDepartRole
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-分页列表查询")
|
||||
@ApiOperation(value="部门角色-分页列表查询", notes="部门角色-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(SysDepartRole sysDepartRole,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name="deptId",required=false) String deptId,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<SysDepartRole> queryWrapper = QueryGenerator.initQueryWrapper(sysDepartRole, req.getParameterMap());
|
||||
Page<SysDepartRole> page = new Page<SysDepartRole>(pageNo, pageSize);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
List<String> deptIds = null;
|
||||
if(oConvertUtils.isEmpty(deptId)){
|
||||
if(oConvertUtils.isNotEmpty(user.getIdentity()) && user.getIdentity() == CommonConstant.USER_IDENTITY_2 ){
|
||||
deptIds = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
|
||||
}else{
|
||||
return Result.ok(null);
|
||||
}
|
||||
}else{
|
||||
deptIds = sysDepartService.getSubDepIdsByDepId(deptId);
|
||||
}
|
||||
queryWrapper.in("depart_id",deptIds);
|
||||
IPage<SysDepartRole> pageList = sysDepartRoleService.page(page, queryWrapper);
|
||||
return Result.ok(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param sysDepartRole
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-添加")
|
||||
@ApiOperation(value="部门角色-添加", notes="部门角色-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody SysDepartRole sysDepartRole) {
|
||||
sysDepartRoleService.save(sysDepartRole);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param sysDepartRole
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-编辑")
|
||||
@ApiOperation(value="部门角色-编辑", notes="部门角色-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody SysDepartRole sysDepartRole) {
|
||||
sysDepartRoleService.updateById(sysDepartRole);
|
||||
return Result.ok("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-通过id删除")
|
||||
@ApiOperation(value="部门角色-通过id删除", notes="部门角色-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysDepartRoleService.removeById(id);
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-批量删除")
|
||||
@ApiOperation(value="部门角色-批量删除", notes="部门角色-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.sysDepartRoleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.ok("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "部门角色-通过id查询")
|
||||
@ApiOperation(value="部门角色-通过id查询", notes="部门角色-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
SysDepartRole sysDepartRole = sysDepartRoleService.getById(id);
|
||||
return Result.ok(sysDepartRole);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取部门下角色
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDeptRoleList", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartRole>> getDeptRoleList(@RequestParam(value = "departId") String departId){
|
||||
Result<List<SysDepartRole>> result = new Result<>();
|
||||
List<SysDepartRole> deptRoleList = sysDepartRoleService.list(new QueryWrapper<SysDepartRole>().eq("depart_id",departId));
|
||||
result.setSuccess(true);
|
||||
result.setResult(deptRoleList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置
|
||||
* @param json
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/deptRoleUserAdd", method = RequestMethod.POST)
|
||||
public Result<?> deptRoleAdd(@RequestBody JSONObject json) {
|
||||
String newRoleId = json.getString("newRoleId");
|
||||
String oldRoleId = json.getString("oldRoleId");
|
||||
String userId = json.getString("userId");
|
||||
departRoleUserService.deptRoleUserAdd(userId,newRoleId,oldRoleId);
|
||||
return Result.ok("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id获取已设置部门角色
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDeptRoleByUserId", method = RequestMethod.GET)
|
||||
public Result<List<SysDepartRoleUser>> getDeptRoleByUserId(@RequestParam(value = "userId") String userId){
|
||||
Result<List<SysDepartRoleUser>> result = new Result<>();
|
||||
List<SysDepartRoleUser> roleUserList = departRoleUserService.list(new QueryWrapper<SysDepartRoleUser>().eq("user_id",userId));
|
||||
result.setSuccess(true);
|
||||
result.setResult(roleUserList);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询数据规则数据
|
||||
*/
|
||||
@GetMapping(value = "/datarule/{permissionId}/{departId}/{roleId}")
|
||||
public Result<?> loadDatarule(@PathVariable("permissionId") String permissionId,@PathVariable("departId") String departId,@PathVariable("roleId") String roleId) {
|
||||
//查询已授权的部门规则
|
||||
List<SysPermissionDataRule> list = sysDepartPermissionService.getPermRuleListByDeptIdAndPermId(departId,permissionId);
|
||||
if(list==null || list.size()==0) {
|
||||
return Result.error("未找到权限配置信息");
|
||||
}else {
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
|
||||
.eq(SysDepartRolePermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartRolePermission::getRoleId,roleId);
|
||||
SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.getOne(query);
|
||||
if(sysRolePermission==null) {
|
||||
//return Result.error("未找到角色菜单配置信息");
|
||||
}else {
|
||||
String drChecked = sysRolePermission.getDataRuleIds();
|
||||
if(oConvertUtils.isNotEmpty(drChecked)) {
|
||||
map.put("drChecked", drChecked.endsWith(",")?drChecked.substring(0, drChecked.length()-1):drChecked);
|
||||
}
|
||||
}
|
||||
return Result.ok(map);
|
||||
//TODO 以后按钮权限的查询也走这个请求 无非在map中多加两个key
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存数据规则至角色菜单关联表
|
||||
*/
|
||||
@PostMapping(value = "/datarule")
|
||||
public Result<?> saveDatarule(@RequestBody JSONObject jsonObject) {
|
||||
try {
|
||||
String permissionId = jsonObject.getString("permissionId");
|
||||
String roleId = jsonObject.getString("roleId");
|
||||
String dataRuleIds = jsonObject.getString("dataRuleIds");
|
||||
log.info("保存数据规则>>"+"菜单ID:"+permissionId+"角色ID:"+ roleId+"数据权限ID:"+dataRuleIds);
|
||||
LambdaQueryWrapper<SysDepartRolePermission> query = new LambdaQueryWrapper<SysDepartRolePermission>()
|
||||
.eq(SysDepartRolePermission::getPermissionId, permissionId)
|
||||
.eq(SysDepartRolePermission::getRoleId,roleId);
|
||||
SysDepartRolePermission sysRolePermission = sysDepartRolePermissionService.getOne(query);
|
||||
if(sysRolePermission==null) {
|
||||
return Result.error("请先保存角色菜单权限!");
|
||||
}else {
|
||||
sysRolePermission.setDataRuleIds(dataRuleIds);
|
||||
this.sysDepartRolePermissionService.updateById(sysRolePermission);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("SysRoleController.saveDatarule()发生异常:" + e.getMessage(),e);
|
||||
return Result.error("保存失败");
|
||||
}
|
||||
return Result.ok("保存成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param sysDepartRole
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysDepartRole sysDepartRole) {
|
||||
return super.exportXls(request, sysDepartRole, SysDepartRole.class, "部门角色");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, SysDepartRole.class);
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,7 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -18,6 +14,7 @@ import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
@ -35,6 +32,7 @@ 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.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@ -69,9 +67,10 @@ public class SysDictController {
|
||||
|
||||
@Autowired
|
||||
private ISysDictService sysDictService;
|
||||
|
||||
@Autowired
|
||||
private ISysDictItemService sysDictItemService;
|
||||
@Autowired
|
||||
public RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<IPage<SysDict>> queryPageList(SysDict sysDict,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@ -226,7 +225,6 @@ public class SysDictController {
|
||||
}else {
|
||||
sysDict.setUpdateTime(new Date());
|
||||
boolean ok = sysDictService.updateById(sysDict);
|
||||
//TODO 返回false说明什么?
|
||||
if(ok) {
|
||||
result.success("编辑成功!");
|
||||
}
|
||||
@ -270,11 +268,29 @@ public class SysDictController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @功能:刷新缓存
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/refleshCache")
|
||||
public Result<?> refleshCache() {
|
||||
Result<?> result = new Result<SysDict>();
|
||||
//清空字典缓存
|
||||
Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
|
||||
Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
|
||||
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
|
||||
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
|
||||
redisTemplate.delete(keys);
|
||||
redisTemplate.delete(keys2);
|
||||
redisTemplate.delete(keys3);
|
||||
redisTemplate.delete(keys4);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysDict sysDict,HttpServletRequest request) {
|
||||
|
||||
@ -1,43 +1,32 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.util.MD5Util;
|
||||
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.SysRolePermission;
|
||||
import org.jeecg.modules.system.model.SysPermissionTree;
|
||||
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.util.PermissionDataUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
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.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.MD5Util;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.entity.SysRolePermission;
|
||||
import org.jeecg.modules.system.model.SysPermissionTree;
|
||||
import org.jeecg.modules.system.model.SysRoleDeisgnModel;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.util.PermissionDataUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -61,6 +50,9 @@ public class SysPermissionController {
|
||||
@Autowired
|
||||
private ISysPermissionDataRuleService sysPermissionDataRuleService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
/**
|
||||
* 加载数据节点
|
||||
*
|
||||
@ -116,7 +108,6 @@ public class SysPermissionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询子菜单
|
||||
* @param parentId
|
||||
@ -145,6 +136,42 @@ public class SysPermissionController {
|
||||
}
|
||||
/*update_end author:wuxianquan date:20190908 for:先查询一级菜单,当用户点击展开菜单时加载子菜单 */
|
||||
|
||||
// update_begin author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
|
||||
/**
|
||||
* 查询子菜单
|
||||
*
|
||||
* @param parentIds 父ID(多个采用半角逗号分割)
|
||||
* @return 返回 key-value 的 Map
|
||||
*/
|
||||
@GetMapping("/getSystemSubmenuBatch")
|
||||
public Result getSystemSubmenuBatch(@RequestParam("parentIds") String parentIds) {
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<>();
|
||||
List<String> parentIdList = Arrays.asList(parentIds.split(","));
|
||||
query.in(SysPermission::getParentId, parentIdList);
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
Map<String, List<SysPermissionTree>> listMap = new HashMap<>();
|
||||
for (SysPermission item : list) {
|
||||
String pid = item.getParentId();
|
||||
if (parentIdList.contains(pid)) {
|
||||
List<SysPermissionTree> mapList = listMap.get(pid);
|
||||
if (mapList == null) {
|
||||
mapList = new ArrayList<>();
|
||||
}
|
||||
mapList.add(new SysPermissionTree(item));
|
||||
listMap.put(pid, mapList);
|
||||
}
|
||||
}
|
||||
return Result.ok(listMap);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error("批量查询子菜单失败:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
// update_end author:sunjianlei date:20200108 for: 新增批量根据父ID查询子级菜单的接口 -------------
|
||||
|
||||
// /**
|
||||
// * 查询用户拥有的菜单权限和按钮权限(根据用户账号)
|
||||
// *
|
||||
@ -183,7 +210,12 @@ public class SysPermissionController {
|
||||
String username = JwtUtil.getUsername(token);
|
||||
List<SysPermission> metaList = sysPermissionService.queryByUser(username);
|
||||
//添加首页路由
|
||||
PermissionDataUtil.addIndexPage(metaList);
|
||||
//update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
if(!PermissionDataUtil.hasIndexPage(metaList)){
|
||||
SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0);
|
||||
metaList.add(0,indexMenu);
|
||||
}
|
||||
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
JSONObject json = new JSONObject();
|
||||
JSONArray menujsonArray = new JSONArray();
|
||||
this.getPermissionJsonArray(menujsonArray, metaList, null);
|
||||
@ -217,6 +249,7 @@ public class SysPermissionController {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
public Result<SysPermission> add(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<SysPermission>();
|
||||
@ -236,6 +269,7 @@ public class SysPermissionController {
|
||||
* @param permission
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT, RequestMethod.POST })
|
||||
public Result<SysPermission> edit(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -255,6 +289,7 @@ public class SysPermissionController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -274,6 +309,7 @@ public class SysPermissionController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -371,6 +407,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveRolePermission", method = RequestMethod.POST)
|
||||
@RequiresRoles({ "admin" })
|
||||
public Result<String> saveRolePermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
@ -429,8 +466,7 @@ public class SysPermissionController {
|
||||
/**
|
||||
* 获取权限JSON数组
|
||||
* @param jsonArray
|
||||
* @param metaList
|
||||
* @param parentJson
|
||||
* @param allList
|
||||
*/
|
||||
private void getAllAuthJsonArray(JSONArray jsonArray,List<SysPermission> allList) {
|
||||
JSONObject json = null;
|
||||
@ -448,7 +484,6 @@ public class SysPermissionController {
|
||||
* 获取权限JSON数组
|
||||
* @param jsonArray
|
||||
* @param metaList
|
||||
* @param parentJson
|
||||
*/
|
||||
private void getAuthJsonArray(JSONArray jsonArray,List<SysPermission> metaList) {
|
||||
for (SysPermission permission : metaList) {
|
||||
@ -718,4 +753,45 @@ public class SysPermissionController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 部门权限表
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryDepartPermission", method = RequestMethod.GET)
|
||||
public Result<List<String>> queryDepartPermission(@RequestParam(name = "departId", required = true) String departId) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
List<SysDepartPermission> list = sysDepartPermissionService.list(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId));
|
||||
result.setResult(list.stream().map(SysDepartPermission -> String.valueOf(SysDepartPermission.getPermissionId())).collect(Collectors.toList()));
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存部门授权
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/saveDepartPermission", method = RequestMethod.POST)
|
||||
@RequiresRoles({ "admin" })
|
||||
public Result<String> saveDepartPermission(@RequestBody JSONObject json) {
|
||||
long start = System.currentTimeMillis();
|
||||
Result<String> result = new Result<>();
|
||||
try {
|
||||
String departId = json.getString("departId");
|
||||
String permissionIds = json.getString("permissionIds");
|
||||
String lastPermissionIds = json.getString("lastpermissionIds");
|
||||
this.sysDepartPermissionService.saveDepartPermission(departId, permissionIds, lastPermissionIds);
|
||||
result.success("保存成功!");
|
||||
log.info("======部门授权成功=====耗时:" + (System.currentTimeMillis() - start) + "毫秒");
|
||||
} catch (Exception e) {
|
||||
result.error500("授权失败!");
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -245,7 +245,6 @@ public class SysRoleController {
|
||||
/**
|
||||
* 导出excel
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(SysRole sysRole,HttpServletRequest request) {
|
||||
@ -308,6 +307,7 @@ public class SysRoleController {
|
||||
map.put("datarule", list);
|
||||
LambdaQueryWrapper<SysRolePermission> query = new LambdaQueryWrapper<SysRolePermission>()
|
||||
.eq(SysRolePermission::getPermissionId, permissionId)
|
||||
.isNotNull(SysRolePermission::getDataRuleIds)
|
||||
.eq(SysRolePermission::getRoleId,roleId);
|
||||
SysRolePermission sysRolePermission = sysRolePermissionService.getOne(query);
|
||||
if(sysRolePermission==null) {
|
||||
|
||||
@ -0,0 +1,52 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.oss.entity.OSSFile;
|
||||
import org.jeecg.modules.oss.service.IOSSFileService;
|
||||
import org.jeecg.modules.system.util.MinioUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* minio文件上传示例
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sys/upload")
|
||||
public class SysUploadController {
|
||||
@Autowired
|
||||
private IOSSFileService ossFileService;
|
||||
|
||||
/**
|
||||
* 上传
|
||||
* @param request
|
||||
*/
|
||||
@PostMapping(value = "/uploadMinio")
|
||||
public Result<?> uploadMinio(HttpServletRequest request) {
|
||||
Result<?> result = new Result<>();
|
||||
String bizPath = request.getParameter("biz");
|
||||
if(oConvertUtils.isEmpty(bizPath)){
|
||||
bizPath = "";
|
||||
}
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
MultipartFile file = multipartRequest.getFile("file");// 获取上传文件对象
|
||||
String orgName = file.getOriginalFilename();// 获取文件名
|
||||
String file_url = MinioUtil.upload(file,bizPath);
|
||||
//保存文件信息
|
||||
OSSFile minioFile = new OSSFile();
|
||||
minioFile.setFileName(orgName);
|
||||
minioFile.setUrl(file_url);
|
||||
ossFileService.save(minioFile);
|
||||
result.setMessage(file_url);
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -1,26 +1,21 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang.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.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
@ -29,7 +24,10 @@ import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
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.entity.SysUserRole;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysUserSysDepartModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
@ -44,27 +42,16 @@ 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.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
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.ModelAndView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -106,12 +93,26 @@ public class SysUserController {
|
||||
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(user, req.getParameterMap());
|
||||
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->{
|
||||
//TODO 临时借用这个字段用于页面展示
|
||||
item.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
log.info(pageList.toString());
|
||||
return result;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@RequiresPermissions("user:add")
|
||||
public Result<SysUser> add(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
String selectedRoles = jsonObject.getString("selectedroles");
|
||||
@ -136,6 +137,7 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
//@RequiresPermissions("user:edit")
|
||||
public Result<SysUser> edit(@RequestBody JSONObject jsonObject) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
try {
|
||||
@ -272,8 +274,9 @@ public class SysUserController {
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@RequestMapping(value = "/changPassword", method = RequestMethod.PUT)
|
||||
public Result<?> changPassword(@RequestBody SysUser sysUser) {
|
||||
@RequiresRoles({"admin"})
|
||||
@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()));
|
||||
if (u == null) {
|
||||
return Result.error("用户不存在!");
|
||||
@ -335,7 +338,22 @@ public class SysUserController {
|
||||
@RequestMapping(value = "/queryUserByDepId", method = RequestMethod.GET)
|
||||
public Result<List<SysUser>> queryUserByDepId(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<List<SysUser>> result = new Result<>();
|
||||
List<SysUser> userList = sysUserDepartService.queryUserByDepId(id);
|
||||
//List<SysUser> userList = sysUserDepartService.queryUserByDepId(id);
|
||||
SysDepart sysDepart = sysDepartService.getById(id);
|
||||
List<SysUser> userList = sysUserDepartService.queryUserByDepCode(sysDepart.getOrgCode());
|
||||
|
||||
//批量查询用户的所属部门
|
||||
//step.1 先拿到全部的 useids
|
||||
//step.2 通过 useids,一次性查询用户的所属部门名字
|
||||
List<String> userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
Map<String,String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
userList.forEach(item->{
|
||||
//TODO 临时借用这个字段用于页面展示
|
||||
item.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
|
||||
try {
|
||||
result.setSuccess(true);
|
||||
result.setResult(userList);
|
||||
@ -397,6 +415,7 @@ public class SysUserController {
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("user:import")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
@ -562,9 +581,37 @@ public class SysUserController {
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
String depId = req.getParameter("depId");
|
||||
String username = req.getParameter("username");
|
||||
IPage<SysUser> pageList = sysUserService.getUserByDepId(page,depId,username);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
//根据部门ID查询,当前和下级所有的部门IDS
|
||||
List<String> subDepids = new ArrayList<>();
|
||||
//部门id为空时,查询我的部门下所有用户
|
||||
if(oConvertUtils.isEmpty(depId)){
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
int userIdentity = user.getIdentity() != null?user.getIdentity():CommonConstant.USER_IDENTITY_1;
|
||||
if(oConvertUtils.isNotEmpty(userIdentity) && userIdentity == CommonConstant.USER_IDENTITY_2 ){
|
||||
subDepids = sysDepartService.getMySubDepIdsByDepId(user.getDepartIds());
|
||||
}
|
||||
}else{
|
||||
subDepids = sysDepartService.getSubDepIdsByDepId(depId);
|
||||
}
|
||||
if(subDepids != null && subDepids.size()>0){
|
||||
IPage<SysUser> pageList = sysUserService.getUserByDepIds(page,subDepids,username);
|
||||
//批量查询用户的所属部门
|
||||
//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.setOrgCode(useDepNames.get(item.getId()));
|
||||
});
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
}else{
|
||||
result.setSuccess(true);
|
||||
result.setResult(null);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -592,7 +639,7 @@ public class SysUserController {
|
||||
public Result<?> queryByOrgCodeForAddressList(
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(name = "orgCode") String orgCode,
|
||||
@RequestParam(name = "orgCode",required = false) String orgCode,
|
||||
SysUser userParams
|
||||
) {
|
||||
IPage page = new Page(pageNo, pageSize);
|
||||
@ -669,8 +716,12 @@ public class SysUserController {
|
||||
try {
|
||||
QueryWrapper<SysUserDepart> queryWrapper = new QueryWrapper<SysUserDepart>();
|
||||
queryWrapper.eq("dep_id", depId).eq("user_id",userId);
|
||||
sysUserDepartService.remove(queryWrapper);
|
||||
result.success("删除成功!");
|
||||
boolean b = sysUserDepartService.remove(queryWrapper);
|
||||
if(b){
|
||||
result.success("删除成功!");
|
||||
}else{
|
||||
result.error500("当前选中部门与用户无关联关系!");
|
||||
}
|
||||
}catch(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("删除失败!");
|
||||
@ -737,7 +788,15 @@ public class SysUserController {
|
||||
String smscode = jsonObject.getString("smscode");
|
||||
Object code = redisUtil.get(phone);
|
||||
String username = jsonObject.getString("username");
|
||||
//未设置用户名,则用手机号作为用户名
|
||||
if(oConvertUtils.isEmpty(username)){
|
||||
username = phone;
|
||||
}
|
||||
//未设置密码,则随机生成一个密码
|
||||
String password = jsonObject.getString("password");
|
||||
if(oConvertUtils.isEmpty(password)){
|
||||
password = RandomUtil.randomString(8);
|
||||
}
|
||||
String email = jsonObject.getString("email");
|
||||
SysUser sysUser1 = sysUserService.getUserByName(username);
|
||||
if (sysUser1 != null) {
|
||||
@ -746,18 +805,20 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
SysUser sysUser2 = sysUserService.getUserByPhone(phone);
|
||||
|
||||
if (sysUser2 != null) {
|
||||
result.setMessage("该手机号已注册");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
SysUser sysUser3 = sysUserService.getUserByEmail(email);
|
||||
if (sysUser3 != null) {
|
||||
result.setMessage("邮箱已被注册");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
if(oConvertUtils.isNotEmpty(email)){
|
||||
SysUser sysUser3 = sysUserService.getUserByEmail(email);
|
||||
if (sysUser3 != null) {
|
||||
result.setMessage("邮箱已被注册");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
if (!smscode.equals(code)) {
|
||||
result.setMessage("手机验证码错误");
|
||||
@ -851,19 +912,27 @@ public class SysUserController {
|
||||
@RequestParam(name="smscode")String smscode,
|
||||
@RequestParam(name="phone") String phone) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
if(oConvertUtils.isEmpty(username) || oConvertUtils.isEmpty(password) || oConvertUtils.isEmpty(smscode) || oConvertUtils.isEmpty(phone) ) {
|
||||
result.setMessage("重置密码失败!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
SysUser sysUser=new SysUser();
|
||||
Object object= redisUtil.get(phone);
|
||||
if(null==object) {
|
||||
result.setMessage("更改密码失败");
|
||||
result.setMessage("短信验证码失效!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
if(!smscode.equals(object)) {
|
||||
result.setMessage("更改密码失败");
|
||||
result.setMessage("短信验证码不匹配!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username));
|
||||
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username).eq(SysUser::getPhone,phone));
|
||||
if (sysUser == null) {
|
||||
result.setMessage("未找到对应实体");
|
||||
result.setMessage("未找到用户!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
} else {
|
||||
@ -873,7 +942,7 @@ public class SysUserController {
|
||||
sysUser.setPassword(passwordEncode);
|
||||
this.sysUserService.updateById(sysUser);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("密码修改完成!");
|
||||
result.setMessage("密码重置完成!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@ -941,5 +1010,55 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取被逻辑删除的用户列表,无分页
|
||||
*
|
||||
* @return logicDeletedUserList
|
||||
*/
|
||||
@GetMapping("/recycleBin")
|
||||
public Result getRecycleBin() {
|
||||
List<SysUser> logicDeletedUserList = sysUserService.queryLogicDeleted();
|
||||
if (logicDeletedUserList.size() > 0) {
|
||||
// 批量查询用户的所属部门
|
||||
// step.1 先拿到全部的 userIds
|
||||
List<String> userIds = logicDeletedUserList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
// step.2 通过 userIds,一次性查询用户的所属部门名字
|
||||
Map<String, String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
logicDeletedUserList.forEach(item -> item.setOrgCode(useDepNames.get(item.getId())));
|
||||
}
|
||||
return Result.ok(logicDeletedUserList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 还原被逻辑删除的用户
|
||||
*
|
||||
* @param userIds 被还原的用户ID,是个 list 集合
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/recycleBin")
|
||||
public Result putRecycleBin(@RequestBody List<String> userIds, HttpServletRequest request) {
|
||||
if (userIds != null && userIds.size() > 0) {
|
||||
SysUser updateUser = new SysUser();
|
||||
updateUser.setUpdateBy(JwtUtil.getUserNameByToken(request));
|
||||
updateUser.setUpdateTime(new Date());
|
||||
sysUserService.revertLogicDeleted(userIds, updateUser);
|
||||
}
|
||||
return Result.ok("还原成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 彻底删除用户
|
||||
*
|
||||
* @param userIds 被删除的用户ID,多个id用半角逗号分割
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping("/recycleBin")
|
||||
public Result deleteRecycleBin(@RequestParam("userIds") String userIds) {
|
||||
if (StringUtils.isNotBlank(userIds)) {
|
||||
sysUserService.removeLogicDeleted(Arrays.asList(userIds.split(",")));
|
||||
}
|
||||
return Result.ok("删除成功");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -124,4 +124,20 @@ public class SysAnnouncement implements Serializable {
|
||||
* 指定用户
|
||||
**/
|
||||
private java.lang.String userIds;
|
||||
/**
|
||||
* 业务类型(email:邮件 bpm:流程)
|
||||
*/
|
||||
private java.lang.String busType;
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private java.lang.String busId;
|
||||
/**
|
||||
* 打开方式 组件:component 路由:url
|
||||
*/
|
||||
private java.lang.String openType;
|
||||
/**
|
||||
* 组件/路由 地址
|
||||
*/
|
||||
private java.lang.String openPage;
|
||||
}
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
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.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_check_rule")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "sys_check_rule对象", description = "编码校验规则")
|
||||
public class SysCheckRule {
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private String id;
|
||||
/**
|
||||
* 规则名称
|
||||
*/
|
||||
@Excel(name = "规则名称", width = 15)
|
||||
@ApiModelProperty(value = "规则名称")
|
||||
private String ruleName;
|
||||
/**
|
||||
* 规则Code
|
||||
*/
|
||||
@Excel(name = "规则Code", width = 15)
|
||||
@ApiModelProperty(value = "规则Code")
|
||||
private String ruleCode;
|
||||
/**
|
||||
* 规则JSON
|
||||
*/
|
||||
@Excel(name = "规则JSON", width = 15)
|
||||
@ApiModelProperty(value = "规则JSON")
|
||||
private String ruleJson;
|
||||
/**
|
||||
* 规则描述
|
||||
*/
|
||||
@Excel(name = "规则描述", width = 15)
|
||||
@ApiModelProperty(value = "规则描述")
|
||||
private String ruleDescription;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private String updateBy;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updateTime;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private String createBy;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private Date createTime;
|
||||
}
|
||||
@ -0,0 +1,124 @@
|
||||
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.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_data_source")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "sys_data_source对象", description = "多数据源管理")
|
||||
public class SysDataSource {
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 数据源编码
|
||||
*/
|
||||
@Excel(name = "数据源编码", width = 15)
|
||||
@ApiModelProperty(value = "数据源编码")
|
||||
private java.lang.String code;
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
@Excel(name = "数据源名称", width = 15)
|
||||
@ApiModelProperty(value = "数据源名称")
|
||||
private java.lang.String name;
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private java.lang.String remark;
|
||||
/**
|
||||
* 数据库类型
|
||||
*/
|
||||
@Dict(dicCode = "database_type")
|
||||
@Excel(name = "数据库类型", width = 15, dicCode = "database_type")
|
||||
@ApiModelProperty(value = "数据库类型")
|
||||
private java.lang.String dbType;
|
||||
/**
|
||||
* 驱动类
|
||||
*/
|
||||
@Excel(name = "驱动类", width = 15)
|
||||
@ApiModelProperty(value = "驱动类")
|
||||
private java.lang.String dbDriver;
|
||||
/**
|
||||
* 数据源地址
|
||||
*/
|
||||
@Excel(name = "数据源地址", width = 15)
|
||||
@ApiModelProperty(value = "数据源地址")
|
||||
private java.lang.String dbUrl;
|
||||
/**
|
||||
* 数据库名称
|
||||
*/
|
||||
@Excel(name = "数据库名称", width = 15)
|
||||
@ApiModelProperty(value = "数据库名称")
|
||||
private java.lang.String dbName;
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
@Excel(name = "用户名", width = 15)
|
||||
@ApiModelProperty(value = "用户名")
|
||||
private java.lang.String dbUsername;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
@Excel(name = "密码", width = 15)
|
||||
@ApiModelProperty(value = "密码")
|
||||
private java.lang.String dbPassword;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@Excel(name = "创建日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@Excel(name = "更新日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
/**
|
||||
* 所属部门
|
||||
*/
|
||||
@Excel(name = "所属部门", width = 15)
|
||||
@ApiModelProperty(value = "所属部门")
|
||||
private java.lang.String sysOrgCode;
|
||||
}
|
||||
@ -0,0 +1,55 @@
|
||||
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 com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_permission")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_permission对象", description="部门权限表")
|
||||
public class SysDepartPermission {
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**部门id*/
|
||||
@Excel(name = "部门id", width = 15)
|
||||
@ApiModelProperty(value = "部门id")
|
||||
private java.lang.String departId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private java.lang.String permissionId;
|
||||
/**数据规则id*/
|
||||
@ApiModelProperty(value = "数据规则id")
|
||||
private java.lang.String dataRuleIds;
|
||||
|
||||
public SysDepartPermission() {
|
||||
|
||||
}
|
||||
|
||||
public SysDepartPermission(String departId, String permissionId) {
|
||||
this.departId = departId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,75 @@
|
||||
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 com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_role")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_role对象", description="部门角色")
|
||||
public class SysDepartRole {
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**部门id*/
|
||||
@Excel(name = "部门id", width = 15)
|
||||
@ApiModelProperty(value = "部门id")
|
||||
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
|
||||
private java.lang.String departId;
|
||||
/**部门角色名称*/
|
||||
@Excel(name = "部门角色名称", width = 15)
|
||||
@ApiModelProperty(value = "部门角色名称")
|
||||
private java.lang.String roleName;
|
||||
/**部门角色编码*/
|
||||
@Excel(name = "部门角色编码", width = 15)
|
||||
@ApiModelProperty(value = "部门角色编码")
|
||||
private java.lang.String roleCode;
|
||||
/**描述*/
|
||||
@Excel(name = "描述", width = 15)
|
||||
@ApiModelProperty(value = "描述")
|
||||
private java.lang.String description;
|
||||
/**创建人*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
@ApiModelProperty(value = "创建人")
|
||||
private java.lang.String createBy;
|
||||
/**创建时间*/
|
||||
@Excel(name = "创建时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建时间")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
@ApiModelProperty(value = "更新人")
|
||||
private java.lang.String updateBy;
|
||||
/**更新时间*/
|
||||
@Excel(name = "更新时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
|
||||
}
|
||||
@ -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 com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_role_permission")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_role_permission对象", description="部门角色权限")
|
||||
public class SysDepartRolePermission {
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**部门id*/
|
||||
@Excel(name = "部门id", width = 15)
|
||||
@ApiModelProperty(value = "部门id")
|
||||
private java.lang.String departId;
|
||||
/**角色id*/
|
||||
@Excel(name = "角色id", width = 15)
|
||||
@ApiModelProperty(value = "角色id")
|
||||
private java.lang.String roleId;
|
||||
/**权限id*/
|
||||
@Excel(name = "权限id", width = 15)
|
||||
@ApiModelProperty(value = "权限id")
|
||||
private java.lang.String permissionId;
|
||||
/**dataRuleIds*/
|
||||
@Excel(name = "dataRuleIds", width = 15)
|
||||
@ApiModelProperty(value = "dataRuleIds")
|
||||
private java.lang.String dataRuleIds;
|
||||
|
||||
public SysDepartRolePermission() {
|
||||
}
|
||||
|
||||
public SysDepartRolePermission(String roleId, String permissionId) {
|
||||
this.roleId = roleId;
|
||||
this.permissionId = permissionId;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,52 @@
|
||||
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 com.baomidou.mybatisplus.annotation.TableField;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_depart_role_user")
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="sys_depart_role_user对象", description="部门角色人员信息")
|
||||
public class SysDepartRoleUser {
|
||||
|
||||
/**主键id*/
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@ApiModelProperty(value = "主键id")
|
||||
private java.lang.String id;
|
||||
/**用户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.String droleId;
|
||||
|
||||
public SysDepartRoleUser() {
|
||||
|
||||
}
|
||||
|
||||
public SysDepartRoleUser(String userId, String droleId) {
|
||||
this.userId = userId;
|
||||
this.droleId = droleId;
|
||||
}
|
||||
}
|
||||
@ -98,7 +98,7 @@ public class SysUser implements Serializable {
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 部门code
|
||||
* 部门code(当前选择登录部门)
|
||||
*/
|
||||
private String orgCode;
|
||||
|
||||
@ -158,5 +158,16 @@ public class SysUser implements Serializable {
|
||||
*/
|
||||
private String activitiSync;
|
||||
|
||||
/**
|
||||
* 身份(0 普通成员 1 上级)
|
||||
*/
|
||||
@Excel(name="(1普通成员 2上级)",width = 15)
|
||||
private Integer identity;
|
||||
|
||||
/**
|
||||
* 负责部门
|
||||
*/
|
||||
@Excel(name="负责部门",width = 15,dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
|
||||
@Dict(dictTable ="sys_depart",dicText = "depart_name",dicCode = "id")
|
||||
private String departIds;
|
||||
}
|
||||
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysCheckRuleMapper extends BaseMapper<SysCheckRule> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDataSourceMapper extends BaseMapper<SysDataSource> {
|
||||
|
||||
}
|
||||
@ -38,4 +38,18 @@ public interface SysDepartMapper extends BaseMapper<SysDepart> {
|
||||
@Select("select id,parent_id from sys_depart where id=#{departId}")
|
||||
public SysDepart getParentDepartId(@Param("departId") String departId);
|
||||
|
||||
/**
|
||||
* 根据部门Id查询,当前和下级所有部门IDS
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
List<String> getSubDepIdsByDepId(@Param("departId") String departId);
|
||||
|
||||
/**
|
||||
* 根据部门编码获取部门下所有IDS
|
||||
* @param orgCodes
|
||||
* @return
|
||||
*/
|
||||
List<String> getSubDepIdsByOrgCodes(@org.apache.ibatis.annotations.Param("orgCodes") String[] orgCodes);
|
||||
|
||||
}
|
||||
|
||||
@ -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.SysDepartPermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartPermissionMapper extends BaseMapper<SysDepartPermission> {
|
||||
|
||||
}
|
||||
@ -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.SysDepartRole;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartRoleMapper extends BaseMapper<SysDepartRole> {
|
||||
|
||||
}
|
||||
@ -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.SysDepartRolePermission;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartRolePermissionMapper extends BaseMapper<SysDepartRolePermission> {
|
||||
|
||||
}
|
||||
@ -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.SysDepartRoleUser;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysDepartRoleUserMapper extends BaseMapper<SysDepartRoleUser> {
|
||||
|
||||
}
|
||||
@ -1,11 +1,14 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -33,6 +36,21 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
*/
|
||||
IPage<SysUser> getUserByDepId(Page page, @Param("departId") String departId, @Param("username") String username);
|
||||
|
||||
/**
|
||||
* 根据用户Ids,查询用户所属部门名称信息
|
||||
* @param userIds
|
||||
* @return
|
||||
*/
|
||||
List<SysUserDepVo> getDepNamesByUserIds(@Param("userIds")List<String> userIds);
|
||||
|
||||
/**
|
||||
* 根据部门Ids,查询部门下用户信息
|
||||
* @param page
|
||||
* @param departIds
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> getUserByDepIds(Page page, @Param("departIds") List<String> departIds, @Param("username") String username);
|
||||
|
||||
/**
|
||||
* 根据角色Id查询用户信息
|
||||
* @param page
|
||||
@ -96,4 +114,20 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @Description: 批量删除角色与权限关系
|
||||
*/
|
||||
void deleteBathRolePermissionRelation(@Param("roleIdArray") String[] roleIdArray);
|
||||
|
||||
/**
|
||||
* 查询被逻辑删除的用户
|
||||
*/
|
||||
List<SysUser> selectLogicDeleted(@Param(Constants.WRAPPER) Wrapper<SysUser> wrapper);
|
||||
|
||||
/**
|
||||
* 还原被逻辑删除的用户
|
||||
*/
|
||||
int revertLogicDeleted(@Param("userIds") String userIds, @Param("entity") SysUser entity);
|
||||
|
||||
/**
|
||||
* 彻底删除被逻辑删除的用户
|
||||
*/
|
||||
int deleteLogicDeleted(@Param("userIds") String userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -21,6 +21,10 @@
|
||||
<result column="update_by" property="updateBy" jdbcType="VARCHAR"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="user_ids" property="userIds" jdbcType="VARCHAR"/>
|
||||
<result column="bus_type" property="busType" jdbcType="VARCHAR"/>
|
||||
<result column="bus_id" property="busId" jdbcType="VARCHAR"/>
|
||||
<result column="open_type" property="openType" jdbcType="VARCHAR"/>
|
||||
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
@ -12,6 +12,9 @@
|
||||
<result column="priority" property="priority" jdbcType="VARCHAR"/>
|
||||
<result column="msg_category" property="msgCategory" jdbcType="VARCHAR"/>
|
||||
<result column="send_time" property="sendTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="bus_id" property="busId" jdbcType="VARCHAR"/>
|
||||
<result column="open_type" property="openType" jdbcType="VARCHAR"/>
|
||||
<result column="open_page" property="openPage" jdbcType="VARCHAR"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="queryByUserId" parameterType="String" resultType="String">
|
||||
@ -30,7 +33,10 @@
|
||||
sa.sender as sender,
|
||||
sa.priority as priority,
|
||||
sa.msg_category,
|
||||
sa.send_time as send_time
|
||||
sa.send_time as send_time,
|
||||
sa.bus_id as bus_id,
|
||||
sa.open_type as open_type,
|
||||
sa.open_page as open_page
|
||||
from sys_announcement_send sas
|
||||
left join sys_announcement sa ON sas.annt_id = sa.id
|
||||
where sa.send_status = '1'
|
||||
|
||||
@ -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.SysCheckRuleMapper">
|
||||
|
||||
</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.SysDataSourceMapper">
|
||||
|
||||
</mapper>
|
||||
@ -21,4 +21,17 @@
|
||||
)
|
||||
</select>
|
||||
|
||||
<!-- 根据部门Id查询,当前和下级所有部门IDS -->
|
||||
<select id="getSubDepIdsByDepId" resultType="java.lang.String">
|
||||
select id from sys_depart where del_flag = '0' and org_code like concat((select org_code from sys_depart where id=#{departId}),'%')
|
||||
</select>
|
||||
|
||||
<!--根据部门编码获取我的部门下所有部门ids -->
|
||||
<select id="getSubDepIdsByOrgCodes" resultType="java.lang.String">
|
||||
select id from sys_depart where del_flag = '0' and
|
||||
<foreach collection="orgCodes" item="item" index="index" open="(" separator="or" close=")">
|
||||
org_code LIKE CONCAT(#{item},'%')
|
||||
</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.SysDepartPermissionMapper">
|
||||
|
||||
</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.SysDepartRoleMapper">
|
||||
|
||||
</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.SysDepartRolePermissionMapper">
|
||||
|
||||
</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.SysDepartRoleUserMapper">
|
||||
|
||||
</mapper>
|
||||
@ -11,6 +11,16 @@
|
||||
join sys_user_role d on d.role_id = c.id
|
||||
join sys_user e on d.user_id = e.id
|
||||
where e.username = #{username} and b.id = #{permissionId}
|
||||
<!--update begin Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
union
|
||||
select data_rule_ids
|
||||
from sys_depart_role_permission a
|
||||
join sys_permission b on a.permission_id = b.id
|
||||
join sys_depart_role c on a.role_id = c.id
|
||||
join sys_depart_role_user d on d.drole_id = c.id
|
||||
join sys_user e on d.user_id = e.id
|
||||
where e.username = #{username} and b.id = #{permissionId}
|
||||
<!--update end Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -41,17 +41,31 @@
|
||||
|
||||
<!-- 获取登录用户拥有的权限 -->
|
||||
<select id="queryByUser" parameterType="Object" resultMap="SysPermission">
|
||||
SELECT p.*
|
||||
FROM sys_permission p
|
||||
WHERE exists(
|
||||
select a.id from sys_role_permission a
|
||||
join sys_role b on a.role_id = b.id
|
||||
join sys_user_role c on c.role_id = b.id
|
||||
join sys_user d on d.id = c.user_id
|
||||
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
|
||||
)
|
||||
and p.del_flag = 0
|
||||
order by p.sort_no ASC
|
||||
SELECT * FROM (
|
||||
SELECT p.*
|
||||
FROM sys_permission p
|
||||
WHERE exists(
|
||||
select a.id from sys_role_permission a
|
||||
join sys_role b on a.role_id = b.id
|
||||
join sys_user_role c on c.role_id = b.id
|
||||
join sys_user d on d.id = c.user_id
|
||||
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
|
||||
)
|
||||
and p.del_flag = 0
|
||||
<!--update begin Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
UNION
|
||||
SELECT p.*
|
||||
FROM sys_permission p
|
||||
WHERE exists(
|
||||
select a.id from sys_depart_role_permission a
|
||||
join sys_depart_role b on a.role_id = b.id
|
||||
join sys_depart_role_user c on c.drole_id = b.id
|
||||
join sys_user d on d.id = c.user_id
|
||||
where p.id = a.permission_id AND d.username = #{username,jdbcType=VARCHAR}
|
||||
)
|
||||
and p.del_flag = 0
|
||||
<!--update end Author:lvdandan Date:20200213 for:加入部门权限 -->
|
||||
) h order by h.sort_no ASC
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,29 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 查询用户的所属部门名称信息 -->
|
||||
<select id="getDepNamesByUserIds" resultType="org.jeecg.modules.system.vo.SysUserDepVo">
|
||||
select d.depart_name,ud.user_id from sys_user_depart ud,sys_depart d where d.id = ud.dep_id and ud.user_id in
|
||||
<foreach collection="userIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<!-- 通过多个部门IDS,查询部门下的用户信息 -->
|
||||
<select id="getUserByDepIds" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where del_flag = '0'
|
||||
<if test="departIds!=null and departIds.size()>0">
|
||||
and id in (select user_id from sys_user_depart where dep_id in
|
||||
<foreach collection="departIds" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
)
|
||||
</if>
|
||||
<if test="username!=null and username!=''">
|
||||
and username = #{username}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据角色Id查询 -->
|
||||
<select id="getUserByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where del_flag = '0' and id in (select user_id from sys_user_role where role_id=#{roleId})
|
||||
@ -47,7 +70,7 @@
|
||||
-- 关联查询出该用户的详细信息
|
||||
INNER JOIN sys_user ON sys_user.id = sys_user_depart.user_id
|
||||
WHERE
|
||||
sys_depart.org_code LIKE '${orgCode}%'
|
||||
sys_user.del_flag = "0" AND sys_depart.org_code LIKE '${orgCode}%'
|
||||
|
||||
<if test="userParams != null">
|
||||
<if test="userParams.realname != null and userParams.realname != ''">
|
||||
@ -97,4 +120,28 @@
|
||||
#{id}
|
||||
</foreach>
|
||||
</update>
|
||||
|
||||
<!-- 查询被逻辑删除的用户 -->
|
||||
<select id="selectLogicDeleted" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
SELECT * FROM sys_user ${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<!-- 更新被逻辑删除的用户 -->
|
||||
<update id="revertLogicDeleted">
|
||||
UPDATE
|
||||
sys_user
|
||||
SET
|
||||
del_flag = "0",
|
||||
update_by = #{entity.updateBy},
|
||||
update_time = #{entity.updateTime}
|
||||
WHERE
|
||||
del_flag = "1"
|
||||
AND id IN (${userIds})
|
||||
</update>
|
||||
|
||||
<!-- 彻底删除被逻辑删除的用户 -->
|
||||
<delete id="deleteLogicDeleted">
|
||||
DELETE FROM sys_user WHERE del_flag = "1" AND id IN (${userIds})
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
@ -51,4 +51,16 @@ public class AnnouncementSendModel implements Serializable {
|
||||
* 消息类型1:通知公告2:系统消息
|
||||
*/
|
||||
private java.lang.String msgCategory;
|
||||
/**
|
||||
* 业务id
|
||||
*/
|
||||
private java.lang.String busId;
|
||||
/**
|
||||
* 打开方式 组件:component 路由:url
|
||||
*/
|
||||
private java.lang.String openType;
|
||||
/**
|
||||
* 组件/路由 地址
|
||||
*/
|
||||
private java.lang.String openPage;
|
||||
}
|
||||
|
||||
@ -0,0 +1,24 @@
|
||||
package org.jeecg.modules.system.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* Created by Administrator on 2019/12/12.
|
||||
*/
|
||||
@Data
|
||||
public class SysRoleDeisgnModel {
|
||||
/**主键*/
|
||||
private java.lang.String id;
|
||||
/**变单设计器code*/
|
||||
private java.lang.String desformCode;
|
||||
/**变单设计器名称*/
|
||||
private java.lang.String desformName;
|
||||
/**变单设计器图标*/
|
||||
private java.lang.String desformIcon;
|
||||
/**流程类型*/
|
||||
private java.lang.String procType;
|
||||
/**流程名称*/
|
||||
private java.lang.String procName;
|
||||
/**标题表达式*/
|
||||
private java.lang.String titleExp;
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysCheckRuleService extends IService<SysCheckRule> {
|
||||
|
||||
/**
|
||||
* 通过 code 获取规则
|
||||
*
|
||||
* @param ruleCode
|
||||
* @return
|
||||
*/
|
||||
SysCheckRule getByCode(String ruleCode);
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户设定的自定义校验规则校验传入的值
|
||||
*
|
||||
* @param checkRule
|
||||
* @param value
|
||||
* @return 返回 null代表通过校验,否则就是返回的错误提示文本
|
||||
*/
|
||||
JSONObject checkValue(SysCheckRule checkRule, String value);
|
||||
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDataSourceService extends IService<SysDataSource> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,30 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartPermissionService extends IService<SysDepartPermission> {
|
||||
/**
|
||||
* 保存授权 将上次的权限和这次作比较 差异处理提高效率
|
||||
* @param departId
|
||||
* @param permissionIds
|
||||
* @param lastPermissionIds
|
||||
*/
|
||||
public void saveDepartPermission(String departId,String permissionIds,String lastPermissionIds);
|
||||
|
||||
/**
|
||||
* 根据部门id,菜单id获取数据规则
|
||||
* @param permissionId
|
||||
* @return
|
||||
*/
|
||||
List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId,String permissionId);
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartRolePermissionService extends IService<SysDepartRolePermission> {
|
||||
/**
|
||||
* 保存授权 将上次的权限和这次作比较 差异处理提高效率
|
||||
* @param roleId
|
||||
* @param permissionIds
|
||||
* @param lastPermissionIds
|
||||
*/
|
||||
public void saveDeptRolePermission(String roleId,String permissionIds,String lastPermissionIds);
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRole;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartRoleService extends IService<SysDepartRole> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRoleUser;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysDepartRoleUserService extends IService<SysDepartRoleUser> {
|
||||
|
||||
void deptRoleUserAdd(String userId,String newRoleId,String oldRoleId);
|
||||
}
|
||||
@ -16,6 +16,11 @@ import java.util.List;
|
||||
*/
|
||||
public interface ISysDepartService extends IService<SysDepart>{
|
||||
|
||||
/**
|
||||
* 查询我的部门信息,并分节点进行显示
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeModel> queryMyDeptTreeList(String departIds);
|
||||
|
||||
/**
|
||||
* 查询所有部门信息,并分节点进行显示
|
||||
@ -84,5 +89,18 @@ public interface ISysDepartService extends IService<SysDepart>{
|
||||
* @return
|
||||
*/
|
||||
void deleteBatchWithChildren(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据部门Id查询,当前和下级所有部门IDS
|
||||
* @param departId
|
||||
* @return
|
||||
*/
|
||||
List<String> getSubDepIdsByDepId(String departId);
|
||||
|
||||
/**
|
||||
* 获取我的部门下级所有部门IDS
|
||||
* @return
|
||||
*/
|
||||
List<String> getMySubDepIdsByDepId(String departIds);
|
||||
|
||||
}
|
||||
|
||||
@ -34,4 +34,8 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryUserByDepId(String depId);
|
||||
/**
|
||||
* 根据部门code,查询当前部门和下级部门的用户信息
|
||||
*/
|
||||
public List<SysUser> queryUserByDepCode(String depCode);
|
||||
}
|
||||
|
||||
@ -1,8 +1,10 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
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;
|
||||
@ -95,6 +97,20 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
*/
|
||||
public IPage<SysUser> getUserByDepId(Page<SysUser> page, String departId, String username);
|
||||
|
||||
/**
|
||||
* 根据部门Ids查询
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username);
|
||||
|
||||
/**
|
||||
* 根据 userIds查询,查询用户所属部门的名称(多个部门名逗号隔开)
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
public Map<String,String> getDepNamesByUserIds(List<String> userIds);
|
||||
|
||||
/**
|
||||
* 根据部门 Id 和 QueryWrapper 查询
|
||||
*
|
||||
@ -178,4 +194,24 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
*/
|
||||
Result checkUserIsEffective(SysUser sysUser);
|
||||
|
||||
/**
|
||||
* 查询被逻辑删除的用户
|
||||
*/
|
||||
List<SysUser> queryLogicDeleted();
|
||||
|
||||
/**
|
||||
* 查询被逻辑删除的用户(可拼装查询条件)
|
||||
*/
|
||||
List<SysUser> queryLogicDeleted(LambdaQueryWrapper<SysUser> wrapper);
|
||||
|
||||
/**
|
||||
* 还原被逻辑删除的用户
|
||||
*/
|
||||
boolean revertLogicDeleted(List<String> userIds, SysUser updateEntity);
|
||||
|
||||
/**
|
||||
* 彻底删除被逻辑删除的用户
|
||||
*/
|
||||
boolean removeLogicDeleted(List<String> userIds);
|
||||
|
||||
}
|
||||
|
||||
@ -13,26 +13,31 @@ import javax.servlet.http.HttpServletRequest;
|
||||
import javax.sql.DataSource;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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 org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.constant.DataBaseConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.ComboModel;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysDepartModel;
|
||||
import org.jeecg.common.system.vo.*;
|
||||
import org.jeecg.common.util.IPUtils;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.SysAnnmentTypeEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.common.util.oss.OssBootUtil;
|
||||
import org.jeecg.modules.message.entity.SysMessageTemplate;
|
||||
import org.jeecg.modules.message.service.ISysMessageTemplateService;
|
||||
import org.jeecg.modules.message.websocket.WebSocket;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.service.ISysDataSourceService;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.util.MinioUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -42,6 +47,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @Description: 底层共通业务API,提供其他独立模块调用
|
||||
@ -76,7 +82,12 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
private SysRoleMapper roleMapper;
|
||||
@Resource
|
||||
private SysDepartMapper departMapper;
|
||||
|
||||
@Resource
|
||||
private SysCategoryMapper categoryMapper;
|
||||
|
||||
@Autowired
|
||||
private ISysDataSourceService dataSourceService;
|
||||
|
||||
@Override
|
||||
public void addLog(String LogContent, Integer logType, Integer operatetype) {
|
||||
SysLog sysLog = new SysLog();
|
||||
@ -228,7 +239,64 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, String msgContent, String setMsgCategory, String busType, String busId) {
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(msgContent);
|
||||
announcement.setSender(fromUser);
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(setMsgCategory);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
announcement.setBusId(busId);
|
||||
announcement.setBusType(busType);
|
||||
announcement.setOpenType(SysAnnmentTypeEnum.getByType(busType).getOpenType());
|
||||
announcement.setOpenPage(SysAnnmentTypeEnum.getByType(busType).getOpenPage());
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String userId = toUser;
|
||||
String[] userIds = userId.split(",");
|
||||
String anntId = announcement.getId();
|
||||
for(int i=0;i<userIds.length;i++) {
|
||||
if(oConvertUtils.isNotEmpty(userIds[i])) {
|
||||
SysUser sysUser = userMapper.getUserByName(userIds[i]);
|
||||
if(sysUser==null) {
|
||||
continue;
|
||||
}
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("cmd", "user");
|
||||
obj.put("userId", sysUser.getId());
|
||||
obj.put("msgId", announcement.getId());
|
||||
obj.put("msgTxt", announcement.getTitile());
|
||||
webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysAnnounReadFlag(String busType, String busId) {
|
||||
SysAnnouncement announcement = sysAnnouncementMapper.selectOne(new QueryWrapper<SysAnnouncement>().eq("bus_type",busType).eq("bus_id",busId));
|
||||
if(announcement != null){
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
String userId = sysUser.getId();
|
||||
LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
|
||||
updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
|
||||
updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
|
||||
updateWrapper.last("where annt_id ='"+announcement.getId()+"' and user_id ='"+userId+"'");
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
sysAnnouncementSendMapper.update(announcementSend, updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String parseTemplateByCode(String templateCode,Map<String, String> map) {
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
|
||||
@ -301,6 +369,64 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSysAnnouncement(String fromUser, String toUser, String title, Map<String, String> map, String templateCode, String busType, String busId) {
|
||||
List<SysMessageTemplate> sysSmsTemplates = sysMessageTemplateService.selectByCode(templateCode);
|
||||
if(sysSmsTemplates==null||sysSmsTemplates.size()==0){
|
||||
throw new JeecgBootException("消息模板不存在,模板编码:"+templateCode);
|
||||
}
|
||||
SysMessageTemplate sysSmsTemplate = sysSmsTemplates.get(0);
|
||||
//模板标题
|
||||
title = title==null?sysSmsTemplate.getTemplateName():title;
|
||||
//模板内容
|
||||
String content = sysSmsTemplate.getTemplateContent();
|
||||
if(map!=null) {
|
||||
for (Map.Entry<String, String> entry : map.entrySet()) {
|
||||
String str = "${" + entry.getKey() + "}";
|
||||
title = title.replace(str, entry.getValue());
|
||||
content = content.replace(str, entry.getValue());
|
||||
}
|
||||
}
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(content);
|
||||
announcement.setSender(fromUser);
|
||||
announcement.setPriority(CommonConstant.PRIORITY_M);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
announcement.setBusId(busId);
|
||||
announcement.setBusType(busType);
|
||||
announcement.setOpenType(SysAnnmentTypeEnum.getByType(busType).getOpenType());
|
||||
announcement.setOpenPage(SysAnnmentTypeEnum.getByType(busType).getOpenPage());
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
String userId = toUser;
|
||||
String[] userIds = userId.split(",");
|
||||
String anntId = announcement.getId();
|
||||
for(int i=0;i<userIds.length;i++) {
|
||||
if(oConvertUtils.isNotEmpty(userIds[i])) {
|
||||
SysUser sysUser = userMapper.getUserByName(userIds[i]);
|
||||
if(sysUser==null) {
|
||||
continue;
|
||||
}
|
||||
SysAnnouncementSend announcementSend = new SysAnnouncementSend();
|
||||
announcementSend.setAnntId(anntId);
|
||||
announcementSend.setUserId(sysUser.getId());
|
||||
announcementSend.setReadFlag(CommonConstant.NO_READ_FLAG);
|
||||
sysAnnouncementSendMapper.insert(announcementSend);
|
||||
JSONObject obj = new JSONObject();
|
||||
obj.put("cmd", "user");
|
||||
obj.put("userId", sysUser.getId());
|
||||
obj.put("msgId", announcement.getId());
|
||||
obj.put("msgTxt", announcement.getTitile());
|
||||
webSocket.sendOneMessage(sysUser.getId(), obj.toJSONString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据库类型
|
||||
* @param dataSource
|
||||
@ -349,11 +475,23 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysCategoryModel> queryAllDSysCategory() {
|
||||
List<SysCategory> ls = categoryMapper.selectList(null);
|
||||
List<SysCategoryModel> res = oConvertUtils.entityListToModelList(ls,SysCategoryModel.class);
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryFilterTableDictInfo(String table, String text, String code, String filterSql) {
|
||||
return sysDictService.queryTableDictItemsByCodeAndFilter(table,text,code,filterSql);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String[] keyArray) {
|
||||
return sysDictService.queryTableDictByKeys(table,text,code,keyArray);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllUser() {
|
||||
List<ComboModel> list = new ArrayList<ComboModel>();
|
||||
@ -362,20 +500,25 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
ComboModel model = new ComboModel();
|
||||
model.setTitle(user.getRealname());
|
||||
model.setId(user.getId());
|
||||
model.setUsername(user.getUsername());
|
||||
list.add(model);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ComboModel> queryAllUser(String[] userIds) {
|
||||
public JSONObject queryAllUser(String[] userIds,int pageNo,int pageSize) {
|
||||
JSONObject json = new JSONObject();
|
||||
QueryWrapper<SysUser> queryWrapper = new QueryWrapper<SysUser>().eq("status","1").eq("del_flag","0");
|
||||
List<ComboModel> list = new ArrayList<ComboModel>();
|
||||
List<SysUser> userList = userMapper.selectList(new QueryWrapper<SysUser>().eq("status","1").eq("del_flag","0"));
|
||||
for(SysUser user : userList){
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
IPage<SysUser> pageList = userMapper.selectPage(page, queryWrapper);
|
||||
for(SysUser user : pageList.getRecords()){
|
||||
ComboModel model = new ComboModel();
|
||||
model.setUsername(user.getUsername());
|
||||
model.setTitle(user.getRealname());
|
||||
model.setId(user.getId());
|
||||
model.setEmail(user.getEmail());
|
||||
if(oConvertUtils.isNotEmpty(userIds)){
|
||||
for(int i = 0; i<userIds.length;i++){
|
||||
if(userIds[i].equals(user.getId())){
|
||||
@ -385,7 +528,9 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
list.add(model);
|
||||
}
|
||||
return list;
|
||||
json.put("list",list);
|
||||
json.put("total",pageList.getTotal());
|
||||
return json;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -409,6 +554,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
ComboModel model = new ComboModel();
|
||||
model.setTitle(role.getRoleName());
|
||||
model.setId(role.getId());
|
||||
model.setRoleCode(role.getRoleCode());
|
||||
if(oConvertUtils.isNotEmpty(roleIds)) {
|
||||
for (int i = 0; i < roleIds.length; i++) {
|
||||
if (roleIds[i].equals(role.getId())) {
|
||||
@ -449,4 +595,38 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
return departModelList;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceById(String dbSourceId) {
|
||||
SysDataSource dbSource = dataSourceService.getById(dbSourceId);
|
||||
return new DynamicDataSourceModel(dbSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DynamicDataSourceModel getDynamicDbSourceByCode(String dbSourceCode) {
|
||||
SysDataSource dbSource = dataSourceService.getOne(new LambdaQueryWrapper<SysDataSource>().eq(SysDataSource::getCode, dbSourceCode));
|
||||
return new DynamicDataSourceModel(dbSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getDeptHeadByDepId(String deptId) {
|
||||
List<SysUser> userList = userMapper.selectList(new QueryWrapper<SysUser>().like("depart_ids",deptId).eq("status","1").eq("del_flag","0"));
|
||||
List<String> list = new ArrayList<>();
|
||||
for(SysUser user : userList){
|
||||
list.add(user.getUsername());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String upload(MultipartFile file,String bizPath,String uploadType) {
|
||||
String url = "";
|
||||
if(CommonConstant.UPLOAD_TYPE_MINIO.equals(uploadType)){
|
||||
url = MinioUtil.upload(file,bizPath);
|
||||
}else{
|
||||
url = OssBootUtil.upload(file,bizPath);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,98 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.modules.system.entity.SysCheckRule;
|
||||
import org.jeecg.modules.system.mapper.SysCheckRuleMapper;
|
||||
import org.jeecg.modules.system.service.ISysCheckRuleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Description: 编码校验规则
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-04
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysCheckRuleServiceImpl extends ServiceImpl<SysCheckRuleMapper, SysCheckRule> implements ISysCheckRuleService {
|
||||
|
||||
/**
|
||||
* 位数特殊符号,用于检查整个值,而不是裁剪某一段
|
||||
*/
|
||||
private final String CHECK_ALL_SYMBOL = "*";
|
||||
|
||||
@Override
|
||||
public SysCheckRule getByCode(String ruleCode) {
|
||||
LambdaQueryWrapper<SysCheckRule> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysCheckRule::getRuleCode, ruleCode);
|
||||
return super.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过用户设定的自定义校验规则校验传入的值
|
||||
*
|
||||
* @param checkRule
|
||||
* @param value
|
||||
* @return 返回 null代表通过校验,否则就是返回的错误提示文本
|
||||
*/
|
||||
@Override
|
||||
public JSONObject checkValue(SysCheckRule checkRule, String value) {
|
||||
if (checkRule != null && StringUtils.isNotBlank(value)) {
|
||||
String ruleJson = checkRule.getRuleJson();
|
||||
if (StringUtils.isNotBlank(ruleJson)) {
|
||||
// 开始截取的下标,根据规则的顺序递增,但是 * 号不计入递增范围
|
||||
int beginIndex = 0;
|
||||
JSONArray rules = JSON.parseArray(ruleJson);
|
||||
for (int i = 0; i < rules.size(); i++) {
|
||||
JSONObject result = new JSONObject();
|
||||
JSONObject rule = rules.getJSONObject(i);
|
||||
// 位数
|
||||
String digits = rule.getString("digits");
|
||||
result.put("digits", digits);
|
||||
// 验证规则
|
||||
String pattern = rule.getString("pattern");
|
||||
result.put("pattern", pattern);
|
||||
// 未通过时的提示文本
|
||||
String message = rule.getString("message");
|
||||
result.put("message", message);
|
||||
|
||||
// 根据用户设定的区间,截取字符串进行验证
|
||||
String checkValue;
|
||||
// 是否检查整个值而不截取
|
||||
if (CHECK_ALL_SYMBOL.equals(digits)) {
|
||||
checkValue = value;
|
||||
} else {
|
||||
int num = Integer.parseInt(digits);
|
||||
int endIndex = beginIndex + num;
|
||||
// 如果结束下标大于给定的值的长度,则取到最后一位
|
||||
endIndex = endIndex > value.length() ? value.length() : endIndex;
|
||||
// 如果开始下标大于结束下标,则说明用户还尚未输入到该位置,直接赋空值
|
||||
if (beginIndex > endIndex) {
|
||||
checkValue = "";
|
||||
} else {
|
||||
checkValue = value.substring(beginIndex, endIndex);
|
||||
}
|
||||
result.put("beginIndex", beginIndex);
|
||||
result.put("endIndex", endIndex);
|
||||
beginIndex += num;
|
||||
}
|
||||
result.put("checkValue", checkValue);
|
||||
boolean passed = Pattern.matches(pattern, checkValue);
|
||||
result.put("passed", passed);
|
||||
// 如果没有通过校验就返回错误信息
|
||||
if (!passed) {
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.jeecg.modules.system.entity.SysDataSource;
|
||||
import org.jeecg.modules.system.mapper.SysDataSourceMapper;
|
||||
import org.jeecg.modules.system.service.ISysDataSourceService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @Description: 多数据源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-12-25
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysDataSourceServiceImpl extends ServiceImpl<SysDataSourceMapper, SysDataSource> implements ISysDataSourceService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,92 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.mapper.SysDepartPermissionMapper;
|
||||
import org.jeecg.modules.system.mapper.SysPermissionDataRuleMapper;
|
||||
import org.jeecg.modules.system.service.ISysDepartPermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 部门权限表
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-11
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysDepartPermissionServiceImpl extends ServiceImpl<SysDepartPermissionMapper, SysDepartPermission> implements ISysDepartPermissionService {
|
||||
@Resource
|
||||
private SysPermissionDataRuleMapper ruleMapper;
|
||||
|
||||
@Override
|
||||
public void saveDepartPermission(String departId, String permissionIds, String lastPermissionIds) {
|
||||
List<String> add = getDiff(lastPermissionIds,permissionIds);
|
||||
if(add!=null && add.size()>0) {
|
||||
List<SysDepartPermission> list = new ArrayList<SysDepartPermission>();
|
||||
for (String p : add) {
|
||||
if(oConvertUtils.isNotEmpty(p)) {
|
||||
SysDepartPermission rolepms = new SysDepartPermission(departId, p);
|
||||
list.add(rolepms);
|
||||
}
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
List<String> delete = getDiff(permissionIds,lastPermissionIds);
|
||||
if(delete!=null && delete.size()>0) {
|
||||
for (String permissionId : delete) {
|
||||
this.remove(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysPermissionDataRule> getPermRuleListByDeptIdAndPermId(String departId, String permissionId) {
|
||||
SysDepartPermission departPermission = this.getOne(new QueryWrapper<SysDepartPermission>().lambda().eq(SysDepartPermission::getDepartId, departId).eq(SysDepartPermission::getPermissionId, permissionId));
|
||||
if(departPermission != null){
|
||||
LambdaQueryWrapper<SysPermissionDataRule> query = new LambdaQueryWrapper<SysPermissionDataRule>();
|
||||
query.in(SysPermissionDataRule::getId, Arrays.asList(departPermission.getDataRuleIds().split(",")));
|
||||
query.orderByDesc(SysPermissionDataRule::getCreateTime);
|
||||
List<SysPermissionDataRule> permRuleList = this.ruleMapper.selectList(query);
|
||||
return permRuleList;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从diff中找出main中没有的元素
|
||||
* @param main
|
||||
* @param diff
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDiff(String main,String diff){
|
||||
if(oConvertUtils.isEmpty(diff)) {
|
||||
return null;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(main)) {
|
||||
return Arrays.asList(diff.split(","));
|
||||
}
|
||||
|
||||
String[] mainArr = main.split(",");
|
||||
String[] diffArr = diff.split(",");
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for (String string : mainArr) {
|
||||
map.put(string, 1);
|
||||
}
|
||||
List<String> res = new ArrayList<String>();
|
||||
for (String key : diffArr) {
|
||||
if(oConvertUtils.isNotEmpty(key) && !map.containsKey(key)) {
|
||||
res.add(key);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartRolePermission;
|
||||
import org.jeecg.modules.system.mapper.SysDepartRolePermissionMapper;
|
||||
import org.jeecg.modules.system.service.ISysDepartRolePermissionService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色权限
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysDepartRolePermissionServiceImpl extends ServiceImpl<SysDepartRolePermissionMapper, SysDepartRolePermission> implements ISysDepartRolePermissionService {
|
||||
|
||||
@Override
|
||||
public void saveDeptRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
|
||||
List<String> add = getDiff(lastPermissionIds,permissionIds);
|
||||
if(add!=null && add.size()>0) {
|
||||
List<SysDepartRolePermission> list = new ArrayList<SysDepartRolePermission>();
|
||||
for (String p : add) {
|
||||
if(oConvertUtils.isNotEmpty(p)) {
|
||||
SysDepartRolePermission rolepms = new SysDepartRolePermission(roleId, p);
|
||||
list.add(rolepms);
|
||||
}
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
|
||||
List<String> delete = getDiff(permissionIds,lastPermissionIds);
|
||||
if(delete!=null && delete.size()>0) {
|
||||
for (String permissionId : delete) {
|
||||
this.remove(new QueryWrapper<SysDepartRolePermission>().lambda().eq(SysDepartRolePermission::getRoleId, roleId).eq(SysDepartRolePermission::getPermissionId, permissionId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从diff中找出main中没有的元素
|
||||
* @param main
|
||||
* @param diff
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDiff(String main, String diff){
|
||||
if(oConvertUtils.isEmpty(diff)) {
|
||||
return null;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(main)) {
|
||||
return Arrays.asList(diff.split(","));
|
||||
}
|
||||
|
||||
String[] mainArr = main.split(",");
|
||||
String[] diffArr = diff.split(",");
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for (String string : mainArr) {
|
||||
map.put(string, 1);
|
||||
}
|
||||
List<String> res = new ArrayList<String>();
|
||||
for (String key : diffArr) {
|
||||
if(oConvertUtils.isNotEmpty(key) && !map.containsKey(key)) {
|
||||
res.add(key);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,19 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysDepartRole;
|
||||
import org.jeecg.modules.system.mapper.SysDepartRoleMapper;
|
||||
import org.jeecg.modules.system.service.ISysDepartRoleService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-12
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysDepartRoleServiceImpl extends ServiceImpl<SysDepartRoleMapper, SysDepartRole> implements ISysDepartRoleService {
|
||||
|
||||
}
|
||||
@ -0,0 +1,72 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepartRoleUser;
|
||||
import org.jeecg.modules.system.mapper.SysDepartRoleUserMapper;
|
||||
import org.jeecg.modules.system.service.ISysDepartRoleUserService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @Description: 部门角色人员信息
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2020-02-13
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysDepartRoleUserServiceImpl extends ServiceImpl<SysDepartRoleUserMapper, SysDepartRoleUser> implements ISysDepartRoleUserService {
|
||||
|
||||
@Override
|
||||
public void deptRoleUserAdd(String userId, String newRoleId, String oldRoleId) {
|
||||
List<String> add = getDiff(oldRoleId,newRoleId);
|
||||
if(add!=null && add.size()>0) {
|
||||
List<SysDepartRoleUser> list = new ArrayList<>();
|
||||
for (String roleId : add) {
|
||||
if(oConvertUtils.isNotEmpty(roleId)) {
|
||||
SysDepartRoleUser rolepms = new SysDepartRoleUser(userId, roleId);
|
||||
list.add(rolepms);
|
||||
}
|
||||
}
|
||||
this.saveBatch(list);
|
||||
}
|
||||
List<String> remove = getDiff(newRoleId,oldRoleId);
|
||||
if(remove!=null && remove.size()>0) {
|
||||
for (String roleId : remove) {
|
||||
this.remove(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, userId).eq(SysDepartRoleUser::getDroleId, roleId));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从diff中找出main中没有的元素
|
||||
* @param main
|
||||
* @param diff
|
||||
* @return
|
||||
*/
|
||||
private List<String> getDiff(String main, String diff){
|
||||
if(oConvertUtils.isEmpty(diff)) {
|
||||
return null;
|
||||
}
|
||||
if(oConvertUtils.isEmpty(main)) {
|
||||
return Arrays.asList(diff.split(","));
|
||||
}
|
||||
|
||||
String[] mainArr = main.split(",");
|
||||
String[] diffArr = diff.split(",");
|
||||
Map<String, Integer> map = new HashMap<>();
|
||||
for (String string : mainArr) {
|
||||
map.put(string, 1);
|
||||
}
|
||||
List<String> res = new ArrayList<String>();
|
||||
for (String key : diffArr) {
|
||||
if(oConvertUtils.isNotEmpty(key) && !map.containsKey(key)) {
|
||||
res.add(key);
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
@ -1,11 +1,9 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.FillRuleUtil;
|
||||
@ -36,6 +34,30 @@ import io.netty.util.internal.StringUtil;
|
||||
@Service
|
||||
public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart> implements ISysDepartService {
|
||||
|
||||
@Override
|
||||
public List<SysDepartTreeModel> queryMyDeptTreeList(String departIds) {
|
||||
//根据部门id获取所负责部门
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
String[] codeArr = this.getMyDeptParentOrgCode(departIds);
|
||||
for(int i=0;i<codeArr.length;i++){
|
||||
query.or().likeRight(SysDepart::getOrgCode,codeArr[i]);
|
||||
}
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
query.orderByAsc(SysDepart::getDepartOrder);
|
||||
//将父节点ParentId设为null
|
||||
List<SysDepart> listDepts = this.list(query);
|
||||
for(int i=0;i<codeArr.length;i++){
|
||||
for(SysDepart dept : listDepts){
|
||||
if(dept.getOrgCode().equals(codeArr[i])){
|
||||
dept.setParentId(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 调用wrapTreeDataToTreeList方法生成树状数据
|
||||
List<SysDepartTreeModel> listResult = FindsDepartsChildrenUtil.wrapTreeDataToTreeList(listDepts);
|
||||
return listResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* queryTreeList 对应 queryTreeList 查询所有的部门数据,以树结构形式响应给前端
|
||||
*/
|
||||
@ -200,6 +222,19 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
this.removeByIds(idList);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getSubDepIdsByDepId(String departId) {
|
||||
return this.baseMapper.getSubDepIdsByDepId(departId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMySubDepIdsByDepId(String departIds) {
|
||||
//根据部门id获取所负责部门
|
||||
String[] codeArr = this.getMyDeptParentOrgCode(departIds);
|
||||
return this.baseMapper.getSubDepIdsByOrgCodes(codeArr);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 根据关键字搜索相关的部门数据
|
||||
@ -266,4 +301,67 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
return baseMapper.queryDepartsByUsername(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户所负责部门ids获取父级部门编码
|
||||
* @param departIds
|
||||
* @return
|
||||
*/
|
||||
private String[] getMyDeptParentOrgCode(String departIds){
|
||||
//根据部门id查询所负责部门
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
query.in(SysDepart::getId, Arrays.asList(departIds.split(",")));
|
||||
query.orderByAsc(SysDepart::getOrgCode);
|
||||
List<SysDepart> list = this.list(query);
|
||||
//查找根部门
|
||||
if(list == null || list.size()==0){
|
||||
return null;
|
||||
}
|
||||
String orgCode = this.getMyDeptParentNode(list);
|
||||
String[] codeArr = orgCode.split(",");
|
||||
return codeArr;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取负责部门父节点
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
private String getMyDeptParentNode(List<SysDepart> list){
|
||||
Map<String,String> map = new HashMap<>();
|
||||
//1.先将同一公司归类
|
||||
for(SysDepart dept : list){
|
||||
String code = dept.getOrgCode().substring(0,3);
|
||||
if(map.containsKey(code)){
|
||||
String mapCode = map.get(code)+","+dept.getOrgCode();
|
||||
map.put(code,mapCode);
|
||||
}else{
|
||||
map.put(code,dept.getOrgCode());
|
||||
}
|
||||
}
|
||||
StringBuffer parentOrgCode = new StringBuffer();
|
||||
//2.获取同一公司的根节点
|
||||
for(String str : map.values()){
|
||||
String[] arrStr = str.split(",");
|
||||
parentOrgCode.append(",").append(this.getMinLengthNode(arrStr));
|
||||
}
|
||||
return parentOrgCode.substring(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取同一公司中部门编码长度最小的部门
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
private String getMinLengthNode(String[] str){
|
||||
int min =str[0].length();
|
||||
String orgCode = str[0];
|
||||
for(int i =1;i<str.length;i++){
|
||||
if(str[i].length()<=min){
|
||||
min = str[i].length();
|
||||
orgCode = orgCode+","+str[i];
|
||||
}
|
||||
}
|
||||
return orgCode;
|
||||
}
|
||||
}
|
||||
|
||||
@ -72,7 +72,7 @@ public class SysPermissionDataRuleImpl extends ServiceImpl<SysPermissionDataRule
|
||||
}
|
||||
String[] arr = ids.split(",");
|
||||
for (String id : arr) {
|
||||
if(oConvertUtils.isNotEmpty(id)) {
|
||||
if(oConvertUtils.isNotEmpty(id) && !set.contains(id)) {
|
||||
set.add(id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,10 @@ package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserDepart;
|
||||
@ -90,5 +93,35 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
}
|
||||
return new ArrayList<SysUser>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门code,查询当前部门和下级部门的 用户信息
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> queryUserByDepCode(String depCode) {
|
||||
LambdaQueryWrapper<SysDepart> queryByDepCode = new LambdaQueryWrapper<SysDepart>();
|
||||
queryByDepCode.likeRight(SysDepart::getOrgCode,depCode);
|
||||
List<SysDepart> sysDepartList = sysDepartService.list(queryByDepCode);
|
||||
List<String> depIds = sysDepartList.stream().map(SysDepart::getId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
|
||||
queryUDep.in(SysUserDepart::getDepId, depIds);
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
List<SysUserDepart> uDepList = this.list(queryUDep);
|
||||
if(uDepList != null && uDepList.size() > 0) {
|
||||
for(SysUserDepart uDep : uDepList) {
|
||||
userIdList.add(uDep.getUserId());
|
||||
}
|
||||
List<SysUser> userList = (List<SysUser>) sysUserService.listByIds(userIdList);
|
||||
//update-begin-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息
|
||||
for (SysUser sysUser : userList) {
|
||||
sysUser.setSalt("");
|
||||
sysUser.setPassword("");
|
||||
}
|
||||
//update-end-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息
|
||||
return userList;
|
||||
}
|
||||
return new ArrayList<SysUser>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
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 com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
@ -18,12 +20,14 @@ 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.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -87,12 +91,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public boolean deleteUser(String userId) {
|
||||
//1.删除用户
|
||||
this.removeById(userId);
|
||||
//2.删除用户部门关联关系
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>();
|
||||
query.eq(SysUserDepart::getUserId, userId);
|
||||
sysUserDepartMapper.delete(query);
|
||||
//3.删除用户角色关联关系
|
||||
//TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -102,14 +100,6 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
public boolean deleteBatchUsers(String userIds) {
|
||||
//1.删除用户
|
||||
this.removeByIds(Arrays.asList(userIds.split(",")));
|
||||
//2.删除用户部门关系
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>();
|
||||
for(String id : userIds.split(",")) {
|
||||
query.eq(SysUserDepart::getUserId, id);
|
||||
this.sysUserDepartMapper.delete(query);
|
||||
}
|
||||
//3.删除用户角色关系
|
||||
//TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -231,6 +221,27 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return userMapper.getUserByDepId(page, departId,username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> getUserByDepIds(Page<SysUser> page, List<String> departIds, String username) {
|
||||
return userMapper.getUserByDepIds(page, departIds,username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getDepNamesByUserIds(List<String> userIds) {
|
||||
List<SysUserDepVo> list = this.baseMapper.getDepNamesByUserIds(userIds);
|
||||
|
||||
Map<String, String> res = new HashMap<String, String>();
|
||||
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
|
||||
public IPage<SysUser> getUserByDepartIdAndQueryWrapper(Page<SysUser> page, String departId, QueryWrapper<SysUser> queryWrapper) {
|
||||
LambdaQueryWrapper<SysUser> lambdaQueryWrapper = queryWrapper.lambda();
|
||||
@ -336,4 +347,38 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> queryLogicDeleted() {
|
||||
return this.queryLogicDeleted(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> queryLogicDeleted(LambdaQueryWrapper<SysUser> wrapper) {
|
||||
if (wrapper == null) {
|
||||
wrapper = new LambdaQueryWrapper<>();
|
||||
}
|
||||
wrapper.eq(SysUser::getDelFlag, "1");
|
||||
return userMapper.selectLogicDeleted(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean revertLogicDeleted(List<String> userIds, SysUser updateEntity) {
|
||||
String ids = String.format("'%s'", String.join("','", userIds));
|
||||
return userMapper.revertLogicDeleted(ids, updateEntity) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean removeLogicDeleted(List<String> userIds) {
|
||||
String ids = String.format("'%s'", String.join("','", userIds));
|
||||
// 1. 删除用户
|
||||
int line = userMapper.deleteLogicDeleted(ids);
|
||||
// 2. 删除用户部门关系
|
||||
line += sysUserDepartMapper.delete(new LambdaQueryWrapper<SysUserDepart>().in(SysUserDepart::getUserId, userIds));
|
||||
//3. 删除用户角色关系
|
||||
line += sysUserRoleMapper.delete(new LambdaQueryWrapper<SysUserRole>().in(SysUserRole::getUserId, userIds));
|
||||
return line != 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,114 @@
|
||||
package org.jeecg.modules.system.util;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import io.minio.errors.*;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.xmlpull.v1.XmlPullParserException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* minio文件上传工具类
|
||||
*/
|
||||
@Slf4j
|
||||
public class MinioUtil {
|
||||
private static String minioUrl;
|
||||
private static String minioName;
|
||||
private static String minioPass;
|
||||
private static String bucketName;
|
||||
|
||||
public static void setMinioUrl(String minioUrl) {
|
||||
MinioUtil.minioUrl = minioUrl;
|
||||
}
|
||||
|
||||
public static void setMinioName(String minioName) {
|
||||
MinioUtil.minioName = minioName;
|
||||
}
|
||||
|
||||
public static void setMinioPass(String minioPass) {
|
||||
MinioUtil.minioPass = minioPass;
|
||||
}
|
||||
|
||||
public static void setBucketName(String bucketName) {
|
||||
MinioUtil.bucketName = bucketName;
|
||||
}
|
||||
|
||||
private static MinioClient minioClient = null;
|
||||
|
||||
/**
|
||||
* 上传文件
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static String upload(MultipartFile file,String bizPath) {
|
||||
String file_url = "";
|
||||
try {
|
||||
initMinio(minioUrl, minioName,minioPass);
|
||||
// 检查存储桶是否已经存在
|
||||
if(minioClient.bucketExists(bucketName)) {
|
||||
log.info("Bucket already exists.");
|
||||
} else {
|
||||
// 创建一个名为ota的存储桶
|
||||
minioClient.makeBucket(bucketName);
|
||||
log.info("create a new bucket.");
|
||||
}
|
||||
InputStream stream = file.getInputStream();
|
||||
String orgName = file.getOriginalFilename();// 获取文件名
|
||||
String objectName = bizPath+"/"+orgName.substring(0, orgName.lastIndexOf(".")) + "_" + System.currentTimeMillis() + orgName.substring(orgName.indexOf("."));
|
||||
|
||||
// 使用putObject上传一个本地文件到存储桶中。
|
||||
minioClient.putObject(bucketName,objectName, stream,stream.available(),"application/octet-stream");
|
||||
stream.close();
|
||||
file_url = minioUrl+bucketName+"/"+objectName;
|
||||
}catch (IOException e){
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (InvalidKeyException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (NoResponseException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (XmlPullParserException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (InvalidArgumentException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (RegionConflictException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (InvalidBucketNameException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (ErrorResponseException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (InternalException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
} catch (InsufficientDataException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
return file_url;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化客户端
|
||||
* @param minioUrl
|
||||
* @param minioName
|
||||
* @param minioPass
|
||||
* @return
|
||||
*/
|
||||
private static MinioClient initMinio(String minioUrl, String minioName,String minioPass) {
|
||||
if (minioClient == null) {
|
||||
try {
|
||||
minioClient = new MinioClient(minioUrl, minioName,minioPass);
|
||||
} catch (InvalidEndpointException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidPortException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return minioClient;
|
||||
}
|
||||
}
|
||||
@ -75,5 +75,21 @@ public class PermissionDataUtil {
|
||||
metaList.add(0,new SysPermission(true));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否授权首页
|
||||
* @param metaList
|
||||
* @return
|
||||
*/
|
||||
public static boolean hasIndexPage(List<SysPermission> metaList){
|
||||
boolean hasIndexMenu = false;
|
||||
for (SysPermission sysPermission : metaList) {
|
||||
if("首页".equals(sysPermission.getName())) {
|
||||
hasIndexMenu = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return hasIndexMenu;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,139 @@
|
||||
package org.jeecg.modules.system.util;
|
||||
|
||||
import sun.misc.BASE64Encoder;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Random;
|
||||
|
||||
public class RandImageUtil {
|
||||
|
||||
public static final String key = "JEECG_LOGIN_KEY";
|
||||
|
||||
/**
|
||||
* 定义图形大小
|
||||
*/
|
||||
private static final int width = 105;
|
||||
/**
|
||||
* 定义图形大小
|
||||
*/
|
||||
private static final int height = 35;
|
||||
|
||||
/**
|
||||
* 定义干扰线数量
|
||||
*/
|
||||
private static final int count = 200;
|
||||
|
||||
/**
|
||||
* 干扰线的长度=1.414*lineWidth
|
||||
*/
|
||||
private static final int lineWidth = 2;
|
||||
|
||||
/**
|
||||
* 图片格式
|
||||
*/
|
||||
private static final String IMG_FORMAT = "JPEG";
|
||||
|
||||
/**
|
||||
* base64 图片前缀
|
||||
*/
|
||||
private static final String BASE64_PRE = "data:image/jpg;base64,";
|
||||
|
||||
/**
|
||||
* 直接通过response 返回图片
|
||||
* @param response
|
||||
* @param resultCode
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void generate(HttpServletResponse response, String resultCode) throws IOException {
|
||||
BufferedImage image = getImageBuffer(resultCode);
|
||||
// 输出图象到页面
|
||||
ImageIO.write(image, IMG_FORMAT, response.getOutputStream());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成base64字符串
|
||||
* @param resultCode
|
||||
* @return
|
||||
* @throws IOException
|
||||
*/
|
||||
public static String generate(String resultCode) throws IOException {
|
||||
BufferedImage image = getImageBuffer(resultCode);
|
||||
|
||||
ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
|
||||
//写入流中
|
||||
ImageIO.write(image, IMG_FORMAT, byteStream);
|
||||
//转换成字节
|
||||
byte[] bytes = byteStream.toByteArray();
|
||||
BASE64Encoder encoder = new BASE64Encoder();
|
||||
//转换成base64串
|
||||
String base64 = encoder.encodeBuffer(bytes).trim();
|
||||
base64 = base64.replaceAll("\n", "").replaceAll("\r", "");//删除 \r\n
|
||||
|
||||
//写到指定位置
|
||||
//ImageIO.write(bufferedImage, "png", new File(""));
|
||||
|
||||
return BASE64_PRE+base64;
|
||||
}
|
||||
|
||||
private static BufferedImage getImageBuffer(String resultCode){
|
||||
// 在内存中创建图象
|
||||
final BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
|
||||
// 获取图形上下文
|
||||
final Graphics2D graphics = (Graphics2D) image.getGraphics();
|
||||
// 设定背景颜色
|
||||
graphics.setColor(Color.WHITE); // ---1
|
||||
graphics.fillRect(0, 0, width, height);
|
||||
// 设定边框颜色
|
||||
// graphics.setColor(getRandColor(100, 200)); // ---2
|
||||
graphics.drawRect(0, 0, width - 1, height - 1);
|
||||
|
||||
final Random random = new Random();
|
||||
// 随机产生干扰线,使图象中的认证码不易被其它程序探测到
|
||||
for (int i = 0; i < count; i++) {
|
||||
graphics.setColor(getRandColor(150, 200)); // ---3
|
||||
|
||||
final int x = random.nextInt(width - lineWidth - 1) + 1; // 保证画在边框之内
|
||||
final int y = random.nextInt(height - lineWidth - 1) + 1;
|
||||
final int xl = random.nextInt(lineWidth);
|
||||
final int yl = random.nextInt(lineWidth);
|
||||
graphics.drawLine(x, y, x + xl, y + yl);
|
||||
}
|
||||
// 取随机产生的认证码
|
||||
for (int i = 0; i < resultCode.length(); i++) {
|
||||
// 将认证码显示到图象中,调用函数出来的颜色相同,可能是因为种子太接近,所以只能直接生成
|
||||
// graphics.setColor(new Color(20 + random.nextInt(130), 20 + random
|
||||
// .nextInt(130), 20 + random.nextInt(130)));
|
||||
// 设置字体颜色
|
||||
graphics.setColor(Color.BLACK);
|
||||
// 设置字体样式
|
||||
// graphics.setFont(new Font("Arial Black", Font.ITALIC, 18));
|
||||
graphics.setFont(new Font("Times New Roman", Font.BOLD, 24));
|
||||
// 设置字符,字符间距,上边距
|
||||
graphics.drawString(String.valueOf(resultCode.charAt(i)), (23 * i) + 8, 26);
|
||||
}
|
||||
// 图象生效
|
||||
graphics.dispose();
|
||||
return image;
|
||||
}
|
||||
|
||||
private static Color getRandColor(int fc, int bc) { // 取得给定范围随机颜色
|
||||
final Random random = new Random();
|
||||
if (fc > 255) {
|
||||
fc = 255;
|
||||
}
|
||||
if (bc > 255) {
|
||||
bc = 255;
|
||||
}
|
||||
|
||||
final int r = fc + random.nextInt(bc - fc);
|
||||
final int g = fc + random.nextInt(bc - fc);
|
||||
final int b = fc + random.nextInt(bc - fc);
|
||||
|
||||
return new Color(r, g, b);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Author qinfeng
|
||||
* @Date 2020/1/2 21:58
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Data
|
||||
public class SysUserDepVo {
|
||||
private String userId;
|
||||
private String departName;
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
server:
|
||||
port: 8080
|
||||
tomcat:
|
||||
tomcat:
|
||||
max-swallow-size: -1
|
||||
servlet:
|
||||
context-path: /jeecg-boot
|
||||
@ -8,16 +8,16 @@ server:
|
||||
enabled: true
|
||||
min-response-size: 1024
|
||||
mime-types: application/javascript,application/json,application/xml,text/html,text/xml,text/plain,text/css,image/*
|
||||
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
web:
|
||||
exposure:
|
||||
include: metrics,httptrace
|
||||
|
||||
|
||||
spring:
|
||||
servlet:
|
||||
multipart:
|
||||
multipart:
|
||||
max-file-size: 10MB
|
||||
max-request-size: 10MB
|
||||
mail:
|
||||
@ -96,7 +96,7 @@ spring:
|
||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false
|
||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot-?characterEncoding=UTF-8&useUnicode=true&useSSL=false
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
@ -130,16 +130,20 @@ mybatis-plus:
|
||||
id-type: 4
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
#configuration:
|
||||
configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 返回类型为Map,显示null对应的字段
|
||||
call-setters-on-nulls: true
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: local
|
||||
path :
|
||||
#文件上传根目录 设置
|
||||
upload: D://upFiles
|
||||
upload: D://opt//upFiles
|
||||
#webapp文件路径
|
||||
webapp: D://webapp
|
||||
webapp: D://opt//webapp
|
||||
#短信秘钥
|
||||
sms:
|
||||
accessKeyId: ??
|
||||
@ -155,18 +159,24 @@ jeecg :
|
||||
staticDomain: ??
|
||||
# ElasticSearch 设置
|
||||
elasticsearch:
|
||||
cluster-name: jeecg-ES
|
||||
cluster-name: docker-cluster
|
||||
cluster-nodes: 127.0.0.1:9200
|
||||
# 表单设计器配置
|
||||
desform:
|
||||
# 主题颜色(仅支持 16进制颜色代码)
|
||||
theme-color: "#1890ff"
|
||||
# 在线预览文件服务器地址配置
|
||||
file-view-domain: http://127.0.0.1:8012
|
||||
file-view-domain: http://fileview.jeecg.com
|
||||
# minio文件上传
|
||||
minio:
|
||||
minio_url: http://minio.jeecg.com
|
||||
minio_name: ??
|
||||
minio_pass: ??
|
||||
bucketName: ??
|
||||
#Mybatis输出sql日志
|
||||
logging:
|
||||
level:
|
||||
org.jeecg.modules.system.mapper : debug
|
||||
#cas单点登录
|
||||
cas:
|
||||
prefixUrl: http://cas.example.org:8443/cas
|
||||
prefixUrl: http://cas.example.org:8443/cas
|
||||
|
||||
@ -130,8 +130,15 @@ mybatis-plus:
|
||||
id-type: 4
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 返回类型为Map,显示null对应的字段
|
||||
call-setters-on-nulls: true
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: local
|
||||
path :
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/jeecg-boot/upload
|
||||
@ -159,7 +166,13 @@ jeecg :
|
||||
# 主题颜色(仅支持 16进制颜色代码)
|
||||
theme-color: "#1890ff"
|
||||
# 在线预览文件服务器地址配置
|
||||
file-view-domain: 127.0.0.1:8012
|
||||
file-view-domain: http://fileview.jeecg.com
|
||||
# minio文件上传
|
||||
minio:
|
||||
minio_url: http://minio.jeecg.com
|
||||
minio_name: ??
|
||||
minio_pass: ??
|
||||
bucketName: ??
|
||||
#cas单点登录
|
||||
cas:
|
||||
prefixUrl: http://cas.example.org:8443/cas
|
||||
|
||||
@ -133,13 +133,17 @@ mybatis-plus:
|
||||
configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
# 返回类型为Map,显示null对应的字段
|
||||
call-setters-on-nulls: true
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: local
|
||||
path :
|
||||
#文件上传根目录 设置
|
||||
upload: D://upFiles
|
||||
upload: D://opt//upFiles
|
||||
#webapp文件路径
|
||||
webapp: D://webapp
|
||||
webapp: D://opt//webapp
|
||||
#短信秘钥
|
||||
sms:
|
||||
accessKeyId: LTAIpW4gUG7xYDNI
|
||||
@ -152,7 +156,7 @@ jeecg :
|
||||
accessKey: WegDpuKzOuPK6D3N
|
||||
secretKey: ??
|
||||
bucketName: jeecgos
|
||||
staticDomain: ??
|
||||
staticDomain: https://static.jeecg.com
|
||||
# ElasticSearch 设置
|
||||
elasticsearch:
|
||||
cluster-name: jeecg-ES
|
||||
@ -163,6 +167,12 @@ jeecg :
|
||||
theme-color: "#1890ff"
|
||||
# 在线预览文件服务器地址配置
|
||||
file-view-domain: 127.0.0.1:8012
|
||||
# minio文件上传
|
||||
minio:
|
||||
minio_url: http://minio.jeecg.com
|
||||
minio_name: ??
|
||||
minio_pass: ??
|
||||
bucketName: ??
|
||||
#cas单点登录
|
||||
cas:
|
||||
prefixUrl: http://cas.example.org:8443/cas
|
||||
@ -9,6 +9,6 @@ ${AnsiColor.BRIGHT_BLUE}
|
||||
|
||||
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
Jeecg Boot Version: 2.1.3
|
||||
Jeecg Boot Version: 2.1.4
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
${AnsiColor.BLACK}
|
||||
|
||||
@ -32,6 +32,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
|
||||
/**
|
||||
* @Description: ${tableVo.ftlDescription}
|
||||
@ -39,6 +42,7 @@ import com.alibaba.fastjson.JSON;
|
||||
* @Date: ${.now?string["yyyy-MM-dd"]}
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="${tableVo.ftlDescription}")
|
||||
@RestController
|
||||
@RequestMapping("/${entityPackage}/${entityName?uncap_first}")
|
||||
@Slf4j
|
||||
@ -55,6 +59,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-分页列表查询")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(${entityName} ${entityName?uncap_first},
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@ -72,6 +78,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
|
||||
* @param ${entityName?uncap_first}
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-添加")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody ${entityName} ${entityName?uncap_first}) {
|
||||
${entityName?uncap_first}Service.save(${entityName?uncap_first});
|
||||
@ -84,6 +92,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
|
||||
* @param ${entityName?uncap_first}
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-编辑")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody ${entityName} ${entityName?uncap_first}) {
|
||||
${entityName?uncap_first}Service.updateById(${entityName?uncap_first});
|
||||
@ -96,6 +106,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-通过id删除")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-通过id删除", notes="${tableVo.ftlDescription}-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
${entityName?uncap_first}Service.removeById(id);
|
||||
@ -108,6 +120,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-批量删除")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-批量删除", notes="${tableVo.ftlDescription}-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.${entityName?uncap_first}Service.removeByIds(Arrays.asList(ids.split(",")));
|
||||
@ -120,6 +134,8 @@ public class ${entityName}Controller extends JeecgController<${entityName}, I${e
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-通过id查询")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-通过id查询", notes="${tableVo.ftlDescription}-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
|
||||
@ -12,6 +12,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: ${tableVo.ftlDescription}
|
||||
@ -21,27 +25,46 @@ import org.jeecg.common.aspect.annotation.Dict;
|
||||
*/
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
|
||||
public class ${entityName} implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
<#list originalColumns as po>
|
||||
<#-- 生成字典Code -->
|
||||
<#assign list_field_dictCode="">
|
||||
<#if po.classType='sel_user'>
|
||||
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
|
||||
<#elseif po.classType='sel_depart'>
|
||||
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
|
||||
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
|
||||
</#if>
|
||||
</#if>
|
||||
/**${po.filedComment}*/
|
||||
<#if po.fieldName == primaryKeyField>
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
<#else>
|
||||
<#if po.fieldDbType =='Date'>
|
||||
<#if po.classType=='date'>
|
||||
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
|
||||
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
<#else>
|
||||
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
</#if>
|
||||
<#else>
|
||||
@Excel(name = "${po.filedComment}", width = 15)
|
||||
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
|
||||
</#if>
|
||||
<#if list_field_dictCode?length gt 1>
|
||||
@Dict(${list_field_dictCode?substring(2)})
|
||||
</#if>
|
||||
<#-- <#if po.classType!='popup'>
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
@Dict(dicCode="${po.dictField}",dicText="${po.dictText}",dictTable="${po.dictTable}")
|
||||
@ -79,6 +102,7 @@ public class ${entityName} implements Serializable {
|
||||
return "";
|
||||
}
|
||||
<#else>
|
||||
@ApiModelProperty(value = "${po.filedComment}")
|
||||
private ${po.fieldType} ${po.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
@ -18,7 +18,7 @@
|
||||
<template v-if="toggleSearchStatus">
|
||||
</#if>
|
||||
<#if po.queryMode=='single'>
|
||||
<#if query_field_no gt 1> </#if><a-col :md="6" :sm="8">
|
||||
<#if query_field_no gt 1> </#if><a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
|
||||
<#if po.classType=='date'>
|
||||
<#assign query_field_date=true>
|
||||
@ -42,7 +42,7 @@
|
||||
<#if query_field_no gt 1> </#if></a-form-item>
|
||||
<#if query_field_no gt 1> </#if></a-col>
|
||||
<#else>
|
||||
<#if query_field_no gt 1> </#if><a-col :md="12" :sm="16">
|
||||
<#if query_field_no gt 1> </#if><a-col :xl="10" :lg="11" :md="12" :sm="24">
|
||||
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
|
||||
<#if po.classType=='date'>
|
||||
<#assign query_field_date=true>
|
||||
@ -77,7 +77,7 @@
|
||||
</template>
|
||||
</#if>
|
||||
<#if query_flag>
|
||||
<a-col :md="6" :sm="8" >
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
||||
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
|
||||
<a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
|
||||
@ -186,7 +186,7 @@
|
||||
import { loadCategoryData } from '@/api/api'
|
||||
</#if>
|
||||
<#if list_need_dict>
|
||||
import {initDictOptions, filterMultiDictText} from '@/components/dict/JDictSelectUtil'
|
||||
import {filterMultiDictText} from '@/components/dict/JDictSelectUtil'
|
||||
</#if>
|
||||
|
||||
export default {
|
||||
@ -239,34 +239,15 @@
|
||||
<#elseif po.classType=='image'>
|
||||
dataIndex: '${po.fieldName}',
|
||||
scopedSlots: {customRender: 'imgSlot'}
|
||||
<#elseif po.classType=='sel_search' || po.classType=='list_multi' || po.classType=='list' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart'>
|
||||
dataIndex: '${po.fieldName}',
|
||||
customRender:(text)=>{
|
||||
if(!text){
|
||||
return ''
|
||||
}else{
|
||||
return filterMultiDictText(this.dictOptions['${po.fieldName}'], text+"")
|
||||
}
|
||||
}
|
||||
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'>
|
||||
dataIndex: '${po.fieldName}_dictText'
|
||||
<#elseif po.classType=='cat_tree'>
|
||||
<#if list_need_category>
|
||||
dataIndex: '${po.fieldName}',
|
||||
customRender:(text)=>{
|
||||
if(!text){
|
||||
return ''
|
||||
}else{
|
||||
return filterMultiDictText(this.dictOptions['${po.fieldName}'], text+"")
|
||||
}
|
||||
}
|
||||
customRender: (text) => (text ? filterMultiDictText(this.dictOptions['${po.fieldName}'], text) : '')
|
||||
<#else>
|
||||
dataIndex: '${po.fieldName}',
|
||||
customRender:(text,record)=>{
|
||||
if(!text){
|
||||
return ''
|
||||
}else{
|
||||
return record['${po.dictText}']
|
||||
}
|
||||
}
|
||||
customRender: (text, record) => (text ? record['${po.dictText}'] : '')
|
||||
</#if>
|
||||
<#else>
|
||||
dataIndex: '${po.fieldName}'
|
||||
@ -292,15 +273,7 @@
|
||||
exportXlsUrl: "/${entityPackage}/${entityName?uncap_first}/exportXls",
|
||||
importExcelUrl: "${entityPackage}/${entityName?uncap_first}/importExcel",
|
||||
},
|
||||
dictOptions:{
|
||||
<#list columns as po>
|
||||
<#if (po.isQuery=='Y' || po.isShowList=='Y')>
|
||||
<#if po.classType='sel_depart' || po.classType=='list_multi' || po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
|
||||
${po.fieldName}:[],
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
dictOptions:{},
|
||||
<#if tableVo.extendParams.scroll=='1'>
|
||||
tableScroll:{x :${showColNum}*147+50}
|
||||
</#if>
|
||||
@ -315,38 +288,19 @@
|
||||
initDictConfig(){
|
||||
<#list columns as po>
|
||||
<#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
|
||||
<#if po.classType='sel_depart'>
|
||||
initDictOptions('sys_depart,depart_name,id').then((res) => {
|
||||
if (res.success) {
|
||||
this.$set(this.dictOptions, '${po.fieldName}', res.result)
|
||||
}
|
||||
})
|
||||
<#elseif po.classType=='cat_tree' && list_need_category==true>
|
||||
<#if po.classType=='cat_tree' && list_need_category==true>
|
||||
loadCategoryData({code:"${po.dictField}"}).then((res) => {
|
||||
if (res.success) {
|
||||
this.$set(this.dictOptions, '${po.fieldName}', res.result)
|
||||
}
|
||||
})
|
||||
<#elseif po.classType=='sel_search' || po.classType=='list_multi' || po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
|
||||
<#assign list_field_dictCode="">
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode="${po.dictField}">
|
||||
</#if>
|
||||
initDictOptions('${list_field_dictCode}').then((res) => {
|
||||
if (res.success) {
|
||||
this.$set(this.dictOptions, '${po.fieldName}', res.result)
|
||||
}
|
||||
})
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style scoped>
|
||||
@import '~@assets/less/common.less'
|
||||
@import '~@assets/less/common.less';
|
||||
</style>
|
||||
@ -42,6 +42,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
|
||||
/**
|
||||
* @Description: ${tableVo.ftlDescription}
|
||||
@ -49,6 +52,7 @@ import com.alibaba.fastjson.JSON;
|
||||
* @Date: ${.now?string["yyyy-MM-dd"]}
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="${tableVo.ftlDescription}")
|
||||
@RestController
|
||||
@RequestMapping("/${entityPackage}/${entityName?uncap_first}")
|
||||
@Slf4j
|
||||
@ -69,6 +73,8 @@ public class ${entityName}Controller {
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-分页列表查询")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-分页列表查询", notes="${tableVo.ftlDescription}-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<?> queryPageList(${entityName} ${entityName?uncap_first},
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@ -86,6 +92,8 @@ public class ${entityName}Controller {
|
||||
* @param ${entityName?uncap_first}Page
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-添加")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-添加", notes="${tableVo.ftlDescription}-添加")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<?> add(@RequestBody ${entityName}Page ${entityName?uncap_first}Page) {
|
||||
${entityName} ${entityName?uncap_first} = new ${entityName}();
|
||||
@ -100,6 +108,8 @@ public class ${entityName}Controller {
|
||||
* @param ${entityName?uncap_first}Page
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-编辑")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-编辑", notes="${tableVo.ftlDescription}-编辑")
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<?> edit(@RequestBody ${entityName}Page ${entityName?uncap_first}Page) {
|
||||
${entityName} ${entityName?uncap_first} = new ${entityName}();
|
||||
@ -118,6 +128,8 @@ public class ${entityName}Controller {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-通过id删除")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-通过id删除", notes="${tableVo.ftlDescription}-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
${entityName?uncap_first}Service.delMain(id);
|
||||
@ -130,6 +142,8 @@ public class ${entityName}Controller {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-批量删除")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-批量删除", notes="${tableVo.ftlDescription}-批量删除")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.${entityName?uncap_first}Service.delBatchMain(Arrays.asList(ids.split(",")));
|
||||
@ -142,6 +156,8 @@ public class ${entityName}Controller {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-通过id查询")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-通过id查询", notes="${tableVo.ftlDescription}-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
|
||||
@ -159,6 +175,8 @@ public class ${entityName}Controller {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "${sub.ftlDescription}集合-通过id查询")
|
||||
@ApiOperation(value="${sub.ftlDescription}集合-通过id查询", notes="${sub.ftlDescription}-通过id查询")
|
||||
@GetMapping(value = "/query${sub.entityName}ByMainId")
|
||||
public Result<?> query${sub.entityName}ListByMainId(@RequestParam(name="id",required=true) String id) {
|
||||
List<${sub.entityName}> ${sub.entityName?uncap_first}List = ${sub.entityName?uncap_first}Service.selectByMainId(id);
|
||||
@ -8,6 +8,10 @@ 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 org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @Description: ${tableVo.ftlDescription}
|
||||
@ -15,26 +19,46 @@ import org.springframework.format.annotation.DateTimeFormat;
|
||||
* @Date: ${.now?string["yyyy-MM-dd"]}
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
|
||||
@Data
|
||||
@TableName("${tableName}")
|
||||
public class ${entityName} implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
<#list originalColumns as po>
|
||||
<#-- 生成字典Code -->
|
||||
<#assign list_field_dictCode="">
|
||||
<#if po.classType='sel_user'>
|
||||
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
|
||||
<#elseif po.classType='sel_depart'>
|
||||
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
|
||||
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
|
||||
</#if>
|
||||
</#if>
|
||||
/**${po.filedComment}*/
|
||||
<#if po.fieldName == primaryKeyField>
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
<#else>
|
||||
<#if po.fieldDbType =='Date'>
|
||||
<#if po.classType=='date'>
|
||||
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
<#else>
|
||||
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
</#if>
|
||||
<#else>
|
||||
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
|
||||
</#if>
|
||||
<#if list_field_dictCode?length gt 1>
|
||||
@Dict(${list_field_dictCode?substring(2)})
|
||||
</#if>
|
||||
</#if>
|
||||
<#if po.fieldDbType=='Blob'>
|
||||
private transient java.lang.String ${po.fieldName}String;
|
||||
@ -65,6 +89,7 @@ public class ${entityName} implements Serializable {
|
||||
return "";
|
||||
}
|
||||
<#else>
|
||||
@ApiModelProperty(value = "${po.filedComment}")
|
||||
private ${po.fieldType} ${po.fieldName};
|
||||
</#if>
|
||||
</#list>
|
||||
@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import java.util.Date;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @Description: ${subTab.ftlDescription}
|
||||
@ -18,30 +20,45 @@ import java.util.Date;
|
||||
* @Date: ${.now?string["yyyy-MM-dd"]}
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@ApiModel(value="${tableName}对象", description="${tableVo.ftlDescription}")
|
||||
@Data
|
||||
@TableName("${subTab.tableName}")
|
||||
public class ${subTab.entityName} implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
||||
<#list subTab.originalColumns as po>
|
||||
<#-- 生成字典Code -->
|
||||
<#assign list_field_dictCode="">
|
||||
<#if po.classType='sel_user'>
|
||||
<#assign list_field_dictCode=', dictTable = "sys_user", dicText = "realname", dicCode = "username"'>
|
||||
<#elseif po.classType='sel_depart'>
|
||||
<#assign list_field_dictCode=', dictTable = "sys_depart", dicText = "depart_name", dicCode = "id"'>
|
||||
<#elseif po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox'>
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode=', dictTable = "${po.dictTable}", dicText = "${po.dictText}", dicCode = "${po.dictField}"'>
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#assign list_field_dictCode=', dicCode = "${po.dictField}"'>
|
||||
</#if>
|
||||
</#if>
|
||||
/**${po.filedComment}*/
|
||||
<#if po.fieldName == primaryKeyField>
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
<#else>
|
||||
<#if po.fieldDbType =='Date'>
|
||||
<#if po.classType=='date'>
|
||||
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd")
|
||||
@Excel(name = "${po.filedComment}", width = 15, format = "yyyy-MM-dd"${list_field_dictCode})
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd")
|
||||
<#else>
|
||||
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "${po.filedComment}", width = 20, format = "yyyy-MM-dd HH:mm:ss"${list_field_dictCode})
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
</#if>
|
||||
<#elseif !subTab.foreignKeys?seq_contains(po.fieldName?cap_first)>
|
||||
@Excel(name = "${po.filedComment}", width = 15)
|
||||
@Excel(name = "${po.filedComment}", width = 15${list_field_dictCode})
|
||||
</#if>
|
||||
</#if>
|
||||
@ApiModelProperty(value = "${po.filedComment}")
|
||||
private <#if po.fieldType=='java.sql.Blob'>byte[]<#else>${po.fieldType}</#if> ${po.fieldName};
|
||||
</#list>
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user