去除企业微信/钉钉对接功能、去除职位管理及用户职位关联功能
This commit is contained in:
		
							parent
							
								
									7ccfbe9c18
								
							
						
					
					
						commit
						303e1c9aad
					
				|  | @ -503,13 +503,6 @@ public interface ISysBaseAPI extends CommonAPI { | |||
|      */ | ||||
|     List<String> queryUserIdsByRoleds(List<String> roleCodes); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据职务ID查询用户ID | ||||
|      * @param positionIds | ||||
|      * @return | ||||
|      */ | ||||
|     List<String> queryUserIdsByPositionIds(List<String> positionIds); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据部门和子部门下的所有用户账号 | ||||
|      * | ||||
|  |  | |||
|  | @ -24,12 +24,6 @@ | |||
| 			<groupId>org.jeecgframework.boot3</groupId> | ||||
| 			<artifactId>hibernate-re</artifactId> | ||||
| 		</dependency> | ||||
| 
 | ||||
| 		<!-- 企业微信/钉钉 api --> | ||||
| 		<dependency> | ||||
| 			<groupId>org.jeecgframework</groupId> | ||||
| 			<artifactId>weixin4j</artifactId> | ||||
| 		</dependency> | ||||
| 	</dependencies> | ||||
| 	 | ||||
| </project> | ||||
|  |  | |||
|  | @ -918,17 +918,6 @@ public class SystemApiController { | |||
|         return sysBaseApi.queryUserIdsByRoleds(roleCodes); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 根据职务ID查询用户ID | ||||
|      * @param positionIds | ||||
|      * @return | ||||
|      */ | ||||
|     @GetMapping("/queryUserIdsByPositionIds") | ||||
|     public List<String> queryUserIdsByPositionIds(@RequestParam("positionIds") List<String> positionIds){ | ||||
|         return sysBaseApi.queryUserIdsByPositionIds(positionIds); | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 根据部门和子部门下的所有用户账号 | ||||
|      * | ||||
|  |  | |||
|  | @ -1,13 +1,10 @@ | |||
| package org.jeecg.modules.system.controller; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSON; | ||||
| import com.alibaba.fastjson.JSONArray; | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import com.jeecg.dingtalk.api.core.response.Response; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.shiro.SecurityUtils; | ||||
|  | @ -39,7 +36,6 @@ import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.context.annotation.Lazy; | ||||
| import org.springframework.data.redis.core.RedisTemplate; | ||||
| import org.springframework.http.HttpStatus; | ||||
| import org.springframework.security.core.context.SecurityContextHolder; | ||||
| import org.springframework.util.CollectionUtils; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
|  |  | |||
|  | @ -1,401 +0,0 @@ | |||
| package org.jeecg.modules.system.controller; | ||||
| 
 | ||||
| import cn.hutool.core.util.RandomUtil; | ||||
| import com.alibaba.fastjson.JSON; | ||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.jeecg.common.api.vo.Result; | ||||
| import org.jeecg.common.aspect.annotation.AutoLog; | ||||
| import org.jeecg.common.config.TenantContext; | ||||
| import org.jeecg.common.constant.CommonConstant; | ||||
| import org.jeecg.common.system.query.QueryGenerator; | ||||
| import org.jeecg.common.system.vo.LoginUser; | ||||
| import org.jeecg.common.util.ImportExcelUtil; | ||||
| import org.jeecg.common.util.oConvertUtils; | ||||
| import org.jeecg.config.mybatis.MybatisPlusSaasConfig; | ||||
| import org.jeecg.config.security.utils.SecureUtil; | ||||
| import org.jeecg.modules.system.entity.SysPosition; | ||||
| import org.jeecg.modules.system.entity.SysUser; | ||||
| import org.jeecg.modules.system.service.IAuthUserService; | ||||
| import org.jeecg.modules.system.service.ISysPositionService; | ||||
| import org.jeecg.modules.system.service.ISysUserPositionService; | ||||
| import org.jeecgframework.poi.excel.ExcelImportUtil; | ||||
| import org.jeecgframework.poi.excel.def.NormalExcelConstants; | ||||
| import org.jeecgframework.poi.excel.entity.ExportParams; | ||||
| import org.jeecgframework.poi.excel.entity.ImportParams; | ||||
| import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.security.core.context.SecurityContextHolder; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import org.springframework.web.multipart.MultipartHttpServletRequest; | ||||
| import org.springframework.web.servlet.ModelAndView; | ||||
| 
 | ||||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import jakarta.servlet.http.HttpServletResponse; | ||||
| import java.io.IOException; | ||||
| import java.io.UnsupportedEncodingException; | ||||
| import java.net.URLDecoder; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Arrays; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 职务表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date: 2019-09-19 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| @Slf4j | ||||
| @Tag(name = "职务表") | ||||
| @RestController | ||||
| @RequestMapping("/sys/position") | ||||
| public class SysPositionController { | ||||
| 
 | ||||
|     @Autowired | ||||
|     private ISysPositionService sysPositionService; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private ISysUserPositionService userPositionService; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private IAuthUserService authUserService; | ||||
| 
 | ||||
|     /** | ||||
|      * 分页列表查询 | ||||
|      * | ||||
|      * @param sysPosition | ||||
|      * @param pageNo | ||||
|      * @param pageSize | ||||
|      * @param req | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-分页列表查询") | ||||
|     @Operation(summary = "职务表-分页列表查询") | ||||
|     @GetMapping(value = "/list") | ||||
|     public Result<IPage<SysPosition>> queryPageList(SysPosition sysPosition, | ||||
|                                                     @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, | ||||
|                                                     @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, | ||||
|                                                     HttpServletRequest req) { | ||||
|         Result<IPage<SysPosition>> result = new Result<IPage<SysPosition>>(); | ||||
|         //------------------------------------------------------------------------------------------------ | ||||
|         //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 | ||||
|         if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ | ||||
|             sysPosition.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0)); | ||||
|         } | ||||
|         //------------------------------------------------------------------------------------------------ | ||||
|         QueryWrapper<SysPosition> queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, req.getParameterMap()); | ||||
|         Page<SysPosition> page = new Page<SysPosition>(pageNo, pageSize); | ||||
|         IPage<SysPosition> pageList = sysPositionService.page(page, queryWrapper); | ||||
|         result.setSuccess(true); | ||||
|         result.setResult(pageList); | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 添加 | ||||
|      * | ||||
|      * @param sysPosition | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-添加") | ||||
|     @Operation(summary = "职务表-添加") | ||||
|     @PostMapping(value = "/add") | ||||
|     public Result<SysPosition> add(@RequestBody SysPosition sysPosition) { | ||||
|         Result<SysPosition> result = new Result<SysPosition>(); | ||||
|         try { | ||||
|             //update-begin---author:wangshuai ---date:20230313  for:【QQYUN-4558】vue3职位功能调整,去掉编码和级别,可以先隐藏------------ | ||||
|             //编号是空的,不需要判断多租户隔离了 | ||||
|             if(oConvertUtils.isEmpty(sysPosition.getCode())){ | ||||
|                 //生成职位编码10位 | ||||
|                 sysPosition.setCode(RandomUtil.randomString(10)); | ||||
|             } | ||||
|             //update-end---author:wangshuai ---date:20230313  for:【QQYUN-4558】vue3职位功能调整,去掉编码和级别,可以先隐藏------------- | ||||
|             sysPositionService.save(sysPosition); | ||||
|             result.success("添加成功!"); | ||||
|         } catch (Exception e) { | ||||
|             log.error(e.getMessage(), e); | ||||
|             result.error500("操作失败"); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 编辑 | ||||
|      * | ||||
|      * @param sysPosition | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-编辑") | ||||
|     @Operation(summary = "职务表-编辑") | ||||
|     @RequestMapping(value = "/edit", method ={RequestMethod.PUT, RequestMethod.POST}) | ||||
|     public Result<SysPosition> edit(@RequestBody SysPosition sysPosition) { | ||||
|         Result<SysPosition> result = new Result<SysPosition>(); | ||||
|         SysPosition sysPositionEntity = sysPositionService.getById(sysPosition.getId()); | ||||
|         if (sysPositionEntity == null) { | ||||
|             result.error500("未找到对应实体"); | ||||
|         } else { | ||||
|             boolean ok = sysPositionService.updateById(sysPosition); | ||||
|             //TODO 返回false说明什么? | ||||
|             if (ok) { | ||||
|                 result.success("修改成功!"); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过id删除 | ||||
|      * | ||||
|      * @param id | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-通过id删除") | ||||
|     @Operation(summary = "职务表-通过id删除") | ||||
|     @DeleteMapping(value = "/delete") | ||||
|     public Result<?> delete(@RequestParam(name = "id", required = true) String id) { | ||||
|         try { | ||||
|             sysPositionService.removeById(id); | ||||
|             //删除用户职位关系表 | ||||
|             userPositionService.removeByPositionId(id); | ||||
|         } catch (Exception e) { | ||||
|             log.error("删除失败", e.getMessage()); | ||||
|             return Result.error("删除失败!"); | ||||
|         } | ||||
|         return Result.ok("删除成功!"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 批量删除 | ||||
|      * | ||||
|      * @param ids | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-批量删除") | ||||
|     @Operation(summary = "职务表-批量删除") | ||||
|     @DeleteMapping(value = "/deleteBatch") | ||||
|     public Result<SysPosition> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { | ||||
|         Result<SysPosition> result = new Result<SysPosition>(); | ||||
|         if (ids == null || "".equals(ids.trim())) { | ||||
|             result.error500("参数不识别!"); | ||||
|         } else { | ||||
|             this.sysPositionService.removeByIds(Arrays.asList(ids.split(","))); | ||||
|             result.success("删除成功!"); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过id查询 | ||||
|      * | ||||
|      * @param id | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-通过id查询") | ||||
|     @Operation(summary = "职务表-通过id查询") | ||||
|     @GetMapping(value = "/queryById") | ||||
|     public Result<SysPosition> queryById(@RequestParam(name = "id", required = true) String id) { | ||||
|         Result<SysPosition> result = new Result<SysPosition>(); | ||||
|         SysPosition sysPosition = sysPositionService.getById(id); | ||||
|         if (sysPosition == null) { | ||||
|             result.error500("未找到对应实体"); | ||||
|         } else { | ||||
|             result.setResult(sysPosition); | ||||
|             result.setSuccess(true); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 导出excel | ||||
|      * | ||||
|      * @param request | ||||
|      * @param response | ||||
|      */ | ||||
|     @RequestMapping(value = "/exportXls") | ||||
|     public ModelAndView exportXls(SysPosition sysPosition,HttpServletRequest request, HttpServletResponse response) { | ||||
|         // Step.1 组装查询条件 | ||||
|         QueryWrapper<SysPosition> queryWrapper = null; | ||||
|         try { | ||||
|             String paramsStr = request.getParameter("paramsStr"); | ||||
|             if (oConvertUtils.isNotEmpty(paramsStr)) { | ||||
|                 String deString = URLDecoder.decode(paramsStr, "UTF-8"); | ||||
|                 sysPosition = JSON.parseObject(deString, SysPosition.class); | ||||
|                 //------------------------------------------------------------------------------------------------ | ||||
|                 //是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】 | ||||
|                 if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ | ||||
|                     sysPosition.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(),0)); | ||||
|                 } | ||||
|                 //------------------------------------------------------------------------------------------------ | ||||
|             } | ||||
|             queryWrapper = QueryGenerator.initQueryWrapper(sysPosition, request.getParameterMap()); | ||||
|         } catch (UnsupportedEncodingException e) { | ||||
|             e.printStackTrace(); | ||||
|         } | ||||
|         //update-begin--Author:liusq  Date:20240715 for:[03]职务导出,如果选择数据则只导出相关数据-------------------- | ||||
|         String selections = request.getParameter("selections"); | ||||
|         if(!oConvertUtils.isEmpty(selections)){ | ||||
|             queryWrapper.in("id",selections.split(",")); | ||||
|         } | ||||
|         //update-end--Author:liusq  Date:20240715 for:[03]职务导出,如果选择数据则只导出相关数据---------------------- | ||||
|         //Step.2 AutoPoi 导出Excel | ||||
|         ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); | ||||
|         List<SysPosition> pageList = sysPositionService.list(queryWrapper); | ||||
|         LoginUser user = SecureUtil.currentUser(); | ||||
|         //导出文件名称 | ||||
|         mv.addObject(NormalExcelConstants.FILE_NAME, "职务表列表"); | ||||
|         mv.addObject(NormalExcelConstants.CLASS, SysPosition.class); | ||||
|         mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("职务表列表数据", "导出人:"+user.getRealname(),"导出信息")); | ||||
|         mv.addObject(NormalExcelConstants.DATA_LIST, pageList); | ||||
|         return mv; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过excel导入数据 | ||||
|      * | ||||
|      * @param request | ||||
|      * @param response | ||||
|      * @return | ||||
|      */ | ||||
|     @RequestMapping(value = "/importExcel", method = RequestMethod.POST) | ||||
|     public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response)throws IOException { | ||||
|         MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; | ||||
|         Map<String, MultipartFile> fileMap = multipartRequest.getFileMap(); | ||||
|         // 错误信息 | ||||
|         List<String> errorMessage = new ArrayList<>(); | ||||
|         int successLines = 0, errorLines = 0; | ||||
|         for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) { | ||||
|             // 获取上传文件对象 | ||||
|             MultipartFile file = entity.getValue(); | ||||
|             ImportParams params = new ImportParams(); | ||||
|             params.setTitleRows(2); | ||||
|             params.setHeadRows(1); | ||||
|             params.setNeedSave(true); | ||||
|             try { | ||||
|                 List<Object>  listSysPositions = ExcelImportUtil.importExcel(file.getInputStream(), SysPosition.class, params); | ||||
|                 List<String> list = ImportExcelUtil.importDateSave(listSysPositions, ISysPositionService.class, errorMessage,CommonConstant.SQL_INDEX_UNIQ_CODE); | ||||
|                 errorLines+=list.size(); | ||||
|                 successLines+=(listSysPositions.size()-errorLines); | ||||
|             } catch (Exception e) { | ||||
|                 log.error(e.getMessage(), e); | ||||
|                 return Result.error("文件导入失败:" + e.getMessage()); | ||||
|             } finally { | ||||
|                 try { | ||||
|                     file.getInputStream().close(); | ||||
|                 } catch (IOException e) { | ||||
|                     e.printStackTrace(); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         return ImportExcelUtil.imporReturnRes(errorLines,successLines,errorMessage); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 通过code查询 | ||||
|      * | ||||
|      * @param code | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-通过code查询") | ||||
|     @Operation(summary = "职务表-通过code查询") | ||||
|     @GetMapping(value = "/queryByCode") | ||||
|     public Result<SysPosition> queryByCode(@RequestParam(name = "code", required = true) String code) { | ||||
|         Result<SysPosition> result = new Result<SysPosition>(); | ||||
|         QueryWrapper<SysPosition> queryWrapper = new QueryWrapper<SysPosition>(); | ||||
|         queryWrapper.eq("code",code); | ||||
|         SysPosition sysPosition = sysPositionService.getOne(queryWrapper); | ||||
|         if (sysPosition == null) { | ||||
|             result.error500("未找到对应实体"); | ||||
|         } else { | ||||
|             result.setResult(sysPosition); | ||||
|             result.setSuccess(true); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 通过多个ID查询 | ||||
|      * | ||||
|      * @param ids | ||||
|      * @return | ||||
|      */ | ||||
|     @AutoLog(value = "职务表-通过多个查询") | ||||
|     @Operation(summary = "职务表-通过多个id查询") | ||||
|     @GetMapping(value = "/queryByIds") | ||||
|     public Result<List<SysPosition>> queryByIds(@RequestParam(name = "ids") String ids) { | ||||
|         Result<List<SysPosition>> result = new Result<>(); | ||||
|         QueryWrapper<SysPosition> queryWrapper = new QueryWrapper<>(); | ||||
|         queryWrapper.in(true,"id",ids.split(",")); | ||||
|         List<SysPosition> list = sysPositionService.list(queryWrapper); | ||||
|         if (list == null) { | ||||
|             result.error500("未找到对应实体"); | ||||
|         } else { | ||||
|             result.setResult(list); | ||||
|             result.setSuccess(true); | ||||
|         } | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 获取职位用户列表 | ||||
|      * | ||||
|      * @param pageNo | ||||
|      * @param pageSize | ||||
|      * @param positionId | ||||
|      * @return | ||||
|      */ | ||||
|     @GetMapping("/getPositionUserList") | ||||
|     public Result<IPage<SysUser>> getPositionUserList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, | ||||
|                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, | ||||
|                                                       @RequestParam(name = "positionId") String positionId) { | ||||
| 
 | ||||
|         Page<SysUser> page = new Page<>(pageNo, pageSize); | ||||
|         IPage<SysUser> pageList = userPositionService.getPositionUserList(page, positionId); | ||||
|         List<String> userIds = pageList.getRecords().stream().map(SysUser::getId).collect(Collectors.toList()); | ||||
|         if (null != userIds && userIds.size() > 0) { | ||||
|             Map<String, String> useDepNames = authUserService.getDepNamesByUserIds(userIds); | ||||
|             pageList.getRecords().forEach(item -> { | ||||
|                 item.setOrgCodeTxt(useDepNames.get(item.getId())); | ||||
|             }); | ||||
|         } | ||||
|         return Result.ok(pageList); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 添加成员到用户职位关系表 | ||||
|      * | ||||
|      * @param userIds | ||||
|      * @param positionId | ||||
|      * @return | ||||
|      */ | ||||
|     @PostMapping("/savePositionUser") | ||||
|     public Result<String> saveUserPosition(@RequestParam(name = "userIds") String userIds, | ||||
|                                            @RequestParam(name = "positionId") String positionId) { | ||||
|         userPositionService.saveUserPosition(userIds, positionId); | ||||
|         return Result.ok("添加成功"); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 职位列表移除成员 | ||||
|      * | ||||
|      * @param userIds | ||||
|      * @param positionId | ||||
|      * @return | ||||
|      */ | ||||
|     @DeleteMapping("/removePositionUser") | ||||
|     public Result<String> removeUserPosition(@RequestParam(name = "userIds") String userIds, | ||||
|                                              @RequestParam(name = "positionId") String positionId) { | ||||
|         userPositionService.removePositionUser(userIds, positionId); | ||||
|         return Result.OK("移除成员成功"); | ||||
|     } | ||||
| } | ||||
|  | @ -97,9 +97,6 @@ public class SysUserController { | |||
|     @Autowired | ||||
|     private ISysUserAgentService sysUserAgentService; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private ISysPositionService sysPositionService; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private JeecgRedisClient jeecgRedisClient; | ||||
|      | ||||
|  | @ -1572,31 +1569,6 @@ public class SysUserController { | |||
|         if(user==null) { | ||||
|             return Result.error("未找到该用户数据"); | ||||
|         } | ||||
| 
 | ||||
|         //update-begin---author:wangshuai ---date:20230220  for:[QQYUN-3980]组织管理中 职位功能 职位表加租户id 加职位-用户关联表------------ | ||||
|         //获取用户id通过职位数据 | ||||
|         List<SysPosition> sysPositionList = sysPositionService.getPositionList(user.getId()); | ||||
|         if(null != sysPositionList && sysPositionList.size()>0){ | ||||
|         //update-end---author:wangshuai ---date:20230220  for:[QQYUN-3980]组织管理中 职位功能 职位表加租户id 加职位-用户关联表------------ | ||||
|             StringBuilder nameBuilder = new StringBuilder(); | ||||
|             StringBuilder idBuilder = new StringBuilder(); | ||||
|             String verticalBar = " | "; | ||||
|             for (SysPosition sysPosition:sysPositionList){ | ||||
|                 nameBuilder.append(sysPosition.getName()).append(verticalBar); | ||||
|                 idBuilder.append(sysPosition.getId()).append(SymbolConstant.COMMA); | ||||
|             } | ||||
|             String names = nameBuilder.toString(); | ||||
|             if(oConvertUtils.isNotEmpty(names)){ | ||||
|                 names = names.substring(0,names.lastIndexOf(verticalBar)); | ||||
|                 user.setPostText(names); | ||||
|             } | ||||
|             //拼接职位id | ||||
|             String ids = idBuilder.toString(); | ||||
|             if(oConvertUtils.isNotEmpty(ids)){ | ||||
|                 ids = ids.substring(0,ids.lastIndexOf(SymbolConstant.COMMA)); | ||||
|                 user.setPost(ids); | ||||
|             } | ||||
|         } | ||||
|         return Result.ok(user); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,91 +0,0 @@ | |||
| package org.jeecg.modules.system.entity; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.annotation.IdType; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.experimental.Accessors; | ||||
| import org.jeecg.common.aspect.annotation.Dict; | ||||
| import org.jeecgframework.poi.excel.annotation.Excel; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 职务表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date: 2019-09-19 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| @Data | ||||
| @TableName("sys_position") | ||||
| @EqualsAndHashCode(callSuper = false) | ||||
| @Accessors(chain = true) | ||||
| @Schema(description = "职务表") | ||||
| public class SysPosition { | ||||
| 
 | ||||
|     /** | ||||
|      * id | ||||
|      */ | ||||
|     @TableId(type = IdType.ASSIGN_ID) | ||||
|     @Schema(description = "id") | ||||
|     private java.lang.String id; | ||||
|     /** | ||||
|      * 职务编码 | ||||
|      */ | ||||
|     @Excel(name = "职务编码", width = 15) | ||||
|     @Schema(description = "职务编码") | ||||
|     private java.lang.String code; | ||||
|     /** | ||||
|      * 职务名称 | ||||
|      */ | ||||
|     @Excel(name = "职务名称", width = 15) | ||||
|     @Schema(description = "职务名称") | ||||
|     private java.lang.String name; | ||||
|     /** | ||||
|      * 职级 | ||||
|      */ | ||||
|     //@Excel(name = "职级", width = 15,dicCode ="position_rank") | ||||
|     @Schema(description = "职级") | ||||
|     @Dict(dicCode = "position_rank") | ||||
|     private java.lang.String postRank; | ||||
|     /** | ||||
|      * 公司id | ||||
|      */ | ||||
|     @Schema(description = "公司id") | ||||
|     private java.lang.String companyId; | ||||
|     /** | ||||
|      * 创建人 | ||||
|      */ | ||||
|     @Schema(description = "创建人") | ||||
|     private java.lang.String createBy; | ||||
|     /** | ||||
|      * 创建时间 | ||||
|      */ | ||||
|     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     @Schema(description = "创建时间") | ||||
|     private java.util.Date createTime; | ||||
|     /** | ||||
|      * 修改人 | ||||
|      */ | ||||
|     @Schema(description = "修改人") | ||||
|     private java.lang.String updateBy; | ||||
|     /** | ||||
|      * 修改时间 | ||||
|      */ | ||||
|     @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     @Schema(description = "修改时间") | ||||
|     private java.util.Date updateTime; | ||||
|     /** | ||||
|      * 组织机构编码 | ||||
|      */ | ||||
|     @Schema(description = "组织机构编码") | ||||
|     private java.lang.String sysOrgCode; | ||||
| 
 | ||||
|     /**租户ID*/ | ||||
|     @Schema(description = "租户ID") | ||||
|     private java.lang.Integer tenantId; | ||||
| } | ||||
|  | @ -129,14 +129,6 @@ public class SysUser implements Serializable { | |||
|     @Excel(name = "工号", width = 15) | ||||
|     private String workNo; | ||||
| 
 | ||||
|     /** | ||||
|      * 职务,关联职务表 | ||||
|      */ | ||||
|     @Excel(name = "职务", width = 15) | ||||
|     @Dict(dictTable ="sys_position",dicText = "name",dicCode = "id") | ||||
|     @TableField(exist = false) | ||||
|     private String post; | ||||
| 
 | ||||
|     /** | ||||
|      * 座机号 | ||||
|      */ | ||||
|  |  | |||
|  | @ -1,53 +0,0 @@ | |||
| package org.jeecg.modules.system.entity; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| import com.baomidou.mybatisplus.annotation.IdType; | ||||
| import com.baomidou.mybatisplus.annotation.TableId; | ||||
| import com.baomidou.mybatisplus.annotation.TableName; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import com.fasterxml.jackson.annotation.JsonFormat; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import org.jeecgframework.poi.excel.annotation.Excel; | ||||
| import java.util.Date; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 用户职位关系表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date:   2023-02-14 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| @Schema(description="用户职位关系表") | ||||
| @Data | ||||
| @TableName("sys_user_position") | ||||
| public class SysUserPosition implements Serializable { | ||||
|     private static final long serialVersionUID = 1L; | ||||
| 
 | ||||
| 	/**主键*/ | ||||
| 	@TableId(type = IdType.ASSIGN_ID) | ||||
|     @Schema(description = "主键") | ||||
|     private String id; | ||||
| 	/**用户id*/ | ||||
| 	@Excel(name = "用户id", width = 15) | ||||
|     @Schema(description = "用户id") | ||||
|     private String userId; | ||||
| 	/**职位id*/ | ||||
|     @Schema(description = "职位id") | ||||
|     private String positionId; | ||||
| 	/**创建人*/ | ||||
|     @Schema(description = "创建人") | ||||
|     private String createBy; | ||||
| 	/**创建时间*/ | ||||
| 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") | ||||
|     @DateTimeFormat(pattern="yyyy-MM-dd") | ||||
|     @Schema(description = "创建时间") | ||||
|     private Date createTime; | ||||
| 	/**修改人*/ | ||||
|     @Schema(description = "修改人") | ||||
|     private String updateBy; | ||||
| 	/**修改时间*/ | ||||
| 	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") | ||||
|     @DateTimeFormat(pattern="yyyy-MM-dd") | ||||
|     @Schema(description = "修改时间") | ||||
|     private Date updateTime; | ||||
| } | ||||
|  | @ -1,40 +0,0 @@ | |||
| package org.jeecg.modules.system.mapper; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import org.apache.ibatis.annotations.Select; | ||||
| import org.jeecg.modules.system.entity.SysPosition; | ||||
| import org.springframework.data.repository.query.Param; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 职务表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date: 2019-09-19 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| public interface SysPositionMapper extends BaseMapper<SysPosition> { | ||||
| 
 | ||||
|     /** | ||||
|      * 通过用户id获取职位名称 | ||||
|      * @param userId | ||||
|      * @return | ||||
|      */ | ||||
|     List<SysPosition> getPositionList(@Param("userId") String userId); | ||||
| 
 | ||||
|     /** | ||||
|      * 通过职位id获取职位名称 | ||||
|      * @param postList | ||||
|      * @return | ||||
|      */ | ||||
|     List<SysPosition> getPositionName(@Param("postList") List<String> postList); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据职位名称获取职位id | ||||
|      * @param name | ||||
|      * @return | ||||
|      */ | ||||
|     @Select("SELECT id FROM sys_position WHERE name = #{name} AND tenant_id = #{tenantId} ORDER BY create_time DESC") | ||||
|     List<String> getPositionIdByName(@Param("name") String name, @Param("tenantId") Integer tenantId, @Param("page") Page<SysPosition> page); | ||||
| } | ||||
|  | @ -1,86 +0,0 @@ | |||
| package org.jeecg.modules.system.mapper; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.annotation.InterceptorIgnore; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import org.apache.ibatis.annotations.Delete; | ||||
| import org.apache.ibatis.annotations.Select; | ||||
| import org.jeecg.modules.system.entity.SysUser; | ||||
| import org.jeecg.modules.system.entity.SysUserPosition; | ||||
| import com.baomidou.mybatisplus.core.mapper.BaseMapper; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
| import org.jeecg.modules.system.vo.SysUserPositionVo; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 用户职位关系表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date:   2023-02-14 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| public interface SysUserPositionMapper extends BaseMapper<SysUserPosition> { | ||||
| 
 | ||||
|     /** | ||||
|      * 获取职位用户列表 | ||||
|      * @param page | ||||
|      * @param positionId | ||||
|      * @return | ||||
|      */ | ||||
|     List<SysUser> getPositionUserList(@Param("page") Page<SysUser> page, @Param("positionId") String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 获取成员是否存在职位中 | ||||
|      * @param userId | ||||
|      * @param positionId | ||||
|      * @return | ||||
|      */ | ||||
|     @Select("SELECT count(*) FROM sys_user_position WHERE user_id = #{userId} and position_id = #{positionId}") | ||||
|     Long getUserPositionCount(@Param("userId") String userId, @Param("positionId") String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 通过职位id删除用户职位关系表 | ||||
|      * @param positionId | ||||
|      */ | ||||
|     @Delete("DELETE FROM sys_user_position WHERE position_id = #{positionId} ") | ||||
|     void removeByPositionId(@Param("positionId") String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 职位列表移除成员 | ||||
|      * @param userIdList | ||||
|      * @param positionId | ||||
|      */ | ||||
|     void removePositionUser(@Param("userIdList") List<String> userIdList, @Param("positionId") String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据用户id查询职位id | ||||
|      * @param userId | ||||
|      * @return | ||||
|      */ | ||||
|     List<String> getPositionIdByUserId(@Param("userId") String userId); | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 根据用户ID和租户ID获取职位id | ||||
|      * @param userId | ||||
|      * @param tenantId | ||||
|      * @return | ||||
|      */ | ||||
|     @InterceptorIgnore(tenantLine = "true") | ||||
|     List<String> getPositionIdByUserTenantId(@Param("userId")String userId, @Param("tenantId")Integer tenantId); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据用户id获取用户职位 | ||||
|      * @param userIdList | ||||
|      * @param tenantId | ||||
|      * @return | ||||
|      */ | ||||
|     List<SysUserPositionVo> getPositionIdByUsersTenantId(@Param("userIdList") List<SysUser> userIdList, @Param("tenantId") Integer tenantId); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据职位名称和租户id,删除用户职位关系表 | ||||
|      * @param positionNames | ||||
|      * @param tenantId | ||||
|      * @param userId | ||||
|      */ | ||||
|     void deleteUserPosByNameAndTenantId(@Param("positionNames") List<String> positionNames, @Param("tenantId") Integer tenantId, @Param("userId") String userId); | ||||
| } | ||||
|  | @ -1,22 +0,0 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="org.jeecg.modules.system.mapper.SysPositionMapper"> | ||||
| 
 | ||||
|     <!--通过用户id获取职位数据--> | ||||
|     <select id="getPositionList" resultType="org.jeecg.modules.system.entity.SysPosition"> | ||||
|         SELECT sp.name,sp.id FROM sys_position sp | ||||
|         INNER JOIN sys_user_position sup on sp.id = sup.position_id | ||||
|         WHERE | ||||
|         sup.user_id = #{userId} | ||||
|     </select> | ||||
| 
 | ||||
|     <!--通过职位id获取职位名称--> | ||||
|     <select id="getPositionName" resultType="org.jeecg.modules.system.entity.SysPosition"> | ||||
|         SELECT name FROM sys_position | ||||
|         WHERE | ||||
|         id IN | ||||
|         <foreach collection="postList" index="index" item="positionId" open="(" separator="," close=")"> | ||||
|             #{positionId} | ||||
|         </foreach> | ||||
|     </select> | ||||
| </mapper> | ||||
|  | @ -1,68 +0,0 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||||
| <mapper namespace="org.jeecg.modules.system.mapper.SysUserPositionMapper"> | ||||
| 
 | ||||
|     <!--获取职位用户列表--> | ||||
|     <select id="getPositionUserList" resultType="org.jeecg.modules.system.entity.SysUser"> | ||||
|         SELECT su.realname,su.id,su.username,su.email,su.phone,su.work_no | ||||
|         FROM sys_user_position sup | ||||
|         INNER JOIN sys_user su on sup.user_id = su.id and su.del_flag = 0 | ||||
|         WHERE | ||||
|         sup.position_id = #{positionId} | ||||
|         ORDER BY sup.create_time DESC | ||||
|     </select> | ||||
| 
 | ||||
|     <!--根据用户id查询职位id--> | ||||
|     <select id="getPositionIdByUserId" resultType="java.lang.String"> | ||||
|         SELECT position_id FROM sys_user_position | ||||
|         WHERE | ||||
|         user_id = #{userId} | ||||
|         ORDER BY create_time DESC | ||||
|     </select> | ||||
| 
 | ||||
|     <!--根据用户ID和租户ID获取职位id--> | ||||
|     <select id="getPositionIdByUserTenantId" resultType="java.lang.String"> | ||||
|         SELECT sp.id FROM sys_user_position sup | ||||
|         LEFT JOIN sys_position sp ON sup.position_id = sp.id | ||||
|         WHERE | ||||
|         sup.user_id = #{userId} | ||||
|        <if test="tenantId != null and tenantId != 0"> | ||||
|            AND sp.tenant_id = #{tenantId} | ||||
|        </if> | ||||
|     </select> | ||||
| 
 | ||||
|     <!--职位列表移除成员--> | ||||
|     <update id="removePositionUser"> | ||||
|         DELETE FROM sys_user_position | ||||
|         WHERE | ||||
|         position_id = #{positionId} | ||||
|         AND user_id IN | ||||
|         <foreach collection="userIdList" index="index" item="userId" open="(" separator="," close=")"> | ||||
|             #{userId} | ||||
|         </foreach> | ||||
|     </update> | ||||
|      | ||||
|     <!--根据用户id获取用户职位--> | ||||
|     <select id="getPositionIdByUsersTenantId" resultType="org.jeecg.modules.system.vo.SysUserPositionVo"> | ||||
|         SELECT sp.name,sup.user_id FROM sys_position sp | ||||
|         RIGHT JOIN sys_user_position sup on sup.position_id = sp.id | ||||
|         WHERE sup.user_id IN | ||||
|         <foreach collection="userIdList" index="index" item="userIds" open="(" separator="," close=")"> | ||||
|             #{userIds.id} | ||||
|         </foreach> | ||||
|         AND sp.tenant_id = #{tenantId} | ||||
|     </select> | ||||
|      | ||||
|     <!--根据职位名称和租户id,删除用户职位关系表--> | ||||
|     <delete id="deleteUserPosByNameAndTenantId"> | ||||
|         DELETE FROM sys_user_position | ||||
|         WHERE user_id = #{userId}  | ||||
|         AND position_id in (  | ||||
|             SELECT id FROM sys_position where name in | ||||
|             <foreach collection="positionNames" index="index" item="name" open="(" separator="," close=")"> | ||||
|                 #{name} | ||||
|             </foreach> | ||||
|             AND tenant_id = #{tenantId} | ||||
|         ) | ||||
|     </delete> | ||||
| </mapper> | ||||
|  | @ -15,7 +15,6 @@ public class SysUserSysDepartModel { | |||
|     private String id; | ||||
|     private String realname; | ||||
|     private String workNo; | ||||
|     private String post; | ||||
|     private String telephone; | ||||
|     private String email; | ||||
|     private String phone; | ||||
|  |  | |||
|  | @ -150,18 +150,6 @@ public interface IAuthUserService extends IService<SysUser> { | |||
| 	 */ | ||||
| 	public Map<String,String> getDepNamesByUserIds(List<String> userIds); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据部门 Id 和 QueryWrapper 查询 | ||||
|      * | ||||
|      * @param page | ||||
|      * @param departId | ||||
|      * @param queryWrapper | ||||
|      * @return | ||||
|      */ | ||||
|     //update-begin-author:taoyan date:2022-9-13 for: VUEN-2245【漏洞】发现新漏洞待处理20220906 ----sql注入 方法没有使用,注掉 | ||||
|     // public IPage<SysUser> getUserByDepartIdAndQueryWrapper(Page<SysUser> page, String departId, QueryWrapper<SysUser> queryWrapper); | ||||
| 	//update-end-author:taoyan date:2022-9-13 for: VUEN-2245【漏洞】发现新漏洞待处理20220906 ----sql注入 方法没有使用,注掉 | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 根据 orgCode 查询用户,包括子部门下的用户 | ||||
| 	 * | ||||
|  | @ -487,13 +475,4 @@ public interface IAuthUserService extends IService<SysUser> { | |||
| 	 * @return | ||||
| 	 */ | ||||
| 	IPage<SysUser> getProcessUserList(Page<SysUser> page, String orgCode, String keyword, List<String> excludeUserIdList); | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 获取职位用户列表 | ||||
| 	 * @param page | ||||
| 	 * @param positionId | ||||
| 	 * @return | ||||
| 	 */ | ||||
| 	List<SysUser> getPositionUserList(Page<SysUser> page, String positionId); | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -1,36 +0,0 @@ | |||
| package org.jeecg.modules.system.service; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | ||||
| import org.jeecg.modules.system.entity.SysPosition; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 职务表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date: 2019-09-19 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| public interface ISysPositionService extends IService<SysPosition> { | ||||
| 
 | ||||
|     /** | ||||
|      * 通过code查询 | ||||
|      * @param code 职务编码 | ||||
|      * @return SysPosition | ||||
|      */ | ||||
|     SysPosition getByCode(String code); | ||||
| 
 | ||||
|     /** | ||||
|      * 通过用户id获取职位名称列表 | ||||
|      * @param userId | ||||
|      * @return | ||||
|      */ | ||||
|     List<SysPosition> getPositionList(String userId); | ||||
| 
 | ||||
|     /** | ||||
|      * 获取职位名称 | ||||
|      * @param postList | ||||
|      * @return | ||||
|      */ | ||||
|     String getPositionName(List<String> postList); | ||||
| } | ||||
|  | @ -1,43 +0,0 @@ | |||
| package org.jeecg.modules.system.service; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import org.jeecg.modules.system.entity.SysUser; | ||||
| import org.jeecg.modules.system.entity.SysUserPosition; | ||||
| import com.baomidou.mybatisplus.extension.service.IService; | ||||
| /** | ||||
|  * @Description: 用户职位关系表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date:   2023-02-14 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| public interface ISysUserPositionService extends IService<SysUserPosition> { | ||||
| 
 | ||||
|     /** | ||||
|      * 获取职位用户列表 | ||||
|      * @param page | ||||
|      * @param positionId | ||||
|      * @return | ||||
|      */ | ||||
|     IPage<SysUser> getPositionUserList(Page<SysUser> page, String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 添加成员到用户职位关系表 | ||||
|      * @param userIds | ||||
|      * @param positionId | ||||
|      */ | ||||
|     void saveUserPosition(String userIds, String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 通过职位id删除用户职位关系表 | ||||
|      * @param positionId | ||||
|      */ | ||||
|     void removeByPositionId(String positionId); | ||||
| 
 | ||||
|     /** | ||||
|      * 移除成员 | ||||
|      * @param userIds | ||||
|      * @param positionId | ||||
|      */ | ||||
|     void removePositionUser(String userIds, String positionId); | ||||
| } | ||||
|  | @ -1,89 +0,0 @@ | |||
| package org.jeecg.modules.system.service; | ||||
| 
 | ||||
| import org.jeecg.common.api.dto.message.MessageDTO; | ||||
| import org.jeecg.modules.system.vo.thirdapp.SyncInfoVo; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * 第三方App对接 | ||||
|  * @author: jeecg-boot | ||||
|  */ | ||||
| public interface IThirdAppService { | ||||
| 
 | ||||
|     /** | ||||
|      * 获取AccessToken | ||||
|      * @return String | ||||
|      */ | ||||
|     String getAccessToken(); | ||||
| 
 | ||||
|     /** | ||||
|      * 将本地部门同步到第三方App<br> | ||||
|      * 同步方向:本地 --> 第三方APP | ||||
|      * 同步逻辑:<br> | ||||
|      * 1. 先判断是否同步过,有则修改,无则创建;<br> | ||||
|      * 2. 本地没有但第三方App里有则删除第三方App里的。 | ||||
|      * @param ids | ||||
|      * @return 成功返回true | ||||
|      */ | ||||
|     SyncInfoVo syncLocalDepartmentToThirdApp(String ids); | ||||
| 
 | ||||
| //    /** | ||||
| //     * 将第三方App部门同步到本地<br> | ||||
| //     * 同步方向:第三方APP --> 本地 | ||||
| //     * 同步逻辑:<br> | ||||
| //     * 1. 先判断是否同步过,有则修改,无则创建;<br> | ||||
| //     * 2. 本地没有但第三方App里有则删除第三方App里的。 | ||||
| //     * @param ids | ||||
| //     * @return 成功返回true | ||||
| //     */ | ||||
| //    SyncInfoVo syncThirdAppDepartmentToLocal(String ids); | ||||
| 
 | ||||
|     /** | ||||
|      * 将本地用户同步到第三方App<br> | ||||
|      * 同步方向:本地 --> 第三方APP <br> | ||||
|      * 同步逻辑:先判断是否同步过,有则修改、无则创建<br> | ||||
|      * 注意:同步人员的状态,比如离职、禁用、逻辑删除等。 | ||||
|      * (特殊点:1、目前逻辑特意做的不删除用户,防止企业微信提前上线,用户已经存在,但是平台无此用户。 | ||||
|      *  企业微信支持禁用账号;钉钉不支持 | ||||
|      *  2、企业微信里面是手机号激活,只能用户自己改,不允许通过接口改) | ||||
|      * @param ids | ||||
|      * @return 成功返回空数组,失败返回错误信息 | ||||
|      */ | ||||
|     SyncInfoVo syncLocalUserToThirdApp(String ids); | ||||
| 
 | ||||
| //    /** | ||||
| //     * 将第三方App用户同步到本地<br> | ||||
| //     * 同步方向:第三方APP --> 本地 <br> | ||||
| //     * 同步逻辑:先判断是否同步过,有则修改、无则创建<br> | ||||
| //     * 注意:同步人员的状态,比如离职、禁用、逻辑删除等。 | ||||
| //     * | ||||
| //     * @return 成功返回空数组,失败返回错误信息 | ||||
| //     */ | ||||
| //    SyncInfoVo syncThirdAppUserToLocal(); | ||||
| 
 | ||||
|     /** | ||||
|      * 根据本地用户ID,删除第三方APP的用户 | ||||
|      * | ||||
|      * @param userIdList 本地用户ID列表 | ||||
|      * @return 0表示成功,其他值表示失败 | ||||
|      */ | ||||
|     int removeThirdAppUser(List<String> userIdList); | ||||
| 
 | ||||
|     /** | ||||
|      * 发送消息 | ||||
|      * | ||||
|      * @param message | ||||
|      * @param verifyConfig 是否验证配置(未启用的APP会拒绝发送) | ||||
|      * @return | ||||
|      */ | ||||
|     boolean sendMessage(MessageDTO message, boolean verifyConfig); | ||||
| 
 | ||||
|     /** | ||||
|      * 发送消息 | ||||
|      * @param message | ||||
|      * @return boolean | ||||
|      */ | ||||
|     boolean sendMessage(MessageDTO message); | ||||
| 
 | ||||
| } | ||||
|  | @ -16,9 +16,6 @@ import jakarta.annotation.Resource; | |||
| import jakarta.servlet.http.HttpServletRequest; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.apache.commons.lang.StringUtils; | ||||
| import org.apache.commons.lang3.ObjectUtils; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
| import org.jeecg.common.api.dto.message.MessageDTO; | ||||
| import org.jeecg.common.api.vo.Result; | ||||
| import org.jeecg.common.config.TenantContext; | ||||
| import org.jeecg.common.constant.CacheConstant; | ||||
|  | @ -26,9 +23,7 @@ import org.jeecg.common.constant.CommonConstant; | |||
| import org.jeecg.common.constant.FillRuleConstant; | ||||
| import org.jeecg.common.constant.SymbolConstant; | ||||
| import org.jeecg.common.constant.enums.DySmsEnum; | ||||
| import org.jeecg.common.constant.enums.MessageTypeEnum; | ||||
| import org.jeecg.common.constant.enums.RoleIndexConfigEnum; | ||||
| import org.jeecg.common.constant.enums.SysAnnmentTypeEnum; | ||||
| import org.jeecg.common.desensitization.annotation.SensitiveEncode; | ||||
| import org.jeecg.common.exception.JeecgBootException; | ||||
| import org.jeecg.common.system.vo.LoginUser; | ||||
|  | @ -108,10 +103,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 	private BaseCommonService baseCommonService; | ||||
| 	@Autowired | ||||
|     ISysRoleIndexService sysRoleIndexService; | ||||
| 	@Autowired | ||||
| 	private SysUserPositionMapper sysUserPositionMapper; | ||||
| 	@Autowired | ||||
| 	private SysPositionMapper sysPositionMapper; | ||||
| 	@Autowired | ||||
| 	private SystemSendMsgHandle systemSendMsgHandle; | ||||
| 
 | ||||
|  | @ -121,7 +112,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 	@Override | ||||
| 	public Result<IPage<SysUser>> queryPageList(HttpServletRequest req, QueryWrapper<SysUser> queryWrapper, Integer pageSize, Integer pageNo) { | ||||
| 		Result<IPage<SysUser>> result = new Result<IPage<SysUser>>(); | ||||
| 		//update-begin-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id | ||||
| 		//部门ID | ||||
| 		String departId = req.getParameter("departId"); | ||||
| 		if (oConvertUtils.isNotEmpty(departId)) { | ||||
|  | @ -129,13 +119,11 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 			query.eq(SysUserDepart::getDepId, departId); | ||||
| 			List<SysUserDepart> list = sysUserDepartMapper.selectList(query); | ||||
| 			List<String> userIds = list.stream().map(SysUserDepart::getUserId).collect(Collectors.toList()); | ||||
| 			//update-begin---author:wangshuai ---date:20220322  for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------ | ||||
| 			if (oConvertUtils.listIsNotEmpty(userIds)) { | ||||
| 				queryWrapper.in("id", userIds); | ||||
| 			} else { | ||||
| 				return Result.OK(); | ||||
| 			} | ||||
| 			//update-end---author:wangshuai ---date:20220322  for:[issues/I4XTYB]查询用户时,当部门id 下没有分配用户时接口报错------------ | ||||
| 		} | ||||
| 		//用户ID | ||||
| 		String code = req.getParameter("code"); | ||||
|  | @ -143,29 +131,10 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 			queryWrapper.in("id", Arrays.asList(code.split(","))); | ||||
| 			pageSize = code.split(",").length; | ||||
| 		} | ||||
| 		//update-end-Author:wangshuai--Date:20211119--for:【vue3】通过部门id查询用户,通过code查询id | ||||
| 
 | ||||
| 		//update-begin-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户 | ||||
| 		String status = req.getParameter("status"); | ||||
| 		if (oConvertUtils.isNotEmpty(status)) { | ||||
| 			queryWrapper.eq("status", Integer.parseInt(status)); | ||||
| 		} | ||||
| 		//update-end-author:taoyan--date:20220104--for: JTC-372 【用户冻结问题】 online授权、用户组件,选择用户都能看到被冻结的用户 | ||||
| 
 | ||||
| 		//update-begin---author:wangshuai---date:2024-03-08---for:【QQYUN-8110】在线通讯录支持设置权限(只能看分配的技术支持)--- | ||||
| 		String tenantId = TokenUtils.getTenantIdByRequest(req); | ||||
| 		String lowAppId = TokenUtils.getLowAppIdByRequest(req); | ||||
| //		Object bean = ResourceUtil.getImplementationClass(DataEnhanceEnum.getClassPath(tenantId,lowAppId)); | ||||
| //		if(null != bean){ | ||||
| //			UserFilterEnhance userEnhanceService = (UserFilterEnhance) bean; | ||||
| //			LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); | ||||
| //			List<String> userIds = userEnhanceService.getUserIds(sysUser.getId()); | ||||
| //			if(CollectionUtil.isNotEmpty(userIds)){ | ||||
| //				queryWrapper.in("id", userIds); | ||||
| //			} | ||||
| //		} | ||||
| 		//update-end---author:wangshuai---date:2024-03-08---for:【QQYUN-8110】在线通讯录支持设置权限(只能看分配的技术支持)--- | ||||
| 		 | ||||
| 		//TODO 外部模拟登陆临时账号,列表不显示 | ||||
| 		queryWrapper.ne("username", "_reserve_user_external"); | ||||
| 		Page<SysUser> page = new Page<SysUser>(pageNo, pageSize); | ||||
|  | @ -183,13 +152,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 				if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) { | ||||
| 					posTenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0);;		 | ||||
| 				} | ||||
| 				//查询用户职位关系表(获取租户下面的) | ||||
| 				//update-begin---author:wangshuai---date:2023-11-15---for:【QQYUN-7028】用户职务保存后未回显--- | ||||
| 				List<String> positionList =  sysUserPositionMapper.getPositionIdByUserTenantId(item.getId(),posTenantId); | ||||
| 				//update-end---author:wangshuai---date:2023-11-15---for:【QQYUN-7028】用户职务保存后未回显--- | ||||
| 				//update-end---author:wangshuai ---date:20230228  for:[QQYUN-4354]加入更多字段:当前加入时间应该取当前租户的/职位也是当前租户下的------------ | ||||
| 				item.setPost(CommonUtils.getSplitText(positionList,SymbolConstant.COMMA)); | ||||
| 				//update-end---author:wangshuai---date:2023-10-08---for:【QQYUN-6668】钉钉部门和用户同步,我怎么知道哪些用户是双向绑定成功的--- | ||||
| 			}); | ||||
| 		} | ||||
| 
 | ||||
|  | @ -514,12 +476,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 	@Override | ||||
| 	public IPage<SysUserSysDepartModel> queryUserByOrgCode(String orgCode, SysUser userParams, IPage page) { | ||||
| 		List<SysUserSysDepartModel> list = queryUserDepartList(orgCode, userParams); | ||||
| 		//根据部门orgCode查询部门,需要将职位id进行传递 | ||||
| 		for (SysUserSysDepartModel model:list) { | ||||
| 			List<String> positionList = sysUserPositionMapper.getPositionIdByUserId(model.getId()); | ||||
| 			model.setPost(CommonUtils.getSplitText(positionList,SymbolConstant.COMMA)); | ||||
| 		} | ||||
| 
 | ||||
| 		int current = (int)page.getCurrent(); // 当前页码 | ||||
| 		int size = (int)page.getSize();      // 每页大小 | ||||
| 		Integer total = list.size(); | ||||
|  | @ -615,8 +571,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 			for (SysUser sysUser : userRoleList.getRecords()) { | ||||
| 				//设置部门 | ||||
| 				sysUser.setOrgCodeTxt(useDepNames.get(sysUser.getId())); | ||||
| 				//设置用户职位id | ||||
| 				this.userPositionId(sysUser); | ||||
| 			} | ||||
| 		} | ||||
| 		return userRoleList; | ||||
|  | @ -810,9 +764,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 				sysUserDepartMapper.insert(userDeaprt); | ||||
| 			} | ||||
| 		} | ||||
| 
 | ||||
| 		//step.4 保存职位 | ||||
| 		this.saveUserPosition(user.getId(),user.getPost()); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
|  | @ -867,9 +818,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		// 更新手机号、邮箱空字符串为 null | ||||
| 		authUserMapper.updateNullByEmptyString("email"); | ||||
| 		authUserMapper.updateNullByEmptyString("phone"); | ||||
| 
 | ||||
| 		//step.5 修改职位 | ||||
| 		this.editUserPosition(user.getId(),user.getPost()); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
|  | @ -889,8 +837,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		} | ||||
| 		LoginUser loginUser = new LoginUser(); | ||||
| 		SysUser sysUser = authUserMapper.getUserByName(username); | ||||
| 		//设置职位id | ||||
| 		this.userPositionId(sysUser); | ||||
| 		if(sysUser==null) { | ||||
| 			return null; | ||||
| 		} | ||||
|  | @ -908,19 +854,8 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		List<String> idList = JSONArray.parseArray(userIds, String.class); | ||||
| 		//部门 | ||||
| 		String selecteddeparts = json.getString("selecteddeparts"); | ||||
| 		//职位 | ||||
| 		String post = json.getString("post"); | ||||
| 		//工作地点? 没有这个字段 | ||||
| 		String workAddress = json.getString("workAddress"); | ||||
| 		//批量修改用户职位 | ||||
| 		if(oConvertUtils.isNotEmpty(post)) { | ||||
| 			//update-begin---author:wangshuai ---date:20230220  for:[QQYUN-3980]组织管理中 职位功能 职位表加租户id 加职位-用户关联表------------ | ||||
| 			//修改职位用户关系表 | ||||
| 			for (String userId:idList) { | ||||
| 				this.editUserPosition(userId,post); | ||||
| 			} | ||||
| 			//update-end---author:wangshuai ---date:20230220  for:[QQYUN-3980]组织管理中 职位功能 职位表加租户id 加职位-用户关联表------------ | ||||
| 		} | ||||
| 		if(oConvertUtils.isNotEmpty(selecteddeparts)) { | ||||
| 			//查询当前租户的部门列表 | ||||
| 			Integer currentTenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0); | ||||
|  | @ -1199,8 +1134,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 			this.updateTenantDepart(user, tenantId, departs); | ||||
| 		} | ||||
| 		//update-end---author:wangshuai ---date:20230424  for:【QQYUN-5251】人员与部门:部门删除不掉------------ | ||||
| 		//修改用户下的职位 | ||||
| 		this.editUserPosition(sysUser.getId(),sysUser.getPost()); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
|  | @ -1260,50 +1193,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		System.out.println("修改用户部门用时:" + (endTime2 - startTime) + "ms"); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 保存用户职位 | ||||
| 	 * | ||||
| 	 * @param userId | ||||
| 	 * @param positionIds | ||||
| 	 */ | ||||
| 	private void saveUserPosition(String userId, String positionIds) { | ||||
| 		if (oConvertUtils.isNotEmpty(positionIds)) { | ||||
| 			String[] positionIdArray = positionIds.split(SymbolConstant.COMMA); | ||||
| 			for (String postId : positionIdArray) { | ||||
| 				SysUserPosition userPosition = new SysUserPosition(); | ||||
| 				userPosition.setUserId(userId); | ||||
| 				userPosition.setPositionId(postId); | ||||
| 				sysUserPositionMapper.insert(userPosition); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 编辑用户职位 | ||||
| 	 * | ||||
| 	 * @param userId | ||||
| 	 * @param positionIds | ||||
| 	 */ | ||||
| 	private void editUserPosition(String userId, String positionIds) { | ||||
| 		//先删除 | ||||
| 		LambdaQueryWrapper<SysUserPosition> query = new LambdaQueryWrapper<>(); | ||||
| 		query.eq(SysUserPosition::getUserId, userId); | ||||
| 		sysUserPositionMapper.delete(query); | ||||
| 		//后新增数据 | ||||
| 		this.saveUserPosition(userId, positionIds); | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 设置用户职位id(已逗号拼接起来) | ||||
| 	 * @param sysUser | ||||
| 	 */ | ||||
| 	private void userPositionId(SysUser sysUser) { | ||||
| 		if(null != sysUser){ | ||||
| 			List<String> positionList = sysUserPositionMapper.getPositionIdByUserId(sysUser.getId()); | ||||
| 			sysUser.setPost(CommonUtils.getSplitText(positionList,SymbolConstant.COMMA)); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 查询用户当前登录部门的id | ||||
| 	 * | ||||
|  | @ -1394,8 +1283,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		List<SysUser> userList = authUserMapper.selectList(userWrapper); | ||||
| 		//获取部门名称 | ||||
| 		List<SysUserDepVo> userDepVos = sysDepartMapper.getUserDepartByTenantUserId(userList, tenantId); | ||||
| 		//获取职位 | ||||
| 		List<SysUserPositionVo> positionVos = sysUserPositionMapper.getPositionIdByUsersTenantId(userList, tenantId); | ||||
| 		// step2 根据用户id进行分类 | ||||
| 		//循环用户数据将数据整合导出 | ||||
| 		List<AppExportUserVo> exportUserVoList = new ArrayList<>(); | ||||
|  | @ -1405,8 +1292,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 			String departNames = userDepVos.stream().filter(item -> item.getUserId().equals(sysUser.getId())) | ||||
| 					.map(SysUserDepVo::getDepartName).collect(Collectors.joining(SymbolConstant.SEMICOLON)); | ||||
| 			exportUserVo.setDepart(departNames); | ||||
| 			String posNames = positionVos.stream().filter(item -> item.getUserId().equals(sysUser.getId())).map(SysUserPositionVo::getName).collect(Collectors.joining(SymbolConstant.SEMICOLON)); | ||||
| 			exportUserVo.setPosition(posNames); | ||||
| 			exportUserVoList.add(exportUserVo); | ||||
| 		} | ||||
| 		//step3 封装导出excel参数 | ||||
|  | @ -1459,7 +1344,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 					String phone = sysUserExcel.getPhone(); | ||||
| 					String realname = sysUserExcel.getRealname(); | ||||
| 					String depart = sysUserExcel.getDepart(); | ||||
| 					String position = sysUserExcel.getPosition(); | ||||
| 					SysUser sysUser = new SysUser(); | ||||
| 					//判断id是否存在,如果存在的话就是更新 | ||||
| 					if (oConvertUtils.isNotEmpty(id)) { | ||||
|  | @ -1509,10 +1393,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 								authUserMapper.insert(sysUser); | ||||
| 							} | ||||
| 						} | ||||
| 						//新增或编辑职位 | ||||
| 						if (oConvertUtils.isNotEmpty(position)) { | ||||
| 							this.addOrEditPosition(sysUser.getId(), position, isEdit, tenantId, positionMap); | ||||
| 						} | ||||
| 						//新增的时候才可以添加部门 | ||||
| 						if (!isEdit) { | ||||
| 							//新增或编辑部门 | ||||
|  | @ -1559,67 +1439,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		return null; | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 新增或者编辑职位 | ||||
| 	 * | ||||
| 	 * @param userId      用户id | ||||
| 	 * @param position    职位名称 已/拼接 | ||||
| 	 * @param isEdit      新增或编辑 | ||||
| 	 * @param positionMap 职位map key为name,value为职位id | ||||
| 	 */ | ||||
| 	private void addOrEditPosition(String userId, String position, Boolean isEdit, Integer tenantId, Map<String, String> positionMap) { | ||||
| 		Page<SysPosition> page = new Page<>(1, 1); | ||||
| 		String[] positions = position.split(SymbolConstant.SEMICOLON); | ||||
| 		List<String> positionList = Arrays.asList(positions); | ||||
| 		positionList = positionList.stream().distinct().collect(Collectors.toList()); | ||||
| 		//删除当前租户下的职位,根据职位名称、租户id、用户id | ||||
| 		sysUserPositionMapper.deleteUserPosByNameAndTenantId(positionList, tenantId, userId); | ||||
| 		//循环需要添加或修改的数据 | ||||
| 		for (String pos : positionList) { | ||||
| 			String posId = ""; | ||||
| 			if (positionMap.containsKey(pos)) { | ||||
| 				posId = positionMap.get(pos); | ||||
| 			} else { | ||||
| 				List<String> namePage = sysPositionMapper.getPositionIdByName(pos, tenantId, page); | ||||
| 				if (CollectionUtil.isNotEmpty(namePage)) { | ||||
| 					posId = namePage.get(0); | ||||
| 					positionMap.put(pos, posId); | ||||
| 				} | ||||
| 			} | ||||
| 
 | ||||
| 			//职位id不为空直接新增 | ||||
| 			if (oConvertUtils.isNotEmpty(posId)) { | ||||
| 				this.addSysUserPosition(userId, posId); | ||||
| 				continue; | ||||
| 			} | ||||
| 
 | ||||
| 			//不是编辑的情况下职位才会新增 | ||||
| 			if (!isEdit) { | ||||
| 				//新增职位和用户职位关系 | ||||
| 				SysPosition sysPosition = new SysPosition(); | ||||
| 				sysPosition.setName(pos); | ||||
| 				sysPosition.setCode(RandomUtil.randomString(10)); | ||||
| 				sysPosition.setTenantId(tenantId); | ||||
| 				sysPositionMapper.insert(sysPosition); | ||||
| 				positionMap.put(pos, sysPosition.getId()); | ||||
| 				this.addSysUserPosition(userId, sysPosition.getId()); | ||||
| 			} | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 添加用户职位 | ||||
| 	 */ | ||||
| 	private void addSysUserPosition(String userId, String positionId) { | ||||
| 		Long count = sysUserPositionMapper.getUserPositionCount(userId, positionId); | ||||
| 		if(count == 0){ | ||||
| 			SysUserPosition userPosition = new SysUserPosition(); | ||||
| 			userPosition.setUserId(userId); | ||||
| 			userPosition.setPositionId(positionId); | ||||
| 			sysUserPositionMapper.insert(userPosition); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	/** | ||||
| 	 * 新增或编辑部门 | ||||
| 	 * | ||||
|  | @ -1951,17 +1770,6 @@ public class AuthUserServiceImpl extends ServiceImpl<AuthUserMapper, SysUser> im | |||
| 		return pageUser(page, sysUsers); | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public List<SysUser> getPositionUserList(Page<SysUser> page, String positionId){ | ||||
| 		List<SysUserPosition> sysUserPositions = | ||||
| 				sysUserPositionMapper.selectList(new LambdaQueryWrapper<SysUserPosition>().eq(SysUserPosition::getPositionId, positionId).orderByAsc(SysUserPosition::getCreateTime)); | ||||
| 		List<String> userIds = sysUserPositions.stream().map(SysUserPosition::getUserId).collect(Collectors.toList()); | ||||
| 		LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<SysUser>(); | ||||
| 		queryWrapper.eq(SysUser::getDelFlag,0); | ||||
| 		queryWrapper.in(SysUser::getId,userIds); | ||||
| 		return authUserMapper.selectList(queryWrapper); | ||||
| 	} | ||||
| 
 | ||||
| 	public IPage<SysUser> pageUser(Page<SysUser> page, List<SysUser> sysUsers){ | ||||
| 		//计算分页参数 | ||||
| 		int current = (int)page.getCurrent(); // 当前页码 | ||||
|  |  | |||
|  | @ -125,9 +125,6 @@ public class SysBaseApiImpl implements ISysBaseAPI  { | |||
| 	@Autowired | ||||
| 	private ISysUserRoleService sysUserRoleService; | ||||
| 
 | ||||
| 	@Autowired | ||||
| 	private ISysUserPositionService sysUserPositionService; | ||||
| 
 | ||||
| 	@Autowired | ||||
| 	private IDictTableWhiteListHandler dictTableWhiteListHandler; | ||||
| 
 | ||||
|  | @ -1711,13 +1708,6 @@ public class SysBaseApiImpl implements ISysBaseAPI  { | |||
| 		return null; | ||||
| 	} | ||||
| 
 | ||||
| 	@Override | ||||
| 	public List<String> queryUserIdsByPositionIds(List<String> positionIds) { | ||||
| 		QueryWrapper<SysUserPosition> queryWrapper = new QueryWrapper<>(); | ||||
| 		queryWrapper.lambda().select(SysUserPosition::getUserId).in(true,SysUserPosition::getPositionId,positionIds); | ||||
| 		return sysUserPositionService.listObjs(queryWrapper,e->e.toString()); | ||||
| 	} | ||||
| 
 | ||||
| 	//update-begin-author:taoyan date:2023-2-21 for: 解决参数顺序问题 | ||||
| 	/** | ||||
| 	 * 获取带参数的报表地址,因为多个参数可能顺序会变,所以要将参数顺序重排,获取所有可能的地址集合 | ||||
|  |  | |||
|  | @ -1,43 +0,0 @@ | |||
| package org.jeecg.modules.system.service.impl; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | ||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import org.jeecg.common.constant.SymbolConstant; | ||||
| import org.jeecg.modules.system.entity.SysPosition; | ||||
| import org.jeecg.modules.system.mapper.SysPositionMapper; | ||||
| import org.jeecg.modules.system.service.ISysPositionService; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 职务表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date: 2019-09-19 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| @Service | ||||
| public class SysPositionServiceImpl extends ServiceImpl<SysPositionMapper, SysPosition> implements ISysPositionService { | ||||
| 
 | ||||
|     @Override | ||||
|     public SysPosition getByCode(String code) { | ||||
|         LambdaQueryWrapper<SysPosition> queryWrapper = new LambdaQueryWrapper<>(); | ||||
|         queryWrapper.eq(SysPosition::getCode, code); | ||||
|         return super.getOne(queryWrapper); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public List<SysPosition> getPositionList(String userId) { | ||||
|         return this.baseMapper.getPositionList(userId); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String getPositionName(List<String> postList) { | ||||
|         List<SysPosition> positionNameList = this.baseMapper.getPositionName(postList); | ||||
|         if (null != positionNameList && positionNameList.size()>0) { | ||||
|             return positionNameList.stream().map(SysPosition::getName).collect(Collectors.joining(SymbolConstant.COMMA)); | ||||
|         } | ||||
|         return ""; | ||||
|     } | ||||
| } | ||||
|  | @ -1,84 +0,0 @@ | |||
| package org.jeecg.modules.system.service.impl; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | ||||
| import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||
| import org.jeecg.common.constant.SymbolConstant; | ||||
| import org.jeecg.common.exception.JeecgBootException; | ||||
| import org.jeecg.common.util.oConvertUtils; | ||||
| import org.jeecg.modules.system.entity.SysPosition; | ||||
| import org.jeecg.modules.system.entity.SysUser; | ||||
| import org.jeecg.modules.system.entity.SysUserPosition; | ||||
| import org.jeecg.modules.system.mapper.AuthUserMapper; | ||||
| import org.jeecg.modules.system.mapper.SysUserPositionMapper; | ||||
| import org.jeecg.modules.system.service.IAuthUserService; | ||||
| import org.jeecg.modules.system.service.ISysUserPositionService; | ||||
| import org.springframework.stereotype.Service; | ||||
| 
 | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| 
 | ||||
| /** | ||||
|  * @Description: 用户职位关系表 | ||||
|  * @Author: jeecg-boot | ||||
|  * @Date: 2023-02-14 | ||||
|  * @Version: V1.0 | ||||
|  */ | ||||
| @Service | ||||
| public class SysUserPositionServiceImpl extends ServiceImpl<SysUserPositionMapper, SysUserPosition> implements ISysUserPositionService { | ||||
| 
 | ||||
|     @Autowired | ||||
|     private SysUserPositionMapper sysUserPositionMapper; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private AuthUserMapper authUserMapper; | ||||
|     @Autowired | ||||
|     private IAuthUserService authUserService; | ||||
| 
 | ||||
|     @Override | ||||
|     public IPage<SysUser> getPositionUserList(Page<SysUser> page, String positionId) { | ||||
|         return page.setRecords(authUserService.getPositionUserList(page, positionId)); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void saveUserPosition(String userIds, String positionId) { | ||||
|         String[] userIdArray = userIds.split(SymbolConstant.COMMA); | ||||
|         //存在的用户 | ||||
|         StringBuilder userBuilder = new StringBuilder(); | ||||
|         for (String userId : userIdArray) { | ||||
|             //获取成员是否存在于职位中 | ||||
|             Long count = sysUserPositionMapper.getUserPositionCount(userId, positionId); | ||||
|             if (count == 0) { | ||||
|                 //插入到用户职位关系表里面 | ||||
|                 SysUserPosition userPosition = new SysUserPosition(); | ||||
|                 userPosition.setPositionId(positionId); | ||||
|                 userPosition.setUserId(userId); | ||||
|                 sysUserPositionMapper.insert(userPosition); | ||||
|             } else { | ||||
|                 userBuilder.append(userId).append(SymbolConstant.COMMA); | ||||
|             } | ||||
|         } | ||||
|         //如果用户id存在,说明已存在用户职位关系表中,提示用户已存在 | ||||
|         String uIds = userBuilder.toString(); | ||||
|         if (oConvertUtils.isNotEmpty(uIds)) { | ||||
|             //查询用户列表 | ||||
|             List<SysUser> sysUsers = authUserMapper.selectBatchIds(Arrays.asList(uIds.split(SymbolConstant.COMMA))); | ||||
|             String realnames = sysUsers.stream().map(SysUser::getRealname).collect(Collectors.joining(SymbolConstant.COMMA)); | ||||
|             throw new JeecgBootException(realnames + "已存在该职位中"); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void removeByPositionId(String positionId) { | ||||
|         sysUserPositionMapper.removeByPositionId(positionId); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void removePositionUser(String userIds, String positionId) { | ||||
|         String[] userIdArray = userIds.split(SymbolConstant.COMMA); | ||||
| 		sysUserPositionMapper.removePositionUser(Arrays.asList(userIdArray),positionId); | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -22,10 +22,6 @@ public class AppExportUserVo { | |||
|     @Excel(name="姓名",width=30) | ||||
|     private String realname; | ||||
|      | ||||
|     /**职位*/ | ||||
|     @Excel(name = "职位",width = 30) | ||||
|     private String position; | ||||
| 
 | ||||
|     /**部门*/ | ||||
|     @Excel(name = "部门",width = 30) | ||||
|     private String depart; | ||||
|  |  | |||
|  | @ -1,89 +0,0 @@ | |||
| package org.jeecg.modules.system.vo.thirdapp; | ||||
| 
 | ||||
| import com.jeecg.dingtalk.api.department.vo.Department; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
| 
 | ||||
| /** | ||||
|  * 钉钉树结构的部门 | ||||
|  * | ||||
|  * @author sunjianlei | ||||
|  */ | ||||
| public class JdtDepartmentTreeVo extends Department { | ||||
| 
 | ||||
|     private List<JdtDepartmentTreeVo> children; | ||||
| 
 | ||||
|     public List<JdtDepartmentTreeVo> getChildren() { | ||||
|         return children; | ||||
|     } | ||||
| 
 | ||||
|     public JdtDepartmentTreeVo setChildren(List<JdtDepartmentTreeVo> children) { | ||||
|         this.children = children; | ||||
|         return this; | ||||
|     } | ||||
| 
 | ||||
|     public JdtDepartmentTreeVo(Department department) { | ||||
|         BeanUtils.copyProperties(department, this); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 是否有子项 | ||||
|      */ | ||||
|     public boolean hasChildren() { | ||||
|         return children != null && children.size() > 0; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return "JwDepartmentTree{" + | ||||
|                 "children=" + children + | ||||
|                 "} " + super.toString(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 静态辅助方法,将list转为tree结构 | ||||
|      */ | ||||
|     public static List<JdtDepartmentTreeVo> listToTree(List<Department> allDepartment) { | ||||
|         // 先找出所有的父级 | ||||
|         List<JdtDepartmentTreeVo> treeList = getByParentId(1, allDepartment); | ||||
|         Optional<Department> departmentOptional = allDepartment.stream().filter(item -> item.getParent_id() == null).findAny(); | ||||
|         Department department = new Department(); | ||||
|         //判断是否找到数据 | ||||
|         if(departmentOptional.isPresent()){ | ||||
|             department = departmentOptional.get(); | ||||
|         } | ||||
|         getChildrenRecursion(treeList, allDepartment); | ||||
|         //update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】钉钉同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息--- | ||||
|         JdtDepartmentTreeVo treeVo = new JdtDepartmentTreeVo(department); | ||||
|         treeVo.setChildren(treeList); | ||||
|         List<JdtDepartmentTreeVo> list = new ArrayList<>(); | ||||
|         list.add(treeVo); | ||||
|         return list; | ||||
|         //update-end---author:wangshuai---date:2024-04-10---for:【issues/6017】钉钉同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息--- | ||||
|     } | ||||
| 
 | ||||
|     private static List<JdtDepartmentTreeVo> getByParentId(Integer parentId, List<Department> allDepartment) { | ||||
|         List<JdtDepartmentTreeVo> list = new ArrayList<>(); | ||||
|         for (Department department : allDepartment) { | ||||
|             if (parentId.equals(department.getParent_id())) { | ||||
|                 list.add(new JdtDepartmentTreeVo(department)); | ||||
|             } | ||||
|         } | ||||
|         return list; | ||||
|     } | ||||
| 
 | ||||
|     private static void getChildrenRecursion(List<JdtDepartmentTreeVo> treeList, List<Department> allDepartment) { | ||||
|         for (JdtDepartmentTreeVo departmentTree : treeList) { | ||||
|             // 递归寻找子级 | ||||
|             List<JdtDepartmentTreeVo> children = getByParentId(departmentTree.getDept_id(), allDepartment); | ||||
|             if (children.size() > 0) { | ||||
|                 departmentTree.setChildren(children); | ||||
|                 getChildrenRecursion(children, allDepartment); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -1,89 +0,0 @@ | |||
| package org.jeecg.modules.system.vo.thirdapp; | ||||
| 
 | ||||
| import com.jeecg.qywx.api.department.vo.Department; | ||||
| import org.springframework.beans.BeanUtils; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| import java.util.Optional; | ||||
| 
 | ||||
| /** | ||||
|  * 企业微信树结构的部门 | ||||
|  * | ||||
|  * @author sunjianlei | ||||
|  */ | ||||
| public class JwDepartmentTreeVo extends Department { | ||||
| 
 | ||||
|     private List<JwDepartmentTreeVo> children; | ||||
| 
 | ||||
|     public List<JwDepartmentTreeVo> getChildren() { | ||||
|         return children; | ||||
|     } | ||||
| 
 | ||||
|     public JwDepartmentTreeVo setChildren(List<JwDepartmentTreeVo> children) { | ||||
|         this.children = children; | ||||
|         return this; | ||||
|     } | ||||
| 
 | ||||
|     public JwDepartmentTreeVo(Department department) { | ||||
|         BeanUtils.copyProperties(department, this); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 是否有子项 | ||||
|      */ | ||||
|     public boolean hasChildren() { | ||||
|         return children != null && children.size() > 0; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public String toString() { | ||||
|         return "JwDepartmentTree{" + | ||||
|                 "children=" + children + | ||||
|                 "} " + super.toString(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 静态辅助方法,将list转为tree结构 | ||||
|      */ | ||||
|     public static List<JwDepartmentTreeVo> listToTree(List<Department> allDepartment) { | ||||
|         // 先找出所有的父级 | ||||
|         List<JwDepartmentTreeVo> treeList = getByParentId("1", allDepartment); | ||||
|         Optional<Department> departmentOptional = allDepartment.stream().filter(item -> "0".equals(item.getParentid())).findAny(); | ||||
|         Department department = new Department(); | ||||
|         //判断是否找到数据 | ||||
|         if(departmentOptional.isPresent()){ | ||||
|             department = departmentOptional.get(); | ||||
|         } | ||||
|         getChildrenRecursion(treeList, allDepartment); | ||||
|         //update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】企业微信同步部门时没有最顶层的部门名,同步用户时,用户没有部门信息--- | ||||
|         JwDepartmentTreeVo treeVo = new JwDepartmentTreeVo(department); | ||||
|         treeVo.setChildren(treeList); | ||||
|         List<JwDepartmentTreeVo> list = new ArrayList<>(); | ||||
|         list.add(treeVo); | ||||
|         return list; | ||||
|         //update-begin---author:wangshuai---date:2024-04-10---for:【issues/6017】企业微信部门时没有最顶层的部门名,同步用户时,用户没有部门信息--- | ||||
|     } | ||||
| 
 | ||||
|     private static List<JwDepartmentTreeVo> getByParentId(String parentId, List<Department> allDepartment) { | ||||
|         List<JwDepartmentTreeVo> list = new ArrayList<>(); | ||||
|         for (Department department : allDepartment) { | ||||
|             if (parentId.equals(department.getParentid())) { | ||||
|                 list.add(new JwDepartmentTreeVo(department)); | ||||
|             } | ||||
|         } | ||||
|         return list; | ||||
|     } | ||||
| 
 | ||||
|     private static void getChildrenRecursion(List<JwDepartmentTreeVo> treeList, List<Department> allDepartment) { | ||||
|         for (JwDepartmentTreeVo departmentTree : treeList) { | ||||
|             // 递归寻找子级 | ||||
|             List<JwDepartmentTreeVo> children = getByParentId(departmentTree.getId(), allDepartment); | ||||
|             if (children.size() > 0) { | ||||
|                 departmentTree.setChildren(children); | ||||
|                 getChildrenRecursion(children, allDepartment); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  | @ -1,23 +0,0 @@ | |||
| package org.jeecg.modules.system.vo.thirdapp; | ||||
| 
 | ||||
| import lombok.Data; | ||||
| 
 | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * 企业微信的实现类 | ||||
|  */ | ||||
| @Data | ||||
| public class JwSysUserDepartVo { | ||||
| 
 | ||||
|     /** | ||||
|      * 企业微信和用户的映射类 | ||||
|      */ | ||||
|     private List<JwUserDepartVo> jwUserDepartVos; | ||||
| 
 | ||||
|     /** | ||||
|      * 用户列表 | ||||
|      */ | ||||
|     private List<JwUserDepartVo> userList; | ||||
| 
 | ||||
| } | ||||
|  | @ -1,48 +0,0 @@ | |||
| package org.jeecg.modules.system.vo.thirdapp; | ||||
| 
 | ||||
| import lombok.Data; | ||||
| 
 | ||||
| /** | ||||
| * @Description: 企业微信用户同步工具类 | ||||
| * | ||||
| * @author: wangshuai | ||||
| * @date: 2023/11/28 18:17 | ||||
| */ | ||||
| @Data | ||||
| public class JwUserDepartVo { | ||||
|      | ||||
|     /** | ||||
|      * 用户id | ||||
|      */ | ||||
|     private String userId; | ||||
| 
 | ||||
|     /** | ||||
|      * 用户头像 | ||||
|      */ | ||||
|     private String avatar; | ||||
| 
 | ||||
|     /** | ||||
|      * 真实姓名 | ||||
|      */ | ||||
|     private String realName; | ||||
| 
 | ||||
|     /** | ||||
|      * 企业微信的名字 | ||||
|      */ | ||||
|     private String wechatRealName; | ||||
| 
 | ||||
|     /** | ||||
|      * 企业微信对应的部门 | ||||
|      */ | ||||
|     private String wechatDepartId; | ||||
| 
 | ||||
|     /** | ||||
|      * 企业微信对应的用户id | ||||
|      */ | ||||
|     private String wechatUserId; | ||||
| 
 | ||||
|     /** | ||||
|      * 第三方id | ||||
|      */ | ||||
|     private String thirdId; | ||||
| } | ||||
|  | @ -1,44 +0,0 @@ | |||
| package org.jeecg.modules.system.vo.thirdapp; | ||||
| 
 | ||||
| import lombok.Data; | ||||
| 
 | ||||
| import java.util.ArrayList; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * 同步结果信息,包含成功的信息和失败的信息 | ||||
|  * | ||||
|  * @author sunjianlei | ||||
|  */ | ||||
| @Data | ||||
| public class SyncInfoVo { | ||||
| 
 | ||||
|     /** | ||||
|      * 成功的信息 | ||||
|      */ | ||||
|     private List<String> successInfo; | ||||
|     /** | ||||
|      * 失败的信息 | ||||
|      */ | ||||
|     private List<String> failInfo; | ||||
| 
 | ||||
|     public SyncInfoVo() { | ||||
|         this.successInfo = new ArrayList<>(); | ||||
|         this.failInfo = new ArrayList<>(); | ||||
|     } | ||||
| 
 | ||||
|     public SyncInfoVo(List<String> successInfo, List<String> failInfo) { | ||||
|         this.successInfo = successInfo; | ||||
|         this.failInfo = failInfo; | ||||
|     } | ||||
| 
 | ||||
|     public SyncInfoVo addSuccessInfo(String info) { | ||||
|         this.successInfo.add(info); | ||||
|         return this; | ||||
|     } | ||||
| 
 | ||||
|     public SyncInfoVo addFailInfo(String info) { | ||||
|         this.failInfo.add(info); | ||||
|         return this; | ||||
|     } | ||||
| } | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 panbaolin
						panbaolin