mirror of
https://github.com/jeecgboot/JeecgBoot.git
synced 2025-12-08 17:12:28 +08:00
JeecgBoot 2.4.6版本发布
This commit is contained in:
@ -10,6 +10,6 @@ WORKDIR /jeecg-boot
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
ADD ./target/jeecg-boot-module-system-2.4.5.jar ./
|
||||
ADD ./target/jeecg-boot-module-system-2.4.6.jar ./
|
||||
|
||||
CMD sleep 60;java -Djava.security.egd=file:/dev/./urandom -jar jeecg-boot-module-system-2.4.5.jar
|
||||
CMD sleep 60;java -Djava.security.egd=file:/dev/./urandom -jar jeecg-boot-module-system-2.4.6.jar
|
||||
@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-parent</artifactId>
|
||||
<version>2.4.5</version>
|
||||
<version>2.4.6</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<repository>
|
||||
<id>aliyun</id>
|
||||
<name>aliyun Repository</name>
|
||||
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
|
||||
<url>https://maven.aliyun.com/repository/public</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
@ -22,7 +22,7 @@
|
||||
<repository>
|
||||
<id>jeecg</id>
|
||||
<name>jeecg Repository</name>
|
||||
<url>http://maven.jeecg.org/nexus/content/repositories/jeecg</url>
|
||||
<url>https://maven.jeecg.org/nexus/content/repositories/jeecg</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
@ -34,28 +34,35 @@
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-system-local-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>jeewx-api</artifactId>
|
||||
<version>1.4.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- DEMO 示例模块 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.boot</groupId>
|
||||
<artifactId>jeecg-boot-module-demo</artifactId>
|
||||
<version>${jeecgboot.version}</version>
|
||||
<version>2.4.6</version>
|
||||
</dependency>
|
||||
<!-- jeewx api -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>spring-boot-starter-jimureport</artifactId>
|
||||
<version>1.3.4-beta</version>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>jeewx-api</artifactId>
|
||||
<version>1.4.5</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.jeecgframework</groupId>
|
||||
<artifactId>autopoi-web</artifactId>
|
||||
<artifactId>commons-beanutils</artifactId>
|
||||
<groupId>commons-beanutils</groupId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<groupId>commons-lang</groupId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 积木报表 -->
|
||||
<dependency>
|
||||
<groupId>org.jeecgframework.jimureport</groupId>
|
||||
<artifactId>jimureport-spring-boot-starter</artifactId>
|
||||
<version>1.3.78</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -12,6 +12,7 @@ import org.springframework.context.annotation.Configuration;
|
||||
* @Description: 代码生成器,自定义DB配置
|
||||
* 【加了此类,则online模式DB连接,使用平台的配置,jeecg_database.properties配置无效;
|
||||
* 但是使用GUI模式代码生成,还是走jeecg_database.properties配置】
|
||||
* 提醒: 达梦数据库需要修改下面的参数${spring.datasource.dynamic.datasource.master.url:}配置
|
||||
* @author: scott
|
||||
* @date: 2021年02月18日 16:30
|
||||
*/
|
||||
|
||||
@ -1,8 +1,8 @@
|
||||
package org.jeecg.modules.api.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.dto.message.*;
|
||||
import org.jeecg.common.api.dto.OnlineAuthDTO;
|
||||
import org.jeecg.common.api.dto.message.*;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.vo.*;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
@ -143,6 +143,17 @@ public class SystemAPIController {
|
||||
return sysBaseAPI.queryDictItemsByCode(code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取有效的数据字典
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryEnableDictItemsByCode")
|
||||
List<DictModel> queryEnableDictItemsByCode(@RequestParam("code") String code){
|
||||
return sysBaseAPI.queryEnableDictItemsByCode(code);
|
||||
}
|
||||
|
||||
|
||||
/** 查询所有的父级字典,按照create_time排序 */
|
||||
@GetMapping("/queryAllDict")
|
||||
List<DictModel> queryAllDict(){
|
||||
@ -158,17 +169,6 @@ public class SystemAPIController {
|
||||
return sysBaseAPI.queryAllDSysCategory();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表数据字典
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryTableDictItemsByCode")
|
||||
List<DictModel> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code){
|
||||
return sysBaseAPI.queryTableDictItemsByCode(table, text, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有部门 作为字典信息 id -->value,departName -->text
|
||||
@ -179,34 +179,6 @@ public class SystemAPIController {
|
||||
return sysBaseAPI.queryAllDepartBackDictModel();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 查询表字典 支持过滤数据
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryFilterTableDictInfo")
|
||||
List<DictModel> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql){
|
||||
return sysBaseAPI.queryFilterTableDictInfo(table, text, code, filterSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询指定table的 text code 获取字典,包含text和value
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyArray
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@GetMapping("/queryTableDictByKeys")
|
||||
public List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray){
|
||||
return sysBaseAPI.queryTableDictByKeys(table, text, code, keyArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有角色 带参
|
||||
* roleIds 默认选中角色
|
||||
@ -447,19 +419,6 @@ public class SystemAPIController {
|
||||
return sysBaseAPI.getCacheUser(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字典表的 翻译
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateDictFromTable")
|
||||
public String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key){
|
||||
return sysBaseAPI.translateDictFromTable(table, text, code, key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 普通字典的翻译
|
||||
* @param code
|
||||
@ -477,18 +436,18 @@ public class SystemAPIController {
|
||||
* @param usernames
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryUsersByUsernames")
|
||||
List<JSONObject> queryUsersByUsernames(String usernames){
|
||||
@RequestMapping("/queryUsersByUsernames")
|
||||
List<JSONObject> queryUsersByUsernames(@RequestParam("usernames") String usernames){
|
||||
return this.sysBaseAPI.queryUsersByUsernames(usernames);
|
||||
}
|
||||
|
||||
/**
|
||||
* 37根据多个用户id(逗号分隔),查询返回多个用户信息
|
||||
* @param usernames
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryUsersByIds")
|
||||
List<JSONObject> queryUsersByIds(String ids){
|
||||
@RequestMapping("/queryUsersByIds")
|
||||
List<JSONObject> queryUsersByIds(@RequestParam("ids") String ids){
|
||||
return this.sysBaseAPI.queryUsersByIds(ids);
|
||||
}
|
||||
|
||||
@ -498,18 +457,18 @@ public class SystemAPIController {
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDepartsByOrgcodes")
|
||||
List<JSONObject> queryDepartsByOrgcodes(String orgCodes){
|
||||
List<JSONObject> queryDepartsByOrgcodes(@RequestParam("orgCodes") String orgCodes){
|
||||
return this.sysBaseAPI.queryDepartsByOrgcodes(orgCodes);
|
||||
}
|
||||
|
||||
/**
|
||||
* 39根据多个部门ID(逗号分隔),查询返回多个部门信息
|
||||
* @param orgCodes
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryDepartsByIds")
|
||||
List<JSONObject> queryDepartsByIds(String orgCodes){
|
||||
return this.sysBaseAPI.queryDepartsByIds(orgCodes);
|
||||
List<JSONObject> queryDepartsByIds(@RequestParam("ids") String ids){
|
||||
return this.sysBaseAPI.queryDepartsByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -530,4 +489,146 @@ public class SystemAPIController {
|
||||
List<Map> getDeptUserByOrgCode(@RequestParam("orgCode")String orgCode){
|
||||
return this.sysBaseAPI.getDeptUserByOrgCode(orgCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分类字典翻译
|
||||
*
|
||||
* @param ids 分类字典表id
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadCategoryDictItem")
|
||||
public List<String> loadCategoryDictItem(@RequestParam("ids") String ids) {
|
||||
return sysBaseAPI.loadCategoryDictItem(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadDictItem")
|
||||
public List<String> loadDictItem(@RequestParam("dictCode") String dictCode, @RequestParam("keys") String keys) {
|
||||
return sysBaseAPI.loadDictItem(dictCode, keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code查询字典项
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param dictCode 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getDictItems")
|
||||
public List<DictModel> getDictItems(@RequestParam("dictCode") String dictCode) {
|
||||
return sysBaseAPI.getDictItems(dictCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据多个字典code查询多个字典项
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return key = dictCode ; value=对应的字典项
|
||||
*/
|
||||
@RequestMapping("/getManyDictItems")
|
||||
public Map<String, List<DictModel>> getManyDictItems(@RequestParam("dictCodeList") List<String> dictCodeList) {
|
||||
return sysBaseAPI.getManyDictItems(dictCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【下拉搜索】
|
||||
* 大数据量的字典表 走异步加载,即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @param keyword 过滤关键字
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/loadDictItemByKeyword")
|
||||
public List<DictModel> loadDictItemByKeyword(@RequestParam("dictCode") String dictCode, @RequestParam("keyword") String keyword, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
return sysBaseAPI.loadDictItemByKeyword(dictCode, keyword, pageSize);
|
||||
}
|
||||
|
||||
/**
|
||||
* 48 普通字典的翻译,根据多个dictCode和多条数据,多个以逗号分割
|
||||
* @param dictCodes
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateManyDict")
|
||||
public Map<String, List<DictModel>> translateManyDict(@RequestParam("dictCodes") String dictCodes, @RequestParam("keys") String keys){
|
||||
return this.sysBaseAPI.translateManyDict(dictCodes, keys);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取表数据字典 【接口签名验证】
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryTableDictItemsByCode")
|
||||
List<DictModel> queryTableDictItemsByCode(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code){
|
||||
return sysBaseAPI.queryTableDictItemsByCode(table, text, code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询表字典 支持过滤数据 【接口签名验证】
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/queryFilterTableDictInfo")
|
||||
List<DictModel> queryFilterTableDictInfo(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("filterSql") String filterSql){
|
||||
return sysBaseAPI.queryFilterTableDictInfo(table, text, code, filterSql);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 查询指定table的 text code 获取字典,包含text和value
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keyArray
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@GetMapping("/queryTableDictByKeys")
|
||||
public List<String> queryTableDictByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keyArray") String[] keyArray){
|
||||
return sysBaseAPI.queryTableDictByKeys(table, text, code, keyArray);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 字典表的 翻译【接口签名验证】
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateDictFromTable")
|
||||
public String translateDictFromTable(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("key") String key){
|
||||
return sysBaseAPI.translateDictFromTable(table, text, code, key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 49 字典表的 翻译,可批量
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys 多个用逗号分割
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/translateDictFromTableByKeys")
|
||||
public List<DictModel> translateDictFromTableByKeys(@RequestParam("table") String table, @RequestParam("text") String text, @RequestParam("code") String code, @RequestParam("keys") String keys) {
|
||||
return this.sysBaseAPI.translateDictFromTableByKeys(table, text, code, keys);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -11,6 +11,7 @@ import org.jeecg.modules.quartz.service.IQuartzJobService;
|
||||
import org.quartz.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@ -43,6 +44,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
* 保存&启动定时任务
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = JeecgBootException.class)
|
||||
public boolean saveAndScheduleJob(QuartzJob quartzJob) {
|
||||
// DB设置修改
|
||||
quartzJob.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
@ -60,6 +62,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
* 恢复定时任务
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = JeecgBootException.class)
|
||||
public boolean resumeJob(QuartzJob quartzJob) {
|
||||
schedulerDelete(quartzJob.getId());
|
||||
schedulerAdd(quartzJob.getId(), quartzJob.getJobClassName().trim(), quartzJob.getCronExpression().trim(), quartzJob.getParameter());
|
||||
@ -72,6 +75,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
* @throws SchedulerException
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = JeecgBootException.class)
|
||||
public boolean editAndScheduleJob(QuartzJob quartzJob) throws SchedulerException {
|
||||
if (CommonConstant.STATUS_NORMAL.equals(quartzJob.getStatus())) {
|
||||
schedulerDelete(quartzJob.getId());
|
||||
@ -86,6 +90,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
* 删除&停止删除定时任务
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = JeecgBootException.class)
|
||||
public boolean deleteAndStopJob(QuartzJob job) {
|
||||
schedulerDelete(job.getId());
|
||||
boolean ok = this.removeById(job.getId());
|
||||
@ -116,6 +121,7 @@ public class QuartzJobServiceImpl extends ServiceImpl<QuartzJobMapper, QuartzJob
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = JeecgBootException.class)
|
||||
public void pause(QuartzJob quartzJob){
|
||||
schedulerDelete(quartzJob.getId());
|
||||
quartzJob.setStatus(CommonConstant.STATUS_DISABLE);
|
||||
|
||||
@ -211,7 +211,7 @@ public class CommonController {
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
imgPath = imgPath.replace("..", "");
|
||||
imgPath = imgPath.replace("..", "").replace("../","");
|
||||
if (imgPath.endsWith(",")) {
|
||||
imgPath = imgPath.substring(0, imgPath.length() - 1);
|
||||
}
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.aliyuncs.exceptions.ClientException;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -13,18 +12,16 @@ 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.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.common.util.encryption.EncryptedString;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.system.entity.SysDepart;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.SysLoginModel;
|
||||
import org.jeecg.modules.system.service.ISysDepartService;
|
||||
import org.jeecg.modules.system.service.ISysDictService;
|
||||
import org.jeecg.modules.system.service.ISysLogService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.util.RandImageUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -55,6 +52,8 @@ public class LoginController {
|
||||
@Autowired
|
||||
private ISysDepartService sysDepartService;
|
||||
@Autowired
|
||||
private ISysTenantService sysTenantService;
|
||||
@Autowired
|
||||
private ISysDictService sysDictService;
|
||||
@Resource
|
||||
private BaseCommonService baseCommonService;
|
||||
@ -357,12 +356,6 @@ public class LoginController {
|
||||
private Result<JSONObject> userInfo(SysUser sysUser, Result<JSONObject> result) {
|
||||
String syspassword = sysUser.getPassword();
|
||||
String username = sysUser.getUsername();
|
||||
// 生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
// 设置token缓存有效时间
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME*2 / 1000);
|
||||
|
||||
// 获取用户部门信息
|
||||
JSONObject obj = new JSONObject();
|
||||
List<SysDepart> departs = sysDepartService.queryUserDeparts(sysUser.getId());
|
||||
@ -382,6 +375,25 @@ public class LoginController {
|
||||
// update-end--Author:wangshuai Date:20200805 for:如果用戶为选择部门,数据库为存在上一次登录部门,则取一条存进去
|
||||
obj.put("multi_depart", 2);
|
||||
}
|
||||
// update-begin--Author:sunjianlei Date:20210802 for:获取用户租户信息
|
||||
String tenantIds = sysUser.getRelTenantIds();
|
||||
if (oConvertUtils.isNotEmpty(tenantIds)) {
|
||||
List<String> tenantIdList = Arrays.asList(tenantIds.split(","));
|
||||
// 该方法仅查询有效的租户,如果返回0个就说明所有的租户均无效。
|
||||
List<SysTenant> tenantList = sysTenantService.queryEffectiveTenant(tenantIdList);
|
||||
if (tenantList.size() == 0) {
|
||||
result.error500("与该用户关联的租户均已被冻结,无法登录!");
|
||||
return result;
|
||||
} else {
|
||||
obj.put("tenantList", tenantList);
|
||||
}
|
||||
}
|
||||
// update-end--Author:sunjianlei Date:20210802 for:获取用户租户信息
|
||||
// 生成token
|
||||
String token = JwtUtil.sign(username, syspassword);
|
||||
// 设置token缓存有效时间
|
||||
redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
|
||||
obj.put("token", token);
|
||||
obj.put("userInfo", sysUser);
|
||||
obj.put("sysAllDictItems", sysDictService.queryAllDictItems());
|
||||
|
||||
@ -26,6 +26,7 @@ import org.jeecg.modules.system.service.ISysAnnouncementSendService;
|
||||
import org.jeecg.modules.system.service.ISysAnnouncementService;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
|
||||
import org.jeecg.modules.system.util.XSSUtils;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
@ -119,6 +120,10 @@ public class SysAnnouncementController {
|
||||
public Result<SysAnnouncement> add(@RequestBody SysAnnouncement sysAnnouncement) {
|
||||
Result<SysAnnouncement> result = new Result<SysAnnouncement>();
|
||||
try {
|
||||
// update-begin-author:liusq date:20210804 for:标题处理xss攻击的问题
|
||||
String title = XSSUtils.striptXSS(sysAnnouncement.getTitile());
|
||||
sysAnnouncement.setTitile(title);
|
||||
// update-end-author:liusq date:20210804 for:标题处理xss攻击的问题
|
||||
sysAnnouncement.setDelFlag(CommonConstant.DEL_FLAG_0.toString());
|
||||
sysAnnouncement.setSendStatus(CommonSendStatus.UNPUBLISHED_STATUS_0);//未发布
|
||||
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
|
||||
@ -142,6 +147,10 @@ public class SysAnnouncementController {
|
||||
if(sysAnnouncementEntity==null) {
|
||||
result.error500("未找到对应实体");
|
||||
}else {
|
||||
// update-begin-author:liusq date:20210804 for:标题处理xss攻击的问题
|
||||
String title = XSSUtils.striptXSS(sysAnnouncement.getTitile());
|
||||
sysAnnouncement.setTitile(title);
|
||||
// update-end-author:liusq date:20210804 for:标题处理xss攻击的问题
|
||||
boolean ok = sysAnnouncementService.upDateAnnouncement(sysAnnouncement);
|
||||
//TODO 返回false说明什么?
|
||||
if(ok) {
|
||||
|
||||
@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
@ -71,8 +72,13 @@ public class SysDepartController {
|
||||
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
try {
|
||||
if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){
|
||||
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(user.getDepartIds());
|
||||
result.setResult(list);
|
||||
//update-begin--Author:liusq Date:20210624 for:部门查询ids为空后的前端显示问题 issues/I3UD06
|
||||
String departIds = user.getDepartIds();
|
||||
if(StringUtils.isNotBlank(departIds)){
|
||||
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(departIds);
|
||||
result.setResult(list);
|
||||
}
|
||||
//update-end--Author:liusq Date:20210624 for:部门查询ids为空后的前端显示问题 issues/I3UD06
|
||||
result.setMessage(CommonConstant.USER_IDENTITY_2.toString());
|
||||
result.setSuccess(true);
|
||||
}else{
|
||||
|
||||
@ -111,33 +111,6 @@ public class SysDictController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
* @param dictCode 字典code
|
||||
* @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
|
||||
log.info(" dictCode : "+ dictCode);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
try {
|
||||
List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
if (ls == null) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.debug(result.toString());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取全部字典数据
|
||||
*
|
||||
@ -172,7 +145,36 @@ public class SysDictController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取字典数据 【接口签名验证】
|
||||
* @param dictCode 字典code
|
||||
* @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign,HttpServletRequest request) {
|
||||
log.info(" dictCode : "+ dictCode);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
try {
|
||||
List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
if (ls == null) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.debug(result.toString());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
@ -203,6 +205,7 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 【给表单设计器的表字典使用】下拉搜索模式,有值时动态拼接数据
|
||||
* @param dictCode
|
||||
* @param keyword 当前控件的值,可以逗号分割
|
||||
@ -243,7 +246,7 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 【接口签名验证】
|
||||
* 根据字典code加载字典text 返回
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
@ -280,6 +283,7 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 【接口签名验证】
|
||||
* 根据表名——显示字段-存储字段 pid 加载树形数据
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -378,7 +382,7 @@ public class SysDictController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDict> delete(@RequestParam(name="id",required=true) String id) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
boolean ok = sysDictService.removeById(id);
|
||||
@ -397,7 +401,7 @@ public class SysDictController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDict> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
Result<SysDict> result = new Result<SysDict>();
|
||||
if(oConvertUtils.isEmpty(ids)) {
|
||||
@ -418,6 +422,7 @@ public class SysDictController {
|
||||
Result<?> result = new Result<SysDict>();
|
||||
//清空字典缓存
|
||||
Set keys = redisTemplate.keys(CacheConstant.SYS_DICT_CACHE + "*");
|
||||
Set keys7 = redisTemplate.keys(CacheConstant.SYS_ENABLE_DICT_CACHE + "*");
|
||||
Set keys2 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_CACHE + "*");
|
||||
Set keys21 = redisTemplate.keys(CacheConstant.SYS_DICT_TABLE_BY_KEYS_CACHE + "*");
|
||||
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*");
|
||||
@ -431,6 +436,7 @@ public class SysDictController {
|
||||
redisTemplate.delete(keys4);
|
||||
redisTemplate.delete(keys5);
|
||||
redisTemplate.delete(keys6);
|
||||
redisTemplate.delete(keys7);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -562,7 +568,7 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 取回
|
||||
* 逻辑删除的字段,进行取回
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
|
||||
@ -73,7 +73,7 @@ public class SysDictItemController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/add", method = RequestMethod.POST)
|
||||
@CacheEvict(value= CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
@CacheEvict(value= {CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDictItem> add(@RequestBody SysDictItem sysDictItem) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
try {
|
||||
@ -94,7 +94,7 @@ public class SysDictItemController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/edit", method = RequestMethod.PUT)
|
||||
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_DICT_CACHE}, allEntries=true)
|
||||
public Result<SysDictItem> edit(@RequestBody SysDictItem sysDictItem) {
|
||||
Result<SysDictItem> result = new Result<SysDictItem>();
|
||||
SysDictItem sysdict = sysDictItemService.getById(sysDictItem.getId());
|
||||
@ -118,7 +118,7 @@ public class SysDictItemController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_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);
|
||||
@ -140,7 +140,7 @@ public class SysDictItemController {
|
||||
*/
|
||||
//@RequiresRoles({"admin"})
|
||||
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE)
|
||||
@CacheEvict(value=CacheConstant.SYS_DICT_CACHE, allEntries=true)
|
||||
@CacheEvict(value={CacheConstant.SYS_DICT_CACHE, CacheConstant.SYS_ENABLE_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())) {
|
||||
|
||||
@ -5,11 +5,11 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresRoles;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.constant.enums.RoleIndexConfigEnum;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.MD5Util;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
@ -52,6 +52,9 @@ public class SysPermissionController {
|
||||
@Autowired
|
||||
private ISysDepartPermissionService sysDepartPermissionService;
|
||||
|
||||
@Autowired
|
||||
private ISysUserService sysUserService;
|
||||
|
||||
/**
|
||||
* 加载数据节点
|
||||
*
|
||||
@ -212,6 +215,18 @@ public class SysPermissionController {
|
||||
//update-begin-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
if(!PermissionDataUtil.hasIndexPage(metaList)){
|
||||
SysPermission indexMenu = sysPermissionService.list(new LambdaQueryWrapper<SysPermission>().eq(SysPermission::getName,"首页")).get(0);
|
||||
//update-begin--Author:liusq Date:20210624 for:自定义首页地址LOWCOD-1578
|
||||
List<String> roles = sysUserService.getRole(loginUser.getUsername());
|
||||
if(roles.size()>0){
|
||||
for (String code:roles) {
|
||||
String componentUrl = RoleIndexConfigEnum.getIndexByCode(code);
|
||||
if(StringUtils.isNotBlank(componentUrl)){
|
||||
indexMenu.setComponent(componentUrl);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//update-end--Author:liusq Date:20210624 for:自定义首页地址LOWCOD-1578
|
||||
metaList.add(0,indexMenu);
|
||||
}
|
||||
//update-end-author:taoyan date:20200211 for: TASK #3368 【路由缓存】首页的缓存设置有问题,需要根据后台的路由配置来实现是否缓存
|
||||
|
||||
@ -14,9 +14,9 @@ import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.service.ISysTenantService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -99,7 +99,7 @@ public class SysTenantController {
|
||||
*/
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.DELETE)
|
||||
public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
||||
sysTenantService.removeById(id);
|
||||
sysTenantService.removeTenantById(id);
|
||||
return Result.ok("删除成功");
|
||||
}
|
||||
|
||||
@ -114,9 +114,25 @@ public class SysTenantController {
|
||||
if(oConvertUtils.isEmpty(ids)) {
|
||||
result.error500("未选中租户!");
|
||||
}else {
|
||||
List<String> ls = Arrays.asList(ids.split(","));
|
||||
sysTenantService.removeByIds(ls);
|
||||
result.success("删除成功!");
|
||||
String[] ls = ids.split(",");
|
||||
// 过滤掉已被引用的租户
|
||||
List<String> idList = new ArrayList<>();
|
||||
for (String id : ls) {
|
||||
int userCount = sysTenantService.countUserLinkTenant(id);
|
||||
if (userCount == 0) {
|
||||
idList.add(id);
|
||||
}
|
||||
}
|
||||
if (idList.size() > 0) {
|
||||
sysTenantService.removeByIds(idList);
|
||||
if (ls.length == idList.size()) {
|
||||
result.success("删除成功!");
|
||||
} else {
|
||||
result.success("部分删除成功!(被引用的租户无法删除)");
|
||||
}
|
||||
}else {
|
||||
result.error500("选择的租户都已被引用,无法删除!");
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -942,42 +942,42 @@ public class SysUserController {
|
||||
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 user = sysUserService.getUserByPhone(phone);
|
||||
if(user!=null) {
|
||||
map.put("username",user.getUsername());
|
||||
map.put("phone",user.getPhone());
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
if (oConvertUtils.isNotEmpty(username)) {
|
||||
SysUser user = sysUserService.getUserByName(username);
|
||||
if(user!=null) {
|
||||
map.put("username",user.getUsername());
|
||||
map.put("phone",user.getPhone());
|
||||
result.setSuccess(true);
|
||||
result.setResult(map);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
result.setSuccess(false);
|
||||
result.setMessage("验证失败");
|
||||
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 user = sysUserService.getUserByPhone(phone);
|
||||
// if(user!=null) {
|
||||
// map.put("username",user.getUsername());
|
||||
// map.put("phone",user.getPhone());
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(map);
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
// if (oConvertUtils.isNotEmpty(username)) {
|
||||
// SysUser user = sysUserService.getUserByName(username);
|
||||
// if(user!=null) {
|
||||
// map.put("username",user.getUsername());
|
||||
// map.put("phone",user.getPhone());
|
||||
// result.setSuccess(true);
|
||||
// result.setResult(map);
|
||||
// return result;
|
||||
// }
|
||||
// }
|
||||
// result.setSuccess(false);
|
||||
// result.setMessage("验证失败");
|
||||
// return result;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 用户手机号验证
|
||||
*/
|
||||
@ -1028,7 +1028,7 @@ public class SysUserController {
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
if(!smscode.equals(object)) {
|
||||
if(!smscode.equals(object.toString())) {
|
||||
result.setMessage("短信验证码不匹配!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
@ -1347,7 +1347,7 @@ public class SysUserController {
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
if(!smscode.equals(object)) {
|
||||
if(!smscode.equals(object.toString())) {
|
||||
result.setMessage("短信验证码不匹配!");
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
@ -1361,5 +1361,21 @@ public class SysUserController {
|
||||
return Result.ok("手机号设置成功!");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据对象里面的属性值作in查询 属性可能会变 用户组件用到
|
||||
* @param sysUser
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/getMultiUser")
|
||||
public List<SysUser> getMultiUser(SysUser sysUser){
|
||||
QueryWrapper<SysUser> queryWrapper = QueryGenerator.initQueryWrapper(sysUser, null);
|
||||
List<SysUser> ls = this.sysUserService.list(queryWrapper);
|
||||
for(SysUser user: ls){
|
||||
user.setPassword(null);
|
||||
user.setSalt(null);
|
||||
}
|
||||
return ls;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,7 +1,11 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
@ -14,17 +18,15 @@ import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.jeecg.modules.system.vo.SysOnlineVO;
|
||||
import org.jeecg.modules.system.vo.SysUserOnlineVO;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @Description: 在线用户
|
||||
@ -35,7 +37,7 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequestMapping("/sys/online")
|
||||
@Slf4j
|
||||
public class SysOnlineController {
|
||||
public class SysUserOnlineController {
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
@ -53,13 +55,13 @@ public class SysOnlineController {
|
||||
private BaseCommonService baseCommonService;
|
||||
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
public Result<Page<SysOnlineVO>> list(@RequestParam(name="username", required=false) String username, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||
public Result<Page<SysUserOnlineVO>> list(@RequestParam(name="username", required=false) String username, @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
|
||||
Collection<String> keys = redisTemplate.keys(CommonConstant.PREFIX_USER_TOKEN + "*");
|
||||
SysOnlineVO online;
|
||||
List<SysOnlineVO> onlineList = new ArrayList<SysOnlineVO>();
|
||||
SysUserOnlineVO online;
|
||||
List<SysUserOnlineVO> onlineList = new ArrayList<SysUserOnlineVO>();
|
||||
for (String key : keys) {
|
||||
online = new SysOnlineVO();
|
||||
online = new SysUserOnlineVO();
|
||||
String token = (String) redisUtil.get(key);
|
||||
if (!StringUtils.isEmpty(token)){
|
||||
online.setToken(token);
|
||||
@ -75,9 +77,9 @@ public class SysOnlineController {
|
||||
}
|
||||
}
|
||||
|
||||
Page<SysOnlineVO> page = new Page<SysOnlineVO>(pageNo, pageSize);
|
||||
Page<SysUserOnlineVO> page = new Page<SysUserOnlineVO>(pageNo, pageSize);
|
||||
int count = onlineList.size();
|
||||
List<SysOnlineVO> pages = new ArrayList<>();
|
||||
List<SysUserOnlineVO> pages = new ArrayList<>();
|
||||
//计算当前页第一条数据的下标
|
||||
int currId = pageNo>1 ? (pageNo-1)*pageSize:0;
|
||||
for (int i=0; i<pageSize && i<count - currId;i++){
|
||||
@ -92,7 +94,7 @@ public class SysOnlineController {
|
||||
|
||||
Collections.reverse(onlineList);
|
||||
onlineList.removeAll(Collections.singleton(null));
|
||||
Result<Page<SysOnlineVO>> result = new Result<Page<SysOnlineVO>>();
|
||||
Result<Page<SysUserOnlineVO>> result = new Result<Page<SysUserOnlineVO>>();
|
||||
result.setSuccess(true);
|
||||
result.setResult(page);
|
||||
return result;
|
||||
@ -102,7 +104,7 @@ public class SysOnlineController {
|
||||
* 强退用户
|
||||
*/
|
||||
@RequestMapping(value = "/forceLogout",method = RequestMethod.POST)
|
||||
public Result<Object> forceLogout(@RequestBody SysOnlineVO online) {
|
||||
public Result<Object> forceLogout(@RequestBody SysUserOnlineVO online) {
|
||||
//用户退出逻辑
|
||||
if(oConvertUtils.isEmpty(online.getToken())) {
|
||||
return Result.error("退出登录失败!");
|
||||
@ -1,6 +1,5 @@
|
||||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import cn.hutool.crypto.SecureUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.xkcoding.justauth.AuthRequestFactory;
|
||||
@ -11,18 +10,22 @@ import me.zhyd.oauth.model.AuthResponse;
|
||||
import me.zhyd.oauth.request.AuthRequest;
|
||||
import me.zhyd.oauth.utils.AuthStateUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.util.*;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.common.system.util.JwtUtil;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.PasswordUtil;
|
||||
import org.jeecg.common.util.RedisUtil;
|
||||
import org.jeecg.common.util.RestUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.thirdapp.ThirdAppConfig;
|
||||
import org.jeecg.config.thirdapp.ThirdAppTypeItemVo;
|
||||
import org.jeecg.modules.base.service.BaseCommonService;
|
||||
import org.jeecg.modules.system.entity.SysThirdAccount;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.ThirdLoginModel;
|
||||
import org.jeecg.modules.system.service.ISysThirdAccountService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppDingtalkServiceImpl;
|
||||
import org.jeecg.modules.system.service.impl.ThirdAppWechatEnterpriseServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.ModelMap;
|
||||
@ -30,7 +33,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Date;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -45,7 +49,7 @@ public class ThirdLoginController {
|
||||
private ISysUserService sysUserService;
|
||||
@Autowired
|
||||
private ISysThirdAccountService sysThirdAccountService;
|
||||
|
||||
|
||||
@Autowired
|
||||
private BaseCommonService baseCommonService;
|
||||
@Autowired
|
||||
@ -53,6 +57,13 @@ public class ThirdLoginController {
|
||||
@Autowired
|
||||
private AuthRequestFactory factory;
|
||||
|
||||
@Autowired
|
||||
ThirdAppConfig thirdAppConfig;
|
||||
@Autowired
|
||||
private ThirdAppWechatEnterpriseServiceImpl thirdAppWechatEnterpriseService;
|
||||
@Autowired
|
||||
private ThirdAppDingtalkServiceImpl thirdAppDingtalkService;
|
||||
|
||||
@RequestMapping("/render/{source}")
|
||||
public void render(@PathVariable("source") String source, HttpServletResponse response) throws IOException {
|
||||
log.info("第三方登录进入render:" + source);
|
||||
@ -61,7 +72,7 @@ public class ThirdLoginController {
|
||||
log.info("第三方登录认证地址:" + authorizeUrl);
|
||||
response.sendRedirect(authorizeUrl);
|
||||
}
|
||||
|
||||
|
||||
@RequestMapping("/{source}/callback")
|
||||
public String loginThird(@PathVariable("source") String source, AuthCallback callback,ModelMap modelMap) {
|
||||
log.info("第三方登录进入callback:" + source + " params:" + JSONObject.toJSONString(callback));
|
||||
@ -70,7 +81,7 @@ public class ThirdLoginController {
|
||||
log.info(JSONObject.toJSONString(response));
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
if(response.getCode()==2000) {
|
||||
|
||||
|
||||
JSONObject data = JSONObject.parseObject(JSONObject.toJSONString(response.getData()));
|
||||
String username = data.getString("username");
|
||||
String avatar = data.getString("avatar");
|
||||
@ -86,7 +97,7 @@ public class ThirdLoginController {
|
||||
SysThirdAccount user = null;
|
||||
if(thridList==null || thridList.size()==0) {
|
||||
//否则直接创建新账号
|
||||
user = saveThirdUser(tlm);
|
||||
user = sysThirdAccountService.saveThirdUser(tlm);
|
||||
}else {
|
||||
//已存在 只设置用户名 不设置头像
|
||||
user = thridList.get(0);
|
||||
@ -130,7 +141,7 @@ public class ThirdLoginController {
|
||||
}
|
||||
//创建新账号
|
||||
//update-begin-author:wangshuai date:20201118 for:修改成从第三方登录查出来的user_id,在查询用户表尽行token
|
||||
SysThirdAccount user = saveThirdUser(model);
|
||||
SysThirdAccount user = sysThirdAccountService.saveThirdUser(model);
|
||||
if(oConvertUtils.isNotEmpty(user.getSysUserId())){
|
||||
String sysUserId = user.getSysUserId();
|
||||
SysUser sysUser = sysUserService.getById(sysUserId);
|
||||
@ -173,7 +184,7 @@ public class ThirdLoginController {
|
||||
result.setSuccess(false);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
sysUserService.updateById(user);
|
||||
result.setSuccess(true);
|
||||
// 生成token
|
||||
@ -182,22 +193,6 @@ public class ThirdLoginController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新用户
|
||||
* @param tlm 第三方登录信息
|
||||
*/
|
||||
private SysThirdAccount saveThirdUser(ThirdLoginModel tlm){
|
||||
SysThirdAccount user = new SysThirdAccount();
|
||||
user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
user.setStatus(1);
|
||||
user.setThirdType(tlm.getSource());
|
||||
user.setAvatar(tlm.getAvatar());
|
||||
user.setRealname(tlm.getUsername());
|
||||
user.setThirdUserUuid(tlm.getUuid());
|
||||
sysThirdAccountService.save(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
private String saveToken(SysUser user) {
|
||||
// 生成token
|
||||
String token = JwtUtil.sign(user.getUsername(), user.getPassword());
|
||||
@ -206,14 +201,14 @@ public class ThirdLoginController {
|
||||
redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME / 1000);
|
||||
return token;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@RequestMapping(value = "/getLoginUser/{token}/{thirdType}", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Result<JSONObject> getThirdLoginUser(@PathVariable("token") String token,@PathVariable("thirdType") String thirdType) throws Exception {
|
||||
Result<JSONObject> result = new Result<JSONObject>();
|
||||
String username = JwtUtil.getUsername(token);
|
||||
|
||||
|
||||
//1. 校验用户是否有效
|
||||
SysUser sysUser = sysUserService.getUserByName(username);
|
||||
result = sysUserService.checkUserIsEffective(sysUser);
|
||||
@ -277,4 +272,118 @@ public class ThirdLoginController {
|
||||
result.setResult(token);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业微信/钉钉 OAuth2登录
|
||||
*
|
||||
* @param source
|
||||
* @param state
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping("/oauth2/{source}/login")
|
||||
public String oauth2LoginCallback(@PathVariable("source") String source, @RequestParam("state") String state, HttpServletResponse response) throws Exception {
|
||||
String url;
|
||||
if (ThirdAppConfig.WECHAT_ENTERPRISE.equalsIgnoreCase(source)) {
|
||||
ThirdAppTypeItemVo config = thirdAppConfig.getWechatEnterprise();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// 构造企业微信OAuth2登录授权地址
|
||||
builder.append("https://open.weixin.qq.com/connect/oauth2/authorize");
|
||||
// 企业的CorpID
|
||||
builder.append("?appid=").append(config.getClientId());
|
||||
// 授权后重定向的回调链接地址,请使用urlencode对链接进行处理
|
||||
String redirectUri = RestUtil.getBaseUrl() + "/sys/thirdLogin/oauth2/wechat_enterprise/callback";
|
||||
builder.append("&redirect_uri=").append(URLEncoder.encode(redirectUri, "UTF-8"));
|
||||
// 返回类型,此时固定为:code
|
||||
builder.append("&response_type=code");
|
||||
// 应用授权作用域。
|
||||
// snsapi_base:静默授权,可获取成员的的基础信息(UserId与DeviceId);
|
||||
builder.append("&scope=snsapi_base");
|
||||
// 重定向后会带上state参数,长度不可超过128个字节
|
||||
builder.append("&state=").append(state);
|
||||
// 终端使用此参数判断是否需要带上身份信息
|
||||
builder.append("#wechat_redirect");
|
||||
url = builder.toString();
|
||||
} else if (ThirdAppConfig.DINGTALK.equalsIgnoreCase(source)) {
|
||||
ThirdAppTypeItemVo config = thirdAppConfig.getDingtalk();
|
||||
StringBuilder builder = new StringBuilder();
|
||||
// 构造钉钉OAuth2登录授权地址
|
||||
builder.append("https://login.dingtalk.com/oauth2/auth");
|
||||
// 授权通过/拒绝后回调地址。
|
||||
// 注意 需要与注册应用时登记的域名保持一致。
|
||||
String redirectUri = RestUtil.getBaseUrl() + "/sys/thirdLogin/oauth2/dingtalk/callback";
|
||||
builder.append("?redirect_uri=").append(URLEncoder.encode(redirectUri, "UTF-8"));
|
||||
// 固定值为code。
|
||||
// 授权通过后返回authCode。
|
||||
builder.append("&response_type=code");
|
||||
// 步骤一中创建的应用详情中获取。
|
||||
// 企业内部应用:client_id为应用的AppKey。
|
||||
builder.append("&client_id=").append(config.getClientId());
|
||||
// 授权范围,授权页面显示的授权信息以应用注册时配置的为准。
|
||||
// openid:授权后可获得用户userid
|
||||
builder.append("&scope=openid");
|
||||
// 跟随authCode原样返回。
|
||||
builder.append("&state=").append(state);
|
||||
url = builder.toString();
|
||||
} else {
|
||||
return "不支持的source";
|
||||
}
|
||||
log.info("oauth2 login url:" + url);
|
||||
response.sendRedirect(url);
|
||||
return "login…";
|
||||
}
|
||||
|
||||
/**
|
||||
* 企业微信/钉钉 OAuth2登录回调
|
||||
*
|
||||
* @param code
|
||||
* @param state
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping("/oauth2/{source}/callback")
|
||||
public String oauth2LoginCallback(
|
||||
@PathVariable("source") String source,
|
||||
// 企业微信返回的code
|
||||
@RequestParam(value = "code", required = false) String code,
|
||||
// 钉钉返回的code
|
||||
@RequestParam(value = "authCode", required = false) String authCode,
|
||||
@RequestParam("state") String state,
|
||||
HttpServletResponse response
|
||||
) {
|
||||
SysUser loginUser;
|
||||
if (ThirdAppConfig.WECHAT_ENTERPRISE.equalsIgnoreCase(source)) {
|
||||
log.info("【企业微信】OAuth2登录进入callback:code=" + code + ", state=" + state);
|
||||
loginUser = thirdAppWechatEnterpriseService.oauth2Login(code);
|
||||
if (loginUser == null) {
|
||||
return "登录失败";
|
||||
}
|
||||
} else if (ThirdAppConfig.DINGTALK.equalsIgnoreCase(source)) {
|
||||
log.info("【钉钉】OAuth2登录进入callback:authCode=" + authCode + ", state=" + state);
|
||||
loginUser = thirdAppDingtalkService.oauth2Login(authCode);
|
||||
if (loginUser == null) {
|
||||
return "登录失败";
|
||||
}
|
||||
} else {
|
||||
return "不支持的source";
|
||||
}
|
||||
try {
|
||||
String token = saveToken(loginUser);
|
||||
state += "/oauth2-app/login?oauth2LoginToken=" + URLEncoder.encode(token, "UTF-8");
|
||||
state += "&thirdType=" + "wechat_enterprise";
|
||||
log.info("OAuth2登录重定向地址: " + state);
|
||||
try {
|
||||
response.sendRedirect(state);
|
||||
return "ok";
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return "重定向失败";
|
||||
}
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return "解码失败";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,20 +1,20 @@
|
||||
package org.jeecg.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.DictModelMany;
|
||||
import org.jeecg.common.system.vo.DictQuery;
|
||||
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;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@ -30,11 +30,29 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* 重复检查SQL
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
public Long duplicateCheckCountSql(DuplicateCheckVo duplicateCheckVo);
|
||||
@Deprecated
|
||||
public Long duplicateCheckCountSqlNoDataId(DuplicateCheckVo duplicateCheckVo);
|
||||
|
||||
public List<DictModel> queryDictItemsByCode(@Param("code") String code);
|
||||
|
||||
/**
|
||||
* 查询有效的数据字典项
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryEnableDictItemsByCode(@Param("code") String code);
|
||||
|
||||
|
||||
/**
|
||||
* 通过多个字典code获取字典数据
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return
|
||||
*/
|
||||
public List<DictModelMany> queryDictItemsByCodeList(@Param("dictCodeList") List<String> dictCodeList);
|
||||
|
||||
@Deprecated
|
||||
public List<DictModel> queryTableDictItemsByCode(@Param("table") String table,@Param("text") String text,@Param("code") String code);
|
||||
|
||||
@ -47,9 +65,29 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
|
||||
public String queryDictTextByKey(@Param("code") String code,@Param("key") String key);
|
||||
|
||||
/**
|
||||
* 可通过多个字典code查询翻译文本
|
||||
* @param dictCodeList 多个字典code
|
||||
* @param keys 数据列表
|
||||
* @return
|
||||
*/
|
||||
List<DictModelMany> queryManyDictByKeys(@Param("dictCodeList") List<String> dictCodeList, @Param("keys") List<String> keys);
|
||||
|
||||
@Deprecated
|
||||
public String queryTableDictTextByKey(@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("key") String key);
|
||||
|
||||
/**
|
||||
* 通过查询指定table的 text code key 获取字典值,可批量查询
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
List<DictModel> queryTableDictTextByKeys(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keys") List<String> keys);
|
||||
|
||||
@Deprecated
|
||||
public List<DictModel> queryTableDictByKeys(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("keyArray") String[] keyArray);
|
||||
|
||||
@ -142,6 +180,7 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
IPage<DictModel> queryTableDictWithFilter(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
|
||||
|
||||
/**
|
||||
@ -152,5 +191,6 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
List<DictModel> queryAllTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
|
||||
}
|
||||
|
||||
@ -131,6 +131,7 @@ public interface SysUserMapper extends BaseMapper<SysUser> {
|
||||
int deleteLogicDeleted(@Param("userIds") String userIds);
|
||||
|
||||
/** 更新空字符串为null【此写法有sql注入风险,禁止随便用】 */
|
||||
@Deprecated
|
||||
int updateNullByEmptyString(@Param("fieldName") String fieldName);
|
||||
|
||||
/**
|
||||
|
||||
@ -8,7 +8,32 @@
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
order by s.sort_order asc
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 通过字典code获取有效的字典数据项 -->
|
||||
<select id="queryEnableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select s.item_value as "value",s.item_text as "text" from sys_dict_item s
|
||||
where dict_id = (select id from sys_dict where dict_code = #{code})
|
||||
and s.status = 1
|
||||
order by s.sort_order asc
|
||||
</select>
|
||||
|
||||
<!-- 通过多个字典code获取字典数据 -->
|
||||
<select id="queryDictItemsByCodeList" parameterType="String" resultType="org.jeecg.common.system.vo.DictModelMany">
|
||||
SELECT
|
||||
dict.dict_code,
|
||||
item.item_text AS "text",
|
||||
item.item_value AS "value"
|
||||
FROM
|
||||
sys_dict_item item
|
||||
INNER JOIN sys_dict dict ON dict.id = item.dict_id
|
||||
WHERE dict.dict_code IN (
|
||||
<foreach item="dictCode" collection="dictCodeList" separator=",">
|
||||
#{dictCode}
|
||||
</foreach>
|
||||
)
|
||||
ORDER BY item.sort_order ASC
|
||||
</select>
|
||||
|
||||
<!-- 通过字典code获取字典数据 -->
|
||||
<select id="queryDictTextByKey" parameterType="String" resultType="String">
|
||||
select s.item_text from sys_dict_item s
|
||||
@ -16,6 +41,26 @@
|
||||
and s.item_value = #{key}
|
||||
</select>
|
||||
|
||||
<!-- 通过字典code获取字典数据,可批量查询 -->
|
||||
<select id="queryManyDictByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModelMany">
|
||||
SELECT
|
||||
dict.dict_code,
|
||||
item.item_text AS "text",
|
||||
item.item_value AS "value"
|
||||
FROM
|
||||
sys_dict_item item
|
||||
INNER JOIN sys_dict dict ON dict.id = item.dict_id
|
||||
WHERE dict.dict_code IN (
|
||||
<foreach item="dictCode" collection="dictCodeList" separator=",">
|
||||
#{dictCode}
|
||||
</foreach>
|
||||
)
|
||||
AND item.item_value IN (
|
||||
<foreach item="key" collection="keys" separator=",">
|
||||
#{key}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典-->
|
||||
<select id="queryTableDictItemsByCode" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
@ -35,6 +80,15 @@
|
||||
select ${text} as "text" from ${table} where ${code}= #{key}
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code key 获取字典值,可批量查询-->
|
||||
<select id="queryTableDictTextByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table} where ${code} IN (
|
||||
<foreach item="key" collection="keys" separator=",">
|
||||
#{key}
|
||||
</foreach>
|
||||
)
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code key 获取字典值,包含value-->
|
||||
<select id="queryTableDictByKeys" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table} where ${code} in
|
||||
|
||||
@ -24,7 +24,7 @@
|
||||
|
||||
<!-- 首页访问统计 -->
|
||||
<select id="findVisitCount" resultType="java.util.HashMap">
|
||||
<if test="dbType == 'MYSQL' || dbType == 'MARIADB'">
|
||||
<if test="dbType == 'mysql' || dbType == 'mariadb' || dbType == 'clickhouse'|| dbType == 'sqlite'">
|
||||
select count(*) as visit
|
||||
,count(distinct(ip)) as ip
|
||||
,DATE_FORMAT(create_time, '%Y-%m-%d') as tian
|
||||
@ -34,30 +34,30 @@
|
||||
group by tian,type
|
||||
order by tian asc
|
||||
</if>
|
||||
<if test="dbType == 'ORACLE' || dbType == 'DM'">
|
||||
<if test="dbType == 'oracle' || dbType == 'oracle12c' || dbType == 'dm'">
|
||||
select count(*) as visit
|
||||
,count(distinct(ip)) as ip
|
||||
,to_char(create_time, 'yyyy-mm-dd') as tian
|
||||
,to_char(create_time, 'yyyy-mm-dd') as tian
|
||||
,to_char(create_time, 'mm-dd') as type
|
||||
from sys_log
|
||||
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
||||
group by to_char(create_time, 'yyyy-mm-dd'),to_char(create_time, 'mm-dd')
|
||||
order by to_char(create_time, 'yyyy-mm-dd') asc
|
||||
</if>
|
||||
<if test="dbType == 'POSTGRESQL'">
|
||||
<if test="dbType == 'postgresql' || dbType == 'kingbasees' || dbType == 'zenith'">
|
||||
select count(*) as visit
|
||||
,count(distinct(ip)) as ip
|
||||
,to_char(create_time, 'yyyy-mm-dd') as tian
|
||||
,to_char(create_time, 'yyyy-mm-dd') as tian
|
||||
,to_char(create_time, 'mm-dd') as type
|
||||
from sys_log
|
||||
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
||||
group by tian,type
|
||||
order by tian asc
|
||||
</if>
|
||||
<if test="dbType == 'SQLSERVER'">
|
||||
<if test="dbType == 'sqlserver' || dbType == 'sqlserver2005'">
|
||||
select count(*) as visit
|
||||
,count(distinct(ip)) as ip
|
||||
,CONVERT(varchar(100), create_time, 23) as tian
|
||||
,CONVERT(varchar(100), create_time, 23) as tian
|
||||
,RIGHT(CONVERT(varchar(100), create_time, 23),5) as type
|
||||
from sys_log
|
||||
where log_type = 1 and create_time >= #{dayStart} and create_time < #{dayEnd}
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
<select id="selectThirdIdsByUsername" resultType="org.jeecg.modules.system.entity.SysThirdAccount">
|
||||
SELECT third_user_id FROM sys_third_account
|
||||
INNER JOIN sys_user ON sys_user.id = sys_third_account.sys_user_id
|
||||
WHERE third_type = #{thirdType} AND
|
||||
WHERE sys_third_account.third_type = #{thirdType} AND
|
||||
<!-- TODO in 查询数据量大的时候可能会报错 -->
|
||||
<foreach collection="sysUsernameArr" item="item" open=" sys_user.username IN (" close=")" separator=",">#{item}</foreach>
|
||||
</select>
|
||||
|
||||
@ -22,6 +22,21 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
|
||||
public List<DictModel> queryDictItemsByCode(String code);
|
||||
|
||||
/**
|
||||
* 查询有效的数据字典项
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryEnableDictItemsByCode(String code);
|
||||
|
||||
/**
|
||||
* 通过多个字典code获取字典数据
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return key = 字典code,value=对应的字典选项
|
||||
*/
|
||||
Map<String, List<DictModel>> queryDictItemsByCodeList(List<String> dictCodeList);
|
||||
|
||||
public Map<String,List<DictModel>> queryAllDictItems();
|
||||
|
||||
@Deprecated
|
||||
@ -32,9 +47,28 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
|
||||
public String queryDictTextByKey(String code, String key);
|
||||
|
||||
/**
|
||||
* 可通过多个字典code查询翻译文本
|
||||
* @param dictCodeList 多个字典code
|
||||
* @param keys 数据列表
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys);
|
||||
|
||||
@Deprecated
|
||||
String queryTableDictTextByKey(String table, String text, String code, String key);
|
||||
|
||||
/**
|
||||
* 通过查询指定table的 text code key 获取字典值,可批量查询
|
||||
*
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryTableDictTextByKeys(String table, String text, String code, List<String> keys);
|
||||
|
||||
@Deprecated
|
||||
List<String> queryTableDictByKeys(String table, String text, String code, String keys);
|
||||
@Deprecated
|
||||
|
||||
@ -3,6 +3,33 @@ package org.jeecg.modules.system.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
public interface ISysTenantService extends IService<SysTenant> {
|
||||
|
||||
/**
|
||||
* 查询有效的租户
|
||||
*
|
||||
* @param idList
|
||||
* @return
|
||||
*/
|
||||
List<SysTenant> queryEffectiveTenant(Collection<String> idList);
|
||||
|
||||
/**
|
||||
* 返回某个租户被多少个用户引用了
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
int countUserLinkTenant(String id);
|
||||
|
||||
/**
|
||||
* 根据ID删除租户,会判断是否已被引用
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
boolean removeTenantById(String id);
|
||||
|
||||
}
|
||||
|
||||
@ -3,6 +3,7 @@ package org.jeecg.modules.system.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.jeecg.modules.system.entity.SysThirdAccount;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.model.ThirdLoginModel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -32,4 +33,11 @@ public interface ISysThirdAccountService extends IService<SysThirdAccount> {
|
||||
*/
|
||||
List<SysThirdAccount> listThirdUserIdByUsername(String[] sysUsernameArr, String thirdType);
|
||||
|
||||
/**
|
||||
* 创建新用户
|
||||
*
|
||||
* @param tlm 第三方登录信息
|
||||
*/
|
||||
SysThirdAccount saveThirdUser(ThirdLoginModel tlm);
|
||||
|
||||
}
|
||||
|
||||
@ -97,6 +97,9 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
@Autowired
|
||||
private ThirdAppDingtalkServiceImpl dingtalkService;
|
||||
|
||||
@Autowired
|
||||
ISysCategoryService sysCategoryService;
|
||||
|
||||
@Override
|
||||
@Cacheable(cacheNames=CacheConstant.SYS_USERS_CACHE, key="#username")
|
||||
public LoginUser getUserByName(String username) {
|
||||
@ -276,6 +279,12 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
return sysDictService.queryDictItemsByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_ENABLE_DICT_CACHE,key = "#code", unless = "#result == null ")
|
||||
public List<DictModel> queryEnableDictItemsByCode(String code) {
|
||||
return sysDictService.queryEnableDictItemsByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryTableDictItemsByCode(String table, String text, String code) {
|
||||
//update-begin-author:taoyan date:20200820 for:【Online+系统】字典表加权限控制机制逻辑,想法不错 LOWCOD-799
|
||||
@ -1067,4 +1076,80 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询分类字典翻译
|
||||
*
|
||||
* @param ids 分类字典表id
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> loadCategoryDictItem(String ids) {
|
||||
return sysCategoryService.loadDictItem(ids, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code加载字典text
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<String> loadDictItem(String dictCode, String keys) {
|
||||
String[] params = dictCode.split(",");
|
||||
return sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据字典code查询字典项
|
||||
*
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param dictCode 要查询的key
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DictModel> getDictItems(String dictCode) {
|
||||
List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
if (ls == null) {
|
||||
ls = new ArrayList<>();
|
||||
}
|
||||
return ls;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据多个字典code查询多个字典项
|
||||
*
|
||||
* @param dictCodeList
|
||||
* @return key = dictCode ; value=对应的字典项
|
||||
*/
|
||||
@Override
|
||||
public Map<String, List<DictModel>> getManyDictItems(List<String> dictCodeList) {
|
||||
return sysDictService.queryDictItemsByCodeList(dictCodeList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 【下拉搜索】
|
||||
* 大数据量的字典表 走异步加载,即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @param keyword 过滤关键字
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<DictModel> loadDictItemByKeyword(String dictCode, String keyword, Integer pageSize) {
|
||||
return sysDictService.loadDict(dictCode, keyword, pageSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictModel>> translateManyDict(String dictCodes, String keys) {
|
||||
List<String> dictCodeList = Arrays.asList(dictCodes.split(","));
|
||||
List<String> values = Arrays.asList(keys.split(","));
|
||||
return sysDictService.queryManyDictByKeys(dictCodeList, values);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> translateDictFromTableByKeys(String table, String text, String code, String keys) {
|
||||
return sysDictService.queryTableDictTextByKeys(table, text, code, Arrays.asList(keys.split(",")));
|
||||
}
|
||||
|
||||
}
|
||||
@ -8,6 +8,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.constant.CacheConstant;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.system.vo.DictModel;
|
||||
import org.jeecg.common.system.vo.DictModelMany;
|
||||
import org.jeecg.common.system.vo.DictQuery;
|
||||
import org.jeecg.common.util.SqlInjectionUtil;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
@ -57,6 +58,25 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
return sysDictMapper.queryDictItemsByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_ENABLE_DICT_CACHE,key = "#code", unless = "#result == null ")
|
||||
public List<DictModel> queryEnableDictItemsByCode(String code) {
|
||||
log.debug("无缓存dictCache的时候调用这里!");
|
||||
return sysDictMapper.queryEnableDictItemsByCode(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictModel>> queryDictItemsByCodeList(List<String> dictCodeList) {
|
||||
List<DictModelMany> list = sysDictMapper.queryDictItemsByCodeList(dictCodeList);
|
||||
Map<String, List<DictModel>> dictMap = new HashMap<>();
|
||||
for (DictModelMany dict : list) {
|
||||
List<DictModel> dictItemList = dictMap.computeIfAbsent(dict.getDictCode(), i -> new ArrayList<>());
|
||||
dict.setDictCode(null);
|
||||
dictItemList.add(new DictModel(dict.getValue(), dict.getText()));
|
||||
}
|
||||
return dictMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictModel>> queryAllDictItems() {
|
||||
Map<String, List<DictModel>> res = new HashMap<String, List<DictModel>>();
|
||||
@ -93,6 +113,17 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
return sysDictMapper.queryDictTextByKey(code, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<DictModel>> queryManyDictByKeys(List<String> dictCodeList, List<String> keys) {
|
||||
List<DictModelMany> list = sysDictMapper.queryManyDictByKeys(dictCodeList, keys);
|
||||
Map<String, List<DictModel>> dictMap = new HashMap<>();
|
||||
for (DictModelMany dict : list) {
|
||||
List<DictModel> dictItemList = dictMap.computeIfAbsent(dict.getDictCode(), i -> new ArrayList<>());
|
||||
dictItemList.add(new DictModel(dict.getValue(), dict.getText()));
|
||||
}
|
||||
return dictMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询指定table的 text code 获取字典
|
||||
* dictTableCache采用redis缓存有效期10分钟
|
||||
@ -130,6 +161,11 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
return sysDictMapper.queryTableDictTextByKey(table,text,code,key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryTableDictTextByKeys(String table, String text, String code, List<String> keys) {
|
||||
return sysDictMapper.queryTableDictTextByKeys(table, text, code, keys);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys) {
|
||||
return this.queryTableDictByKeys(table, text, code, keys, true);
|
||||
|
||||
@ -7,6 +7,7 @@ import java.util.Map;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.DbType;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.util.CommonUtils;
|
||||
import org.jeecg.modules.system.entity.SysLog;
|
||||
@ -60,7 +61,7 @@ public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> impleme
|
||||
|
||||
@Override
|
||||
public List<Map<String,Object>> findVisitCount(Date dayStart, Date dayEnd) {
|
||||
String dbType = CommonUtils.getDatabaseType();
|
||||
return sysLogMapper.findVisitCount(dayStart, dayEnd,dbType);
|
||||
DbType dbType = CommonUtils.getDatabaseTypeEnum();
|
||||
return sysLogMapper.findVisitCount(dayStart, dayEnd,dbType.getDb());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,15 +1,56 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.system.entity.SysTenant;
|
||||
import org.jeecg.modules.system.entity.SysUser;
|
||||
import org.jeecg.modules.system.mapper.SysTenantMapper;
|
||||
import org.jeecg.modules.system.service.ISysTenantService;
|
||||
import org.jeecg.modules.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@Service("sysTenantServiceImpl")
|
||||
@Slf4j
|
||||
public class SysTenantServiceImpl extends ServiceImpl<SysTenantMapper, SysTenant> implements ISysTenantService {
|
||||
|
||||
|
||||
@Autowired
|
||||
ISysUserService userService;
|
||||
|
||||
@Override
|
||||
public List<SysTenant> queryEffectiveTenant(Collection<String> idList) {
|
||||
LambdaQueryWrapper<SysTenant> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysTenant::getId, idList);
|
||||
queryWrapper.eq(SysTenant::getStatus, CommonConstant.STATUS_1);
|
||||
//此处查询忽略时间条件
|
||||
return super.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int countUserLinkTenant(String id) {
|
||||
LambdaQueryWrapper<SysUser> userQueryWrapper = new LambdaQueryWrapper<>();
|
||||
userQueryWrapper.eq(SysUser::getRelTenantIds, id);
|
||||
userQueryWrapper.or().like(SysUser::getRelTenantIds, "%," + id);
|
||||
userQueryWrapper.or().like(SysUser::getRelTenantIds, id + ",%");
|
||||
userQueryWrapper.or().like(SysUser::getRelTenantIds, "%," + id + ",%");
|
||||
// 查找出已被关联的用户数量
|
||||
return userService.count(userQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeTenantById(String id) {
|
||||
// 查找出已被关联的用户数量
|
||||
int userCount = this.countUserLinkTenant(id);
|
||||
if (userCount > 0) {
|
||||
throw new JeecgBootException("该租户已被引用,无法删除!");
|
||||
}
|
||||
return super.removeById(id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -15,6 +15,7 @@ import org.jeecg.modules.system.mapper.SysRoleMapper;
|
||||
import org.jeecg.modules.system.mapper.SysThirdAccountMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserMapper;
|
||||
import org.jeecg.modules.system.mapper.SysUserRoleMapper;
|
||||
import org.jeecg.modules.system.model.ThirdLoginModel;
|
||||
import org.jeecg.modules.system.service.ISysThirdAccountService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@ -133,4 +134,18 @@ public class SysThirdAccountServiceImpl extends ServiceImpl<SysThirdAccountMappe
|
||||
return sysThirdAccountMapper.selectThirdIdsByUsername(sysUsernameArr, thirdType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysThirdAccount saveThirdUser(ThirdLoginModel tlm) {
|
||||
SysThirdAccount user = new SysThirdAccount();
|
||||
user.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
user.setStatus(1);
|
||||
user.setThirdType(tlm.getSource());
|
||||
user.setAvatar(tlm.getAvatar());
|
||||
user.setRealname(tlm.getUsername());
|
||||
user.setThirdUserUuid(tlm.getUuid());
|
||||
user.setThirdUserId(tlm.getUuid());
|
||||
super.save(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package org.jeecg.modules.system.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jeecg.dingtalk.api.base.JdtBaseAPI;
|
||||
@ -12,6 +13,8 @@ import com.jeecg.dingtalk.api.message.JdtMessageAPI;
|
||||
import com.jeecg.dingtalk.api.message.vo.ActionCardMessage;
|
||||
import com.jeecg.dingtalk.api.message.vo.Message;
|
||||
import com.jeecg.dingtalk.api.message.vo.TextMessage;
|
||||
import com.jeecg.dingtalk.api.oauth2.JdtOauth2API;
|
||||
import com.jeecg.dingtalk.api.oauth2.vo.ContactUser;
|
||||
import com.jeecg.dingtalk.api.user.JdtUserAPI;
|
||||
import com.jeecg.dingtalk.api.user.body.GetUserListBody;
|
||||
import com.jeecg.dingtalk.api.user.vo.User;
|
||||
@ -25,9 +28,11 @@ import org.jeecg.common.util.RestUtil;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.config.thirdapp.ThirdAppConfig;
|
||||
import org.jeecg.config.thirdapp.ThirdAppTypeItemVo;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
import org.jeecg.modules.system.model.ThirdLoginModel;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.vo.thirdapp.JdtDepartmentTreeVo;
|
||||
import org.jeecg.modules.system.vo.thirdapp.SyncInfoVo;
|
||||
@ -65,6 +70,9 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
@Autowired
|
||||
private SysAnnouncementSendMapper sysAnnouncementSendMapper;
|
||||
|
||||
// 第三方APP类型,当前固定为 dingtalk
|
||||
public final String THIRD_TYPE = ThirdAppConfig.DINGTALK.toLowerCase();
|
||||
|
||||
@Override
|
||||
public String getAccessToken() {
|
||||
String appKey = thirdAppConfig.getDingtalk().getClientId();
|
||||
@ -273,7 +281,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
* 1. 查询 sys_third_account(第三方账号表)是否有数据,如果有代表已同步
|
||||
* 2. 本地表里没有,就先用手机号判断,不通过再用username判断。
|
||||
*/
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneBySysUserId(sysUser.getId(), ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneBySysUserId(sysUser.getId(), THIRD_TYPE);
|
||||
if (sysThirdAccount != null && oConvertUtils.isNotEmpty(sysThirdAccount.getThirdUserId())) {
|
||||
// sys_third_account 表匹配成功,通过第三方userId查询出第三方userInfo
|
||||
dtUserInfo = JdtUserAPI.getUserById(sysThirdAccount.getThirdUserId(), accessToken);
|
||||
@ -315,7 +323,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
sysThirdAccount.setSysUserId(sysUser.getId());
|
||||
sysThirdAccount.setStatus(1);
|
||||
sysThirdAccount.setDelFlag(0);
|
||||
sysThirdAccount.setThirdType(ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
sysThirdAccount.setThirdType(THIRD_TYPE);
|
||||
}
|
||||
// 设置第三方app用户ID
|
||||
sysThirdAccount.setThirdUserId(dtUserId);
|
||||
@ -343,7 +351,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
List<User> ddUserList = this.getDtAllUserByDepartment(allDepartment, accessToken);
|
||||
|
||||
for (User dtUserInfo : ddUserList) {
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneByThirdUserId(dtUserInfo.getUserid(), ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneByThirdUserId(dtUserInfo.getUserid(), THIRD_TYPE);
|
||||
List<SysUser> collect = sysUsersList.stream().filter(user -> (dtUserInfo.getMobile().equals(user.getPhone()) || dtUserInfo.getUserid().equals(user.getUsername()))
|
||||
).collect(Collectors.toList());
|
||||
if (collect != null && collect.size() > 0) {
|
||||
@ -414,7 +422,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
sysThirdAccount.setSysUserId(sysUserId);
|
||||
sysThirdAccount.setStatus(1);
|
||||
sysThirdAccount.setDelFlag(0);
|
||||
sysThirdAccount.setThirdType(ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
sysThirdAccount.setThirdType(THIRD_TYPE);
|
||||
}
|
||||
sysThirdAccount.setThirdUserId(dtUserId);
|
||||
sysThirdAccountService.saveOrUpdate(sysThirdAccount);
|
||||
@ -517,6 +525,9 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
String passwordEncode = PasswordUtil.encrypt(sysUser.getUsername(), password, salt);
|
||||
sysUser.setSalt(salt);
|
||||
sysUser.setPassword(passwordEncode);
|
||||
// update-begin--Author:liusq Date:20210713 for:钉钉同步到本地的人员没有状态,导致同步之后无法登录 #I3ZC2L
|
||||
sysUser.setStatus(1);
|
||||
// update-end--Author:liusq Date:20210713 for:钉钉同步到本地的人员没有状态,导致同步之后无法登录 #I3ZC2L
|
||||
return this.dtUserToSysUser(dtUser, sysUser);
|
||||
}
|
||||
|
||||
@ -629,7 +640,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
return count;
|
||||
}
|
||||
LambdaQueryWrapper<SysThirdAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysThirdAccount::getThirdType, ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
queryWrapper.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
|
||||
queryWrapper.in(SysThirdAccount::getSysUserId, userIdList);
|
||||
// 根据userId,获取第三方用户的id
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.list(queryWrapper);
|
||||
@ -686,7 +697,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
} else {
|
||||
String[] toUsers = message.getToUser().split(",");
|
||||
// 通过第三方账号表查询出第三方userId
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, THIRD_TYPE);
|
||||
List<String> dtUserIds = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
|
||||
textMessage.setUserid_list(dtUserIds);
|
||||
}
|
||||
@ -757,7 +768,7 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
if(userIds!=null){
|
||||
String[] usernameList = sysUserService.userIdToUsername(Arrays.asList(userIds)).toArray(new String[]{});
|
||||
// 通过第三方账号表查询出第三方userId
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(usernameList, ThirdAppConfig.DINGTALK.toLowerCase());
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(usernameList, THIRD_TYPE);
|
||||
List<String> dtUserIds = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
|
||||
actionCardMessage.setUserid_list(dtUserIds);
|
||||
return JdtMessageAPI.sendActionCardMessage(actionCardMessage, accessToken);
|
||||
@ -766,4 +777,91 @@ public class ThirdAppDingtalkServiceImpl implements IThirdAppService {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* OAuth2登录,成功返回登录的SysUser,失败返回null
|
||||
*/
|
||||
public SysUser oauth2Login(String authCode) {
|
||||
ThirdAppTypeItemVo dtConfig = thirdAppConfig.getDingtalk();
|
||||
// 1. 根据免登授权码获取用户 AccessToken
|
||||
String userAccessToken = JdtOauth2API.getUserAccessToken(dtConfig.getClientId(), dtConfig.getClientSecret(), authCode);
|
||||
if (userAccessToken == null) {
|
||||
log.error("oauth2Login userAccessToken is null");
|
||||
return null;
|
||||
}
|
||||
// 2. 根据用户 AccessToken 获取当前用户的基本信息(不包括userId)
|
||||
ContactUser contactUser = JdtOauth2API.getContactUsers("me", userAccessToken);
|
||||
if (contactUser == null) {
|
||||
log.error("oauth2Login contactUser is null");
|
||||
return null;
|
||||
}
|
||||
String unionId = contactUser.getUnionId();
|
||||
// 3. 根据获取到的 unionId 换取用户 userId
|
||||
String accessToken = this.getAccessToken();
|
||||
if (accessToken == null) {
|
||||
log.error("oauth2Login accessToken is null");
|
||||
return null;
|
||||
}
|
||||
Response<String> getUserIdRes = JdtUserAPI.getUseridByUnionid(unionId, accessToken);
|
||||
if (!getUserIdRes.isSuccess()) {
|
||||
log.error("oauth2Login getUseridByUnionid failed: " + JSON.toJSONString(getUserIdRes));
|
||||
return null;
|
||||
}
|
||||
String appUserId = getUserIdRes.getResult();
|
||||
log.info("appUserId: " + appUserId);
|
||||
if (appUserId != null) {
|
||||
// 判断第三方用户表有没有这个人
|
||||
LambdaQueryWrapper<SysThirdAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysThirdAccount::getThirdUserUuid, appUserId);
|
||||
queryWrapper.or().eq(SysThirdAccount::getThirdUserId, appUserId);
|
||||
queryWrapper.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
|
||||
SysThirdAccount thirdAccount = sysThirdAccountService.getOne(queryWrapper);
|
||||
if (thirdAccount != null) {
|
||||
return this.getSysUserByThird(thirdAccount, null, appUserId, accessToken);
|
||||
} else {
|
||||
// 直接创建新账号
|
||||
User appUser = JdtUserAPI.getUserById(appUserId, accessToken).getResult();
|
||||
ThirdLoginModel tlm = new ThirdLoginModel(THIRD_TYPE, appUser.getUserid(), appUser.getName(), appUser.getAvatar());
|
||||
thirdAccount = sysThirdAccountService.saveThirdUser(tlm);
|
||||
return this.getSysUserByThird(thirdAccount, appUser, null, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据第三方账号获取本地账号,如果不存在就创建
|
||||
*
|
||||
* @param thirdAccount
|
||||
* @param appUser
|
||||
* @param appUserId
|
||||
* @param accessToken
|
||||
* @return
|
||||
*/
|
||||
private SysUser getSysUserByThird(SysThirdAccount thirdAccount, User appUser, String appUserId, String accessToken) {
|
||||
String sysUserId = thirdAccount.getSysUserId();
|
||||
if (oConvertUtils.isNotEmpty(sysUserId)) {
|
||||
return sysUserService.getById(sysUserId);
|
||||
} else {
|
||||
// 如果没有 sysUserId ,说明没有绑定账号,获取到手机号之后进行绑定
|
||||
if (appUser == null) {
|
||||
appUser = JdtUserAPI.getUserById(appUserId, accessToken).getResult();
|
||||
}
|
||||
// 判断系统里是否有这个手机号的用户
|
||||
SysUser sysUser = sysUserService.getUserByPhone(appUser.getMobile());
|
||||
if (sysUser != null) {
|
||||
thirdAccount.setAvatar(appUser.getAvatar());
|
||||
thirdAccount.setRealname(appUser.getName());
|
||||
thirdAccount.setThirdUserId(appUser.getUserid());
|
||||
thirdAccount.setThirdUserUuid(appUser.getUserid());
|
||||
thirdAccount.setSysUserId(sysUser.getId());
|
||||
sysThirdAccountService.updateById(thirdAccount);
|
||||
return sysUser;
|
||||
} else {
|
||||
// 没有就走创建逻辑
|
||||
return sysThirdAccountService.createUser(appUser.getMobile(), appUser.getUserid());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -27,6 +27,7 @@ import org.jeecg.config.thirdapp.ThirdAppConfig;
|
||||
import org.jeecg.modules.system.entity.*;
|
||||
import org.jeecg.modules.system.mapper.SysAnnouncementSendMapper;
|
||||
import org.jeecg.modules.system.model.SysDepartTreeModel;
|
||||
import org.jeecg.modules.system.model.ThirdLoginModel;
|
||||
import org.jeecg.modules.system.service.*;
|
||||
import org.jeecg.modules.system.vo.thirdapp.JwDepartmentTreeVo;
|
||||
import org.jeecg.modules.system.vo.thirdapp.SyncInfoVo;
|
||||
@ -62,6 +63,9 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
@Autowired
|
||||
private SysAnnouncementSendMapper sysAnnouncementSendMapper;
|
||||
|
||||
// 第三方APP类型,当前固定为 wechat_enterprise
|
||||
public final String THIRD_TYPE = ThirdAppConfig.WECHAT_ENTERPRISE.toLowerCase();
|
||||
|
||||
@Override
|
||||
public String getAccessToken() {
|
||||
String CORP_ID = thirdAppConfig.getWechatEnterprise().getClientId();
|
||||
@ -302,7 +306,7 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
* 2. 本地表里没有,就先用手机号判断,不通过再用username判断。
|
||||
*/
|
||||
User qwUser;
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneBySysUserId(sysUser.getId(), ThirdAppConfig.WECHAT_ENTERPRISE.toLowerCase());
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneBySysUserId(sysUser.getId(), THIRD_TYPE);
|
||||
for (User qwUserTemp : qwUsers) {
|
||||
if (sysThirdAccount == null || oConvertUtils.isEmpty(sysThirdAccount.getThirdUserId()) || !sysThirdAccount.getThirdUserId().equals(qwUserTemp.getUserid())) {
|
||||
// sys_third_account 表匹配失败,尝试用手机号匹配
|
||||
@ -360,7 +364,7 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
* 1. 查询 sys_third_account(第三方账号表)是否有数据,如果有代表已同步
|
||||
* 2. 本地表里没有,就先用手机号判断,不通过再用username判断。
|
||||
*/
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneByThirdUserId(qwUser.getUserid(), ThirdAppConfig.WECHAT_ENTERPRISE.toLowerCase());
|
||||
SysThirdAccount sysThirdAccount = sysThirdAccountService.getOneByThirdUserId(qwUser.getUserid(), THIRD_TYPE);
|
||||
List<SysUser> collect = sysUsersList.stream().filter(user -> (qwUser.getMobile().equals(user.getPhone()) || qwUser.getUserid().equals(user.getUsername()))
|
||||
).collect(Collectors.toList());
|
||||
|
||||
@ -407,7 +411,7 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
sysThirdAccount.setSysUserId(sysUserId);
|
||||
sysThirdAccount.setStatus(1);
|
||||
sysThirdAccount.setDelFlag(0);
|
||||
sysThirdAccount.setThirdType(ThirdAppConfig.WECHAT_ENTERPRISE.toLowerCase());
|
||||
sysThirdAccount.setThirdType(THIRD_TYPE);
|
||||
}
|
||||
sysThirdAccount.setThirdUserId(qwUserId);
|
||||
sysThirdAccountService.saveOrUpdate(sysThirdAccount);
|
||||
@ -581,6 +585,7 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
private SysUser qwUserToSysUser(User user) {
|
||||
SysUser sysUser = new SysUser();
|
||||
sysUser.setDelFlag(0);
|
||||
sysUser.setStatus(1);
|
||||
// 通过 username 来关联
|
||||
sysUser.setUsername(user.getUserid());
|
||||
// 密码默认为 “123456”,随机加盐
|
||||
@ -680,7 +685,7 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
return count;
|
||||
}
|
||||
LambdaQueryWrapper<SysThirdAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysThirdAccount::getThirdType, ThirdAppConfig.WECHAT_ENTERPRISE.toLowerCase());
|
||||
queryWrapper.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
|
||||
queryWrapper.in(SysThirdAccount::getSysUserId, userIdList);
|
||||
// 根据userId,获取第三方用户的id
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.list(queryWrapper);
|
||||
@ -781,11 +786,93 @@ public class ThirdAppWechatEnterpriseServiceImpl implements IThirdAppService {
|
||||
} else {
|
||||
String[] toUsers = origin.split(",");
|
||||
// 通过第三方账号表查询出第三方userId
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, ThirdAppConfig.WECHAT_ENTERPRISE.toLowerCase());
|
||||
List<SysThirdAccount> thirdAccountList = sysThirdAccountService.listThirdUserIdByUsername(toUsers, THIRD_TYPE);
|
||||
List<String> toUserList = thirdAccountList.stream().map(SysThirdAccount::getThirdUserId).collect(Collectors.toList());
|
||||
// 多个接收者用‘|’分隔
|
||||
return String.join("|", toUserList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据第三方登录获取到的code来获取第三方app的用户ID
|
||||
*
|
||||
* @param code
|
||||
* @return
|
||||
*/
|
||||
public String getUserIdByThirdCode(String code, String accessToken) {
|
||||
JSONObject response = JwUserAPI.getUserInfoByCode(code, accessToken);
|
||||
if (response != null) {
|
||||
log.info("response: " + response.toJSONString());
|
||||
if (response.getIntValue("errcode") == 0) {
|
||||
return response.getString("UserId");
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* OAuth2登录,成功返回登录的SysUser,失败返回null
|
||||
*/
|
||||
public SysUser oauth2Login(String code) {
|
||||
String accessToken = this.getAppAccessToken();
|
||||
if (accessToken == null) {
|
||||
return null;
|
||||
}
|
||||
String appUserId = this.getUserIdByThirdCode(code, accessToken);
|
||||
if (appUserId != null) {
|
||||
// 判断第三方用户表有没有这个人
|
||||
LambdaQueryWrapper<SysThirdAccount> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysThirdAccount::getThirdUserUuid, appUserId);
|
||||
queryWrapper.or().eq(SysThirdAccount::getThirdUserId, appUserId);
|
||||
queryWrapper.eq(SysThirdAccount::getThirdType, THIRD_TYPE);
|
||||
SysThirdAccount thirdAccount = sysThirdAccountService.getOne(queryWrapper);
|
||||
if (thirdAccount != null) {
|
||||
return this.getSysUserByThird(thirdAccount, null, appUserId, accessToken);
|
||||
} else {
|
||||
// 直接创建新账号
|
||||
User appUser = JwUserAPI.getUserByUserid(appUserId, accessToken);
|
||||
ThirdLoginModel tlm = new ThirdLoginModel(THIRD_TYPE, appUser.getUserid(), appUser.getName(), appUser.getAvatar());
|
||||
thirdAccount = sysThirdAccountService.saveThirdUser(tlm);
|
||||
return this.getSysUserByThird(thirdAccount, appUser, null, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据第三方账号获取本地账号,如果不存在就创建
|
||||
*
|
||||
* @param thirdAccount
|
||||
* @param appUser
|
||||
* @param appUserId
|
||||
* @param accessToken
|
||||
* @return
|
||||
*/
|
||||
private SysUser getSysUserByThird(SysThirdAccount thirdAccount, User appUser, String appUserId, String accessToken) {
|
||||
String sysUserId = thirdAccount.getSysUserId();
|
||||
if (oConvertUtils.isNotEmpty(sysUserId)) {
|
||||
return sysUserService.getById(sysUserId);
|
||||
} else {
|
||||
// 如果没有 sysUserId ,说明没有绑定账号,获取到手机号之后进行绑定
|
||||
if (appUser == null) {
|
||||
appUser = JwUserAPI.getUserByUserid(appUserId, accessToken);
|
||||
}
|
||||
// 判断系统里是否有这个手机号的用户
|
||||
SysUser sysUser = sysUserService.getUserByPhone(appUser.getMobile());
|
||||
if (sysUser != null) {
|
||||
thirdAccount.setAvatar(appUser.getAvatar());
|
||||
thirdAccount.setRealname(appUser.getName());
|
||||
thirdAccount.setThirdUserId(appUser.getUserid());
|
||||
thirdAccount.setThirdUserUuid(appUser.getUserid());
|
||||
thirdAccount.setSysUserId(sysUser.getId());
|
||||
sysThirdAccountService.updateById(thirdAccount);
|
||||
return sysUser;
|
||||
} else {
|
||||
// 没有就走创建逻辑
|
||||
return sysThirdAccountService.createUser(appUser.getMobile(), appUser.getUserid());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,44 @@
|
||||
package org.jeecg.modules.system.util;
|
||||
|
||||
import org.springframework.web.util.HtmlUtils;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @Description: 工具类XSSUtils,现在的做法是替换成空字符,CSDN的是进行转义,比如文字开头的"<"转成<
|
||||
* @author: lsq
|
||||
* @date: 2021年07月26日 19:13
|
||||
*/
|
||||
public class XSSUtils {
|
||||
public static String striptXSS(String value) {
|
||||
if (value != null) {
|
||||
value = value.replaceAll(" ", "");
|
||||
Pattern scriptPattern = Pattern.compile("<script>(.*?)</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\'(.*?)\\\'", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("src[\r\n]*=[\r\n]*\\\"(.*?)\\\"", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("</script>", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("<script(.*?)>", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("eval\\((.*?)\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("expression\\((.*?)\\)", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("javascript:", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("vbscript:", Pattern.CASE_INSENSITIVE);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
scriptPattern = Pattern.compile("onload(.*?)=", Pattern.CASE_INSENSITIVE | Pattern.MULTILINE | Pattern.DOTALL);
|
||||
value = scriptPattern.matcher(value).replaceAll("");
|
||||
}
|
||||
return HtmlUtils.htmlEscape(value);
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String s = striptXSS("<img src=x onload=alert(111).*?><script></script>javascript:eval()\\\\.");
|
||||
System.err.println("s======>" + s);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,62 @@
|
||||
package org.jeecg.modules.system.vo;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @Author: chenli
|
||||
* @Date: 2020-06-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class SysUserOnlineVO {
|
||||
/**
|
||||
* 会话id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 会话编号
|
||||
*/
|
||||
private String token;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 用户名
|
||||
*/
|
||||
private String realname;
|
||||
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 生日
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
private Date birthday;
|
||||
|
||||
/**
|
||||
* 性别(1:男 2:女)
|
||||
*/
|
||||
@Dict(dicCode = "sex")
|
||||
private Integer sex;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String phone;
|
||||
}
|
||||
@ -39,7 +39,7 @@ spring:
|
||||
quartz:
|
||||
job-store-type: jdbc
|
||||
initialize-schema: embedded
|
||||
#设置自动启动,默认为 true
|
||||
#定时任务启动开关,true-开 false-关
|
||||
auto-startup: true
|
||||
#启动时更新己存在的Job
|
||||
overwrite-existing-jobs: true
|
||||
@ -118,7 +118,7 @@ spring:
|
||||
timeBetweenEvictionRunsMillis: 60000
|
||||
# 配置一个连接在池中最小生存的时间,单位是毫秒
|
||||
minEvictableIdleTimeMillis: 300000
|
||||
validationQuery: SELECT 1 FROM DUAL
|
||||
validationQuery: SELECT 1
|
||||
testWhileIdle: true
|
||||
testOnBorrow: false
|
||||
testOnReturn: false
|
||||
@ -131,7 +131,7 @@ spring:
|
||||
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
|
||||
datasource:
|
||||
master:
|
||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot-os-re?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
@ -176,8 +176,10 @@ minidao :
|
||||
#DB类型(mysql | postgresql | oracle | sqlserver| other)
|
||||
db-type: mysql
|
||||
jeecg :
|
||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: local
|
||||
uploadType: minio
|
||||
path :
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/upFiles
|
||||
@ -190,7 +192,7 @@ jeecg :
|
||||
accessKey: ??
|
||||
secretKey: ??
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
bucketName: ??
|
||||
bucketName: jeecgdev
|
||||
# ElasticSearch 6设置
|
||||
elasticsearch:
|
||||
cluster-name: jeecg-ES
|
||||
@ -238,12 +240,12 @@ jeecg :
|
||||
port: 30007
|
||||
logPath: logs/jeecg/job/jobhandler/
|
||||
logRetentionDays: 30
|
||||
#自定义路由配置 yml nacos database
|
||||
route:
|
||||
config:
|
||||
data-id: jeecg-gateway-router
|
||||
group: DEFAULT_GROUP
|
||||
data-type: yml
|
||||
#自定义路由配置 yml nacos database
|
||||
data-type: database
|
||||
#分布式锁配置
|
||||
redisson:
|
||||
address: 127.0.0.1:6379
|
||||
@ -259,9 +261,12 @@ logging:
|
||||
org.jeecg.modules.system.mapper : info
|
||||
#swagger
|
||||
knife4j:
|
||||
#开启增强配置
|
||||
enable: true
|
||||
#开启生产环境屏蔽
|
||||
production: false
|
||||
basic:
|
||||
enable: true
|
||||
enable: false
|
||||
username: jeecg
|
||||
password: jeecg1314
|
||||
#第三方登录
|
||||
|
||||
@ -39,7 +39,7 @@ spring:
|
||||
quartz:
|
||||
job-store-type: jdbc
|
||||
initialize-schema: embedded
|
||||
#设置自动启动,默认为 true
|
||||
#定时任务启动开关,true-开 false-关
|
||||
auto-startup: true
|
||||
#启动时更新己存在的Job
|
||||
overwrite-existing-jobs: true
|
||||
@ -176,6 +176,8 @@ minidao :
|
||||
#DB类型(mysql | postgresql | oracle | sqlserver| other)
|
||||
db-type: mysql
|
||||
jeecg :
|
||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: alioss
|
||||
path :
|
||||
@ -190,12 +192,12 @@ jeecg :
|
||||
accessKey: ??
|
||||
secretKey: ??
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
bucketName: ??
|
||||
bucketName: jeecgdev
|
||||
staticDomain: https://static.jeecg.com
|
||||
# ElasticSearch 设置
|
||||
elasticsearch:
|
||||
cluster-name: jeecg-ES
|
||||
cluster-nodes: ??
|
||||
cluster-nodes: 81.70.47.128:9200
|
||||
check-enabled: true
|
||||
# 表单设计器配置
|
||||
desform:
|
||||
@ -213,7 +215,7 @@ jeecg :
|
||||
minio_url: http://minio.jeecg.com
|
||||
minio_name: ??
|
||||
minio_pass: ??
|
||||
bucketName: ??
|
||||
bucketName: otatest
|
||||
#大屏报表参数设置
|
||||
jmreport:
|
||||
mode: prod
|
||||
@ -239,12 +241,12 @@ jeecg :
|
||||
port: 30007
|
||||
logPath: logs/jeecg/job/jobhandler/
|
||||
logRetentionDays: 30
|
||||
#自定义路由配置 yml nacos database
|
||||
route:
|
||||
config:
|
||||
data-id: jeecg-gateway-router
|
||||
group: DEFAULT_GROUP
|
||||
data-type: yml
|
||||
#自定义路由配置 yml nacos database
|
||||
data-type: database
|
||||
#分布式锁配置
|
||||
redisson:
|
||||
address: 127.0.0.1:6379
|
||||
@ -260,7 +262,10 @@ logging:
|
||||
org.jeecg.modules.system.mapper : info
|
||||
#swagger
|
||||
knife4j:
|
||||
production: false
|
||||
#开启增强配置
|
||||
enable: true
|
||||
#开启生产环境屏蔽
|
||||
production: true
|
||||
basic:
|
||||
enable: true
|
||||
username: jeecg
|
||||
|
||||
@ -39,7 +39,7 @@ spring:
|
||||
quartz:
|
||||
job-store-type: jdbc
|
||||
initialize-schema: embedded
|
||||
#设置自动启动,默认为 true
|
||||
#定时任务启动开关,true-开 false-关
|
||||
auto-startup: true
|
||||
#启动时更新己存在的Job
|
||||
overwrite-existing-jobs: true
|
||||
@ -176,6 +176,8 @@ minidao :
|
||||
#DB类型(mysql | postgresql | oracle | sqlserver| other)
|
||||
db-type: mysql
|
||||
jeecg :
|
||||
# 签名密钥串(前后端要一致,正式发布请自行修改)
|
||||
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
|
||||
# 本地:local\Minio:minio\阿里云:alioss
|
||||
uploadType: local
|
||||
path :
|
||||
@ -190,12 +192,12 @@ jeecg :
|
||||
accessKey: ??
|
||||
secretKey: ??
|
||||
endpoint: oss-cn-beijing.aliyuncs.com
|
||||
bucketName: ??
|
||||
bucketName: jeecgdev
|
||||
staticDomain: https://static.jeecg.com
|
||||
# ElasticSearch 设置
|
||||
elasticsearch:
|
||||
cluster-name: jeecg-ES
|
||||
cluster-nodes: ??
|
||||
cluster-nodes: 81.70.47.128:9200
|
||||
check-enabled: false
|
||||
# 表单设计器配置
|
||||
desform:
|
||||
@ -239,12 +241,12 @@ jeecg :
|
||||
port: 30007
|
||||
logPath: logs/jeecg/job/jobhandler/
|
||||
logRetentionDays: 30
|
||||
#自定义路由配置 yml nacos database
|
||||
route:
|
||||
config:
|
||||
data-id: jeecg-gateway-router
|
||||
group: DEFAULT_GROUP
|
||||
data-type: yml
|
||||
#自定义路由配置 yml nacos database
|
||||
data-type: database
|
||||
#分布式锁配置
|
||||
redisson:
|
||||
address: 127.0.0.1:6379
|
||||
@ -260,6 +262,9 @@ cas:
|
||||
prefixUrl: http://cas.example.org:8443/cas
|
||||
#swagger
|
||||
knife4j:
|
||||
#开启增强配置
|
||||
enable: true
|
||||
#开启生产环境屏蔽
|
||||
production: false
|
||||
basic:
|
||||
enable: true
|
||||
|
||||
@ -9,6 +9,6 @@ ${AnsiColor.BRIGHT_BLUE}
|
||||
|
||||
|
||||
${AnsiColor.BRIGHT_GREEN}
|
||||
Jeecg Boot Version: 2.4.5
|
||||
Jeecg Boot Version: 2.4.6
|
||||
Spring Boot Version: ${spring-boot.version}${spring-boot.formatted-version}
|
||||
${AnsiColor.BLACK}
|
||||
|
||||
@ -45,7 +45,7 @@ public class ${entityName} implements Serializable {
|
||||
</#if>
|
||||
/**${po.filedComment}*/
|
||||
<#if po.fieldName == primaryKeyField>
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
<#else>
|
||||
<#if po.fieldDbType =='Date'>
|
||||
<#if po.classType=='date'>
|
||||
|
||||
@ -46,7 +46,7 @@ public class ${subTab.entityName} implements Serializable {
|
||||
</#if>
|
||||
/**${po.filedComment}*/
|
||||
<#if po.fieldName == primaryKeyField>
|
||||
@TableId(type = IdType.ID_WORKER_STR)
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
<#else>
|
||||
<#if po.fieldDbType =='Date'>
|
||||
<#if po.classType=='date'>
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
package org.jeecg;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.util.security.SecurityTools;
|
||||
import org.jeecg.common.util.security.entity.*;
|
||||
import org.junit.Test;
|
||||
@ -30,7 +30,7 @@ public class SecurityToolsTest {
|
||||
// signData为签名数据
|
||||
// data为aes加密数据
|
||||
// asekey为ras加密过的aeskey
|
||||
System.out.println(new JSONObject(sign).toStringPretty());
|
||||
System.out.println(JSONObject.toJSON(sign));
|
||||
|
||||
// 验签解密部分
|
||||
SecurityReq req = new SecurityReq();
|
||||
@ -44,6 +44,6 @@ public class SecurityToolsTest {
|
||||
SecurityResp securityResp = SecurityTools.valid(req);
|
||||
//解密报文data为解密报文
|
||||
//sucess 为验签成功失败标志 true代码验签成功,false代表失败
|
||||
System.out.println(new JSONObject(securityResp).toStringPretty());
|
||||
System.out.println(JSONObject.toJSON(securityResp));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user