Compare commits
2 Commits
51cdf4b1b6
...
e0cecc194b
Author | SHA1 | Date |
---|---|---|
|
e0cecc194b | |
|
4634fddfc4 |
|
@ -20,4 +20,5 @@ public class ServiceNameConstants {
|
|||
* 文件服务的serviceid
|
||||
*/
|
||||
public static final String FILE_SERVICE = "ruoyi-file";
|
||||
|
||||
}
|
||||
|
|
|
@ -141,6 +141,7 @@ public class SysUser extends BaseEntity {
|
|||
*/
|
||||
private Long roleId;
|
||||
|
||||
|
||||
public SysUser (Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
package com.muyu.common.system.domain.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class AuthUserRequest {
|
||||
private Long roleId;
|
||||
private Long[] userIds;
|
||||
|
||||
}
|
|
@ -4,6 +4,7 @@ import com.muyu.common.core.constant.SecurityConstants;
|
|||
import com.muyu.common.core.constant.ServiceNameConstants;
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.vo.AuthUserRequest;
|
||||
import com.muyu.common.system.remote.factory.RemoteUserFallbackFactory;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
|
@ -37,4 +38,10 @@ public interface RemoteUserService {
|
|||
*/
|
||||
@PostMapping("/user/register")
|
||||
public Result<Boolean> registerUserInfo (@RequestBody SysUser sysUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);
|
||||
|
||||
@PostMapping("/user/add")
|
||||
public Result add (@RequestBody SysUser user);
|
||||
|
||||
@PutMapping("/role/authUser/selectAllAdd")
|
||||
public Result selectAuthUserAllAdd (@RequestBody AuthUserRequest authUserRequest);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.muyu.common.system.remote.factory;
|
||||
|
||||
import com.muyu.common.core.domain.Result;
|
||||
import com.muyu.common.system.domain.vo.AuthUserRequest;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.LoginUser;
|
||||
|
@ -31,6 +32,16 @@ public class RemoteUserFallbackFactory implements FallbackFactory<RemoteUserServ
|
|||
public Result<Boolean> registerUserInfo (SysUser sysUser, String source) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result add(SysUser user) {
|
||||
return Result.error("注册用户失败:" + throwable.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result selectAuthUserAllAdd(AuthUserRequest authUserRequest) {
|
||||
return Result.error("用户授权失败失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-company</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>muyu-company-remove</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>17</maven.compiler.source>
|
||||
<maven.compiler.target>17</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
|
@ -103,6 +103,15 @@
|
|||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-common-system</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.muyu</groupId>
|
||||
<artifactId>muyu-modules-system</artifactId>
|
||||
<version>3.6.3</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -6,6 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.muyu.authentication.mapper.EnterpriseMapper;
|
||||
import com.muyu.common.core.utils.DateUtils;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.system.mapper.SysUserMapper;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.muyu.domain.Enterprise;
|
||||
|
@ -18,6 +22,7 @@ import com.muyu.authentication.service.IEnterpriseService;
|
|||
* @date 2024-05-31
|
||||
*/
|
||||
@Service
|
||||
@Log4j2
|
||||
public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper,Enterprise> implements IEnterpriseService
|
||||
{
|
||||
@Autowired
|
||||
|
@ -51,6 +56,8 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper,Enterpri
|
|||
return enterpriseMapper.selectEnterpriseList(enterprise);
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
/**
|
||||
* 新增企业
|
||||
*
|
||||
|
@ -61,7 +68,22 @@ public class EnterpriseServiceImpl extends ServiceImpl<EnterpriseMapper,Enterpri
|
|||
public int insertEnterprise(Enterprise enterprise)
|
||||
{
|
||||
enterprise.setCreateTime(DateUtils.getNowDate());
|
||||
return enterpriseMapper.insert(enterprise);
|
||||
int insert = enterpriseMapper.insert(enterprise);
|
||||
if (insert>0) {
|
||||
SysUser build = SysUser.builder()
|
||||
.userName(enterprise.getEnterpriseName())
|
||||
.nickName(enterprise.getLegalPerson())
|
||||
.email(enterprise.getEmail())
|
||||
.phonenumber(enterprise.getContactPhone())
|
||||
.password(enterprise.getContactPhone().substring(enterprise.getContactPhone().length()-6))
|
||||
.companyId(enterprise.getId())
|
||||
.status("0")
|
||||
.roleId(9L)
|
||||
.build();
|
||||
log.info(build.getPassword());
|
||||
remoteUserService.add(build);
|
||||
}
|
||||
return insert;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
<packaging>pom</packaging>
|
||||
<modules>
|
||||
<module>muyu-company-common</module>
|
||||
<module>muyu-company-remove</module>
|
||||
<module>muyu-company-server</module>
|
||||
</modules>
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@ import com.muyu.common.security.utils.SecurityUtils;
|
|||
import com.muyu.common.system.domain.SysDept;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.vo.AuthUserRequest;
|
||||
import com.muyu.system.domain.SysUserRole;
|
||||
import com.muyu.system.domain.resp.DeptTreeResp;
|
||||
import com.muyu.system.service.SysDeptService;
|
||||
|
@ -199,6 +200,13 @@ public class SysRoleController extends BaseController {
|
|||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
@RequiresPermissions("system:role:edit")
|
||||
@Log(title = "角色管理", businessType = BusinessType.GRANT)
|
||||
@PutMapping("/authUser/selectAllAdd")
|
||||
public Result selectAuthUserAllAdd (@RequestBody AuthUserRequest authUserRequest) {
|
||||
roleService.checkRoleDataScope(authUserRequest.getRoleId());
|
||||
return toAjax(roleService.insertAuthUsers(authUserRequest.getRoleId(), authUserRequest.getUserIds()));
|
||||
}
|
||||
/**
|
||||
* 获取对应角色部门树列表
|
||||
*/
|
||||
|
|
|
@ -180,7 +180,7 @@ public class SysUserController extends BaseController {
|
|||
*/
|
||||
@RequiresPermissions("system:user:add")
|
||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
@PostMapping("/add")
|
||||
public Result add (@Validated @RequestBody SysUser user) {
|
||||
if (!userService.checkUserNameUnique(user)) {
|
||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||
|
|
|
@ -10,6 +10,8 @@ import com.muyu.common.datascope.annotation.DataScope;
|
|||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.common.system.domain.SysRole;
|
||||
import com.muyu.common.system.domain.SysUser;
|
||||
import com.muyu.common.system.domain.vo.AuthUserRequest;
|
||||
import com.muyu.common.system.remote.RemoteUserService;
|
||||
import com.muyu.system.domain.SysPost;
|
||||
import com.muyu.system.domain.SysUserPost;
|
||||
import com.muyu.system.domain.SysUserRole;
|
||||
|
@ -226,6 +228,8 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private RemoteUserService remoteUserService;
|
||||
/**
|
||||
* 新增保存用户信息
|
||||
*
|
||||
|
@ -236,8 +240,22 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertUser (SysUser user) {
|
||||
|
||||
// 新增用户信息
|
||||
int rows = userMapper.insertUser(user);
|
||||
List<Long> arrayList = new ArrayList<>();
|
||||
arrayList.add(user.getUserId());
|
||||
|
||||
// 将 ArrayList 转换为 long[] 数组
|
||||
Long[] userIdArray = arrayList.stream().toArray(Long[]::new);
|
||||
|
||||
|
||||
remoteUserService.selectAuthUserAllAdd(
|
||||
AuthUserRequest.builder()
|
||||
.userIds(userIdArray)
|
||||
.roleId(user.getRoleId())
|
||||
.build()
|
||||
);
|
||||
// 新增用户岗位关联
|
||||
insertUserPost(user);
|
||||
// 新增用户与角色管理
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
<result property="status" column="status"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="loginIp" column="login_ip"/>
|
||||
<result property="companyId" column="company_id"/>
|
||||
<result property="loginDate" column="login_date"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
|
@ -198,6 +199,7 @@
|
|||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="createBy != null and createBy != ''">create_by,</if>
|
||||
<if test="remark != null and remark != ''">remark,</if>
|
||||
<if test="companyId != null and companyId != ''">company_id,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
|
@ -212,6 +214,7 @@
|
|||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="createBy != null and createBy != ''">#{createBy},</if>
|
||||
<if test="remark != null and remark != ''">#{remark},</if>
|
||||
<if test="companyId != null and companyId != ''">#{companyId},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
|
Loading…
Reference in New Issue