mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
JEECG-BOOT 2.0.2版本发布
This commit is contained in:
24
jeecg-boot/jeecg-boot-module-system/docs/规范/编码必看规范
Normal file
24
jeecg-boot/jeecg-boot-module-system/docs/规范/编码必看规范
Normal file
@ -0,0 +1,24 @@
|
||||
【第一部分】代码注释规范
|
||||
|
||||
[1].代码修改注释
|
||||
//update-begin--Author:zhangdaihao Date:20140212 for:[bugfree号]树机构调整--------------------
|
||||
//update-end--Author:zhangdaihao Date:20140212 for:[bugfree号]树机构调整----------------------
|
||||
[2].代码存在缺陷或者留有功能点的代码,采用以下方式进行标示
|
||||
//TODO author:zhangdaihao for:插入未完成 date:20130711
|
||||
|
||||
[3].SVN提交注释
|
||||
[author:用户名 date:20130203 for:(bugfree号码)增加查询条件,组织机构]
|
||||
|
||||
|
||||
【第二部分】修改文件记录
|
||||
代码修改日志 :/jeecg-boot/docs/代码修改日志
|
||||
数据库修改日志:/jeecg-boot/docs/DB修改日志.sql
|
||||
|
||||
【第三部分】建表规范
|
||||
1.主键必须是ID,字符串类型,32位长度,唯一索引;
|
||||
2.建表标准字段,必须有:创建人、创建时间、修改人、修改时间等标准字段;
|
||||
3.表字段注释,每个字段必须设置注释说明;
|
||||
4.表字段注释,状态类型的字段必须说明取值规则(比如性别sex取值规则)
|
||||
比如:'性别 0/男,1/女'
|
||||
5.索引,查询频率高的字段加索引(单字段索引 、组合索引);
|
||||
6.类型字段,尽量用字符串varchar类型1-2长度,少用int类型,避免不必要的问题。
|
||||
Binary file not shown.
18
jeecg-boot/jeecg-boot-module-system/docs/项目说明
Normal file
18
jeecg-boot/jeecg-boot-module-system/docs/项目说明
Normal file
@ -0,0 +1,18 @@
|
||||
|
||||
一、技术文档
|
||||
http://jeecg-boot.mydoc.io
|
||||
|
||||
二、部署文档
|
||||
修改redis、数据库配置文件
|
||||
修改上传文件目录
|
||||
修改登录页面提示账号密码
|
||||
修改前端API的图片访问域名
|
||||
|
||||
|
||||
|
||||
重要方法:
|
||||
|
||||
动态加载路由的类: SysPermissionController.queryByUser
|
||||
路由name命名规则: 通过菜单URL生成路由name(去掉URL前缀斜杠,替换内容中的斜杠‘/’为-)
|
||||
举例: URL = /isystem/role
|
||||
RouteName = isystem-role
|
||||
@ -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.0.1</version>
|
||||
<version>2.0.2</version>
|
||||
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<version>2.0.1</version>
|
||||
<version>2.0.2</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
//package com.baomidou.mybatisplus.extension.handlers;
|
||||
//
|
||||
////import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
//import org.apache.ibatis.reflection.MetaObject;
|
||||
//import org.apache.ibatis.reflection.wrapper.MapWrapper;
|
||||
//
|
||||
//import java.util.Map;
|
||||
//
|
||||
///**
|
||||
// * 返回Map结果集,下划线转驼峰(去掉)
|
||||
// */
|
||||
//public class MybatisMapWrapper extends MapWrapper {
|
||||
//
|
||||
// public MybatisMapWrapper(MetaObject metaObject, Map<String, Object> map) {
|
||||
// super(metaObject, map);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public String findProperty(String name, boolean useCamelCaseMapping) {
|
||||
//// if (useCamelCaseMapping && !StringUtils.isCamel(name)) {
|
||||
//// return StringUtils.underlineToCamel(name);
|
||||
//// }
|
||||
// return name;
|
||||
// }
|
||||
//}
|
||||
@ -1,20 +1,19 @@
|
||||
package org.jeecg;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||
|
||||
@Slf4j
|
||||
@EnableSwagger2
|
||||
@SpringBootApplication
|
||||
@EnableAutoConfiguration
|
||||
public class JeecgApplication {
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException {
|
||||
@ -34,4 +33,5 @@ public class JeecgApplication {
|
||||
"----------------------------------------------------------");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@ -2,6 +2,7 @@ package org.jeecg.config;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.time.Duration;
|
||||
import java.util.Arrays;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -36,17 +37,16 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
* 只需要讲注解上keyGenerator的值设置为keyGenerator即可</br>
|
||||
* @return 自定义策略生成的key
|
||||
*/
|
||||
@Override
|
||||
@Bean
|
||||
public KeyGenerator keyGenerator() {
|
||||
return new KeyGenerator() {
|
||||
@Override
|
||||
public Object generate(Object target, Method method, Object... params) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(target.getClass().getName());
|
||||
sb.append(method.getName());
|
||||
for (Object obj : params) {
|
||||
sb.append(obj.toString());
|
||||
}
|
||||
sb.append(method.getDeclaringClass().getName());
|
||||
Arrays.stream(params).map(Object::toString).forEach(sb::append);
|
||||
return sb.toString();
|
||||
}
|
||||
};
|
||||
@ -82,18 +82,8 @@ public class RedisConfig extends CachingConfigurerSupport {
|
||||
public CacheManager cacheManager(LettuceConnectionFactory factory) {
|
||||
// 以锁写入的方式创建RedisCacheWriter对象
|
||||
RedisCacheWriter writer = RedisCacheWriter.lockingRedisCacheWriter(factory);
|
||||
/**
|
||||
* 设置CacheManager的Value序列化方式为JdkSerializationRedisSerializer,
|
||||
* 但其实RedisCacheConfiguration默认就是使用 StringRedisSerializer序列化key,
|
||||
* JdkSerializationRedisSerializer序列化value, 所以以下注释代码就是默认实现,没必要写,直接注释掉
|
||||
*/
|
||||
// RedisSerializationContext.SerializationPair pair =
|
||||
// RedisSerializationContext.SerializationPair.fromSerializer(new
|
||||
// JdkSerializationRedisSerializer(this.getClass().getClassLoader()));
|
||||
// RedisCacheConfiguration config =
|
||||
// RedisCacheConfiguration.defaultCacheConfig().serializeValuesWith(pair);
|
||||
// 创建默认缓存配置对象
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(1)); // 设置缓存有效期一小时;
|
||||
RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig().entryTtl(Duration.ofHours(3)); //设置缓存默认有效期3小时;
|
||||
RedisCacheManager cacheManager = new RedisCacheManager(writer, config);
|
||||
return cacheManager;
|
||||
}
|
||||
|
||||
@ -44,6 +44,14 @@ public class ShiroConfig {
|
||||
Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();
|
||||
// 配置不会被拦截的链接 顺序判断
|
||||
filterChainDefinitionMap.put("/sys/login", "anon"); //登录接口排除
|
||||
filterChainDefinitionMap.put("/sys/getEncryptedString", "anon"); //获取加密串
|
||||
filterChainDefinitionMap.put("/sys/sms", "anon");//短信验证码
|
||||
filterChainDefinitionMap.put("/sys/phoneLogin", "anon");//手机登录
|
||||
filterChainDefinitionMap.put("/sys/user/checkOnlyUser", "anon");//校验用户是否存在
|
||||
filterChainDefinitionMap.put("/sys/user/register", "anon");//用户注册
|
||||
filterChainDefinitionMap.put("/sys/user/querySysUser", "anon");//根据手机号获取用户信息
|
||||
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
|
||||
@ -68,9 +76,6 @@ public class ShiroConfig {
|
||||
filterChainDefinitionMap.put("/actuator/metrics/**", "anon");
|
||||
filterChainDefinitionMap.put("/actuator/httptrace/**", "anon");
|
||||
filterChainDefinitionMap.put("/actuator/redis/**", "anon");
|
||||
filterChainDefinitionMap.put("/test/jeecgDemo/demo3", "anon"); //模板测试
|
||||
filterChainDefinitionMap.put("/test/jeecgDemo/redisDemo/**", "anon"); //redis测试
|
||||
|
||||
|
||||
// 添加自己的过滤器并且取名为jwt
|
||||
Map<String, Filter> filterMap = new HashMap<String, Filter>(1);
|
||||
|
||||
@ -168,19 +168,14 @@ public class JeecgDemoController extends JeecgController<JeecgDemo,IJeecgDemoSer
|
||||
@AutoLog(value = "删除测试DEMO")
|
||||
@DeleteMapping(value = "/delete")
|
||||
@ApiOperation(value = "通过ID删除DEMO", notes = "通过ID删除DEMO")
|
||||
public Result<JeecgDemo> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<JeecgDemo> result = new Result<JeecgDemo>();
|
||||
JeecgDemo jeecgDemo = jeecgDemoService.getById(id);
|
||||
if (jeecgDemo == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
boolean ok = jeecgDemoService.removeById(id);
|
||||
if (ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
try {
|
||||
jeecgDemoService.removeById(id);
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败",e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,7 +1,5 @@
|
||||
package org.jeecg.modules.demo.test.controller;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -12,7 +10,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderCustomer;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderMain;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderTicket;
|
||||
@ -40,7 +37,6 @@ 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
@ -139,17 +135,15 @@ public class JeecgOrderMainController {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<JeecgOrderMain> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<JeecgOrderMain> result = new Result<JeecgOrderMain>();
|
||||
JeecgOrderMain jeecgOrderMain = jeecgOrderMainService.getById(id);
|
||||
if (jeecgOrderMain == null) {
|
||||
result.error500("未找到对应实体");
|
||||
} else {
|
||||
public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
try {
|
||||
jeecgOrderMainService.delMain(id);
|
||||
result.success("删除成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败",e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.ok("删除成功!");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,7 @@ public class JeecgOrderCustomer implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.UUID)
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
private java.lang.String id;
|
||||
/**客户名*/
|
||||
@Excel(name="客户名字",width=15)
|
||||
|
||||
@ -21,7 +21,7 @@ public class JeecgOrderMain implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.UUID)
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
private java.lang.String id;
|
||||
/**订单号*/
|
||||
private java.lang.String orderCode;
|
||||
|
||||
@ -21,7 +21,7 @@ public class JeecgOrderTicket implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.UUID)
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
private java.lang.String id;
|
||||
/**航班号*/
|
||||
@Excel(name="航班号",width=15)
|
||||
|
||||
@ -207,10 +207,11 @@ public class SysMessageTemplateController extends JeecgController<SysMessageTemp
|
||||
return result;
|
||||
}
|
||||
boolean is_sendSuccess = pushMsgUtil.sendMessage(msgParams.getMsgType(), msgParams.getTemplateCode(), map, msgParams.getReceiver());
|
||||
if (is_sendSuccess)
|
||||
if (is_sendSuccess) {
|
||||
result.success("发送消息任务添加成功!");
|
||||
else
|
||||
} else {
|
||||
result.error500("发送消息任务添加失败!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
package org.jeecg.modules.monitor.service.impl;
|
||||
|
||||
import org.springframework.boot.actuate.health.Health;
|
||||
import org.springframework.boot.actuate.health.HealthIndicator;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 功能说明:自定义邮件检测
|
||||
*
|
||||
* @author: 李波
|
||||
* @email: 503378406@qq.com
|
||||
* @date: 2019-06-29
|
||||
*/
|
||||
@Component
|
||||
public class MailHealthIndicator implements HealthIndicator {
|
||||
|
||||
|
||||
@Override public Health health() {
|
||||
int errorCode = check();
|
||||
if (errorCode != 0) {
|
||||
return Health.down().withDetail("Error Code", errorCode) .build();
|
||||
}
|
||||
return Health.up().build();
|
||||
}
|
||||
int check(){
|
||||
//可以实现自定义的数据库检测逻辑
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -57,11 +57,11 @@ public class NgAlainServiceImpl implements NgAlainService {
|
||||
menu.put("text",meta.get("title"));
|
||||
menu.put("reuse",true);
|
||||
if (jsonObject.get("children")!=null){
|
||||
JSONArray child= parseNgAlain((JSONArray) jsonObject.get("children"));
|
||||
menu.put("children",child);
|
||||
JSONObject icon=new JSONObject();
|
||||
JSONArray child= parseNgAlain((JSONArray) jsonObject.get("children"));
|
||||
menu.put("children",child);
|
||||
JSONObject icon=new JSONObject();
|
||||
icon.put("type", "icon");
|
||||
icon.put("value", "appstore");
|
||||
icon.put("value", meta.get("icon"));
|
||||
menu.put("icon",icon);
|
||||
}else {
|
||||
menu.put("link",path);
|
||||
|
||||
@ -48,7 +48,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
*/
|
||||
@Override
|
||||
public boolean saveAndScheduleJob(QuartzJob quartzJob) {
|
||||
if (CommonConstant.STATUS_NORMAL == quartzJob.getStatus()) {
|
||||
if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
|
||||
// 定时器添加
|
||||
this.schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
|
||||
}
|
||||
@ -74,7 +74,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
*/
|
||||
@Override
|
||||
public boolean editAndScheduleJob(QuartzJob quartzJob) throws SchedulerException {
|
||||
if (CommonConstant.STATUS_NORMAL == quartzJob.getStatus()) {
|
||||
if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
|
||||
schedulerDelete(quartzJob.getJobClassName().trim());
|
||||
schedulerAdd(quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
|
||||
}else{
|
||||
|
||||
@ -12,6 +12,7 @@ import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -101,20 +102,17 @@ public class DictAspect {
|
||||
String text = field.getAnnotation(Dict.class).dicText();
|
||||
String table = field.getAnnotation(Dict.class).dictTable();
|
||||
String key = String.valueOf(item.get(field.getName()));
|
||||
String textValue=null;
|
||||
log.info(" 字典 key : "+ key);
|
||||
if (!StringUtils.isEmpty(table)){
|
||||
textValue= dictService.queryTableDictTextByKey(table,text,code,key);
|
||||
}else {
|
||||
textValue = dictService.queryDictTextByKey(code, key);
|
||||
}
|
||||
log.info(" 字典Val : "+ textValue);
|
||||
log.info(" __翻译字典字段__ "+field.getName() + "_dictText: "+ textValue);
|
||||
item.put(field.getName() + "_dictText", textValue);
|
||||
|
||||
//翻译字典值对应的txt
|
||||
String textValue = translateDictValue(code, text, table, key);
|
||||
|
||||
log.debug(" 字典Val : "+ textValue);
|
||||
log.debug(" __翻译字典字段__ "+field.getName() + CommonConstant.DICT_TEXT_SUFFIX+": "+ textValue);
|
||||
item.put(field.getName() + CommonConstant.DICT_TEXT_SUFFIX, textValue);
|
||||
}
|
||||
//date类型默认转换string格式化日期
|
||||
if (field.getType().getName().equals("java.util.Date")&&field.getAnnotation(JsonFormat.class)==null&&item.get(field.getName())!=null){
|
||||
SimpleDateFormat aDate=new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
|
||||
SimpleDateFormat aDate=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
item.put(field.getName(), aDate.format(new Date((Long) item.get(field.getName()))));
|
||||
}
|
||||
}
|
||||
@ -126,4 +124,41 @@ public class DictAspect {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 翻译字典文本
|
||||
* @param code
|
||||
* @param text
|
||||
* @param table
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
private String translateDictValue(String code, String text, String table, String key) {
|
||||
if(oConvertUtils.isEmpty(key)) {
|
||||
return null;
|
||||
}
|
||||
StringBuffer textValue=new StringBuffer();
|
||||
String[] keys = key.split(",");
|
||||
for (String k : keys) {
|
||||
String tmpValue = null;
|
||||
log.debug(" 字典 key : "+ k);
|
||||
if (k.trim().length() == 0) {
|
||||
continue; //跳过循环
|
||||
}
|
||||
if (!StringUtils.isEmpty(table)){
|
||||
tmpValue= dictService.queryTableDictTextByKey(table,text,code,k.trim());
|
||||
}else {
|
||||
tmpValue = dictService.queryDictTextByKey(code, k.trim());
|
||||
}
|
||||
|
||||
if (tmpValue != null) {
|
||||
if (!"".equals(textValue.toString())) {
|
||||
textValue.append(",");
|
||||
}
|
||||
textValue.append(tmpValue);
|
||||
}
|
||||
|
||||
}
|
||||
return textValue.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,9 +1,6 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -15,8 +12,12 @@ import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.DySmsHelper;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.encryption.AesEncryptUtil;
|
||||
import org.jeecg.common.util.encryption.EncryptedString;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.shiro.vo.DefContants;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
@ -26,13 +27,16 @@ import org.jeecg.modules.system.service.ISysLogService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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.RestController;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -59,53 +63,38 @@ public class LoginController {
|
||||
|
||||
@RequestMapping(value = "/login", method = RequestMethod.POST)
|
||||
@ApiOperation("登录接口")
|
||||
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) {
|
||||
public Result<JSONObject> login(@RequestBody SysLoginModel sysLoginModel) throws Exception {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String username = sysLoginModel.getUsername();
|
||||
String password = sysLoginModel.getPassword();
|
||||
//步骤1:TODO 前端密码加密,后端进行密码解密,防止传输密码篡改等问题,不配就直接提示密码错误,并记录日志后期进行统计分析是否锁定
|
||||
password = AesEncryptUtil.desEncrypt(sysLoginModel.getPassword()).trim();//密码解密
|
||||
//1. 校验用户是否有效
|
||||
SysUser sysUser = sysUserService.getUserByName(username);
|
||||
if(sysUser==null) {
|
||||
result.error500("该用户不存在");
|
||||
sysBaseAPI.addLog("登录失败,用户名:"+username+"不存在!", CommonConstant.LOG_TYPE_1, null);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if(!result.isSuccess()) {
|
||||
return result;
|
||||
}else {
|
||||
//密码验证
|
||||
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
|
||||
String syspassword = sysUser.getPassword();
|
||||
if(!syspassword.equals(userpassword)) {
|
||||
result.error500("用户名或密码错误");
|
||||
return result;
|
||||
}
|
||||
//生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
//设置超时时间
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME/1000);
|
||||
|
||||
//获取用户部门信息
|
||||
JSONObject obj = new JSONObject();
|
||||
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
|
||||
obj.put("departs",departs);
|
||||
if(departs==null || departs.size()==0) {
|
||||
obj.put("multi_depart",0);
|
||||
}else if(departs.size()==1){
|
||||
sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
|
||||
obj.put("multi_depart",1);
|
||||
}else {
|
||||
obj.put("multi_depart",2);
|
||||
}
|
||||
obj.put("token", token);
|
||||
obj.put("userInfo", sysUser);
|
||||
result.setResult(obj);
|
||||
result.success("登录成功");
|
||||
sysBaseAPI.addLog("用户名: "+username+",登录成功!", CommonConstant.LOG_TYPE_1, null);
|
||||
}
|
||||
|
||||
//2. 校验用户名或密码是否正确
|
||||
String userpassword = PasswordUtil.encrypt(username, password, sysUser.getSalt());
|
||||
String syspassword = sysUser.getPassword();
|
||||
if (!syspassword.equals(userpassword)) {
|
||||
result.error500("用户名或密码错误");
|
||||
return result;
|
||||
}
|
||||
|
||||
//用户登录信息
|
||||
userInfo(sysUser, result);
|
||||
sysBaseAPI.addLog("用户名: " + username + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退出登录
|
||||
* @param username
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/logout")
|
||||
@ -137,13 +126,13 @@ public class LoginController {
|
||||
//update-begin--Author:zhangweijian Date:20190428 for:传入开始时间,结束时间参数
|
||||
// 获取一天的开始和结束时间
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.set(Calendar.HOUR_OF_DAY,0);
|
||||
calendar.set(Calendar.MINUTE,0);
|
||||
calendar.set(Calendar.SECOND,0);
|
||||
calendar.set(Calendar.MILLISECOND,0);
|
||||
Date dayStart = calendar.getTime();
|
||||
calendar.add(calendar.DATE, 1);
|
||||
Date dayEnd = calendar.getTime();
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
Date dayStart = calendar.getTime();
|
||||
calendar.add(Calendar.DATE, 1);
|
||||
Date dayEnd = calendar.getTime();
|
||||
// 获取系统访问记录
|
||||
Long totalVisitCount = logService.findTotalVisitCount();
|
||||
obj.put("totalVisitCount", totalVisitCount);
|
||||
@ -157,6 +146,28 @@ public class LoginController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取访问量
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("visitInfo")
|
||||
public Result<List<Map<String,Object>>> visitInfo() {
|
||||
Result<List<Map<String,Object>>> result = new Result<List<Map<String,Object>>>();
|
||||
Calendar calendar = new GregorianCalendar();
|
||||
calendar.set(Calendar.HOUR_OF_DAY,0);
|
||||
calendar.set(Calendar.MINUTE,0);
|
||||
calendar.set(Calendar.SECOND,0);
|
||||
calendar.set(Calendar.MILLISECOND,0);
|
||||
calendar.add(Calendar.DAY_OF_MONTH, 1);
|
||||
Date dayEnd = calendar.getTime();
|
||||
calendar.add(Calendar.DAY_OF_MONTH, -7);
|
||||
Date dayStart = calendar.getTime();
|
||||
List<Map<String,Object>> list = logService.findVisitCount(dayStart, dayEnd);
|
||||
result.setResult(oConvertUtils.toLowerCasePageList(list));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 登陆成功选择用户当前部门
|
||||
* @param user
|
||||
@ -165,10 +176,164 @@ public class LoginController {
|
||||
@RequestMapping(value = "/selectDepart", method = RequestMethod.PUT)
|
||||
public Result<?> selectDepart(@RequestBody SysUser user) {
|
||||
String username = user.getUsername();
|
||||
if(oConvertUtils.isEmpty(username)) {
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
username = sysUser.getUsername();
|
||||
}
|
||||
String orgCode= user.getOrgCode();
|
||||
this.sysUserService.updateUserDepart(username, orgCode);
|
||||
return Result.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* 短信登录接口
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/sms")
|
||||
public Result<String> sms(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<String>();
|
||||
String mobile = jsonObject.get("mobile").toString();
|
||||
String smsmode=jsonObject.get("smsmode").toString();
|
||||
log.info(mobile);
|
||||
Object object = redisUtil.get(mobile);
|
||||
if (object != null) {
|
||||
result.setMessage("验证码10分钟内,仍然有效!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
//随机数
|
||||
String captcha = RandomUtil.randomNumbers(6);
|
||||
try {
|
||||
boolean b = false;
|
||||
//注册模板
|
||||
if (CommonConstant.SMS_TPL_TYPE_1.equals(smsmode)) {
|
||||
SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
||||
if(sysUser!=null) {
|
||||
result.error500(" 手机号已经注册,请直接登录!");
|
||||
sysBaseAPI.addLog("手机号已经注册,请直接登录!", CommonConstant.LOG_TYPE_1, null);
|
||||
return result;
|
||||
}
|
||||
b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.REGISTER_TEMPLATE_CODE);
|
||||
}else {
|
||||
//登录模式,校验用户有效性
|
||||
SysUser sysUser = sysUserService.getUserByPhone(mobile);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if(!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* smsmode 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板
|
||||
*/
|
||||
if (CommonConstant.SMS_TPL_TYPE_0.equals(smsmode)) {
|
||||
//登录模板
|
||||
b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.LOGIN_TEMPLATE_CODE);
|
||||
} else if(CommonConstant.SMS_TPL_TYPE_2.equals(smsmode)) {
|
||||
//忘记密码模板
|
||||
b = DySmsHelper.sendSms(mobile, captcha, DySmsHelper.FORGET_PASSWORD_TEMPLATE_CODE);
|
||||
}
|
||||
}
|
||||
|
||||
if (b == false) {
|
||||
result.setMessage("短信验证码发送失败,请稍后重试");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
//验证码10分钟内有效
|
||||
redisUtil.set(mobile, captcha, 600);
|
||||
result.setResult(captcha);
|
||||
result.setSuccess(true);
|
||||
|
||||
} catch (ClientException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 手机号登录接口
|
||||
*
|
||||
* @param jsonObject
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/phoneLogin")
|
||||
public Result<JSONObject> login(@RequestBody JSONObject jsonObject) {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String phone = jsonObject.getString("mobile");
|
||||
|
||||
//校验用户有效性
|
||||
SysUser sysUser = sysUserService.getUserByPhone(phone);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
if(!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
|
||||
String smscode = jsonObject.getString("captcha");
|
||||
Object code = redisUtil.get(phone);
|
||||
if (!smscode.equals(code)) {
|
||||
result.setMessage("手机验证码错误");
|
||||
return result;
|
||||
}
|
||||
//用户信息
|
||||
userInfo(sysUser, result);
|
||||
//添加日志
|
||||
sysBaseAPI.addLog("用户名: " + sysUser.getUsername() + ",登录成功!", CommonConstant.LOG_TYPE_1, null);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户信息
|
||||
*
|
||||
* @param sysUser
|
||||
* @param result
|
||||
* @return
|
||||
*/
|
||||
private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
|
||||
String syspassword = sysUser.getPassword();
|
||||
String username = sysUser.getUsername();
|
||||
// 生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
// 设置超时时间
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
|
||||
|
||||
// 获取用户部门信息
|
||||
JSONObject obj = new JSONObject();
|
||||
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
|
||||
obj.put("departs", departs);
|
||||
if (departs == null || departs.size() == 0) {
|
||||
obj.put("multi_depart", 0);
|
||||
} else if (departs.size() == 1) {
|
||||
sysUserService.updateUserDepart(username, departs.get(0).getOrgCode());
|
||||
obj.put("multi_depart", 1);
|
||||
} else {
|
||||
obj.put("multi_depart", 2);
|
||||
}
|
||||
obj.put("token", token);
|
||||
obj.put("userInfo", sysUser);
|
||||
result.setResult(obj);
|
||||
result.success("登录成功");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取加密字符串
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getEncryptedString")
|
||||
public Result<Map<String,String>> getEncryptedString(){
|
||||
Result<Map<String,String>> result = new Result<Map<String,String>>();
|
||||
Map<String,String> map = new HashMap<String,String>();
|
||||
map.put("key", EncryptedString.key);
|
||||
map.put("iv",EncryptedString.iv);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@ -266,9 +266,11 @@ public class SysAnnouncementController {
|
||||
Collection<String> anntIds = sysAnnouncementSendService.queryByUserId(userId);
|
||||
LambdaQueryWrapper<SysAnnouncement> querySaWrapper = new LambdaQueryWrapper<SysAnnouncement>();
|
||||
querySaWrapper.eq(SysAnnouncement::getMsgType,CommonConstant.MSG_TYPE_ALL); // 全部人员
|
||||
querySaWrapper.eq(SysAnnouncement::getDelFlag,CommonConstant.DEL_FLAG_0); // 未删除
|
||||
querySaWrapper.eq(SysAnnouncement::getDelFlag,CommonConstant.DEL_FLAG_0.toString()); // 未删除
|
||||
querySaWrapper.eq(SysAnnouncement::getSendStatus, CommonConstant.HAS_SEND); //已发布
|
||||
querySaWrapper.notIn(SysAnnouncement::getId, anntIds);
|
||||
if(anntIds!=null&&anntIds.size()>0) {
|
||||
querySaWrapper.notIn(SysAnnouncement::getId, anntIds);
|
||||
}
|
||||
List<SysAnnouncement> announcements = sysAnnouncementService.list(querySaWrapper);
|
||||
if(announcements.size()>0) {
|
||||
for(int i=0;i<announcements.size();i++) {
|
||||
@ -311,7 +313,8 @@ public class SysAnnouncementController {
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "系统通告列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysAnnouncement.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:Jeecg", "导出信息"));
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("系统通告列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
@ -337,7 +340,7 @@ public class SysAnnouncementController {
|
||||
List<SysAnnouncement> listSysAnnouncements = ExcelImportUtil.importExcel(file.getInputStream(), SysAnnouncement.class, params);
|
||||
for (SysAnnouncement sysAnnouncementExcel : listSysAnnouncements) {
|
||||
if(sysAnnouncementExcel.getDelFlag()==null){
|
||||
sysAnnouncementExcel.setDelFlag("0");
|
||||
sysAnnouncementExcel.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
||||
}
|
||||
sysAnnouncementService.save(sysAnnouncementExcel);
|
||||
}
|
||||
|
||||
@ -0,0 +1,336 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.service.ISysCategoryService;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
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.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/sys/category")
|
||||
@Slf4j
|
||||
public class SysCategoryController {
|
||||
@Autowired
|
||||
private ISysCategoryService sysCategoryService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
* @param sysCategory
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/rootList")
|
||||
public Result<IPage<SysCategory>> queryPageList(SysCategory sysCategory,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
sysCategory.setPid("0");
|
||||
}
|
||||
Result<IPage<SysCategory>> result = new Result<IPage<SysCategory>>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
Page<SysCategory> page = new Page<SysCategory>(pageNo, pageSize);
|
||||
IPage<SysCategory> pageList = sysCategoryService.page(page, queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
}
|
||||
|
||||
@GetMapping(value = "/childList")
|
||||
public Result<List<SysCategory>> queryPageList(SysCategory sysCategory,HttpServletRequest req) {
|
||||
Result<List<SysCategory>> result = new Result<List<SysCategory>>();
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, req.getParameterMap());
|
||||
List<SysCategory> list = sysCategoryService.list(queryWrapper);
|
||||
result.setSuccess(true);
|
||||
result.setResult(list);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 添加
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/add")
|
||||
public Result<SysCategory> add(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
sysCategoryService.addSysCategory(sysCategory);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param sysCategory
|
||||
* @return
|
||||
*/
|
||||
@PutMapping(value = "/edit")
|
||||
public Result<SysCategory> edit(@RequestBody SysCategory sysCategory) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategoryEntity = sysCategoryService.getById(sysCategory.getId());
|
||||
if(sysCategoryEntity==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
sysCategoryService.updateSysCategory(sysCategory);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<SysCategory> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = sysCategoryService.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<SysCategory> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
result.error500("参数不识别!");
|
||||
}else {
|
||||
this.sysCategoryService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<SysCategory> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
SysCategory sysCategory = sysCategoryService.getById(id);
|
||||
if(sysCategory==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
result.setResult(sysCategory);
|
||||
result.setSuccess(true);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
*/
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, SysCategory sysCategory) {
|
||||
// Step.1 组装查询条件查询数据
|
||||
QueryWrapper<SysCategory> queryWrapper = QueryGenerator.initQueryWrapper(sysCategory, request.getParameterMap());
|
||||
List<SysCategory> pageList = sysCategoryService.list(queryWrapper);
|
||||
// Step.2 AutoPoi 导出Excel
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
// 过滤选中数据
|
||||
String selections = request.getParameter("selections");
|
||||
if(oConvertUtils.isEmpty(selections)) {
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
}else {
|
||||
List<String> selectionList = Arrays.asList(selections.split(","));
|
||||
List<SysCategory> exportList = pageList.stream().filter(item -> selectionList.contains(item.getId())).collect(Collectors.toList());
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
}
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "分类字典列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysCategory.class);
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("分类字典列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
return mv;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||
MultipartFile file = entity.getValue();// 获取上传文件对象
|
||||
ImportParams params = new ImportParams();
|
||||
params.setTitleRows(2);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<SysCategory> listSysCategorys = ExcelImportUtil.importExcel(file.getInputStream(), SysCategory.class, params);
|
||||
for (SysCategory sysCategoryExcel : listSysCategorys) {
|
||||
sysCategoryService.save(sysCategoryExcel);
|
||||
}
|
||||
return Result.ok("文件导入成功!数据行数:" + listSysCategorys.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
return Result.error("文件导入失败:"+e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
file.getInputStream().close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
return Result.ok("文件导入失败!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 加载单个数据 用于回显
|
||||
*/
|
||||
@RequestMapping(value = "/loadOne", method = RequestMethod.GET)
|
||||
public Result<SysCategory> loadOne(@RequestParam(name="field") String field,@RequestParam(name="val") String val) {
|
||||
Result<SysCategory> result = new Result<SysCategory>();
|
||||
try {
|
||||
|
||||
QueryWrapper<SysCategory> query = new QueryWrapper<SysCategory>();
|
||||
query.eq(field, val);
|
||||
List<SysCategory> ls = this.sysCategoryService.list(query);
|
||||
if(ls==null || ls.size()==0) {
|
||||
result.setMessage("查询无果");
|
||||
result.setSuccess(false);
|
||||
}else if(ls.size()>1) {
|
||||
result.setMessage("查询数据异常,["+field+"]存在多个值:"+val);
|
||||
result.setSuccess(false);
|
||||
}else {
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls.get(0));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载节点的子数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeChildren", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeChildren(@RequestParam(name="pid") String pid) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByPid(pid);
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载一级节点/如果是同步 则所有数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeRoot", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadTreeRoot(@RequestParam(name="async") Boolean async,@RequestParam(name="pcode") String pcode) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
try {
|
||||
List<TreeSelectModel> ls = this.sysCategoryService.queryListByCode(pcode);
|
||||
if(!async) {
|
||||
loadAllCategoryChildren(ls);
|
||||
}
|
||||
result.setResult(ls);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
result.setMessage(e.getMessage());
|
||||
result.setSuccess(false);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归求子节点 同步加载用到
|
||||
*/
|
||||
private void loadAllCategoryChildren(List<TreeSelectModel> ls) {
|
||||
for (TreeSelectModel tsm : ls) {
|
||||
List<TreeSelectModel> temp = this.sysCategoryService.queryListByPid(tsm.getKey());
|
||||
if(temp!=null && temp.size()>0) {
|
||||
tsm.setChildren(temp);
|
||||
loadAllCategoryChildren(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -10,10 +10,12 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
@ -242,7 +244,8 @@ public class SysDepartController {
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysDepart.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:Jeecg", "导出信息"));
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ -1,9 +1,8 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -11,18 +10,19 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
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.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderCustomer;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderMain;
|
||||
import org.jeecg.modules.demo.test.entity.JeecgOrderTicket;
|
||||
import org.jeecg.modules.demo.test.vo.JeecgOrderMainPage;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.model.SysDictTree;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.service.ISysDictItemService;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.vo.SysDictPage;
|
||||
@ -40,6 +40,9 @@ 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.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -47,9 +50,6 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -75,13 +75,12 @@ public class SysDictController {
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
|
||||
Result<IPage<SysDict>> result = new Result<IPage<SysDict>>();
|
||||
QueryWrapper<SysDict> queryWrapper = QueryGenerator.initQueryWrapper(sysDict, req.getParameterMap());
|
||||
queryWrapper.eq("del_flag", "1");
|
||||
Page<SysDict> page = new Page<SysDict>(pageNo, pageSize);
|
||||
IPage<SysDict> pageList = sysDictService.page(page, queryWrapper);
|
||||
log.info("查询当前页:"+pageList.getCurrent());
|
||||
log.info("查询当前页数量:"+pageList.getSize());
|
||||
log.info("查询结果数量:"+pageList.getRecords().size());
|
||||
log.info("数据总数:"+pageList.getTotal());
|
||||
log.debug("查询当前页:"+pageList.getCurrent());
|
||||
log.debug("查询当前页数量:"+pageList.getSize());
|
||||
log.debug("查询结果数量:"+pageList.getRecords().size());
|
||||
log.debug("数据总数:"+pageList.getTotal());
|
||||
result.setSuccess(true);
|
||||
result.setResult(pageList);
|
||||
return result;
|
||||
@ -106,7 +105,6 @@ public class SysDictController {
|
||||
if(oConvertUtils.isNotEmpty(dictName)) {
|
||||
query.like(true, SysDict::getDictName, dictName);
|
||||
}
|
||||
query.eq(true, SysDict::getDelFlag, "1");
|
||||
query.orderByDesc(true, SysDict::getCreateTime);
|
||||
List<SysDict> list = sysDictService.list(query);
|
||||
List<SysDictTree> treeList = new ArrayList<>();
|
||||
@ -133,11 +131,25 @@ public class SysDictController {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
String[] params = dictCode.split(",");
|
||||
if(params.length!=3) {
|
||||
|
||||
if(params.length<3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {params[0],params[1],params[2]};
|
||||
SqlInjectionUtil.filterContent(sqlInjCheck);
|
||||
|
||||
if(params.length==4) {
|
||||
//SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用)
|
||||
SqlInjectionUtil.specialFilterContent(params[3]);
|
||||
ls = sysDictService.queryTableDictItemsByCodeAndFilter(params[0],params[1],params[2],params[3]);
|
||||
}else if (params.length==3) {
|
||||
ls = sysDictService.queryTableDictItemsByCode(params[0],params[1],params[2]);
|
||||
}else{
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
ls = sysDictService.queryTableDictItemsByCode(params[0],params[1],params[2]);
|
||||
}else {
|
||||
//字典表
|
||||
ls = sysDictService.queryDictItemsByCode(dictCode);
|
||||
@ -187,6 +199,7 @@ public class SysDictController {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
try {
|
||||
sysDict.setCreateTime(new Date());
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
sysDictService.save(sysDict);
|
||||
result.success("保存成功!");
|
||||
} catch (Exception e) {
|
||||
@ -224,19 +237,14 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value="dictCache", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.DICT_CACHE, allEntries=true)
|
||||
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
SysDict sysDict = sysDictService.getById(id);
|
||||
if(sysDict==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
//update-begin--Author:huangzhilin Date:20140417 for:[bugfree号]数据字典增加级联删除功能--------------------
|
||||
boolean ok = sysDictService.deleteByDictId(sysDict);
|
||||
//update-begin--Author:huangzhilin Date:20140417 for:[bugfree号]数据字典增加级联删除功能--------------------
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
boolean ok = sysDictService.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
}else{
|
||||
result.error500("删除失败!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@ -247,18 +255,13 @@ public class SysDictController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value="dictCache", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.DICT_CACHE, allEntries=true)
|
||||
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
if(oConvertUtils.isEmpty(ids)) {
|
||||
result.error500("参数不识别!");
|
||||
}else {
|
||||
String[] id=ids.split(",");
|
||||
for(int i=0;i<id.length;i++) {
|
||||
SysDict sysDict = sysDictService.getById(id[i]);
|
||||
sysDict.setDelFlag(2);
|
||||
sysDictService.updateById(sysDict);
|
||||
}
|
||||
sysDictService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
result.success("删除成功!");
|
||||
}
|
||||
return result;
|
||||
@ -293,7 +296,8 @@ public class SysDictController {
|
||||
// 注解对象Class
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysDictPage.class);
|
||||
// 自定义表格参数
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:Jeecg", "数据字典"));
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("数据字典列表", "导出人:"+user.getRealname(), "数据字典"));
|
||||
// 导出数据列表
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
@ -340,5 +344,83 @@ public class SysDictController {
|
||||
}
|
||||
return Result.error("文件导入失败!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
* @param dictCode
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,@RequestParam(name="keyword") String keyword) {
|
||||
log.info(" 加载字典表数据,加载关键字: "+ keyword);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
List<DictModel> ls = null;
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
String[] params = dictCode.split(",");
|
||||
if(params.length!=3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
ls = sysDictService.queryTableDictItems(params[0],params[1],params[2],keyword);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.info(result.toString());
|
||||
}else {
|
||||
result.error500("字典Code格式不正确!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text 返回
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<String> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String key) {
|
||||
Result<String> result = new Result<String>();
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
String[] params = dictCode.split(",");
|
||||
if(params.length!=3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
String text = sysDictService.queryTableDictTextByKey(params[0], params[1], params[2], key);
|
||||
result.setSuccess(true);
|
||||
result.setResult(text);
|
||||
log.info(result.toString());
|
||||
}else {
|
||||
result.error500("字典Code格式不正确!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据表名——显示字段-存储字段 pid 加载树形数据
|
||||
*/
|
||||
@RequestMapping(value = "/loadTreeData", method = RequestMethod.GET)
|
||||
public Result<List<TreeSelectModel>> loadDict(@RequestParam(name="pid") String pid,@RequestParam(name="pidField") String pidField,
|
||||
@RequestParam(name="tableName") String tbname,
|
||||
@RequestParam(name="text") String text,
|
||||
@RequestParam(name="code") String code,
|
||||
@RequestParam(name="hasChildField") String hasChildField) {
|
||||
Result<List<TreeSelectModel>> result = new Result<List<TreeSelectModel>>();
|
||||
List<TreeSelectModel> ls = sysDictService.queryTreeList(tbname, text, code, pidField, pid,hasChildField);
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import java.util.Date;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
@ -68,7 +69,7 @@ public class SysDictItemController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@CacheEvict(value="dictCache", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.DICT_CACHE, allEntries=true)
|
||||
public Result<SysDictItem> add(@RequestBody SysDictItem sysDictItem) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
try {
|
||||
@ -88,7 +89,7 @@ public class SysDictItemController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
@CacheEvict(value="dictCache", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.DICT_CACHE, allEntries=true)
|
||||
public Result<SysDictItem> edit(@RequestBody SysDictItem sysDictItem) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
SysDictItem sysdict = sysDictItemService.getById(sysDictItem.getId());
|
||||
@ -111,7 +112,7 @@ public class SysDictItemController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value="dictCache", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.DICT_CACHE, allEntries=true)
|
||||
public Result<SysDictItem> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
SysDictItem joinSystem = sysDictItemService.getById(id);
|
||||
@ -132,7 +133,7 @@ public class SysDictItemController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value="dictCache", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.DICT_CACHE, allEntries=true)
|
||||
public Result<SysDictItem> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
if(ids==null || "".equals(ids.trim())) {
|
||||
|
||||
@ -9,6 +9,8 @@ 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;
|
||||
@ -68,7 +70,7 @@ public class SysPermissionController {
|
||||
Result<List<SysPermissionTree>> result = new Result<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, 0);
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
List<SysPermissionTree> treeList = new ArrayList<>();
|
||||
@ -126,8 +128,8 @@ public class SysPermissionController {
|
||||
this.getAuthJsonArray(authjsonArray, metaList);
|
||||
//查询所有的权限
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, 0);
|
||||
query.eq(SysPermission::getMenuType, 2);
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.eq(SysPermission::getMenuType, CommonConstant.MENU_TYPE_2);
|
||||
//query.eq(SysPermission::getStatus, "1");
|
||||
List<SysPermission> allAuthList = sysPermissionService.list(query);
|
||||
JSONArray allauthjsonArray = new JSONArray();
|
||||
@ -170,7 +172,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
@RequestMapping(value = "/edit", method = { RequestMethod.PUT, RequestMethod.POST })
|
||||
public Result<SysPermission> edit(@RequestBody SysPermission permission) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -191,7 +193,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -212,7 +214,7 @@ public class SysPermissionController {
|
||||
* @return
|
||||
*/
|
||||
@RequiresRoles({ "admin" })
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysPermission> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
Result<SysPermission> result = new Result<>();
|
||||
@ -243,7 +245,7 @@ public class SysPermissionController {
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, 0);
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
for (SysPermission sysPer : list) {
|
||||
@ -396,7 +398,7 @@ public class SysPermissionController {
|
||||
continue;
|
||||
}
|
||||
JSONObject json = null;
|
||||
if(permission.getMenuType()==2&&"1".equals(permission.getStatus())) {
|
||||
if(permission.getMenuType().equals(CommonConstant.MENU_TYPE_2) &&CommonConstant.STATUS_1.equals(permission.getStatus())) {
|
||||
json = new JSONObject();
|
||||
json.put("action", permission.getPerms());
|
||||
json.put("type", permission.getPermsType());
|
||||
@ -428,7 +430,7 @@ public class SysPermissionController {
|
||||
}
|
||||
} else if (parentJson != null && oConvertUtils.isNotEmpty(tempPid) && tempPid.equals(parentJson.getString("id"))) {
|
||||
// 类型( 0:一级菜单 1:子菜单 2:按钮 )
|
||||
if (permission.getMenuType() == 2) {
|
||||
if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
|
||||
JSONObject metaJson = parentJson.getJSONObject("meta");
|
||||
if (metaJson.containsKey("permissionList")) {
|
||||
metaJson.getJSONArray("permissionList").add(json);
|
||||
@ -438,7 +440,7 @@ public class SysPermissionController {
|
||||
metaJson.put("permissionList", permissionList);
|
||||
}
|
||||
// 类型( 0:一级菜单 1:子菜单 2:按钮 )
|
||||
} else if (permission.getMenuType() == 1 || permission.getMenuType() == 0) {
|
||||
} else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_1) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_0)) {
|
||||
if (parentJson.containsKey("children")) {
|
||||
parentJson.getJSONArray("children").add(json);
|
||||
} else {
|
||||
@ -459,12 +461,12 @@ public class SysPermissionController {
|
||||
private JSONObject getPermissionJsonObject(SysPermission permission) {
|
||||
JSONObject json = new JSONObject();
|
||||
// 类型(0:一级菜单 1:子菜单 2:按钮)
|
||||
if (permission.getMenuType() == 2) {
|
||||
if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_2)) {
|
||||
//json.put("action", permission.getPerms());
|
||||
//json.put("type", permission.getPermsType());
|
||||
//json.put("describe", permission.getName());
|
||||
return null;
|
||||
} else if (permission.getMenuType() == 0 || permission.getMenuType() == 1) {
|
||||
} else if (permission.getMenuType().equals(CommonConstant.MENU_TYPE_0) || permission.getMenuType().equals(CommonConstant.MENU_TYPE_1)) {
|
||||
json.put("id", permission.getId());
|
||||
if (permission.isRoute()) {
|
||||
json.put("route", "1");// 表示生成路由
|
||||
@ -495,8 +497,13 @@ public class SysPermissionController {
|
||||
}
|
||||
json.put("component", permission.getComponent());
|
||||
JSONObject meta = new JSONObject();
|
||||
// 默认所有的菜单都加路由缓存,提高系统性能
|
||||
meta.put("keepAlive", "true");
|
||||
// 由用户设置是否缓存页面 用布尔值
|
||||
if (permission.isKeepAlive()) {
|
||||
meta.put("keepAlive", true);
|
||||
} else {
|
||||
meta.put("keepAlive", false);
|
||||
}
|
||||
|
||||
meta.put("title", permission.getName());
|
||||
if (oConvertUtils.isEmpty(permission.getParentId())) {
|
||||
// 一级菜单跳转地址
|
||||
|
||||
@ -2,8 +2,6 @@ package org.jeecg.modules.system.controller;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
@ -14,16 +12,16 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
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.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysPermissionDataRule;
|
||||
import org.jeecg.modules.system.entity.SysRole;
|
||||
import org.jeecg.modules.system.entity.SysRolePermission;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.TreeModel;
|
||||
import org.jeecg.modules.system.service.ISysPermissionDataRuleService;
|
||||
import org.jeecg.modules.system.service.ISysPermissionService;
|
||||
@ -47,8 +45,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@ -150,7 +148,7 @@ public class SysRoleController {
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
@ -172,7 +170,7 @@ public class SysRoleController {
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value=CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
public Result<SysRole> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysRole> result = new Result<SysRole>();
|
||||
@ -269,7 +267,8 @@ public class SysRoleController {
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME,"角色列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS,SysRole.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:Jeecg","导出信息"));
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS,new ExportParams("角色列表数据","导出人:"+user.getRealname(),"导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST,pageList);
|
||||
return mv;
|
||||
}
|
||||
@ -378,7 +377,7 @@ public class SysRoleController {
|
||||
List<String> ids = new ArrayList<>();
|
||||
try {
|
||||
LambdaQueryWrapper<SysPermission> query = new LambdaQueryWrapper<SysPermission>();
|
||||
query.eq(SysPermission::getDelFlag, 0);
|
||||
query.eq(SysPermission::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
query.orderByAsc(SysPermission::getSortNo);
|
||||
List<SysPermission> list = sysPermissionService.list(query);
|
||||
for(SysPermission sysPer : list) {
|
||||
|
||||
@ -10,8 +10,10 @@ import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysUserAgent;
|
||||
import org.jeecg.modules.system.service.ISysUserAgentService;
|
||||
@ -210,7 +212,8 @@ public class SysUserAgentController {
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "用户代理人设置列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysUserAgent.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:Jeecg", "导出信息"));
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户代理人设置列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ 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;
|
||||
@ -13,15 +14,22 @@ import java.util.UUID;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
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.SysUserDepartsVO;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysUserDepartService;
|
||||
import org.jeecg.modules.system.service.ISysUserRoleService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
@ -33,6 +41,8 @@ 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.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;
|
||||
@ -68,6 +78,9 @@ public class SysUserController {
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserRoleService sysUserRoleService;
|
||||
|
||||
@ -77,7 +90,11 @@ public class SysUserController {
|
||||
@Autowired
|
||||
private ISysUserRoleService userRoleService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
//@RequiresPermissions("sys:user:list")
|
||||
public Result<IPage<SysUser>> queryPageList(SysUser user,@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,HttpServletRequest req) {
|
||||
Result<IPage<SysUser>> result = new Result<IPage<SysUser>>();
|
||||
@ -90,9 +107,11 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
@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");
|
||||
String selectedDeparts = jsonObject.getString("selecteddeparts");
|
||||
try {
|
||||
SysUser user = JSON.parseObject(jsonObject.toJSONString(), SysUser.class);
|
||||
user.setCreateTime(new Date());//设置创建时间
|
||||
@ -103,6 +122,7 @@ public class SysUserController {
|
||||
user.setStatus(1);
|
||||
user.setDelFlag("0");
|
||||
sysUserService.addUserWithRole(user, selectedRoles);
|
||||
sysUserService.addUserWithDepart(user, selectedDeparts);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@ -112,6 +132,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 {
|
||||
@ -124,7 +145,9 @@ public class SysUserController {
|
||||
//String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt());
|
||||
user.setPassword(sysUser.getPassword());
|
||||
String roles = jsonObject.getString("selectedroles");
|
||||
String departs = jsonObject.getString("selecteddeparts");
|
||||
sysUserService.editUserWithRole(user, roles);
|
||||
sysUserService.editUserWithDepart(user, departs);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@ -240,45 +263,28 @@ public class SysUserController {
|
||||
|
||||
|
||||
/**
|
||||
* 校验用户账号是否唯一<br>
|
||||
* 可以校验其他 需要检验什么就传什么。。。
|
||||
* 校验用户账号是否唯一<br>
|
||||
* 可以校验其他 需要检验什么就传什么。。。
|
||||
*
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/checkOnlyUser", method = RequestMethod.GET)
|
||||
public Result<Boolean> checkUsername(SysUser sysUser) {
|
||||
public Result<Boolean> checkOnlyUser(SysUser sysUser) {
|
||||
Result<Boolean> result = new Result<>();
|
||||
result.setResult(true);//如果此参数为false则程序发生异常
|
||||
String id = sysUser.getId();
|
||||
log.info("--验证用户信息是否唯一---id:" + id);
|
||||
//如果此参数为false则程序发生异常
|
||||
result.setResult(true);
|
||||
try {
|
||||
SysUser oldUser = null;
|
||||
if (oConvertUtils.isNotEmpty(id)) {
|
||||
oldUser = sysUserService.getById(id);
|
||||
} else {
|
||||
sysUser.setId(null);
|
||||
}
|
||||
//通过传入信息查询新的用户信息
|
||||
SysUser newUser = sysUserService.getOne(new QueryWrapper<SysUser>(sysUser));
|
||||
if (newUser != null) {
|
||||
//如果根据传入信息查询到用户了,那么就需要做校验了。
|
||||
if (oldUser == null) {
|
||||
//oldUser为空=>新增模式=>只要用户信息存在则返回false
|
||||
result.setSuccess(false);
|
||||
result.setMessage("用户账号已存在");
|
||||
return result;
|
||||
} else if (!id.equals(newUser.getId())) {
|
||||
//否则=>编辑模式=>判断两者ID是否一致-
|
||||
result.setSuccess(false);
|
||||
result.setMessage("用户账号已存在");
|
||||
return result;
|
||||
}
|
||||
SysUser user = sysUserService.getOne(new QueryWrapper<SysUser>(sysUser));
|
||||
if (user != null) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("用户账号已存在");
|
||||
return result;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
result.setSuccess(false);
|
||||
result.setResult(false);
|
||||
result.setMessage(e.getMessage());
|
||||
return result;
|
||||
}
|
||||
@ -337,53 +343,6 @@ public class SysUserController {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 给指定用户添加对应的部门
|
||||
*
|
||||
* @param sysUserDepartsVO
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/addUDepartIds", method = RequestMethod.POST)
|
||||
public Result<String> addSysUseWithrDepart(@RequestBody SysUserDepartsVO sysUserDepartsVO) {
|
||||
boolean ok = this.sysUserDepartService.addSysUseWithrDepart(sysUserDepartsVO);
|
||||
Result<String> result = new Result<String>();
|
||||
try {
|
||||
if (ok) {
|
||||
result.setMessage("添加成功!");
|
||||
result.setSuccess(true);
|
||||
} else {
|
||||
throw new Exception("添加失败!");
|
||||
}
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("添加数据的过程中出现市场了: " + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id编辑对应的部门信息
|
||||
*
|
||||
* @param sysUserDepartsVO
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/editUDepartIds", method = RequestMethod.PUT)
|
||||
public Result<String> editSysUserWithDepart(@RequestBody SysUserDepartsVO sysUserDepartsVO) {
|
||||
Result<String> result = new Result<String>();
|
||||
boolean ok = sysUserDepartService.editSysUserWithDepart(sysUserDepartsVO);
|
||||
if (ok) {
|
||||
result.setMessage("更新成功!");
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
result.setMessage("更新失败!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成在添加用户情况下没有主键的问题,返回给前端,根据该id绑定部门数据
|
||||
*
|
||||
@ -450,7 +409,8 @@ public class SysUserController {
|
||||
//导出文件名称
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "用户列表");
|
||||
mv.addObject(NormalExcelConstants.CLASS, SysUser.class);
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:Jeecg", "导出信息"));
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("用户列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||
return mv;
|
||||
}
|
||||
@ -463,6 +423,7 @@ public class SysUserController {
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
@RequiresPermissions("user:import")
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||
@ -582,7 +543,6 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
result.setMessage("添加成功!");
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
@ -671,7 +631,6 @@ public class SysUserController {
|
||||
sysUserDepartService.save(sysUserDepart);
|
||||
}
|
||||
}
|
||||
|
||||
result.setMessage("添加成功!");
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
@ -722,5 +681,180 @@ public class SysUserController {
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询当前用户的所有部门/当前部门编码
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getCurrentUserDeparts", method = RequestMethod.GET)
|
||||
public Result<Map<String,Object>> getCurrentUserDeparts() {
|
||||
Result<Map<String,Object>> result = new Result<Map<String,Object>>();
|
||||
try {
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
List<SysDepart> list = this.sysDepartService.queryUserDeparts(sysUser.getId());
|
||||
Map<String,Object> map = new HashMap<String,Object>();
|
||||
map.put("list", list);
|
||||
map.put("orgCode", sysUser.getOrgCode());
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
}catch(Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("查询失败!");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 用户注册接口
|
||||
*
|
||||
* @param jsonObject
|
||||
* @param user
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/register")
|
||||
public Result<JSONObject> userRegister(@RequestBody JSONObject jsonObject, SysUser user) {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String phone = jsonObject.getString("phone");
|
||||
String smscode = jsonObject.getString("smscode");
|
||||
Object code = redisUtil.get(phone);
|
||||
String username = jsonObject.getString("username");
|
||||
String password = jsonObject.getString("password");
|
||||
String email = jsonObject.getString("email");
|
||||
SysUser sysUser1 = sysUserService.getUserByName(username);
|
||||
if (sysUser1 != null) {
|
||||
result.setMessage("用户名已注册");
|
||||
result.setSuccess(false);
|
||||
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 (!smscode.equals(code)) {
|
||||
result.setMessage("手机验证码错误");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
user.setCreateTime(new Date());// 设置创建时间
|
||||
String salt = oConvertUtils.randomGen(8);
|
||||
String passwordEncode = PasswordUtil.encrypt(username, password, salt);
|
||||
user.setSalt(salt);
|
||||
user.setUsername(username);
|
||||
user.setPassword(passwordEncode);
|
||||
user.setEmail(email);
|
||||
user.setPhone(phone);
|
||||
user.setStatus(1);
|
||||
user.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
||||
user.setActivitiSync(CommonConstant.ACT_SYNC_1);
|
||||
sysUserService.save(user);
|
||||
result.success("注册成功");
|
||||
} catch (Exception e) {
|
||||
result.error500("注册失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param 根据用户名或手机号查询用户信息
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/querySysUser")
|
||||
public Result<Map<String, Object>> querySysUser(SysUser sysUser) {
|
||||
String phone = sysUser.getPhone();
|
||||
String username = sysUser.getUsername();
|
||||
Result<Map<String, Object>> result = new Result<Map<String, Object>>();
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
if (oConvertUtils.isNotEmpty(phone)) {
|
||||
SysUser userList = sysUserService.getUserByPhone(phone);
|
||||
map.put("username",userList.getUsername());
|
||||
map.put("phone",userList.getPhone());
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(username)) {
|
||||
SysUser userList = sysUserService.getUserByName(username);
|
||||
map.put("username",userList.getUsername());
|
||||
map.put("phone",userList.getPhone());
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(false);
|
||||
result.setMessage("验证失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户手机号验证
|
||||
*/
|
||||
@PostMapping("/phoneVerification")
|
||||
public Result<String> phoneVerification(@RequestBody JSONObject jsonObject) {
|
||||
Result<String> result = new Result<String>();
|
||||
String phone = jsonObject.getString("phone");
|
||||
String smscode = jsonObject.getString("smscode");
|
||||
Object code = redisUtil.get(phone);
|
||||
if (!smscode.equals(code)) {
|
||||
result.setMessage("手机验证码错误");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
redisUtil.set(phone, smscode);
|
||||
result.setResult(smscode);
|
||||
result.setSuccess(true);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户更改密码
|
||||
*/
|
||||
@GetMapping("/passwordChange")
|
||||
public Result<SysUser> passwordChange(@RequestParam(name="username")String username,
|
||||
@RequestParam(name="password")String password,
|
||||
@RequestParam(name="smscode")String smscode,
|
||||
@RequestParam(name="phone") String phone) {
|
||||
Result<SysUser> result = new Result<SysUser>();
|
||||
SysUser sysUser=new SysUser();
|
||||
Object object= redisUtil.get(phone);
|
||||
if(null==object) {
|
||||
result.setMessage("更改密码失败");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
if(!smscode.equals(object)) {
|
||||
result.setMessage("更改密码失败");
|
||||
result.setSuccess(false);
|
||||
}
|
||||
sysUser = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername,username));
|
||||
if (sysUser == null) {
|
||||
result.setMessage("未找到对应实体");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
} else {
|
||||
String salt = oConvertUtils.randomGen(8);
|
||||
sysUser.setSalt(salt);
|
||||
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
|
||||
sysUser.setPassword(passwordEncode);
|
||||
this.sysUserService.updateById(sysUser);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("密码修改完成!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,60 @@
|
||||
package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
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 lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_category")
|
||||
public class SysCategory implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**主键*/
|
||||
@TableId(type = IdType.UUID)
|
||||
private java.lang.String id;
|
||||
/**父级节点*/
|
||||
@Excel(name = "父级节点", width = 15)
|
||||
private java.lang.String pid;
|
||||
/**类型名称*/
|
||||
@Excel(name = "类型名称", width = 15)
|
||||
private java.lang.String name;
|
||||
/**类型编码*/
|
||||
@Excel(name = "类型编码", width = 15)
|
||||
private java.lang.String code;
|
||||
/**创建人*/
|
||||
@Excel(name = "创建人", width = 15)
|
||||
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")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@Excel(name = "更新人", width = 15)
|
||||
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")
|
||||
private java.util.Date updateTime;
|
||||
/**所属部门*/
|
||||
@Excel(name = "所属部门", width = 15)
|
||||
private java.lang.String sysOrgCode;
|
||||
/**是否有子节点*/
|
||||
@Excel(name = "是否有子节点", width = 15)
|
||||
private java.lang.String hasChild;
|
||||
}
|
||||
@ -5,6 +5,7 @@ import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@ -57,6 +58,7 @@ public class SysDict implements Serializable {
|
||||
/**
|
||||
* 删除状态
|
||||
*/
|
||||
@TableLogic
|
||||
private Integer delFlag;
|
||||
|
||||
/**
|
||||
|
||||
@ -98,6 +98,13 @@ public class SysPermission implements Serializable {
|
||||
@TableField(value="is_route")
|
||||
private boolean route;
|
||||
|
||||
|
||||
/**
|
||||
* 是否缓存页面: 0:不是 1:是(默认值1)
|
||||
*/
|
||||
@TableField(value="keep_alive")
|
||||
private boolean keepAlive;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ -160,6 +167,7 @@ public class SysPermission implements Serializable {
|
||||
this.delFlag=0;
|
||||
this.alwaysShow=false;
|
||||
this.route=true;
|
||||
this.keepAlive=true;
|
||||
this.leaf=true;
|
||||
this.hidden=false;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@ package org.jeecg.modules.system.entity;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
@ -108,6 +109,7 @@ public class SysUser implements Serializable {
|
||||
* 删除状态(0,正常,1已删除)
|
||||
*/
|
||||
@Excel(name = "删除状态", width = 15,dicCode="del_flag")
|
||||
@TableLogic
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
|
||||
@ -25,5 +25,9 @@ public class SysUserDepart implements Serializable {
|
||||
this.userId = userId;
|
||||
this.depId = depId;
|
||||
}
|
||||
|
||||
|
||||
public SysUserDepart(String id, String departId) {
|
||||
this.userId = id;
|
||||
this.depId = departId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,27 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface SysCategoryMapper extends BaseMapper<SysCategory> {
|
||||
|
||||
/**
|
||||
* 根据父级ID查询树节点数据
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<TreeSelectModel> queryListByPid(@Param("pid") String pid);
|
||||
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.model.DuplicateCheckVo;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
@ -27,6 +28,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
|
||||
public List<DictModel> queryDictItemsByCode(@Param("code") String code);
|
||||
public List<DictModel> queryTableDictItemsByCode(@Param("table") String table,@Param("text") String text,@Param("code") String code);
|
||||
public List<DictModel> queryTableDictItemsByCodeAndFilter(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("filterSql") String filterSql);
|
||||
|
||||
|
||||
public String queryDictTextByKey(@Param("code") String code,@Param("key") String key);
|
||||
@ -45,5 +47,26 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryAllUserBackDictModel();
|
||||
|
||||
/**
|
||||
* 通过关键字查询出字典表
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryTableDictItems(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("keyword") String keyword);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 查询树
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param pid
|
||||
* @param hasChildField
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectModel> queryTreeList(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField);
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.jeecg.modules.system.entity.SysLog;
|
||||
@ -44,4 +46,12 @@ public interface SysLogMapper extends BaseMapper<SysLog> {
|
||||
*/
|
||||
Long findTodayIp(@Param("dayStart") Date dayStart, @Param("dayEnd") Date dayEnd);
|
||||
//update-end--Author:zhangweijian Date:20190428 for:传入开始时间,结束时间参数
|
||||
|
||||
/**
|
||||
* 首页:根据时间统计访问数量/ip数量
|
||||
* @param dayStart
|
||||
* @param dayEnd
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> findVisitCount(@Param("dayStart") Date dayStart, @Param("dayEnd") Date dayEnd);
|
||||
}
|
||||
|
||||
@ -44,4 +44,19 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
* @param departId
|
||||
*/
|
||||
void updateUserDepart(@Param("username") String username,@Param("orgCode") String orgCode);
|
||||
|
||||
/**
|
||||
* 根据手机号查询用户信息
|
||||
* @param phone
|
||||
* @return
|
||||
*/
|
||||
public SysUser getUserByPhone(@Param("phone") String phone);
|
||||
|
||||
|
||||
/**
|
||||
* 根据邮箱查询用户信息
|
||||
* @param email
|
||||
* @return
|
||||
*/
|
||||
public SysUser getUserByEmail(@Param("email")String email);
|
||||
}
|
||||
|
||||
@ -0,0 +1,16 @@
|
||||
<?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.SysCategoryMapper">
|
||||
|
||||
<select id="queryListByPid" parameterType="String" resultType="org.jeecg.modules.system.model.TreeSelectModel">
|
||||
select code,
|
||||
name as 'title',
|
||||
id as 'key',
|
||||
(case has_child when '1' then 0 else 1 end) as isLeaf,
|
||||
pid as parentId
|
||||
from sys_category
|
||||
where pid = #{pid}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@ -4,7 +4,7 @@
|
||||
|
||||
<!-- 通过字典code获取字典数据 -->
|
||||
<select id="queryDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select s.item_value value,s.item_text text from sys_dict_item s
|
||||
select s.item_value as value,s.item_text as text from sys_dict_item s
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
order by s.sort_order asc
|
||||
</select>
|
||||
@ -22,6 +22,11 @@
|
||||
select ${text} as 'text',${code} as 'value' from ${table}
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典(指定查询条件)-->
|
||||
<select id="queryTableDictItemsByCodeAndFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as 'text',${code} as 'value' from ${table} where ${filterSql}
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code key 获取字典值-->
|
||||
<select id="queryTableDictTextByKey" parameterType="String" resultType="String">
|
||||
select ${text} as 'text' from ${table} where ${code}= #{key}
|
||||
@ -29,7 +34,7 @@
|
||||
|
||||
<!-- 重复校验 sql语句 -->
|
||||
<select id="duplicateCheckCountSql" resultType="Long" parameterType="org.jeecg.modules.system.model.DuplicateCheckVo">
|
||||
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} and id != #{dataId}
|
||||
SELECT COUNT(*) FROM ${tableName} WHERE ${fieldName} = #{fieldVal} and id <> #{dataId}
|
||||
</select>
|
||||
|
||||
<!-- 重复校验 sql语句 -->
|
||||
@ -46,4 +51,22 @@
|
||||
<select id="queryAllUserBackDictModel" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select username as value,realname as text from sys_depart where del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典数据,且支持关键字查询 -->
|
||||
<select id="queryTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as 'text',${code} as 'value' from ${table} where ${text} like #{keyword}
|
||||
</select>
|
||||
|
||||
<!-- 根据表名、显示字段名、存储字段名、父ID查询树 -->
|
||||
<select id="queryTreeList" parameterType="String" resultType="org.jeecg.modules.system.model.TreeSelectModel">
|
||||
select ${text} as 'title',
|
||||
${code} as 'key',
|
||||
<if test="hasChildField != null and hasChildField != ''">
|
||||
(case ${hasChildField} when '1' then 0 else 1 end) as 'isLeaf',
|
||||
</if>
|
||||
${pidField} as parentId
|
||||
from ${table} where ${pidField} = #{pid}
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -21,5 +21,17 @@
|
||||
<select id="findTodayIp" resultType="long">
|
||||
select count(distinct(ip)) from sys_log where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
||||
</select>
|
||||
|
||||
<!-- 首页访问统计 -->
|
||||
<select id="findVisitCount" resultType="java.util.HashMap">
|
||||
select count(*) as visit,
|
||||
count(distinct(ip)) as ip,
|
||||
DATE_FORMAT(create_time, '%Y-%m-%d') as tian,
|
||||
DATE_FORMAT(create_time, '%m-%d') as type
|
||||
from sys_log
|
||||
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
||||
group by tian
|
||||
order by tian asc
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
<resultMap id="SysPermission" type="org.jeecg.modules.system.entity.SysPermission">
|
||||
<!-- result属性映射非匹配字段 -->
|
||||
<result column="is_route" property="route"/>
|
||||
<result column="keep_alive" property="keepAlive"/>
|
||||
<result column="is_leaf" property="leaf"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
@ -4,12 +4,12 @@
|
||||
|
||||
<!-- 根据用户名查询 -->
|
||||
<select id="getUserByName" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where username = #{username}
|
||||
select * from sys_user where username = #{username} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 根据部门Id查询 -->
|
||||
<select id="getUserByDepId" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where id in (select user_id from sys_user_depart where dep_id=#{departId})
|
||||
select * from sys_user where del_flag = '0' and id in (select user_id from sys_user_depart where dep_id=#{departId})
|
||||
<if test="username!=null and username!=''">
|
||||
and username = #{username}
|
||||
</if>
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
<!-- 根据角色Id查询 -->
|
||||
<select id="getUserByRoleId" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where id in (select user_id from sys_user_role where role_id=#{roleId})
|
||||
select * from sys_user where del_flag = '0' and id in (select user_id from sys_user_role where role_id=#{roleId})
|
||||
<if test="username!=null and username!=''">
|
||||
and username = #{username}
|
||||
</if>
|
||||
@ -28,4 +28,14 @@
|
||||
UPDATE sys_user SET org_code = #{orgCode} where username = #{username}
|
||||
</update>
|
||||
|
||||
<!-- 根据手机号查询 -->
|
||||
<select id="getUserByPhone" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where phone = #{phone} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
<!-- 根据邮箱查询用户信息 -->
|
||||
<select id="getUserByEmail" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select * from sys_user where email = #{email} and del_flag = '0'
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -77,6 +77,13 @@ public class SysPermissionTree implements Serializable {
|
||||
*/
|
||||
private boolean route;
|
||||
|
||||
|
||||
/**
|
||||
* 是否路缓存页面: 0:不是 1:是(默认值1)
|
||||
*/
|
||||
private boolean keepAlive;
|
||||
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@ -141,6 +148,7 @@ public class SysPermissionTree implements Serializable {
|
||||
this.url = permission.getUrl();
|
||||
this.hidden = permission.isHidden();
|
||||
this.route = permission.isRoute();
|
||||
this.keepAlive = permission.isKeepAlive();
|
||||
this.alwaysShow= permission.isAlwaysShow();
|
||||
this.title=permission.getName();
|
||||
if (!permission.isLeaf()) {
|
||||
@ -159,6 +167,22 @@ public class SysPermissionTree implements Serializable {
|
||||
|
||||
private List<SysPermissionTree> children;
|
||||
|
||||
public boolean isLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setLeaf(boolean leaf) {
|
||||
isLeaf = leaf;
|
||||
}
|
||||
|
||||
public boolean isKeepAlive() {
|
||||
return keepAlive;
|
||||
}
|
||||
|
||||
public void setKeepAlive(boolean keepAlive) {
|
||||
this.keepAlive = keepAlive;
|
||||
}
|
||||
|
||||
public boolean isAlwaysShow() {
|
||||
return alwaysShow;
|
||||
}
|
||||
|
||||
@ -1,29 +0,0 @@
|
||||
package org.jeecg.modules.system.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
public class SysUserDepartsVO implements Serializable{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**用户id*/
|
||||
private String userId;
|
||||
/**对应的部门id集合*/
|
||||
private List<String> departIdList;
|
||||
public SysUserDepartsVO(String userId, List<String> departIdList) {
|
||||
super();
|
||||
this.userId = userId;
|
||||
this.departIdList = departIdList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -8,6 +8,9 @@ import java.util.Map;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
|
||||
/**
|
||||
* 树形列表用到
|
||||
*/
|
||||
public class TreeModel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 4013193970046502756L;
|
||||
|
||||
@ -1,9 +1,12 @@
|
||||
package org.jeecg.modules.system.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 树形下拉框
|
||||
*/
|
||||
public class TreeSelectModel implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 9016390975325574747L;
|
||||
|
||||
@ -19,6 +22,8 @@ public class TreeSelectModel implements Serializable {
|
||||
|
||||
private String value;
|
||||
|
||||
private String code;
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
@ -66,7 +71,23 @@ public class TreeSelectModel implements Serializable {
|
||||
public void setIcon(String icon) {
|
||||
this.icon = icon;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(String code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
|
||||
private List<TreeSelectModel> children;
|
||||
|
||||
public List<TreeSelectModel> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<TreeSelectModel> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,40 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface ISysCategoryService extends IService<SysCategory> {
|
||||
|
||||
/**根节点父ID的值*/
|
||||
public static final String ROOT_PID_VALUE = "0";
|
||||
|
||||
void addSysCategory(SysCategory sysCategory);
|
||||
|
||||
void updateSysCategory(SysCategory sysCategory);
|
||||
|
||||
/**
|
||||
* 根据父级编码加载分类字典的数据
|
||||
* @param pcode
|
||||
* @return
|
||||
*/
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException;
|
||||
|
||||
/**
|
||||
* 根据pid查询子节点集合
|
||||
* @param pid
|
||||
* @return
|
||||
*/
|
||||
public List<TreeSelectModel> queryListByPid(String pid);
|
||||
|
||||
}
|
||||
@ -7,6 +7,7 @@ import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -21,6 +22,8 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
public List<DictModel> queryDictItemsByCode(String code);
|
||||
|
||||
List<DictModel> queryTableDictItemsByCode(String table, String text, String code);
|
||||
|
||||
public List<DictModel> queryTableDictItemsByCodeAndFilter(String table, String text, String code, String filterSql);
|
||||
|
||||
public String queryDictTextByKey(String code, String key);
|
||||
|
||||
@ -50,5 +53,27 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryAllUserBackDictModel();
|
||||
|
||||
/**
|
||||
* 通过关键字查询字典表
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryTableDictItems(String table, String text, String code,String keyword);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 查询树
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param pidField
|
||||
* @param pid
|
||||
* @param hasChildField
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectModel> queryTreeList(String table, String text, String code, String pidField,String pid,String hasChildField);
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package org.jeecg.modules.system.service;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jeecg.modules.system.entity.SysLog;
|
||||
|
||||
@ -43,4 +45,12 @@ public interface ISysLogService extends IService<SysLog> {
|
||||
*/
|
||||
Long findTodayIp(Date dayStart, Date dayEnd);
|
||||
//update-end--Author:zhangweijian Date:20190428 for:传入开始时间,结束时间参数
|
||||
|
||||
/**
|
||||
* 首页:根据时间统计访问数量/ip数量
|
||||
* @param dayStart
|
||||
* @param dayEnd
|
||||
* @return
|
||||
*/
|
||||
List<Map<String,Object>> findVisitCount(Date dayStart, Date dayEnd);
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ import java.util.List;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserDepart;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysUserDepartsVO;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@ -19,13 +19,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
*/
|
||||
public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
|
||||
/**
|
||||
* 根据指定用户添加部门信息
|
||||
* @param sysUserDepartsVO
|
||||
* @return
|
||||
*/
|
||||
boolean addSysUseWithrDepart(SysUserDepartsVO sysUserDepartsVO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据指定用户id查询部门信息
|
||||
* @param userId
|
||||
@ -33,13 +27,7 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
*/
|
||||
List<DepartIdModel> queryDepartIdsOfUser(String userId);
|
||||
|
||||
/**
|
||||
* 根据指定用户id编辑部门信息
|
||||
* @param sysUserDepartsVO
|
||||
* @return
|
||||
*/
|
||||
boolean editSysUserWithDepart(SysUserDepartsVO sysUserDepartsVO);
|
||||
|
||||
|
||||
/**
|
||||
* 根据部门id查询用户信息
|
||||
* @param depId
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
|
||||
@ -88,4 +89,38 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @param orgCode
|
||||
*/
|
||||
void updateUserDepart(String username,String orgCode);
|
||||
|
||||
/**
|
||||
* 根据手机号获取用户名和密码
|
||||
*/
|
||||
public SysUser getUserByPhone(String phone);
|
||||
|
||||
|
||||
/**
|
||||
* 根据邮箱获取用户
|
||||
*/
|
||||
public SysUser getUserByEmail(String email);
|
||||
|
||||
|
||||
/**
|
||||
* 添加用户和用户部门关系
|
||||
* @param user
|
||||
* @param selectedParts
|
||||
*/
|
||||
void addUserWithDepart(SysUser user, String selectedParts);
|
||||
|
||||
/**
|
||||
* 编辑用户和用户部门关系
|
||||
* @param user
|
||||
* @param departs
|
||||
*/
|
||||
void editUserWithDepart(SysUser user, String departs);
|
||||
|
||||
/**
|
||||
* 校验用户是否有效
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
Result checkUserIsEffective(SysUser sysUser);
|
||||
|
||||
}
|
||||
|
||||
@ -103,12 +103,12 @@ public class SysAnnouncementServiceImpl extends ServiceImpl<SysAnnouncementMappe
|
||||
SysAnnouncement announcement = new SysAnnouncement();
|
||||
announcement.setTitile(title);
|
||||
announcement.setMsgContent(msgContent);
|
||||
announcement.setSender("共享平台");
|
||||
announcement.setSender("JEECG BOOT");
|
||||
announcement.setPriority(CommonConstant.PRIORITY_L);
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_ALL);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
announcement.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@ package org.jeecg.modules.system.service.impl;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DatabaseMetaData;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ -21,6 +22,7 @@ import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysAnnouncement;
|
||||
import org.jeecg.modules.system.entity.SysAnnouncementSend;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.entity.SysLog;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.mapper.SysAnnouncementMapper;
|
||||
@ -33,6 +35,8 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
@ -116,7 +120,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
|
||||
@Override
|
||||
public String getDatabaseType() throws SQLException {
|
||||
return getDatabaseType();
|
||||
DataSource dataSource = SpringContextUtils.getApplicationContext().getBean(DataSource.class);
|
||||
return getDatabaseTypeByDataSource(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -144,7 +149,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
announcement.setMsgType(CommonConstant.MSG_TYPE_UESR);
|
||||
announcement.setSendStatus(CommonConstant.HAS_SEND);
|
||||
announcement.setSendTime(new Date());
|
||||
announcement.setMsgCategory("2");
|
||||
announcement.setMsgCategory(CommonConstant.MSG_CATEGORY_2);
|
||||
announcement.setDelFlag(String.valueOf(CommonConstant.DEL_FLAG_0));
|
||||
sysAnnouncementMapper.insert(announcement);
|
||||
// 2.插入用户通告阅读标记表记录
|
||||
@ -172,7 +177,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
* @throws SQLException
|
||||
* @throws DBException
|
||||
*/
|
||||
private static String getDatabaseType(DataSource dataSource) throws SQLException{
|
||||
private String getDatabaseTypeByDataSource(DataSource dataSource) throws SQLException{
|
||||
if("".equals(DB_TYPE)) {
|
||||
Connection connection = dataSource.getConnection();
|
||||
try {
|
||||
@ -198,4 +203,19 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
return DB_TYPE;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryAllDict() {
|
||||
// 查询并排序
|
||||
QueryWrapper<SysDict> queryWrapper = new QueryWrapper<SysDict>();
|
||||
queryWrapper.orderByAsc("create_time");
|
||||
List<SysDict> dicts = sysDictService.list(queryWrapper);
|
||||
// 封装成 model
|
||||
List<DictModel> list = new ArrayList<DictModel>();
|
||||
for (SysDict dict : dicts) {
|
||||
list.add(new DictModel(dict.getDictCode(), dict.getDictName()));
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,79 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysCategory;
|
||||
import org.jeecg.modules.system.mapper.SysCategoryMapper;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.service.ISysCategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 分类字典
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2019-05-29
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCategory> implements ISysCategoryService {
|
||||
|
||||
@Override
|
||||
public void addSysCategory(SysCategory sysCategory) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
|
||||
}else{
|
||||
//如果当前节点父ID不为空 则设置父节点的hasChild 为1
|
||||
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
|
||||
if(parent!=null && !"1".equals(parent.getHasChild())){
|
||||
parent.setHasChild("1");
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
baseMapper.insert(sysCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSysCategory(SysCategory sysCategory) {
|
||||
if(oConvertUtils.isEmpty(sysCategory.getPid())){
|
||||
sysCategory.setPid(ISysCategoryService.ROOT_PID_VALUE);
|
||||
}else{
|
||||
//如果当前节点父ID不为空 则设置父节点的hasChild 为1
|
||||
SysCategory parent = baseMapper.selectById(sysCategory.getPid());
|
||||
if(parent!=null && !"1".equals(parent.getHasChild())){
|
||||
parent.setHasChild("1");
|
||||
baseMapper.updateById(parent);
|
||||
}
|
||||
}
|
||||
baseMapper.updateById(sysCategory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByCode(String pcode) throws JeecgBootException{
|
||||
String pid = ROOT_PID_VALUE;
|
||||
if(oConvertUtils.isNotEmpty(pcode)) {
|
||||
List<SysCategory> list = baseMapper.selectList(new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, pcode));
|
||||
if(list==null || list.size() ==0) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】不存在,请核实!");
|
||||
}
|
||||
if(list.size()>1) {
|
||||
throw new JeecgBootException("该编码【"+pcode+"】存在多个,请核实!");
|
||||
}
|
||||
pid = list.get(0).getId();
|
||||
}
|
||||
return baseMapper.queryListByPid(pid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryListByPid(String pid) {
|
||||
if(oConvertUtils.isEmpty(pid)) {
|
||||
pid = ROOT_PID_VALUE;
|
||||
}
|
||||
return baseMapper.queryListByPid(pid);
|
||||
}
|
||||
|
||||
}
|
||||
@ -5,6 +5,7 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.YouBianCodeUtil;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.mapper.SysDepartMapper;
|
||||
@ -36,7 +37,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
@Override
|
||||
public List<SysDepartTreeModel> queryTreeList() {
|
||||
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>();
|
||||
query.eq(SysDepart::getDelFlag, 0);
|
||||
query.eq(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_0.toString());
|
||||
query.orderByAsc(SysDepart::getDepartOrder);
|
||||
List<SysDepart> list = this.list(query);
|
||||
// 调用wrapTreeDataToTreeList方法生成树状数据
|
||||
@ -64,7 +65,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
String orgType = codeArray[1];
|
||||
sysDepart.setOrgType(String.valueOf(orgType));
|
||||
sysDepart.setCreateTime(new Date());
|
||||
sysDepart.setDelFlag("0");
|
||||
sysDepart.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
||||
this.save(sysDepart);
|
||||
}
|
||||
|
||||
|
||||
@ -2,11 +2,14 @@ package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.modules.system.entity.SysDict;
|
||||
import org.jeecg.modules.system.entity.SysDictItem;
|
||||
import org.jeecg.modules.system.mapper.SysDictItemMapper;
|
||||
import org.jeecg.modules.system.mapper.SysDictMapper;
|
||||
import org.jeecg.modules.system.model.TreeSelectModel;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
@ -40,7 +43,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = "dictCache",key = "#code")
|
||||
@Cacheable(value = CacheConstant.DICT_CACHE,key = "#code")
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
log.info("无缓存dictCache的时候调用这里!");
|
||||
return sysDictMapper.queryDictItemsByCode(code);
|
||||
@ -54,7 +57,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Cacheable(value = "dictCache")
|
||||
@Cacheable(value = CacheConstant.DICT_CACHE)
|
||||
public String queryDictTextByKey(String code, String key) {
|
||||
log.info("无缓存dictText的时候调用这里!");
|
||||
return sysDictMapper.queryDictTextByKey(code, key);
|
||||
@ -75,6 +78,12 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
return sysDictMapper.queryTableDictItemsByCode(table,text,code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryTableDictItemsByCodeAndFilter(String table, String text, String code, String filterSql) {
|
||||
log.info("无缓存dictTableList的时候调用这里!");
|
||||
return sysDictMapper.queryTableDictItemsByCodeAndFilter(table,text,code,filterSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询指定table的 text code 获取字典值text
|
||||
* dictTableCache采用redis缓存有效期10分钟
|
||||
@ -96,7 +105,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteByDictId(SysDict sysDict) {
|
||||
sysDict.setDelFlag(2);
|
||||
sysDict.setDelFlag(CommonConstant.DEL_FLAG_1);
|
||||
return this.updateById(sysDict);
|
||||
}
|
||||
|
||||
@ -122,5 +131,15 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
public List<DictModel> queryAllUserBackDictModel() {
|
||||
return baseMapper.queryAllUserBackDictModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryTableDictItems(String table, String text, String code, String keyword) {
|
||||
return baseMapper.queryTableDictItems(table, text, code, "%"+keyword+"%");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryTreeList(String table, String text, String code, String pidField,String pid,String hasChildField) {
|
||||
return baseMapper.queryTreeList(table, text, code, pidField, pid,hasChildField);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@ -49,4 +51,9 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
return sysLogMapper.findTodayIp(dayStart,dayEnd);
|
||||
}
|
||||
//update-end--Author:zhangweijian Date:20190428 for:传入开始时间,结束时间参数
|
||||
|
||||
@Override
|
||||
public List<Map<String,Object>> findVisitCount(Date dayStart, Date dayEnd) {
|
||||
return sysLogMapper.findVisitCount(dayStart, dayEnd);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.Set;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
@ -77,7 +78,7 @@ public class SysPermissionDataRuleImpl extends ServiceImpl<SysPermissionDataRule
|
||||
if(set.size()==0) {
|
||||
return null;
|
||||
}
|
||||
return this.baseMapper.selectList(new QueryWrapper<SysPermissionDataRule>().in("id", set).eq("status","1"));
|
||||
return this.baseMapper.selectList(new QueryWrapper<SysPermissionDataRule>().in("id", set).eq("status",CommonConstant.STATUS_1));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -85,8 +86,8 @@ public class SysPermissionDataRuleImpl extends ServiceImpl<SysPermissionDataRule
|
||||
public void savePermissionDataRule(SysPermissionDataRule sysPermissionDataRule) {
|
||||
this.save(sysPermissionDataRule);
|
||||
SysPermission permission = sysPermissionMapper.selectById(sysPermissionDataRule.getPermissionId());
|
||||
if(permission!=null && (permission.getRuleFlag()==null || permission.getRuleFlag()==0)) {
|
||||
permission.setRuleFlag(1);
|
||||
if(permission!=null && (permission.getRuleFlag()==null || permission.getRuleFlag()==CommonConstant.RULE_FLAG_0)) {
|
||||
permission.setRuleFlag(CommonConstant.RULE_FLAG_1);
|
||||
sysPermissionMapper.updateById(permission);
|
||||
}
|
||||
}
|
||||
@ -101,8 +102,8 @@ public class SysPermissionDataRuleImpl extends ServiceImpl<SysPermissionDataRule
|
||||
//注:同一个事务中删除后再查询是会认为数据已被删除的 若事务回滚上述删除无效
|
||||
if(count==null || count==0) {
|
||||
SysPermission permission = sysPermissionMapper.selectById(dataRule.getPermissionId());
|
||||
if(permission!=null && permission.getRuleFlag()==1) {
|
||||
permission.setRuleFlag(0);
|
||||
if(permission!=null && permission.getRuleFlag()==CommonConstant.RULE_FLAG_1) {
|
||||
permission.setRuleFlag(CommonConstant.RULE_FLAG_0);
|
||||
sysPermissionMapper.updateById(permission);
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,7 @@ import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
@ -50,17 +51,19 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
@CacheEvict(value = "permission",allEntries=true)
|
||||
@CacheEvict(value = CacheConstant.PERMISSION_CACHE,allEntries=true)
|
||||
public void deletePermission(String id) throws JeecgBootException {
|
||||
SysPermission sysPermission = this.getById(id);
|
||||
if(sysPermission==null) {
|
||||
throw new JeecgBootException("未找到菜单信息");
|
||||
}
|
||||
String pid = sysPermission.getParentId();
|
||||
int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
|
||||
if(count==1) {
|
||||
//若父节点无其他子节点,则该父节点是叶子节点
|
||||
this.sysPermissionMapper.setMenuLeaf(pid, 1);
|
||||
if(oConvertUtils.isNotEmpty(pid)) {
|
||||
int count = this.count(new QueryWrapper<SysPermission>().lambda().eq(SysPermission::getParentId, pid));
|
||||
if(count==1) {
|
||||
//若父节点无其他子节点,则该父节点是叶子节点
|
||||
this.sysPermissionMapper.setMenuLeaf(pid, 1);
|
||||
}
|
||||
}
|
||||
sysPermissionMapper.deleteById(id);
|
||||
// 该节点可能是子节点但也可能是其它节点的父节点,所以需要级联删除
|
||||
@ -99,8 +102,8 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
||||
* 逻辑删除
|
||||
*/
|
||||
@Override
|
||||
@CacheEvict(value = "permission",allEntries=true)
|
||||
//@CacheEvict(value = "permission",allEntries=true,condition="#sysPermission.menuType==2")
|
||||
@CacheEvict(value = CacheConstant.PERMISSION_CACHE,allEntries=true)
|
||||
//@CacheEvict(value = CacheConstant.PERMISSION_CACHE,allEntries=true,condition="#sysPermission.menuType==2")
|
||||
public void deletePermissionLogical(String id) throws JeecgBootException {
|
||||
SysPermission sysPermission = this.getById(id);
|
||||
if(sysPermission==null) {
|
||||
@ -117,7 +120,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = "permission",allEntries=true)
|
||||
@CacheEvict(value = CacheConstant.PERMISSION_CACHE,allEntries=true)
|
||||
public void addPermission(SysPermission sysPermission) throws JeecgBootException {
|
||||
//----------------------------------------------------------------------
|
||||
//判断是否是一级菜单,是的话清空父菜单
|
||||
@ -137,7 +140,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value = "permission",allEntries=true)
|
||||
@CacheEvict(value = CacheConstant.PERMISSION_CACHE,allEntries=true)
|
||||
public void editPermission(SysPermission sysPermission) throws JeecgBootException {
|
||||
SysPermission p = this.getById(sysPermission.getId());
|
||||
//TODO 该节点判断是否还有子节点
|
||||
@ -198,7 +201,7 @@ public class SysPermissionServiceImpl extends ServiceImpl<SysPermissionMapper, S
|
||||
* 获取模糊匹配规则的数据权限URL
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = "permission")
|
||||
@Cacheable(value = CacheConstant.PERMISSION_CACHE)
|
||||
public List<String> queryPermissionUrlWithStar() {
|
||||
return this.baseMapper.queryPermissionUrlWithStar();
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysRolePermission;
|
||||
import org.jeecg.modules.system.mapper.SysRolePermissionMapper;
|
||||
@ -30,7 +31,7 @@ import org.springframework.stereotype.Service;
|
||||
public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionMapper, SysRolePermission> implements ISysRolePermissionService {
|
||||
|
||||
@Override
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
public void saveRolePermission(String roleId, String permissionIds) {
|
||||
LambdaQueryWrapper<SysRolePermission> query = new QueryWrapper<SysRolePermission>().lambda().eq(SysRolePermission::getRoleId, roleId);
|
||||
this.remove(query);
|
||||
@ -46,7 +47,7 @@ public class SysRolePermissionServiceImpl extends ServiceImpl<SysRolePermissionM
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
public void saveRolePermission(String roleId, String permissionIds, String lastPermissionIds) {
|
||||
List<String> add = getDiff(lastPermissionIds,permissionIds);
|
||||
if(add!=null && add.size()>0) {
|
||||
|
||||
@ -8,7 +8,6 @@ import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserDepart;
|
||||
import org.jeecg.modules.system.mapper.SysUserDepartMapper;
|
||||
import org.jeecg.modules.system.model.DepartIdModel;
|
||||
import org.jeecg.modules.system.model.SysUserDepartsVO;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysUserDepartService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
@ -32,31 +31,6 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
/**
|
||||
*根据用户id添加部门信息
|
||||
*/
|
||||
@Override
|
||||
public boolean addSysUseWithrDepart(SysUserDepartsVO sysUserDepartsVO) {
|
||||
LambdaQueryWrapper<SysUserDepart> query = new LambdaQueryWrapper<SysUserDepart>();
|
||||
if(sysUserDepartsVO != null) {
|
||||
String userId = sysUserDepartsVO.getUserId();
|
||||
List<String> departIdList = sysUserDepartsVO.getDepartIdList();
|
||||
if(departIdList != null && departIdList.size() > 0) {
|
||||
for(String depId : departIdList) {
|
||||
query.eq(SysUserDepart::getDepId, depId);
|
||||
query.eq(SysUserDepart::getUserId, userId);
|
||||
List<SysUserDepart> uDepList = this.list(query);
|
||||
if(uDepList == null || uDepList.size() == 0) {
|
||||
this.save(new SysUserDepart("",userId,depId));
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}else {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id查询部门信息
|
||||
@ -91,27 +65,6 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据用户id修改部门信息
|
||||
*/
|
||||
@Override
|
||||
public boolean editSysUserWithDepart(SysUserDepartsVO sysUserDepartsVO) {
|
||||
LambdaQueryWrapper<SysUserDepart> queryDep = new LambdaQueryWrapper<SysUserDepart>();
|
||||
List<String> depIdList = sysUserDepartsVO.getDepartIdList();
|
||||
if(depIdList != null && depIdList.size() > 0) {
|
||||
queryDep.eq(SysUserDepart::getUserId, sysUserDepartsVO.getUserId());
|
||||
boolean ok = this.remove(queryDep);
|
||||
if(ok) {
|
||||
for(String str : depIdList) {
|
||||
this.save(new SysUserDepart("", sysUserDepartsVO.getUserId(), str));
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
queryDep.eq(SysUserDepart::getUserId, sysUserDepartsVO.getUserId());
|
||||
boolean ok = this.remove(queryDep);
|
||||
return ok;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据部门id查询用户信息
|
||||
|
||||
@ -5,18 +5,15 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
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.vo.LoginUser;
|
||||
import org.jeecg.common.system.vo.SysUserCacheInfo;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysPermission;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.entity.SysUserRole;
|
||||
import org.jeecg.modules.system.mapper.SysDepartMapper;
|
||||
import org.jeecg.modules.system.mapper.SysPermissionMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserRoleMapper;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.*;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
@ -50,6 +47,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
@Autowired
|
||||
private SysUserRoleMapper sysUserRoleMapper;
|
||||
@Autowired
|
||||
private SysUserDepartMapper sysUserDepartMapper;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
@Autowired
|
||||
private SysDepartMapper sysDepartMapper;
|
||||
@ -74,7 +73,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
@CacheEvict(value= CacheConstant.LOGIN_USER_RULES_CACHE, allEntries=true)
|
||||
@Transactional
|
||||
public void editUserWithRole(SysUser user, String roles) {
|
||||
this.updateById(user);
|
||||
@ -101,7 +100,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @return 角色集合
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = "loginUser_cacheRules",key = "'Roles_'+#username")
|
||||
@Cacheable(value = CacheConstant.LOGIN_USER_RULES_CACHE,key = "'Roles_'+#username")
|
||||
public Set<String> getUserRolesSet(String username) {
|
||||
// 查询用户拥有的角色集合
|
||||
List<String> roles = sysUserRoleMapper.getRoleByUserName(username);
|
||||
@ -116,7 +115,7 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
* @return 权限集合
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = "loginUser_cacheRules",key = "'Permissions_'+#username")
|
||||
@Cacheable(value = CacheConstant.LOGIN_USER_RULES_CACHE,key = "'Permissions_'+#username")
|
||||
public Set<String> getUserPermissionsSet(String username) {
|
||||
Set<String> permissionSet = new HashSet<>();
|
||||
List<SysPermission> permissionList = sysPermissionMapper.queryByUser(username);
|
||||
@ -187,4 +186,75 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
baseMapper.updateUserDepart(username, orgCode);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysUser getUserByPhone(String phone) {
|
||||
return userMapper.getUserByPhone(phone);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public SysUser getUserByEmail(String email) {
|
||||
return userMapper.getUserByEmail(email);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void addUserWithDepart(SysUser user, String selectedParts) {
|
||||
// this.save(user); //保存角色的时候已经添加过一次了
|
||||
if(oConvertUtils.isNotEmpty(selectedParts)) {
|
||||
String[] arr = selectedParts.split(",");
|
||||
for (String deaprtId : arr) {
|
||||
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId);
|
||||
sysUserDepartMapper.insert(userDeaprt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
@CacheEvict(value="loginUser_cacheRules", allEntries=true)
|
||||
public void editUserWithDepart(SysUser user, String departs) {
|
||||
this.updateById(user); //更新角色的时候已经更新了一次了,可以再跟新一次
|
||||
//先删后加
|
||||
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
|
||||
if(oConvertUtils.isNotEmpty(departs)) {
|
||||
String[] arr = departs.split(",");
|
||||
for (String departId : arr) {
|
||||
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId);
|
||||
sysUserDepartMapper.insert(userDepart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验用户是否有效
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<?> checkUserIsEffective(SysUser sysUser) {
|
||||
Result<?> result = new Result<Object>();
|
||||
//情况1:根据用户信息查询,该用户不存在
|
||||
if (sysUser == null) {
|
||||
result.error500("该用户不存在,请注册");
|
||||
sysBaseAPI.addLog("用户登录失败,用户不存在!", CommonConstant.LOG_TYPE_1, null);
|
||||
return result;
|
||||
}
|
||||
//情况2:根据用户信息查询,该用户已注销
|
||||
if (CommonConstant.DEL_FLAG_1.toString().equals(sysUser.getDelFlag())) {
|
||||
sysBaseAPI.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已注销!", CommonConstant.LOG_TYPE_1, null);
|
||||
result.error500("该用户已注销");
|
||||
return result;
|
||||
}
|
||||
//情况3:根据用户信息查询,该用户已冻结
|
||||
if (CommonConstant.USER_FREEZE.equals(sysUser.getStatus())) {
|
||||
sysBaseAPI.addLog("用户登录失败,用户名:" + sysUser.getUsername() + "已冻结!", CommonConstant.LOG_TYPE_1, null);
|
||||
result.error500("该用户已冻结");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,10 +18,10 @@ spring:
|
||||
username: jeecgos@163.com
|
||||
password: ??
|
||||
properties:
|
||||
mail:
|
||||
smtp:
|
||||
mail:
|
||||
smtp:
|
||||
auth: true
|
||||
starttls:
|
||||
starttls:
|
||||
enable: true
|
||||
required: true
|
||||
## quartz定时任务,采用数据库方式
|
||||
@ -57,8 +57,11 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
loginUsername: admin
|
||||
loginPassword: 123456
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
dynamic:
|
||||
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
|
||||
# 连接池的配置信息
|
||||
@ -111,7 +114,17 @@ spring:
|
||||
#mybatis plus 设置
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
|
||||
|
||||
global-config:
|
||||
# 关闭MP3.0自带的banner
|
||||
banner: false
|
||||
db-config:
|
||||
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
|
||||
id-type: 4
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
#configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
path :
|
||||
|
||||
@ -57,8 +57,11 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
loginUsername: admin
|
||||
loginPassword: 123456
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
dynamic:
|
||||
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
|
||||
# 连接池的配置信息
|
||||
@ -111,7 +114,14 @@ spring:
|
||||
#mybatis plus 设置
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
|
||||
|
||||
global-config:
|
||||
# 关闭MP3.0自带的banner
|
||||
banner: false
|
||||
db-config:
|
||||
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
|
||||
id-type: 4
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
path :
|
||||
|
||||
@ -57,8 +57,11 @@ spring:
|
||||
datasource:
|
||||
druid:
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
loginUsername: admin
|
||||
loginPassword: 123456
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
dynamic:
|
||||
druid: # 全局druid参数,绝大部分值和默认保持一致。(现已支持的参数如下,不清楚含义不要乱设置)
|
||||
# 连接池的配置信息
|
||||
@ -111,6 +114,17 @@ spring:
|
||||
#mybatis plus 设置
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:org/jeecg/modules/**/xml/*Mapper.xml
|
||||
global-config:
|
||||
# 关闭MP3.0自带的banner
|
||||
banner: false
|
||||
db-config:
|
||||
#主键类型 0:"数据库ID自增",1:"该类型为未设置主键类型", 2:"用户输入ID",3:"全局唯一ID (数字类型唯一ID)", 4:"全局唯一ID UUID",5:"字符串全局唯一ID (idWorker 的字符串表示)";
|
||||
id-type: 4
|
||||
# 默认数据库表下划线命名
|
||||
table-underline: true
|
||||
#configuration:
|
||||
# 这个配置会将执行的sql打印出来,在开发或测试的时候可以用
|
||||
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
#jeecg专用配置
|
||||
jeecg :
|
||||
path :
|
||||
|
||||
@ -1,7 +1,14 @@
|
||||
(_) | | | |
|
||||
${AnsiColor.BRIGHT_BLUE}
|
||||
(_) | | | |
|
||||
_ ___ ___ ___ __ _ ______| |__ ___ ___ | |_
|
||||
| |/ _ \/ _ \/ __/ _` |______| '_ \ / _ \ / _ \| __|
|
||||
| | __/ __/ (_| (_| | | |_) | (_) | (_) | |_
|
||||
| |\___|\___|\___\__, | |_.__/ \___/ \___/ \__|
|
||||
_/ | __/ |
|
||||
|__/ |___/
|
||||
|__/ |___/
|
||||
|
||||
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
Jeecg Boot Version: 2.0.2
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
${AnsiColor.BLACK}
|
||||
|
||||
@ -125,19 +125,14 @@ public class ${entityName}Controller {
|
||||
@AutoLog(value = "${tableVo.ftlDescription}-通过id删除")
|
||||
@ApiOperation(value="${tableVo.ftlDescription}-通过id删除", notes="${tableVo.ftlDescription}-通过id删除")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<${entityName}> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<${entityName}> result = new Result<${entityName}>();
|
||||
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
|
||||
if(${entityName?uncap_first}==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = ${entityName?uncap_first}Service.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
try {
|
||||
${entityName?uncap_first}Service.removeById(id);
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败",e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -230,9 +225,7 @@ public class ${entityName}Controller {
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<${entityName}> list${entityName}s = ExcelImportUtil.importExcel(file.getInputStream(), ${entityName}.class, params);
|
||||
for (${entityName} ${entityName?uncap_first}Excel : list${entityName}s) {
|
||||
${entityName?uncap_first}Service.save(${entityName?uncap_first}Excel);
|
||||
}
|
||||
${entityName?uncap_first}Service.saveBatch(list${entityName}s);
|
||||
return Result.ok("文件导入成功!数据行数:" + list${entityName}s.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
<#else>
|
||||
</#if>
|
||||
</#list>
|
||||
</template>
|
||||
<#if (columns?size>1) >
|
||||
</template>
|
||||
</#if>
|
||||
<a-col :md="6" :sm="8" >
|
||||
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
||||
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
|
||||
|
||||
@ -117,19 +117,14 @@ public class ${entityName}Controller {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<${entityName}> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<${entityName}> result = new Result<${entityName}>();
|
||||
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
|
||||
if(${entityName?uncap_first}==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
boolean ok = ${entityName?uncap_first}Service.removeById(id);
|
||||
if(ok) {
|
||||
result.success("删除成功!");
|
||||
}
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
try {
|
||||
${entityName?uncap_first}Service.removeById(id);
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败",e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -218,9 +213,7 @@ public class ${entityName}Controller {
|
||||
params.setNeedSave(true);
|
||||
try {
|
||||
List<${entityName}> list${entityName}s = ExcelImportUtil.importExcel(file.getInputStream(), ${entityName}.class, params);
|
||||
for (${entityName} ${entityName?uncap_first}Excel : list${entityName}s) {
|
||||
${entityName?uncap_first}Service.save(${entityName?uncap_first}Excel);
|
||||
}
|
||||
${entityName?uncap_first}Service.saveBatch(list${entityName}s);
|
||||
return Result.ok("文件导入成功!数据行数:" + list${entityName}s.size());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
|
||||
@ -29,7 +29,9 @@
|
||||
<#else>
|
||||
</#if>
|
||||
</#list>
|
||||
</template>
|
||||
<#if (columns?size>1) >
|
||||
</template>
|
||||
</#if>
|
||||
<a-col :md="6" :sm="8" >
|
||||
<span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
|
||||
<a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
|
||||
|
||||
@ -129,17 +129,14 @@ public class ${entityName}Controller {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<${entityName}> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<${entityName}> result = new Result<${entityName}>();
|
||||
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
|
||||
if(${entityName?uncap_first}==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
try {
|
||||
${entityName?uncap_first}Service.delMain(id);
|
||||
result.success("删除成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败",e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -128,17 +128,14 @@ public class ${entityName}Controller {
|
||||
* @return
|
||||
*/
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<${entityName}> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<${entityName}> result = new Result<${entityName}>();
|
||||
${entityName} ${entityName?uncap_first} = ${entityName?uncap_first}Service.getById(id);
|
||||
if(${entityName?uncap_first}==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
try {
|
||||
${entityName?uncap_first}Service.delMain(id);
|
||||
result.success("删除成功!");
|
||||
} catch (Exception e) {
|
||||
log.error("删除失败",e.getMessage());
|
||||
return Result.error("删除失败!");
|
||||
}
|
||||
|
||||
return result;
|
||||
return Result.ok("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user