| | |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dg.core.ResultData; |
| | | import com.dg.core.annotation.Authorization; |
| | | import com.dg.core.annotation.CurrentUser; |
| | | import com.dg.core.db.gen.entity.SysUser; |
| | | import com.dg.core.service.IGuideRepairOrderService; |
| | | import com.dg.core.service.IOrganizationChartService; |
| | | import com.dg.core.service.ISysUserService; |
| | | import com.dg.core.util.PermissionUtil; |
| | | import com.dg.core.util.Snowflake; |
| | | import com.dg.core.util.TableDataInfo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.repository.query.Param; |
| | | import org.springframework.util.Assert; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | ISysUserService IUserService; |
| | | |
| | | |
| | | @Autowired |
| | | IGuideRepairOrderService iGuideRepairOrderService; |
| | | |
| | | @Autowired |
| | | IOrganizationChartService iOrganizationChartService; |
| | | |
| | | /** |
| | | * 查询列表 |
| | | * |
| | |
| | | @GetMapping("/getlist") |
| | | @Authorization |
| | | public TableDataInfo selectConfigList(@RequestParam(value = "pageNum",required = false) Integer pageNum, |
| | | @RequestParam(value = "pageSize",required = false) Integer pageSize) |
| | | @RequestParam(value = "pageSize",required = false) Integer pageSize, |
| | | @RequestParam(value = "keyword",required = false) String keyword, |
| | | @RequestParam(value = "isDivisionHead",required = false) String isDivisionHead, |
| | | @CurrentUser SysUser sysUser) |
| | | { |
| | | Assert.notNull(pageNum, "pageNum can not be empty"); |
| | | Assert.notNull(pageSize, "pageSize can not be empty"); |
| | | Page<SysUser> pageParam = new Page<>(pageNum,pageSize); |
| | | List<SysUser> list = IUserService.selectConfigList(pageParam,pageSize,"2"); |
| | | |
| | | int num=IUserService.selectNum("2"); |
| | | List<String> ids= PermissionUtil.getPermission(sysUser,iOrganizationChartService); |
| | | List<SysUser> list ; |
| | | int num; |
| | | if (isDivisionHead!=null&&!isDivisionHead.equals("")){ |
| | | list = IUserService.selectConfigList(pageParam,pageSize,"2",keyword,ids,isDivisionHead); |
| | | num=IUserService.selectNum("2",keyword,ids,isDivisionHead); |
| | | } |
| | | else{ |
| | | list = IUserService.selectConfigList(pageParam,pageSize,"2",keyword,ids,null); |
| | | num=IUserService.selectNum("2",keyword,ids,null); |
| | | } |
| | | return getDataTable(list,num); |
| | | } |
| | | |
| | |
| | | @ApiOperation("新增导办用户接口") |
| | | @PostMapping("/add") |
| | | @Authorization |
| | | public ResultData insertConfig(@RequestBody SysUser config) |
| | | public ResultData insertConfig(@RequestBody SysUser config,@CurrentUser SysUser sysUser) |
| | | { |
| | | Assert.notNull(config, "parameter can not be empty"); |
| | | |
| | |
| | | return error("密码不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(config.getPhonenumber())) |
| | | { |
| | | return error("手机号不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(config.getUserName())) |
| | | { |
| | | return error("昵称不能为空"); |
| | | } |
| | | |
| | | SysUser user = IUserService.getUserByAccount(config.getLoginName()); |
| | | if (user != null) { |
| | | //提示用户名或密码错误 |
| | | return error("该账户已存在!"); |
| | | if(StringUtils.isEmpty(config.getDepartmentId())) |
| | | { |
| | | return error("部门不能为空"); |
| | | } |
| | | |
| | | config.setUserType("2"); |
| | | |
| | | SysUser user=IUserService.selectData(null,config.getPhonenumber(),null); |
| | | if (user != null) |
| | | { |
| | | user.setPassword(config.getPassword()); |
| | | user.setDepartmentId(config.getDepartmentId()); |
| | | user.setUserName(config.getUserName()); |
| | | user.setPhonenumber(config.getPhonenumber()); |
| | | user.setLoginName(config.getLoginName()); |
| | | user.setMasterIds(config.getMasterIds()); |
| | | //是否是部门领导(1是 2不是) |
| | | if(StringUtils.equals("1",config.getIsDivisionHead())) |
| | | { |
| | | user.setRoleIds("13"); |
| | | if(StringUtils.isEmpty(config.getDataPermission())) { |
| | | user.setDataPermission(config.getMoreDepartmentIds()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(StringUtils.isEmpty(config.getDataPermission())) { |
| | | user.setDataPermission(config.getDepartmentId()); |
| | | } |
| | | user.setRoleIds("2"); |
| | | } |
| | | user.setUserType("2"); |
| | | user.setIsDivisionHead(config.getIsDivisionHead()); |
| | | user.setStatus(config.getStatus()); |
| | | user.setUpdateTime(LocalDateTime.now()); |
| | | user.setDepartmentIds(config.getDepartmentIds()); |
| | | user.setDepartmentIdStr(config.getDepartmentIdStr()); |
| | | user.setMoreDepartmentIds(config.getMoreDepartmentIds()); |
| | | user.setMattersIds(config.getMattersIds()); |
| | | user.setMasterNames(config.getMasterNames()); |
| | | user.setMattersNames(config.getMattersNames()); |
| | | if (config.getMoreDepartmentIds()!=null&&config.getMoreDepartmentIds().indexOf(",")>0) |
| | | user.setDataPermission(config.getMoreDepartmentIds().substring(config.getMoreDepartmentIds().indexOf(",")+1)); |
| | | //提示用户名或密码错误 |
| | | return toAjax(IUserService.updateConfig(user)); |
| | | } |
| | | //是否是部门领导(1是 2不是) |
| | | if(StringUtils.equals("1",config.getIsDivisionHead())) |
| | | { |
| | | config.setRoleIds("13"); |
| | | if(StringUtils.isEmpty(config.getDataPermission())) { |
| | | config.setDataPermission(config.getMoreDepartmentIds()); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | if(StringUtils.isEmpty(config.getDataPermission())) { |
| | | config.setDataPermission(config.getDepartmentId()); |
| | | } |
| | | config.setRoleIds("2"); |
| | | } |
| | | config.setCreateBy(sysUser.getUserId()); |
| | | config.setCreateTime(LocalDateTime.now()); |
| | | config.setUpdateTime(LocalDateTime.now()); |
| | | |
| | | config.setUserId(Snowflake.getId()+""); |
| | | if (config.getMoreDepartmentIds()!=null&&config.getMoreDepartmentIds().indexOf(",")>0) |
| | | config.setDataPermission(config.getMoreDepartmentIds().substring(config.getMoreDepartmentIds().indexOf(",")+1)); |
| | | config.setIsDivisionHead(config.getIsDivisionHead()); |
| | | return toAjax(IUserService.insertConfig(config)); |
| | | } |
| | | |
| | |
| | | return error("userId不能为空"); |
| | | } |
| | | |
| | | if(StringUtils.isEmpty(config.getPhonenumber())) |
| | | { |
| | | return error("手机号不能为空"); |
| | | } |
| | | |
| | | |
| | | if(StringUtils.isEmpty(config.getLoginName())) |
| | | { |
| | | return error("账户不能为空"); |
| | |
| | | |
| | | config.setUserType("2"); |
| | | |
| | | //是否是部门领导(1是 2不是) |
| | | if(StringUtils.equals("1",config.getIsDivisionHead())) |
| | | { |
| | | if (config.getMoreDepartmentIds()!=null&&config.getMoreDepartmentIds().indexOf(",")>0) |
| | | config.setDataPermission(config.getMoreDepartmentIds().substring(config.getMoreDepartmentIds().indexOf(",")+1)); |
| | | else |
| | | { |
| | | config.setDataPermission("0"); |
| | | } |
| | | |
| | | config.setRoleIds("13"); |
| | | } |
| | | else |
| | | { |
| | | if(StringUtils.isEmpty(config.getDataPermission())) { |
| | | config.setDataPermission(config.getDepartmentId()); |
| | | } |
| | | config.setRoleIds("2"); |
| | | } |
| | | |
| | | SysUser user=IUserService.selectData(null,config.getPhonenumber(),null); |
| | | if (user != null && !(user.getUserId().equals(config.getUserId()))) |
| | | { |
| | | //提示用户名或密码错误 |
| | | return ResultData.error("该手机账户已存在!请更换手机号"); |
| | | } |
| | | return toAjax(IUserService.updateConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * 删除聊天记录 |
| | | * 删除导办用户接口 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | |
| | | { |
| | | return error("userId不能为空"); |
| | | } |
| | | return toAjax(IUserService.deleteConfigById(userId)); |
| | | |
| | | int a=iGuideRepairOrderService.countUser(userId,"2"); |
| | | if(a>0) |
| | | { |
| | | return error("该人员有工单未处理完不能删除"); |
| | | } |
| | | SysUser user=IUserService.selectData(userId,null,null); |
| | | user.setUserType("4"); |
| | | user.setRoleIds("4"); |
| | | user.setIsDivisionHead("2"); |
| | | return toAjax(IUserService.updateConfig(user)); |
| | | } |
| | | |
| | | /** |
| | | * 修改空闲状态 |
| | | * 修改导办用户空闲状态接口 |
| | | * |
| | | * @param config 参数配置信息 |
| | | * @return 结果 |
| | |
| | | return toAjax(IUserService.updateConfig(config)); |
| | | } |
| | | |
| | | /** |
| | | * 根据部门id及分类id获取导办用户 |
| | | * |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation("根据部门id及分类id获取导办用户") |
| | | @GetMapping("/selectListByDepartmentId") |
| | | @Authorization |
| | | public ResultData selectListByDepartmentId(@RequestParam("departmentId") String departmentId, |
| | | @RequestParam(value = "classifyId",required = false) String classifyId) |
| | | { |
| | | return ResultData.success(IUserService.selectListByDepartmentId(departmentId,classifyId)); |
| | | } |
| | | |
| | | /** |
| | | * 查询导办用户列表(不分页) |
| | | * @return 结果 |
| | | */ |
| | | @ApiOperation(" 查询导办用户列表(不分页)") |
| | | @GetMapping("/queryList") |
| | | @Authorization |
| | | public ResultData queryList(@RequestParam(value = "keyWord",required = false) String keyWord){ |
| | | return ResultData.success(IUserService.queryList(2,keyWord)); |
| | | } |
| | | |
| | | } |