处理各类bug问题
This commit is contained in:
+3
-8
@@ -425,11 +425,11 @@ public class SysCategoryController {
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("sys:category:list")
|
||||
@RequestMapping(value = "/loadDictItem", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids) {
|
||||
public Result<List<String>> loadDictItem(@RequestParam(name = "ids") String ids, @RequestParam(name = "delNotExist", required = false, defaultValue = "true") boolean delNotExist) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
// 非空判断
|
||||
if (StringUtils.isBlank(ids)) {
|
||||
@@ -437,13 +437,8 @@ public class SysCategoryController {
|
||||
result.setMessage("ids 不能为空");
|
||||
return result;
|
||||
}
|
||||
String[] idArray = ids.split(",");
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysCategory::getId, Arrays.asList(idArray));
|
||||
// 查询数据
|
||||
List<SysCategory> list = this.sysCategoryService.list(query);
|
||||
// 取出name并返回
|
||||
List<String> textList = list.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
List<String> textList = sysCategoryService.loadDictItem(ids, delNotExist);
|
||||
result.setSuccess(true);
|
||||
result.setResult(textList);
|
||||
return result;
|
||||
|
||||
+27
@@ -6,6 +6,7 @@ import java.util.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -130,6 +131,32 @@ public class SysDepartController {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某个部门的所有父级部门的ID
|
||||
*
|
||||
* @param departId 根据departId查
|
||||
* @param orgCode 根据orgCode查,departId和orgCode必须有一个不为空
|
||||
*/
|
||||
@GetMapping("/queryAllParentId")
|
||||
public Result queryParentIds(
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name = "orgCode", required = false) String orgCode
|
||||
) {
|
||||
try {
|
||||
JSONObject data;
|
||||
if (oConvertUtils.isNotEmpty(departId)) {
|
||||
data = sysDepartService.queryAllParentIdByDepartId(departId);
|
||||
} else if (oConvertUtils.isNotEmpty(orgCode)) {
|
||||
data = sysDepartService.queryAllParentIdByOrgCode(orgCode);
|
||||
} else {
|
||||
return Result.error("departId 和 orgCode 不能都为空!");
|
||||
}
|
||||
return Result.OK(data);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return Result.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加新数据 添加用户新建的部门对象数据,并保存到数据库
|
||||
|
||||
+68
-57
@@ -124,47 +124,23 @@ public class SysDictController {
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-根据字典编码获取字典数据", notes = "字典控制器-根据字典编码获取字典数据")
|
||||
@RequestMapping(value = "/getDictItems/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> getDictItems(@PathVariable String dictCode, @RequestParam(value = "sign",required = false) String sign, HttpServletRequest request) {
|
||||
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>>();
|
||||
List<DictModel> ls = null;
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
String[] params = dictCode.split(",");
|
||||
|
||||
if(params.length<3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {params[0],params[1],params[2]};
|
||||
SqlInjectionUtil.filterContent(sqlInjCheck);
|
||||
|
||||
if(params.length==4) {
|
||||
//SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用)
|
||||
SqlInjectionUtil.specialFilterContent(params[3]);
|
||||
ls = sysDictService.queryTableDictItemsByCodeAndFilter(params[0],params[1],params[2],params[3]);
|
||||
}else if (params.length==3) {
|
||||
ls = sysDictService.queryTableDictItemsByCode(params[0],params[1],params[2]);
|
||||
}else{
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
}else {
|
||||
//字典表
|
||||
ls = sysDictService.queryDictItemsByCode(dictCode);
|
||||
List<DictModel> ls = sysDictService.getDictItems(dictCode);
|
||||
if (ls == null) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.debug(result.toString());
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.debug(result.toString());
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
log.error(e.getMessage(), e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -205,52 +181,87 @@ public class SysDictController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
* @param dictCode
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-通过字典code获取字典数据", notes = "字典控制器-通过字典code获取字典数据")
|
||||
@RequestMapping(value = "/loadDict/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadDict(@PathVariable String dictCode,
|
||||
@RequestParam(name="keyword") String keyword,
|
||||
@RequestParam(value = "sign",required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
@RequestParam(name="keyword") String keyword,
|
||||
@RequestParam(value = "sign",required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
log.info(" 加载字典表数据,加载关键字: "+ keyword);
|
||||
Result<List<DictModel>> result = new Result<List<DictModel>>();
|
||||
List<DictModel> ls = null;
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
String[] params = dictCode.split(",");
|
||||
if(params.length!=3) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
if(pageSize!=null){
|
||||
ls = sysDictService.queryLittleTableDictItems(params[0],params[1],params[2],keyword, pageSize);
|
||||
}else{
|
||||
ls = sysDictService.queryTableDictItems(params[0],params[1],params[2],keyword);
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.info(result.toString());
|
||||
}else {
|
||||
List<DictModel> ls = sysDictService.loadDict(dictCode, keyword, pageSize);
|
||||
if (ls == null) {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
result.setSuccess(true);
|
||||
result.setResult(ls);
|
||||
log.info(result.toString());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.error500("操作失败");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 【给表单设计器的表字典使用】下拉搜索模式,有值时动态拼接数据
|
||||
* @param dictCode
|
||||
* @param keyword 当前控件的值,可以逗号分割
|
||||
* @param sign
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/loadDictOrderByValue/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<DictModel>> loadDictOrderByValue(
|
||||
@PathVariable String dictCode,
|
||||
@RequestParam(name = "keyword") String keyword,
|
||||
@RequestParam(value = "sign", required = false) String sign,
|
||||
@RequestParam(value = "pageSize", required = false) Integer pageSize) {
|
||||
// 首次查询查出来用户选中的值,并且不分页
|
||||
Result<List<DictModel>> firstRes = this.loadDict(dictCode, keyword, sign, null);
|
||||
if (!firstRes.isSuccess()) {
|
||||
return firstRes;
|
||||
}
|
||||
// 然后再查询出第一页的数据
|
||||
Result<List<DictModel>> result = this.loadDict(dictCode, "", sign, pageSize);
|
||||
if (!result.isSuccess()) {
|
||||
return result;
|
||||
}
|
||||
// 合并两次查询的数据
|
||||
List<DictModel> firstList = firstRes.getResult();
|
||||
List<DictModel> list = result.getResult();
|
||||
for (DictModel firstItem : firstList) {
|
||||
// anyMatch 表示:判断的条件里,任意一个元素匹配成功,返回true
|
||||
// allMatch 表示:判断条件里的元素,所有的都匹配成功,返回true
|
||||
// noneMatch 跟 allMatch 相反,表示:判断条件里的元素,所有的都匹配失败,返回true
|
||||
boolean none = list.stream().noneMatch(item -> item.getValue().equals(firstItem.getValue()));
|
||||
// 当元素不存在时,再添加到集合里
|
||||
if (none) {
|
||||
list.add(0, firstItem);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 根据字典code加载字典text 返回
|
||||
* @param dictCode 顺序:tableName,text,code
|
||||
* @param keys 要查询的key
|
||||
* @param sign
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@ApiOperation(value = "字典控制器-根据字典code加载字典text", notes = "字典控制器-根据字典code加载字典text")
|
||||
@RequestMapping(value = "/loadDictItem/{dictCode}", method = RequestMethod.GET)
|
||||
public Result<List<String>> loadDictItem(@PathVariable String dictCode, @RequestParam(name="key") String keys, @RequestParam(value = "sign",required = false) String sign, HttpServletRequest request) {
|
||||
public Result<List<String>> loadDictItem(@PathVariable String dictCode,@RequestParam(name="key") String keys, @RequestParam(value = "sign",required = false) String sign,@RequestParam(value = "delNotExist",required = false,defaultValue = "true") boolean delNotExist,HttpServletRequest request) {
|
||||
Result<List<String>> result = new Result<>();
|
||||
try {
|
||||
if(dictCode.indexOf(",")!=-1) {
|
||||
@@ -259,7 +270,7 @@ public class SysDictController {
|
||||
result.error500("字典Code格式不正确!");
|
||||
return result;
|
||||
}
|
||||
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys);
|
||||
List<String> texts = sysDictService.queryTableDictByKeys(params[0], params[1], params[2], keys, delNotExist);
|
||||
|
||||
result.setSuccess(true);
|
||||
result.setResult(texts);
|
||||
|
||||
+35
-8
@@ -170,8 +170,8 @@ public class SysUserController {
|
||||
throw new JeroBootException("邮箱和手机号解密失败!", e);
|
||||
}
|
||||
|
||||
sysUserService.addUserWithRole(user, selectedRoles);
|
||||
sysUserService.addUserWithDepart(user, selectedDeparts);
|
||||
// 保存用户走一个service 保证事务
|
||||
sysUserService.saveUser(user, selectedRoles, selectedDeparts);
|
||||
result.success("添加成功!");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
@@ -217,9 +217,8 @@ public class SysUserController {
|
||||
user.setUpdateTime(new Date());
|
||||
//String passwordEncode = PasswordUtil.encrypt(user.getUsername(), user.getPassword(), sysUser.getSalt());
|
||||
user.setPassword(sysUser.getPassword());
|
||||
sysUserService.editUserWithRole(user, roles);
|
||||
sysUserService.editUserWithDepart(user, departs);
|
||||
sysUserService.updateNullPhoneEmail();
|
||||
// 修改用户走一个service 保证事务
|
||||
sysUserService.editUser(user, roles, departs);
|
||||
result.success("修改成功!");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -313,6 +312,7 @@ public class SysUserController {
|
||||
result.setResult(true);
|
||||
try {
|
||||
//通过传入信息查询新的用户信息
|
||||
sysUser.setPassword(null);
|
||||
SysUser user = sysUserService.getOne(new QueryWrapper<SysUser>(sysUser));
|
||||
if (user != null) {
|
||||
result.setSuccess(false);
|
||||
@@ -329,8 +329,9 @@ public class SysUserController {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@RequiresPermissions("user:edit")
|
||||
/**
|
||||
* 修改密码
|
||||
*/
|
||||
@RequestMapping(value = "/changePassword", method = RequestMethod.PUT)
|
||||
public Result<?> changePassword(@RequestBody SysUser sysUser) {
|
||||
SysUser u = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, sysUser.getUsername()));
|
||||
@@ -424,6 +425,23 @@ public class SysUserController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户选择组件 专用 根据用户账号或部门分页查询
|
||||
* @param departId
|
||||
* @param username
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/queryUserComponentData", method = RequestMethod.GET)
|
||||
public Result<IPage<SysUser>> queryUserComponentData(
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
@RequestParam(name = "departId", required = false) String departId,
|
||||
@RequestParam(name="realname",required=false) String realname,
|
||||
@RequestParam(name="username",required=false) String username) {
|
||||
IPage<SysUser> pageList = sysUserDepartService.queryDepartUserPageList(departId, username, realname, pageSize, pageNo);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
@@ -559,13 +577,20 @@ public class SysUserController {
|
||||
* 首页用户重置密码
|
||||
*/
|
||||
@RequestMapping(value = "/updatePassword", method = RequestMethod.PUT)
|
||||
public Result<?> changPassword(@RequestBody JSONObject json) {
|
||||
public Result<?> updatePassword(@RequestBody JSONObject json) {
|
||||
String username = json.getString("username");
|
||||
String oldpassword = json.getString("oldpassword");
|
||||
String password = json.getString("password");
|
||||
String confirmpassword = json.getString("confirmpassword");
|
||||
String RSAPublicKey = json.getString("rsaPublicKey");
|
||||
|
||||
LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
|
||||
if(!sysUser.getUsername().equals(username)){
|
||||
return Result.error("只允许修改自己的密码!");
|
||||
}
|
||||
|
||||
String RSAPrivateKey = String.valueOf(redisUtil.get(RSAPublicKey));
|
||||
|
||||
try {
|
||||
oldpassword = CommonUtils.decryptBtRsaPriKey(oldpassword, RSAPrivateKey);
|
||||
password = CommonUtils.decryptBtRsaPriKey(password, RSAPrivateKey);
|
||||
@@ -573,6 +598,7 @@ public class SysUserController {
|
||||
}catch (Exception e){
|
||||
log.error(e.getMessage(),e);
|
||||
}
|
||||
|
||||
SysUser user = this.sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUsername, username));
|
||||
if(user==null) {
|
||||
return Result.error("用户不存在!");
|
||||
@@ -1342,4 +1368,5 @@ public class SysUserController {
|
||||
sysUserService.updateById(user);
|
||||
return Result.OK("手机号设置成功!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+24
-1
@@ -99,7 +99,8 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
* @param hasChildField
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectModel> queryTreeList(@Param("query") String query,@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField);
|
||||
@Deprecated
|
||||
List<TreeSelectModel> queryTreeList(@Param("query") Map<String, String> query,@Param("table") String table,@Param("text") String text,@Param("code") String code,@Param("pidField") String pidField,@Param("pid") String pid,@Param("hasChildField") String hasChildField);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名拼接树结构
|
||||
@@ -151,4 +152,26 @@ public interface SysDictMapper extends BaseMapper<SysDict> {
|
||||
*/
|
||||
@Deprecated
|
||||
public Page<DictModel> queryDictTablePageList(Page page, @Param("query") DictQuery query);
|
||||
|
||||
|
||||
/**
|
||||
* 查询 字典表数据 支持查询条件 分页
|
||||
* @param page
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
IPage<DictModel> queryTableDictWithFilter(Page<DictModel> page, @Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
|
||||
|
||||
/**
|
||||
* 查询 字典表数据 支持查询条件 查询所有
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param filterSql
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> queryAllTableDictItems(@Param("table") String table, @Param("text") String text, @Param("code") String code, @Param("filterSql") String filterSql);
|
||||
}
|
||||
|
||||
+22
@@ -1,6 +1,10 @@
|
||||
package com.jero.modules.system.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.jero.modules.system.entity.SysUserDepart;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
@@ -8,4 +12,22 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
public interface SysUserDepartMapper extends BaseMapper<SysUserDepart>{
|
||||
|
||||
List<SysUserDepart> getUserDepartByUid(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* 查询指定部门下的用户 并且支持用户真实姓名模糊查询
|
||||
* @param orgCode
|
||||
* @param realname
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryDepartUserList(@Param("orgCode") String orgCode, @Param("realname") String realname);
|
||||
|
||||
/**
|
||||
* 根据部门查询部门用户
|
||||
* @param page
|
||||
* @param orgCode
|
||||
* @param username
|
||||
* @param realname
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> queryDepartUserPageList(Page<SysUser> page, @Param("orgCode") String orgCode, @Param("username") String username, @Param("realname") String realname);
|
||||
}
|
||||
|
||||
+16
@@ -121,4 +121,20 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 分页-->
|
||||
<select id="queryTableDictWithFilter" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table}
|
||||
<if test="filterSql != null and filterSql != ''">
|
||||
${filterSql}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!--通过查询指定table的 text code 获取字典数据,且支持关键字和自定义查询条件查询 获取所有 -->
|
||||
<select id="queryAllTableDictItems" parameterType="String" resultType="org.jeecg.common.system.vo.DictModel">
|
||||
select ${text} as "text", ${code} as "value" from ${table}
|
||||
<if test="filterSql != null and filterSql != ''">
|
||||
${filterSql}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
+27
@@ -6,4 +6,31 @@
|
||||
FROM sys_user_depart
|
||||
WHERE user_id = #{userId, jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
|
||||
<!-- 查询指定部门下的用户 并且支持用户账号模糊查询 -->
|
||||
<select id="queryDepartUserList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select a.* from sys_user a
|
||||
join sys_user_depart b on b.user_id = a.id
|
||||
join sys_depart c on b.dep_id = c.id
|
||||
where a.del_flag = 0 and c.org_code like '${orgCode}%'
|
||||
<if test="realname!=null and realname!=''">
|
||||
and a.realname like '%${realname}%'
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据部门查询部门用户 分页 -->
|
||||
<select id="queryDepartUserPageList" resultType="org.jeecg.modules.system.entity.SysUser">
|
||||
select a.*, c.depart_name as org_code_txt from sys_user a
|
||||
join sys_user_depart b on b.user_id = a.id
|
||||
join sys_depart c on b.dep_id = c.id
|
||||
where a.del_flag = 0 and c.org_code like '${orgCode}%'
|
||||
<if test="username!=null and username!=''">
|
||||
and a.username like '%${username}%'
|
||||
</if>
|
||||
<if test="realname!=null and realname!=''">
|
||||
and a.realname like '%${realname}%'
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
+18
-1
@@ -58,5 +58,22 @@ public interface ISysCategoryService extends IService<SysCategory> {
|
||||
* @param ids
|
||||
*/
|
||||
void deleteSysCategory(String ids);
|
||||
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<String> loadDictItem(String ids);
|
||||
|
||||
/**
|
||||
* 分类字典控件数据回显[表单页面]
|
||||
*
|
||||
* @param ids
|
||||
* @param delNotExist 是否移除不存在的项,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
List<String> loadDictItem(String ids, boolean delNotExist);
|
||||
|
||||
}
|
||||
|
||||
+17
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.system.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
@@ -129,11 +130,27 @@ public interface ISysDepartService extends IService<SysDepart>{
|
||||
* @return
|
||||
*/
|
||||
List<SysDepartTreeModel> queryTreeListByPid(String parentId);
|
||||
|
||||
/**
|
||||
* 获取某个部门的所有父级部门的ID
|
||||
*
|
||||
* @param departId 根据departId查
|
||||
*/
|
||||
JSONObject queryAllParentIdByDepartId(String departId);
|
||||
|
||||
/**
|
||||
* 获取某个部门的所有父级部门的ID
|
||||
*
|
||||
* @param orgCode 根据orgCode查
|
||||
*/
|
||||
JSONObject queryAllParentIdByOrgCode(String orgCode);
|
||||
|
||||
/**
|
||||
* 获取公司信息
|
||||
* @return
|
||||
*/
|
||||
SysDepart queryCompByOrgCode(String orgCode);
|
||||
|
||||
/**
|
||||
* 获取下级部门
|
||||
* @return
|
||||
|
||||
+35
-3
@@ -38,6 +38,9 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
@Deprecated
|
||||
List<String> queryTableDictByKeys(String table, String text, String code, String keys);
|
||||
|
||||
@Deprecated
|
||||
List<String> queryTableDictByKeys(String table, String text, String code, String keys,boolean delNotExist);
|
||||
|
||||
/**
|
||||
* 根据字典类型删除关联表中其对应的数据
|
||||
*
|
||||
@@ -82,10 +85,21 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code,String keyword, int pageSize);
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String condition, String keyword, int pageSize);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 查询树
|
||||
* 查询字典表所有数据
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
* @param condition
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
public List<DictModel> queryAllTableDictItems(String table, String text, String code, String condition, String keyword);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 查询树
|
||||
* @param table
|
||||
* @param text
|
||||
* @param code
|
||||
@@ -94,7 +108,8 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
* @param hasChildField
|
||||
* @return
|
||||
*/
|
||||
List<TreeSelectModel> queryTreeList(String query,String table, String text, String code, String pidField,String pid,String hasChildField);
|
||||
@Deprecated
|
||||
List<TreeSelectModel> queryTreeList(Map<String, String> query,String table, String text, String code, String pidField,String pid,String hasChildField);
|
||||
|
||||
/**
|
||||
* 根据表名、显示字段名、存储字段名 和查询条件拼接树结构
|
||||
@@ -135,6 +150,23 @@ public interface ISysDictService extends IService<SysDict> {
|
||||
@Deprecated
|
||||
public List<DictModel> queryDictTablePageList(DictQuery query,int pageSize, int pageNo);
|
||||
|
||||
/**
|
||||
* 获取字典数据
|
||||
* @param dictCode 字典code
|
||||
* @param dictCode 表名,文本字段,code字段 | 举例:sys_user,realname,id
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> getDictItems(String dictCode);
|
||||
|
||||
/**
|
||||
* 【JSearchSelectTag下拉搜索组件专用接口】
|
||||
* 大数据量的字典表 走异步加载 即前端输入内容过滤数据
|
||||
*
|
||||
* @param dictCode 字典code格式:table,text,code
|
||||
* @return
|
||||
*/
|
||||
List<DictModel> loadDict(String dictCode, String keyword, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 刷新dict缓存
|
||||
* @date 2021/4/8 9:06
|
||||
|
||||
+15
-2
@@ -3,6 +3,7 @@ package com.jero.modules.system.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
import com.jero.modules.system.entity.SysUserDepart;
|
||||
import com.jero.modules.system.model.DepartIdModel;
|
||||
@@ -34,8 +35,20 @@ public interface ISysUserDepartService extends IService<SysUserDepart> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryUserByDepId(String depId);
|
||||
/**
|
||||
|
||||
/**
|
||||
* 根据部门code,查询当前部门和下级部门的用户信息
|
||||
*/
|
||||
public List<SysUser> queryUserByDepCode(String depCode,String realname);
|
||||
List<SysUser> queryUserByDepCode(String depCode,String realname);
|
||||
|
||||
/**
|
||||
* 用户组件数据查询
|
||||
* @param departId
|
||||
* @param username
|
||||
* @param pageSize
|
||||
* @param pageNo
|
||||
* @return
|
||||
*/
|
||||
IPage<SysUser> queryDepartUserPageList(String departId, String username, String realname, int pageSize, int pageNo);
|
||||
|
||||
}
|
||||
|
||||
+21
@@ -1,5 +1,6 @@
|
||||
package com.jero.modules.system.service;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -233,4 +234,24 @@ public interface ISysUserService extends IService<SysUser> {
|
||||
* @return
|
||||
*/
|
||||
List<SysUser> queryByDepIds(List<String> departIds, String username);
|
||||
|
||||
/**
|
||||
* 保存用户
|
||||
* @param user 用户
|
||||
* @param selectedRoles 选择的角色id,多个以逗号隔开
|
||||
* @param selectedDeparts 选择的部门id,多个以逗号隔开
|
||||
*/
|
||||
void saveUser(SysUser user, String selectedRoles, String selectedDeparts);
|
||||
|
||||
/**
|
||||
* 编辑用户
|
||||
* @param user 用户
|
||||
* @param roles 选择的角色id,多个以逗号隔开
|
||||
* @param departs 选择的部门id,多个以逗号隔开
|
||||
*/
|
||||
void editUser(SysUser user, String roles, String departs);
|
||||
|
||||
/** userId转为username */
|
||||
List<String> userIdToUsername(Collection<String> userIdList);
|
||||
|
||||
}
|
||||
|
||||
+3
-1
@@ -199,6 +199,8 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
info.setSysUserCode(user.getUsername());
|
||||
info.setSysUserName(user.getRealname());
|
||||
info.setSysOrgCode(user.getOrgCode());
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
//多部门支持in查询
|
||||
List<SysDepart> list = departMapper.queryUserDeparts(user.getId());
|
||||
@@ -265,7 +267,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
||||
}
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code")
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code", unless = "#result == null ")
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
return sysDictService.queryDictItemsByCode(code);
|
||||
}
|
||||
|
||||
+30
@@ -1,8 +1,10 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -204,4 +206,32 @@ public class SysCategoryServiceImpl extends ServiceImpl<SysCategoryMapper, SysCa
|
||||
return sb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids) {
|
||||
return this.loadDictItem(ids, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> loadDictItem(String ids, boolean delNotExist) {
|
||||
String[] idArray = ids.split(",");
|
||||
LambdaQueryWrapper<SysCategory> query = new LambdaQueryWrapper<>();
|
||||
query.in(SysCategory::getId, Arrays.asList(idArray));
|
||||
// 查询数据
|
||||
List<SysCategory> list = super.list(query);
|
||||
// 取出name并返回
|
||||
List<String> textList;
|
||||
// update-begin--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
if (delNotExist) {
|
||||
textList = list.stream().map(SysCategory::getName).collect(Collectors.toList());
|
||||
} else {
|
||||
textList = new ArrayList<>();
|
||||
for (String id : idArray) {
|
||||
List<SysCategory> res = list.stream().filter(i -> id.equals(i.getId())).collect(Collectors.toList());
|
||||
textList.add(res.size() > 0 ? res.get(0).getName() : id);
|
||||
}
|
||||
}
|
||||
// update-end--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
return textList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+58
-1
@@ -2,8 +2,11 @@ package com.jero.modules.system.service.impl;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.jero.common.system.vo.SysDepartTreeModel;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
@@ -473,7 +476,7 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
FindsDepartsChildrenUtil.convertSysDepartToSysDepartTreeModel(depart, treeModel);
|
||||
|
||||
//TODO 异步树加载key拼接__+时间戳,以便于每次展开节点会刷新数据
|
||||
treeModel.setKey(treeModel.getKey()+"__"+System.currentTimeMillis());
|
||||
treeModel.setKey(treeModel.getKey());
|
||||
Integer count=this.baseMapper.queryCountByPid(depart.getId());
|
||||
if(count>0){
|
||||
treeModel.setIsLeaf(false);
|
||||
@@ -484,6 +487,60 @@ public class SysDepartServiceImpl extends ServiceImpl<SysDepartMapper, SysDepart
|
||||
}
|
||||
return records;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject queryAllParentIdByDepartId(String departId) {
|
||||
JSONObject result = new JSONObject();
|
||||
for (String id : departId.split(",")) {
|
||||
JSONObject all = this.queryAllParentId("id", id);
|
||||
result.put(id, all);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject queryAllParentIdByOrgCode(String orgCode) {
|
||||
JSONObject result = new JSONObject();
|
||||
for (String code : orgCode.split(",")) {
|
||||
JSONObject all = this.queryAllParentId("org_code", code);
|
||||
result.put(code, all);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某个部门的所有父ID信息
|
||||
*
|
||||
* @param fieldName 字段名
|
||||
* @param value 值
|
||||
*/
|
||||
private JSONObject queryAllParentId(String fieldName, String value) {
|
||||
JSONObject data = new JSONObject();
|
||||
// 父ID集合,有序
|
||||
data.put("parentIds", new JSONArray());
|
||||
// 父ID的部门数据,key是id,value是数据
|
||||
data.put("parentMap", new JSONObject());
|
||||
this.queryAllParentIdRecursion(fieldName, value, data);
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归调用查询父部门接口
|
||||
*/
|
||||
private void queryAllParentIdRecursion(String fieldName, String value, JSONObject data) {
|
||||
QueryWrapper<SysDepart> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(fieldName, value);
|
||||
SysDepart depart = super.getOne(queryWrapper);
|
||||
if (depart != null) {
|
||||
data.getJSONArray("parentIds").add(0, depart.getId());
|
||||
data.getJSONObject("parentMap").put(depart.getId(), depart);
|
||||
if (oConvertUtils.isNotEmpty(depart.getParentId())) {
|
||||
this.queryAllParentIdRecursion("id", depart.getParentId(), data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public SysDepart queryCompByOrgCode(String orgCode) {
|
||||
int length = YouBianCodeUtil.zhanweiLength;
|
||||
|
||||
+124
-14
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.common.util.SqlInjectionUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import com.jero.common.constant.CacheConstant;
|
||||
import com.jero.common.constant.CommonConstant;
|
||||
@@ -53,7 +54,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code")
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code", unless = "#result == null ")
|
||||
public List<DictModel> queryDictItemsByCode(String code) {
|
||||
log.debug("无缓存dictCache的时候调用这里!");
|
||||
return sysDictMapper.queryDictItemsByCode(code);
|
||||
@@ -89,7 +90,7 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
*/
|
||||
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code+':'+#key")
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_CACHE,key = "#code+':'+#key", unless = "#result == null ")
|
||||
public String queryDictTextByKey(String code, String key) {
|
||||
log.debug("无缓存dictText的时候调用这里!");
|
||||
return sysDictMapper.queryDictTextByKey(code, key);
|
||||
@@ -126,12 +127,17 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE)
|
||||
@Cacheable(value = CacheConstant.SYS_DICT_TABLE_CACHE, unless = "#result == null ")
|
||||
public String queryTableDictTextByKey(String table,String text,String code, String key) {
|
||||
log.debug("无缓存dictTable的时候调用这里!");
|
||||
return sysDictMapper.queryTableDictTextByKey(table,text,code,key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys) {
|
||||
return this.queryTableDictByKeys(table, text, code, keys, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过查询指定table的 text code 获取字典,包含text和value
|
||||
* dictTableCache采用redis缓存有效期10分钟
|
||||
@@ -139,28 +145,33 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
* @param text
|
||||
* @param code
|
||||
* @param keys (逗号分隔)
|
||||
* @param delNotExist 是否移除不存在的项,默认为true,设为false如果某个key不存在数据库中,则直接返回key本身
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
//update-begin--Author:lvdandan Date:20201204 for:JT-36【online】树形列表bug修改后,还是显示原来值 暂时去掉缓存
|
||||
//@Cacheable(value = CacheConstant.SYS_DICT_TABLE_BY_KEYS_CACHE)
|
||||
//update-end--Author:lvdandan Date:20201204 for:JT-36【online】树形列表bug修改后,还是显示原来值 暂时去掉缓存
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys) {
|
||||
public List<String> queryTableDictByKeys(String table, String text, String code, String keys, boolean delNotExist) {
|
||||
if(oConvertUtils.isEmpty(keys)){
|
||||
return null;
|
||||
}
|
||||
String[] keyArray = keys.split(",");
|
||||
List<DictModel> dicts = sysDictMapper.queryTableDictByKeys(table, text, code, keyArray);
|
||||
List<String> texts = new ArrayList<>(dicts.size());
|
||||
|
||||
// update-begin--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
// 查询出来的顺序可能是乱的,需要排个序
|
||||
for (String key : keyArray) {
|
||||
for (DictModel dict : dicts) {
|
||||
if (key.equals(dict.getValue())) {
|
||||
texts.add(dict.getText());
|
||||
break;
|
||||
}
|
||||
List<DictModel> res = dicts.stream().filter(i -> key.equals(i.getValue())).collect(Collectors.toList());
|
||||
if (res.size() > 0) {
|
||||
texts.add(res.get(0).getText());
|
||||
} else if (!delNotExist) {
|
||||
texts.add(key);
|
||||
}
|
||||
}
|
||||
// update-end--author:sunjianlei--date:20210514--for:新增delNotExist参数,设为false不删除数据库里不存在的key ----
|
||||
|
||||
return texts;
|
||||
}
|
||||
|
||||
@@ -208,15 +219,53 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String keyword, int pageSize) {
|
||||
Page<DictModel> page = new Page<DictModel>(1, pageSize);
|
||||
IPage<DictModel> pageList = baseMapper.queryTableDictItems(page, table, text, code, "%"+keyword+"%");
|
||||
public List<DictModel> queryLittleTableDictItems(String table, String text, String code, String condition, String keyword, int pageSize) {
|
||||
Page<DictModel> page = new Page<DictModel>(1, pageSize);
|
||||
page.setSearchCount(false);
|
||||
String filterSql = getFilterSql(text, code, condition, keyword);
|
||||
IPage<DictModel> pageList = baseMapper.queryTableDictWithFilter(page, table, text, code, filterSql);
|
||||
return pageList.getRecords();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取条件语句
|
||||
* @param text
|
||||
* @param code
|
||||
* @param condition
|
||||
* @param keyword
|
||||
* @return
|
||||
*/
|
||||
private String getFilterSql(String text, String code, String condition, String keyword){
|
||||
String keywordSql = null, filterSql = "", sql_where = " where ";
|
||||
if(oConvertUtils.isNotEmpty(keyword)){
|
||||
// 判断是否是多选
|
||||
if (keyword.contains(",")) {
|
||||
String inKeywords = "\"" + keyword.replaceAll(",", "\",\"") + "\"";
|
||||
keywordSql = "(" + text + " in (" + inKeywords + ") or " + code + " in (" + inKeywords + "))";
|
||||
} else {
|
||||
keywordSql = "("+text + " like '%"+keyword+"%' or "+ code + " like '%"+keyword+"%')";
|
||||
}
|
||||
}
|
||||
if(oConvertUtils.isNotEmpty(condition) && oConvertUtils.isNotEmpty(keywordSql)){
|
||||
filterSql+= sql_where + condition + " and " + keywordSql;
|
||||
}else if(oConvertUtils.isNotEmpty(condition)){
|
||||
filterSql+= sql_where + condition;
|
||||
}else if(oConvertUtils.isNotEmpty(keywordSql)){
|
||||
filterSql+= sql_where + keywordSql;
|
||||
}
|
||||
return filterSql;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryTreeList(String query,String table, String text, String code, String pidField, String pid, String hasChildField) {
|
||||
return baseMapper.queryTreeList(query, table, text, code, pidField, pid,hasChildField);
|
||||
public List<DictModel> queryAllTableDictItems(String table, String text, String code, String condition, String keyword) {
|
||||
String filterSql = getFilterSql(text, code, condition, keyword);
|
||||
List<DictModel> ls = baseMapper.queryAllTableDictItems(table, text, code, filterSql);
|
||||
return ls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TreeSelectModel> queryTreeList(Map<String, String> query,String table, String text, String code, String pidField,String pid,String hasChildField) {
|
||||
return baseMapper.queryTreeList(query,table, text, code, pidField, pid,hasChildField);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -288,6 +337,65 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
Page<DictModel> pageList = baseMapper.queryDictTablePageList(page, query);
|
||||
return pageList.getRecords();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<DictModel> getDictItems(String dictCode) {
|
||||
List<DictModel> ls;
|
||||
if (dictCode.contains(",")) {
|
||||
//关联表字典(举例:sys_user,realname,id)
|
||||
String[] params = dictCode.split(",");
|
||||
if (params.length < 3) {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
}
|
||||
//SQL注入校验(只限制非法串改数据库)
|
||||
final String[] sqlInjCheck = {params[0], params[1], params[2]};
|
||||
SqlInjectionUtil.filterContent(sqlInjCheck);
|
||||
if (params.length == 4) {
|
||||
// SQL注入校验(查询条件SQL 特殊check,此方法仅供此处使用)
|
||||
SqlInjectionUtil.specialFilterContent(params[3]);
|
||||
ls = this.queryTableDictItemsByCodeAndFilter(params[0], params[1], params[2], params[3]);
|
||||
} else if (params.length == 3) {
|
||||
ls = this.queryTableDictItemsByCode(params[0], params[1], params[2]);
|
||||
} else {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
//字典表
|
||||
ls = this.queryDictItemsByCode(dictCode);
|
||||
}
|
||||
return ls;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictModel> loadDict(String dictCode, String keyword, Integer pageSize) {
|
||||
if (dictCode.contains(",")) {
|
||||
//update-begin-author:taoyan date:20210329 for: 下拉搜索不支持表名后加查询条件
|
||||
String[] params = dictCode.split(",");
|
||||
String condition = null;
|
||||
if (params.length != 3 && params.length != 4) {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
} else if (params.length == 4) {
|
||||
condition = params[3];
|
||||
}
|
||||
List<DictModel> ls;
|
||||
if (pageSize != null) {
|
||||
ls = this.queryLittleTableDictItems(params[0], params[1], params[2], condition, keyword, pageSize);
|
||||
} else {
|
||||
ls = this.queryAllTableDictItems(params[0], params[1], params[2], condition, keyword);
|
||||
}
|
||||
//update-end-author:taoyan date:20210329 for: 下拉搜索不支持表名后加查询条件
|
||||
return ls;
|
||||
} else {
|
||||
// 字典Code格式不正确
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新dict缓存
|
||||
* @date 2021/4/8 9:07
|
||||
@@ -299,12 +407,14 @@ public class SysDictServiceImpl extends ServiceImpl<SysDictMapper, SysDict> impl
|
||||
//清空字典缓存
|
||||
Set keys = redisTemplate.keys(CacheConstant.SYS_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 + "*");
|
||||
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*");
|
||||
Set keys5 = redisTemplate.keys( "jmreport:cache:dict*");
|
||||
Set keys6 = redisTemplate.keys( "jmreport:cache:dictTable*");
|
||||
redisTemplate.delete(keys);
|
||||
redisTemplate.delete(keys2);
|
||||
redisTemplate.delete(keys21);
|
||||
redisTemplate.delete(keys3);
|
||||
redisTemplate.delete(keys4);
|
||||
redisTemplate.delete(keys5);
|
||||
|
||||
+56
-28
@@ -1,11 +1,15 @@
|
||||
package com.jero.modules.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.common.util.oConvertUtils;
|
||||
import com.jero.modules.system.entity.SysDepart;
|
||||
import com.jero.modules.system.entity.SysUser;
|
||||
@@ -100,34 +104,58 @@ public class SysUserDepartServiceImpl extends ServiceImpl<SysUserDepartMapper, S
|
||||
*/
|
||||
@Override
|
||||
public List<SysUser> queryUserByDepCode(String depCode,String realname) {
|
||||
LambdaQueryWrapper<SysDepart> queryByDepCode = new LambdaQueryWrapper<SysDepart>();
|
||||
queryByDepCode.likeRight(SysDepart::getOrgCode,depCode);
|
||||
List<SysDepart> sysDepartList = sysDepartService.list(queryByDepCode);
|
||||
List<String> depIds = sysDepartList.stream().map(SysDepart::getId).collect(Collectors.toList());
|
||||
|
||||
LambdaQueryWrapper<SysUserDepart> queryUDep = new LambdaQueryWrapper<SysUserDepart>();
|
||||
queryUDep.in(SysUserDepart::getDepId, depIds);
|
||||
List<String> userIdList = new ArrayList<>();
|
||||
List<SysUserDepart> uDepList = this.list(queryUDep);
|
||||
if(uDepList != null && uDepList.size() > 0) {
|
||||
for(SysUserDepart uDep : uDepList) {
|
||||
userIdList.add(uDep.getUserId());
|
||||
}
|
||||
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<SysUser>();
|
||||
queryUser.in(SysUser::getId,userIdList);
|
||||
if(oConvertUtils.isNotEmpty(realname)){
|
||||
queryUser.like(SysUser::getRealname,realname.trim());
|
||||
}
|
||||
List<SysUser> userList = (List<SysUser>) sysUserService.list(queryUser);
|
||||
//update-begin-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息
|
||||
for (SysUser sysUser : userList) {
|
||||
sysUser.setSalt("");
|
||||
sysUser.setPassword("");
|
||||
}
|
||||
//update-end-author:taoyan date:201905047 for:接口调用查询返回结果不能返回密码相关信息
|
||||
return userList;
|
||||
//update-begin-author:taoyan date:20210422 for: 根据部门选择用户接口代码优化
|
||||
if(oConvertUtils.isNotEmpty(realname)){
|
||||
realname = realname.trim();
|
||||
}
|
||||
return new ArrayList<SysUser>();
|
||||
List<SysUser> userList = this.baseMapper.queryDepartUserList(depCode, realname);
|
||||
Map<String, SysUser> map = new HashMap<String, SysUser>();
|
||||
for (SysUser sysUser : userList) {
|
||||
// 返回的用户数据去掉密码信息
|
||||
sysUser.setSalt("");
|
||||
sysUser.setPassword("");
|
||||
map.put(sysUser.getId(), sysUser);
|
||||
}
|
||||
return new ArrayList<SysUser>(map.values());
|
||||
//update-end-author:taoyan date:20210422 for: 根据部门选择用户接口代码优化
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<SysUser> queryDepartUserPageList(String departId, String username, String realname, int pageSize, int pageNo) {
|
||||
IPage<SysUser> pageList = null;
|
||||
// 部门ID不存在 直接查询用户表即可
|
||||
Page<SysUser> page = new Page<SysUser>(pageNo, pageSize);
|
||||
if(oConvertUtils.isEmpty(departId)){
|
||||
LambdaQueryWrapper<SysUser> query = new LambdaQueryWrapper<>();
|
||||
if(oConvertUtils.isNotEmpty(username)){
|
||||
query.like(SysUser::getUsername, username);
|
||||
}
|
||||
pageList = sysUserService.page(page, query);
|
||||
}else{
|
||||
// 有部门ID 需要走自定义sql
|
||||
SysDepart sysDepart = sysDepartService.getById(departId);
|
||||
pageList = this.baseMapper.queryDepartUserPageList(page, sysDepart.getOrgCode(), username, realname);
|
||||
}
|
||||
List<SysUser> userList = pageList.getRecords();
|
||||
if(userList!=null && userList.size()>0){
|
||||
List<String> userIds = userList.stream().map(SysUser::getId).collect(Collectors.toList());
|
||||
Map<String, SysUser> map = new HashMap<String, SysUser>();
|
||||
if(userIds!=null && userIds.size()>0){
|
||||
// 查部门名称
|
||||
Map<String,String> useDepNames = sysUserService.getDepNamesByUserIds(userIds);
|
||||
userList.forEach(item->{
|
||||
//TODO 临时借用这个字段用于页面展示
|
||||
item.setOrgCodeTxt(useDepNames.get(item.getId()));
|
||||
item.setSalt("");
|
||||
item.setPassword("");
|
||||
// 去重
|
||||
map.put(item.getId(), item);
|
||||
});
|
||||
}
|
||||
pageList.setRecords(new ArrayList<SysUser>(map.values()));
|
||||
}
|
||||
return pageList;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+85
@@ -439,4 +439,89 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
return userMapper.queryByDepIds(departIds,username);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveUser(SysUser user, String selectedRoles, String selectedDeparts) {
|
||||
//step.1 保存用户
|
||||
this.save(user);
|
||||
//step.2 保存角色
|
||||
if(oConvertUtils.isNotEmpty(selectedRoles)) {
|
||||
String[] arr = selectedRoles.split(",");
|
||||
for (String roleId : arr) {
|
||||
SysUserRole userRole = new SysUserRole(user.getId(), roleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
//step.3 保存所属部门
|
||||
if(oConvertUtils.isNotEmpty(selectedDeparts)) {
|
||||
String[] arr = selectedDeparts.split(",");
|
||||
for (String deaprtId : arr) {
|
||||
SysUserDepart userDeaprt = new SysUserDepart(user.getId(), deaprtId);
|
||||
sysUserDepartMapper.insert(userDeaprt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@CacheEvict(value={CacheConstant.SYS_USERS_CACHE}, allEntries=true)
|
||||
public void editUser(SysUser user, String roles, String departs) {
|
||||
//step.1 修改用户基础信息
|
||||
this.updateById(user);
|
||||
//step.2 修改角色
|
||||
//处理用户角色 先删后加
|
||||
sysUserRoleMapper.delete(new QueryWrapper<SysUserRole>().lambda().eq(SysUserRole::getUserId, user.getId()));
|
||||
if(oConvertUtils.isNotEmpty(roles)) {
|
||||
String[] arr = roles.split(",");
|
||||
for (String roleId : arr) {
|
||||
SysUserRole userRole = new SysUserRole(user.getId(), roleId);
|
||||
sysUserRoleMapper.insert(userRole);
|
||||
}
|
||||
}
|
||||
|
||||
//step.3 修改部门
|
||||
String[] arr = {};
|
||||
if(oConvertUtils.isNotEmpty(departs)){
|
||||
arr = departs.split(",");
|
||||
}
|
||||
//查询已关联部门
|
||||
List<SysUserDepart> userDepartList = sysUserDepartMapper.selectList(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
|
||||
if(userDepartList != null && userDepartList.size()>0){
|
||||
for(SysUserDepart depart : userDepartList ){
|
||||
//修改已关联部门删除部门用户角色关系
|
||||
if(!Arrays.asList(arr).contains(depart.getDepId())){
|
||||
List<SysDepartRole> sysDepartRoleList = sysDepartRoleMapper.selectList(
|
||||
new QueryWrapper<SysDepartRole>().lambda().eq(SysDepartRole::getDepartId,depart.getDepId()));
|
||||
List<String> roleIds = sysDepartRoleList.stream().map(SysDepartRole::getId).collect(Collectors.toList());
|
||||
if(roleIds != null && roleIds.size()>0){
|
||||
departRoleUserMapper.delete(new QueryWrapper<SysDepartRoleUser>().lambda().eq(SysDepartRoleUser::getUserId, user.getId())
|
||||
.in(SysDepartRoleUser::getDroleId,roleIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//先删后加
|
||||
sysUserDepartMapper.delete(new QueryWrapper<SysUserDepart>().lambda().eq(SysUserDepart::getUserId, user.getId()));
|
||||
if(oConvertUtils.isNotEmpty(departs)) {
|
||||
for (String departId : arr) {
|
||||
SysUserDepart userDepart = new SysUserDepart(user.getId(), departId);
|
||||
sysUserDepartMapper.insert(userDepart);
|
||||
}
|
||||
}
|
||||
//step.4 修改手机号和邮箱
|
||||
// 更新手机号、邮箱空字符串为 null
|
||||
userMapper.updateNullByEmptyString("email");
|
||||
userMapper.updateNullByEmptyString("phone");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> userIdToUsername(Collection<String> userIdList) {
|
||||
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(SysUser::getId, userIdList);
|
||||
List<SysUser> userList = super.list(queryWrapper);
|
||||
return userList.stream().map(SysUser::getUsername).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
-25
@@ -1,25 +0,0 @@
|
||||
package com.jero.modules.system.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* 多租户 tenant_id存储器
|
||||
*/
|
||||
@Slf4j
|
||||
public class TenantContext {
|
||||
|
||||
private static ThreadLocal<String> currentTenant = new ThreadLocal<>();
|
||||
|
||||
public static void setTenant(String tenant) {
|
||||
log.debug(" setting tenant to " + tenant);
|
||||
currentTenant.set(tenant);
|
||||
}
|
||||
|
||||
public static String getTenant() {
|
||||
return currentTenant.get();
|
||||
}
|
||||
|
||||
public static void clear(){
|
||||
currentTenant.remove();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user