1. 添加运营商时默认创建运营商账号并添加运营商角色
2.合伙人默认添加合伙人角色
This commit is contained in:
		
							parent
							
								
									4796e03f8c
								
							
						
					
					
						commit
						94e4f9d58f
					
				|  | @ -25,7 +25,7 @@ import com.ruoyi.common.utils.StringUtils; | |||
| import com.ruoyi.system.service.ISysDeptService; | ||||
| 
 | ||||
| /** | ||||
|  * 部门信息 | ||||
|  * 运营商信息 | ||||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
|  | @ -41,7 +41,7 @@ public class SysDeptController extends BaseController | |||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 获取部门列表 | ||||
|      * 获取运营商列表 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('system:dept:list')") | ||||
|     @GetMapping("/list") | ||||
|  | @ -52,7 +52,7 @@ public class SysDeptController extends BaseController | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 查询部门列表(排除节点) | ||||
|      * 查询运营商列表(排除节点) | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('system:dept:list')") | ||||
|     @GetMapping("/list/exclude/{deptId}") | ||||
|  | @ -64,7 +64,7 @@ public class SysDeptController extends BaseController | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 根据部门编号获取详细信息 | ||||
|      * 根据运营商编号获取详细信息 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('system:dept:query')") | ||||
|     @GetMapping(value = "/{deptId}") | ||||
|  | @ -78,26 +78,26 @@ public class SysDeptController extends BaseController | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 新增部门 | ||||
|      * 新增运营商 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('system:dept:add')") | ||||
|     @Log(title = "部门管理", businessType = BusinessType.INSERT) | ||||
|     @Log(title = "运营商管理", businessType = BusinessType.INSERT) | ||||
|     @PostMapping | ||||
|     public AjaxResult add(@Validated @RequestBody SysDept dept) | ||||
|     { | ||||
|         if (!deptService.checkDeptNameUnique(dept)) | ||||
|         { | ||||
|             return error("新增运营商'" + dept.getDeptName() + "'失败,部门名称已存在"); | ||||
|             return error("新增运营商'" + dept.getDeptName() + "'失败,运营商名称已存在"); | ||||
|         } | ||||
|         dept.setCreateBy(getUsername()); | ||||
|         return toAjax(deptService.insertDept(dept)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 修改部门 | ||||
|      * 修改运营商 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('system:dept:edit')") | ||||
|     @Log(title = "部门管理", businessType = BusinessType.UPDATE) | ||||
|     @Log(title = "运营商管理", businessType = BusinessType.UPDATE) | ||||
|     @PutMapping | ||||
|     public AjaxResult edit(@Validated @RequestBody SysDept dept) | ||||
|     { | ||||
|  | @ -105,35 +105,35 @@ public class SysDeptController extends BaseController | |||
|         deptService.checkDeptDataScope(deptId); | ||||
|         if (!deptService.checkDeptNameUnique(dept)) | ||||
|         { | ||||
|             return error("修改运营商'" + dept.getDeptName() + "'失败,部门名称已存在"); | ||||
|             return error("修改运营商'" + dept.getDeptName() + "'失败,运营商名称已存在"); | ||||
|         } | ||||
|         else if (dept.getParentId().equals(deptId)) | ||||
|         { | ||||
|             return error("修改运营商'" + dept.getDeptName() + "'失败,上级部门不能是自己"); | ||||
|             return error("修改运营商'" + dept.getDeptName() + "'失败,上级运营商不能是自己"); | ||||
|         } | ||||
|         else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) | ||||
|         { | ||||
|             return error("该运营商包含未停用的子部门!"); | ||||
|             return error("该运营商包含未停用的子运营商!"); | ||||
|         } | ||||
|         dept.setUpdateBy(getUsername()); | ||||
|         return toAjax(deptService.updateDept(dept)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 删除部门 | ||||
|      * 删除运营商 | ||||
|      */ | ||||
|     @PreAuthorize("@ss.hasPermi('system:dept:remove')") | ||||
|     @Log(title = "部门管理", businessType = BusinessType.DELETE) | ||||
|     @Log(title = "运营商管理", businessType = BusinessType.DELETE) | ||||
|     @DeleteMapping("/{deptId}") | ||||
|     public AjaxResult remove(@PathVariable Long deptId) | ||||
|     { | ||||
|         if (deptService.hasChildByDeptId(deptId)) | ||||
|         { | ||||
|             return warn("存在下级部门,不允许删除"); | ||||
|             return warn("存在下级运营商,不允许删除"); | ||||
|         } | ||||
|         if (deptService.checkDeptExistUser(deptId)) | ||||
|         { | ||||
|             return warn("部门存在用户,不允许删除"); | ||||
|             return warn("运营商存在用户,不允许删除"); | ||||
|         } | ||||
|         deptService.checkDeptDataScope(deptId); | ||||
|         return toAjax(deptService.deleteDeptById(deptId)); | ||||
|  |  | |||
|  | @ -4,9 +4,13 @@ import java.util.List; | |||
| import java.util.Set; | ||||
| 
 | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import com.ruoyi.common.constant.HttpStatus; | ||||
| import com.ruoyi.common.core.domain.entity.AsUser; | ||||
| import com.ruoyi.common.exception.ServiceException; | ||||
| import com.ruoyi.system.service.IAsUserService; | ||||
| import com.ruoyi.system.service.ISysUserService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.PostMapping; | ||||
|  | @ -27,6 +31,7 @@ import com.ruoyi.system.service.ISysMenuService; | |||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| @Slf4j | ||||
| @RestController | ||||
| public class SysLoginController | ||||
| { | ||||
|  | @ -129,6 +134,10 @@ public class SysLoginController | |||
|      */ | ||||
|     @PostMapping("/wxlogin") | ||||
|     public AjaxResult wxlogin(String mobileCode,String jsCode,String areaId) { | ||||
|         if(StrUtil.isBlank(areaId)){ | ||||
|             log.info("没有传入areaId参数:【areaId={}】",areaId); | ||||
|             return AjaxResult.error("请传areaId参数"+"【areaId="+areaId+"】"); | ||||
|         } | ||||
|         AjaxResult ajax = AjaxResult.success(); | ||||
|         // 生成令牌 | ||||
|         String token = loginService.wxloing(mobileCode,jsCode,areaId); | ||||
|  | @ -141,6 +150,10 @@ public class SysLoginController | |||
|      */ | ||||
|     @PostMapping("/loginByopenid") | ||||
|     public AjaxResult loginByopenid(String jsCode,String areaId) { | ||||
|         if(StrUtil.isBlank(areaId)){ | ||||
|             log.info("没有传入areaId参数:【areaId={}】",areaId); | ||||
|             return new AjaxResult(HttpStatus.NOT_IMPLEMENTED, "请传areaId参数"+"【areaId="+areaId+"】", null); | ||||
|         } | ||||
|         AjaxResult ajax = AjaxResult.success(); | ||||
|         // 生成令牌 | ||||
|         String token = loginService.loginByopenid(jsCode,areaId); | ||||
|  |  | |||
|  | @ -5,10 +5,15 @@ import java.util.Iterator; | |||
| import java.util.List; | ||||
| import java.util.stream.Collectors; | ||||
| 
 | ||||
| import com.ruoyi.common.utils.DateUtils; | ||||
| import com.ruoyi.system.domain.EtAreaDept; | ||||
| import com.ruoyi.system.domain.EtAreaRule; | ||||
| import com.ruoyi.system.mapper.EtAreaDeptMapper; | ||||
| import com.ruoyi.system.domain.SysUserRole; | ||||
| import com.ruoyi.system.mapper.*; | ||||
| import com.ruoyi.system.service.IEtOperatingAreaService; | ||||
| import com.ruoyi.system.service.ISysConfigService; | ||||
| import com.ruoyi.system.service.ISysUserService; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | ||||
| import com.ruoyi.common.annotation.DataScope; | ||||
|  | @ -22,8 +27,6 @@ import com.ruoyi.common.exception.ServiceException; | |||
| import com.ruoyi.common.utils.SecurityUtils; | ||||
| import com.ruoyi.common.utils.StringUtils; | ||||
| import com.ruoyi.common.utils.spring.SpringUtils; | ||||
| import com.ruoyi.system.mapper.SysDeptMapper; | ||||
| import com.ruoyi.system.mapper.SysRoleMapper; | ||||
| import com.ruoyi.system.service.ISysDeptService; | ||||
| import org.springframework.transaction.annotation.Transactional; | ||||
| 
 | ||||
|  | @ -34,6 +37,7 @@ import javax.annotation.Resource; | |||
|  * | ||||
|  * @author ruoyi | ||||
|  */ | ||||
| @Slf4j | ||||
| @Service | ||||
| public class SysDeptServiceImpl implements ISysDeptService | ||||
| { | ||||
|  | @ -46,6 +50,15 @@ public class SysDeptServiceImpl implements ISysDeptService | |||
|     @Resource | ||||
|     private EtAreaDeptMapper etAreaDeptMapper; | ||||
| 
 | ||||
|     @Resource | ||||
|     private SysUserMapper userMapper; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private ISysConfigService configService; | ||||
| 
 | ||||
|     @Autowired | ||||
|     private SysUserRoleMapper userRoleMapper; | ||||
| 
 | ||||
|     /** | ||||
|      * 查询部门管理数据 | ||||
|      * | ||||
|  | @ -235,6 +248,8 @@ public class SysDeptServiceImpl implements ISysDeptService | |||
|         for (Long areaId:areaIds){ | ||||
|             etAreaDeptMapper.insert(EtAreaDept.builder().areaId(areaId).deptId(dept.getDeptId()).build()); | ||||
|         } | ||||
|         // 添加运营商账号并添加运营商角色 | ||||
|         createOperator(dept); | ||||
|         return i; | ||||
|     } | ||||
| 
 | ||||
|  | @ -269,9 +284,50 @@ public class SysDeptServiceImpl implements ISysDeptService | |||
|         for (Long areaId:areaIds){ | ||||
|             etAreaDeptMapper.insert(EtAreaDept.builder().areaId(areaId).deptId(dept.getDeptId()).build()); | ||||
|         } | ||||
|         // 添加运营商账号并添加运营商角色 | ||||
|         createOperator(dept); | ||||
|         return result; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 添加运营商账号 | ||||
|      * 创建 | ||||
|      * @param dept 当前部门 | ||||
|      */ | ||||
|     private void createOperator(SysDept dept) { | ||||
|         // 创建运营商账号并添加运营商角色 | ||||
|         SysUser sysUser = new SysUser(); | ||||
|         sysUser.setDeptId(dept.getDeptId()); | ||||
|         sysUser.setUserName(dept.getPhone()); | ||||
|         sysUser.setNickName(dept.getLeader()); | ||||
|         sysUser.setPhonenumber(dept.getPhone()); | ||||
|         sysUser.setUserType("00"); | ||||
|         String password = configService.selectConfigByKey("sys.user.initPassword"); | ||||
|         sysUser.setPassword(SecurityUtils.encryptPassword(password)); | ||||
|         sysUser.setEmail(dept.getEmail()); | ||||
|         sysUser.setStatus("0"); | ||||
|         sysUser.setDelFlag("0"); | ||||
|         sysUser.setCreateBy(SecurityUtils.getUsername()); | ||||
|         sysUser.setCreateTime(DateUtils.getNowDate()); | ||||
|         int rows = userMapper.insertUser(sysUser); | ||||
| 
 | ||||
|         // 添加运营商角色 | ||||
|         if (rows > 0) { | ||||
|             log.info("创建运营商账号成功"); | ||||
|             Long[] roleIds = new Long[]{3L}; | ||||
|             // 新增用户与角色管理 | ||||
|             List<SysUserRole> list = new ArrayList<>(roleIds.length); | ||||
|             for (Long roleId : roleIds) | ||||
|             { | ||||
|                 SysUserRole ur = new SysUserRole(); | ||||
|                 ur.setUserId(sysUser.getUserId()); | ||||
|                 ur.setRoleId(roleId); | ||||
|                 list.add(ur); | ||||
|             } | ||||
|             userRoleMapper.batchUserRole(list); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 修改该部门的父级部门状态 | ||||
|      * | ||||
|  |  | |||
|  | @ -1,6 +1,7 @@ | |||
| package com.ruoyi.system.service.impl; | ||||
| 
 | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.hutool.core.util.StrUtil; | ||||
| import com.alibaba.fastjson2.JSON; | ||||
| import com.ruoyi.common.annotation.DataScope; | ||||
| import com.ruoyi.common.constant.UserConstants; | ||||
|  | @ -314,7 +315,7 @@ public class SysUserServiceImpl implements ISysUserService | |||
|         if(ObjectUtils.isNotEmpty(asUser)){ | ||||
|             addReceiver(user,asUser); | ||||
|         }else{ | ||||
|             throw new ServiceException("未查询到APP用户"); | ||||
|             throw new ServiceException("未查询到APP用户,请登录小程序"); | ||||
|         } | ||||
|         // 新增用户信息 | ||||
|         int rows = userMapper.insertUser(user); | ||||
|  | @ -382,7 +383,7 @@ public class SysUserServiceImpl implements ISysUserService | |||
|             // 添加分账接收方 | ||||
|             addReceiver(user,asUser); | ||||
|         }else{ | ||||
|             throw new ServiceException("未查询到APP用户"); | ||||
|             throw new ServiceException("未查询到APP用户,请登录小程序"); | ||||
|         } | ||||
|         return userMapper.updateUser(user); | ||||
|     } | ||||
|  | @ -494,7 +495,11 @@ public class SysUserServiceImpl implements ISysUserService | |||
|      */ | ||||
|     public void insertUserRole(SysUser user) | ||||
|     { | ||||
|         this.insertUserRole(user.getUserId(), user.getRoleIds()); | ||||
|         if(StrUtil.isNotBlank(user.getUserType()) && "03".equals(user.getUserType())){ | ||||
|             this.insertUserRole(user.getUserId(), new Long[]{4L}); | ||||
|         }else{ | ||||
|             this.insertUserRole(user.getUserId(), user.getRoleIds()); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user