tjf преди 2 месеца
родител
ревизия
75743c0c52

+ 3 - 3
ruoyi-admin/src/main/resources/application.yml

@@ -191,9 +191,9 @@ springdoc:
     version: '版本号: ${ruoyi.version}'
     # 作者信息
     contact:
-      name: Lion Li
-      email: crazylionli@163.com
-      url: https://gitee.com/dromara/RuoYi-Vue-Plus
+      name: Boman
+      email: 123@163.com
+      url: https://baidu.com
   components:
     # 鉴权方式配置
     security-schemes:

+ 1 - 1
ruoyi-common/ruoyi-common-mybatis/src/main/java/org/dromara/common/mybatis/core/domain/BaseEntity.java

@@ -33,7 +33,7 @@ public class BaseEntity implements Serializable {
     /**
      * 创建部门
      */
-    @TableField(fill = FieldFill.INSERT)
+    //@TableField(fill = FieldFill.INSERT)
     private Long createDept;
 
     /**

+ 1 - 1
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/controller/system/SysUserController.java

@@ -124,7 +124,7 @@ public class SysUserController extends BaseController {
         //判断是否需要进行用户认证
         boolean enable = TenantHelper.isEnable();
         if (enable) {
-            if (user.getIsAuthentication().equals(Y)) {
+            if (user.getIsAuthentication().equals(N)) {
                 userInfoVo.setAuthenticationUser(Y);
             }
         }

+ 3 - 5
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/vo/SysUserVo.java

@@ -2,13 +2,11 @@ package org.dromara.system.domain.vo;
 
 import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.fasterxml.jackson.annotation.JsonProperty;
-import org.dromara.common.sensitive.annotation.Sensitive;
-import org.dromara.common.sensitive.core.SensitiveStrategy;
+import io.github.linpeilie.annotations.AutoMapper;
+import lombok.Data;
 import org.dromara.common.translation.annotation.Translation;
 import org.dromara.common.translation.constant.TransConstant;
 import org.dromara.system.domain.SysUser;
-import io.github.linpeilie.annotations.AutoMapper;
-import lombok.Data;
 
 import java.io.Serial;
 import java.io.Serializable;
@@ -67,7 +65,7 @@ public class SysUserVo implements Serializable {
     /**
      * 手机号码
      */
-    @Sensitive(strategy = SensitiveStrategy.PHONE, perms = "system:user:edit")
+    //@Sensitive(strategy = SensitiveStrategy.PHONE, perms = "system:user:edit")
     private String phonenumber;
 
     /**

+ 40 - 2
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/controller/staffManage/StaffManageController.java

@@ -1,6 +1,7 @@
 package org.dromara.controller.staffManage;
 
 import cn.dev33.satoken.annotation.SaCheckPermission;
+import cn.dev33.satoken.annotation.SaIgnore;
 import jakarta.servlet.http.HttpServletResponse;
 import jakarta.validation.constraints.NotEmpty;
 import jakarta.validation.constraints.NotNull;
@@ -69,10 +70,23 @@ public class StaffManageController extends BaseController {
         return R.ok(staffManageService.queryById(staffId));
     }
 
+    /**
+     * 获取员工管理详细信息
+     *
+     * @param userId 用户id
+     */
+    @SaIgnore
+    @GetMapping("/getInfoByUserId/{userId}")
+    public R<StaffManageVo> getInfoByUserId(@NotNull(message = "主键不能为空")
+                                    @PathVariable Long userId) {
+        return R.ok(staffManageService.getInfoByUserId(userId));
+    }
+
     /**
      * 新增员工管理
      */
-    @SaCheckPermission("wuYe:staffManage:add")
+    //@SaCheckPermission("wuYe:staffManage:add")
+    @SaIgnore
     @Log(title = "员工管理", businessType = BusinessType.INSERT)
     @RepeatSubmit()
     @PostMapping()
@@ -80,10 +94,23 @@ public class StaffManageController extends BaseController {
         return toAjax(staffManageService.insertByBo(bo));
     }
 
+
+    /**
+     * 管理员新增员工信息默认认证
+     */
+    @SaCheckPermission("wuYe:staffManage:authentication")
+    @Log(title = "员工管理", businessType = BusinessType.INSERT)
+    @RepeatSubmit()
+    @PostMapping("/authentication")
+    public R<Void> authentication(@Validated(AddGroup.class) @RequestBody StaffManageBo bo) {
+        return toAjax(staffManageService.insertAuthenticationByBo(bo));
+    }
+
     /**
      * 修改员工管理
      */
-    @SaCheckPermission("wuYe:staffManage:edit")
+    //@SaCheckPermission("wuYe:staffManage:edit")
+    @SaIgnore
     @Log(title = "员工管理", businessType = BusinessType.UPDATE)
     @RepeatSubmit()
     @PostMapping("/put")
@@ -91,6 +118,17 @@ public class StaffManageController extends BaseController {
         return toAjax(staffManageService.updateByBo(bo));
     }
 
+    /**
+     * 管理员修改员工管理
+     */
+    @SaCheckPermission("wuYe:staffManage:editAuthentication")
+    @Log(title = "员工管理", businessType = BusinessType.UPDATE)
+    @RepeatSubmit()
+    @PostMapping("/put/authentication")
+    public R<Void> editAuthentication(@Validated(EditGroup.class) @RequestBody StaffManageBo bo) {
+        return toAjax(staffManageService.editAuthentication(bo));
+    }
+
     /**
      * 删除员工管理
      *

+ 3 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/staffManage/StaffManage.java

@@ -32,6 +32,9 @@ public class StaffManage extends TenantEntity {
      */
     private Long userId;
 
+    @TableField(exist = false)
+    private String userType;
+
     /**
      * 员工姓名
      */

+ 6 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/staffManage/bo/StaffManageBo.java

@@ -26,6 +26,12 @@ public class StaffManageBo extends BaseEntity {
     @NotNull(message = "员工管理id不能为空", groups = { EditGroup.class })
     private Long staffId;
 
+    private String userType;
+
+    /**
+     * 租户ID
+     */
+    private String tenantId;
     /**
      * 员工账号id
      */

+ 5 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/domain/staffManage/vo/StaffManageVo.java

@@ -34,6 +34,11 @@ public class StaffManageVo implements Serializable {
     @ExcelProperty(value = "员工管理id")
     private Long staffId;
 
+    /**
+     * 租户ID
+     */
+    private String tenantId;
+
     /**
      * 员工账号id
      */

+ 16 - 0
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/IStaffManageService.java

@@ -25,6 +25,13 @@ public interface IStaffManageService {
      */
     StaffManageVo queryById(Long staffId);
 
+    /**
+     * 获取员工管理详细信息
+     *
+     * @param userId 用户id
+     */
+    StaffManageVo getInfoByUserId(Long userId);
+
     /**
      * 分页查询员工管理列表
      *
@@ -49,6 +56,10 @@ public interface IStaffManageService {
      * @return 是否新增成功
      */
     Boolean insertByBo(StaffManageBo bo);
+    /**
+     * 管理员新增员工信息默认认证
+     */
+    Boolean insertAuthenticationByBo(StaffManageBo bo);
 
     /**
      * 修改员工管理
@@ -58,6 +69,11 @@ public interface IStaffManageService {
      */
     Boolean updateByBo(StaffManageBo bo);
 
+    /**
+     * 管理员修改员工管理
+     */
+    Boolean editAuthentication(StaffManageBo bo);
+
     /**
      * 校验并批量删除员工管理信息
      *

+ 133 - 9
ruoyi-modules/ruoyi-wuye/src/main/java/org/dromara/service/impl/StaffManageServiceImpl.java

@@ -1,9 +1,14 @@
 package org.dromara.service.impl;
 
+import cn.dev33.satoken.secure.BCrypt;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.RequiredArgsConstructor;
+import org.dromara.common.core.config.BoManConfig;
+import org.dromara.common.core.enums.UserType;
+import org.dromara.common.core.exception.user.UserException;
 import org.dromara.common.core.utils.MapstructUtils;
 import org.dromara.common.core.utils.StringUtils;
 import org.dromara.common.mybatis.core.page.PageQuery;
@@ -15,20 +20,22 @@ import org.dromara.domain.staffManage.vo.StaffManageVo;
 import org.dromara.mapper.StaffManageMapper;
 import org.dromara.service.IStaffManageService;
 import org.dromara.system.domain.SysRole;
+import org.dromara.system.domain.SysUser;
 import org.dromara.system.domain.SysUserTenant;
 import org.dromara.system.domain.bo.SysUserBo;
 import org.dromara.system.domain.vo.SysRoleVo;
 import org.dromara.system.mapper.SysRoleMapper;
+import org.dromara.system.mapper.SysUserMapper;
 import org.dromara.system.mapper.SysUserTenantMapper;
 import org.dromara.system.service.ISysUserService;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
+
 import java.util.Collection;
 import java.util.List;
 import java.util.Map;
 
-import static org.dromara.common.core.constant.Constants.TWO;
-import static org.dromara.common.core.constant.Constants.Y;
+import static org.dromara.common.core.constant.Constants.*;
 
 /**
  * 员工管理Service业务层处理
@@ -43,7 +50,9 @@ public class StaffManageServiceImpl implements IStaffManageService {
     private final StaffManageMapper baseMapper;
     private final SysUserTenantMapper sysUserTenantMapper;
     private final SysRoleMapper sysRoleMapper;
-    private final ISysUserService sysUserService;
+    private final ISysUserService userService;
+    private final SysUserMapper userMapper;
+
     /**
      * 查询员工管理
      *
@@ -51,10 +60,21 @@ public class StaffManageServiceImpl implements IStaffManageService {
      * @return 员工管理
      */
     @Override
-    public StaffManageVo queryById(Long staffId){
+    public StaffManageVo queryById(Long staffId) {
         return baseMapper.selectVoById(staffId);
     }
 
+    /**
+     * 获取员工管理详细信息
+     *
+     * @param userId 用户id
+     * @return
+     */
+    @Override
+    public StaffManageVo getInfoByUserId(Long userId) {
+        return baseMapper.selectVoOne(new LambdaQueryWrapper<StaffManage>().eq(StaffManage::getUserId, userId));
+    }
+
     /**
      * 分页查询员工管理列表
      *
@@ -117,6 +137,66 @@ public class StaffManageServiceImpl implements IStaffManageService {
         return flag;
     }
 
+    /**
+     * 管理员新增员工信息默认认证
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean insertAuthenticationByBo(StaffManageBo bo) {
+        StaffManage staffManage = MapstructUtils.convert(bo, StaffManage.class);
+        SysUserBo sysUser = new SysUserBo();
+        String tenantId = "";
+        //手机号、手机验证码注册
+        if (TenantHelper.isEnable()) {
+            tenantId = staffManage.getTenantId();
+        }
+        String username = staffManage.getPhoneNumber();
+        String password = BoManConfig.getPasswordDeft();
+        // 校验用户类型是否存在
+        String userType = UserType.getUserType(staffManage.getUserType()).getUserType();
+
+        sysUser.setUserName(username);
+        sysUser.setNickName(username);
+        sysUser.setPassword(BCrypt.hashpw(password));
+        sysUser.setUserType(userType);
+        sysUser.setPhonenumber(username);
+        sysUser.setIsAuthentication(Y);
+        boolean exist = TenantHelper.dynamic(tenantId, () -> {
+            return userMapper.exists(new LambdaQueryWrapper<SysUser>()
+                .eq(SysUser::getUserName, sysUser.getUserName()));
+        });
+        if (exist) {
+            throw new UserException("user.register.save.error", username);
+        }
+        boolean regFlag = userService.registerUser(sysUser, tenantId);
+        if (!regFlag) {
+            throw new UserException("user.register.error");
+        }
+        staffManage.setExamine(TWO);
+        staffManage.setUserId(sysUser.getUserId());
+        boolean flag = baseMapper.insert(staffManage) > 0;
+        if (flag) {
+            bo.setStaffId(staffManage.getStaffId());
+        }
+        //sys_user_tenant表中
+        SysUserTenant sysUserTenant = new SysUserTenant();
+        sysUserTenant.setUserId(staffManage.getUserId());
+        sysUserTenant.setTenantId(staffManage.getTenantId());
+        sysUserTenantMapper.insert(sysUserTenant);
+
+        //给该userId赋予角色
+        // 新增用户与角色管理
+        //根据权限字符去查询角色id
+        Long[] roles;
+        SysRoleVo sysRoleVo = sysRoleMapper.selectVoOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleKey, staffManage.getStaffCategory()));
+        if (sysRoleVo != null) {
+            roles = new Long[]{sysRoleVo.getRoleId()};
+            sysUser.setRoleIds(roles);
+        }
+        userService.insertUserRole(sysUser, false);
+        return flag;
+    }
+
     /**
      * 修改员工管理
      *
@@ -130,10 +210,54 @@ public class StaffManageServiceImpl implements IStaffManageService {
         return baseMapper.updateById(update) > 0;
     }
 
+    /**
+     * 管理员修改员工管理
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public Boolean editAuthentication(StaffManageBo bo) {
+        StaffManage examineStaffManage = MapstructUtils.convert(bo, StaffManage.class);
+        StaffManageVo staffManageVo = baseMapper.selectVoById(bo.getStaffId());
+        //原始的tenantId
+        String tenantIdOld = staffManageVo.getTenantId();
+        Long userId = examineStaffManage.getUserId();
+        SysUserBo sysUser = new SysUserBo();
+        if (TenantHelper.isEnable()) {
+            //把租户id更新到sys_user表/sys_user_tenant表中
+            String tenantIdNew = examineStaffManage.getTenantId();
+            sysUser.setTenantId(tenantIdNew);
+            //如过两个租户id不一致,更新sys_user_tenant表
+            if (!tenantIdOld.equals(tenantIdNew)) {
+                SysUserTenant sysUserTenant = new SysUserTenant();
+                sysUserTenant.setUserId(userId);
+                sysUserTenant.setTenantId(examineStaffManage.getTenantId());
+                sysUserTenantMapper.update(new LambdaUpdateWrapper<SysUserTenant>()
+                    .set(SysUserTenant::getTenantId, tenantIdNew)
+                    .eq(SysUserTenant::getUserId, userId).eq(SysUserTenant::getTenantId, tenantIdOld));
+
+                //组装sysUser
+                //给该userId赋予角色
+                // 新增用户与角色管理
+                sysUser.setUserId(bo.getUserId());
+                //根据权限字符去查询角色id
+                Long[] roles;
+                SysRoleVo sysRoleVo = sysRoleMapper.selectVoOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleKey, examineStaffManage.getStaffCategory()));
+                if (sysRoleVo != null) {
+                    roles = new Long[]{sysRoleVo.getRoleId()};
+                    sysUser.setRoleIds(roles);
+                }
+                userService.insertUserRole(sysUser, true);
+            }
+        }
+        sysUser.setUserId(examineStaffManage.getUserId());
+        sysUser.setPhonenumber(examineStaffManage.getPhoneNumber());
+        return userService.updateUserById(sysUser) > 0;
+    }
+
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(StaffManage entity){
+    private void validEntityBeforeSave(StaffManage entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -146,7 +270,7 @@ public class StaffManageServiceImpl implements IStaffManageService {
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteByIds(ids) > 0;
@@ -166,11 +290,12 @@ public class StaffManageServiceImpl implements IStaffManageService {
         //判断是否审核通过
         if (TWO.equals(examineStaffManage.getExamine())) {
             SysUserBo sysUser = new SysUserBo();
+            sysUser.setUserId(bo.getUserId());
             if (TenantHelper.isEnable()) {
                 //把租户id更新到sys_user表/sys_user_tenant表中
                 sysUser.setTenantId(examineStaffManage.getTenantId());
                 sysUser.setIsAuthentication(Y);
-                sysUserService.updateUserById(sysUser);
+                userService.updateUserById(sysUser);
                 SysUserTenant sysUserTenant = new SysUserTenant();
                 sysUserTenant.setUserId(examineStaffManage.getUserId());
                 sysUserTenant.setTenantId(examineStaffManage.getTenantId());
@@ -179,7 +304,6 @@ public class StaffManageServiceImpl implements IStaffManageService {
             //组装sysUser
             //给该userId赋予角色
             // 新增用户与角色管理
-            sysUser.setUserId(bo.getUserId());
             //根据权限字符去查询角色id
             Long[] roles;
             SysRoleVo sysRoleVo = sysRoleMapper.selectVoOne(new LambdaQueryWrapper<SysRole>().eq(SysRole::getRoleKey, examineStaffManage.getStaffCategory()));
@@ -187,7 +311,7 @@ public class StaffManageServiceImpl implements IStaffManageService {
                 roles = new Long[]{sysRoleVo.getRoleId()};
                 sysUser.setRoleIds(roles);
             }
-            sysUserService.insertUserRole(sysUser, false);
+            userService.insertUserRole(sysUser, false);
         } else {
             return baseMapper.updateById(examineStaffManage) > 0;
         }