修改租户创建运营商创建账号逻辑
This commit is contained in:
parent
1355e2a0f2
commit
f4b015b0b0
@ -50,6 +50,8 @@ public class SysRole extends BaseEntity
|
||||
/** 删除标志(0代表存在 2代表删除) */
|
||||
private String delFlag;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
/** 用户是否存在此角色标识 默认不存在 */
|
||||
private boolean flag = false;
|
||||
|
||||
@ -201,6 +203,16 @@ public class SysRole extends BaseEntity
|
||||
this.deptIds = deptIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("roleId", getRoleId())
|
||||
@ -217,6 +229,7 @@ public class SysRole extends BaseEntity
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.append("remark", getRemark())
|
||||
.append("tenantId", getTenantId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,8 +9,10 @@ import com.xhpc.common.core.web.page.TableDataInfo;
|
||||
import com.xhpc.common.log.annotation.Log;
|
||||
import com.xhpc.common.log.enums.BusinessType;
|
||||
import com.xhpc.common.security.annotation.PreAuthorize;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.system.api.domain.SysRole;
|
||||
import com.xhpc.system.api.domain.SysUser;
|
||||
import com.xhpc.system.api.model.LoginUser;
|
||||
import com.xhpc.system.domain.SysUserRole;
|
||||
import com.xhpc.system.service.ISysRoleService;
|
||||
import com.xhpc.system.service.ISysUserService;
|
||||
@ -37,6 +39,10 @@ public class SysRoleController extends BaseController
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
|
||||
@PreAuthorize(hasPermi = "system:role:list")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(SysRole role)
|
||||
@ -201,4 +207,19 @@ public class SysRoleController extends BaseController
|
||||
{
|
||||
return toAjax(roleService.insertAuthUsers(roleId, userIds));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取角色列表
|
||||
*/
|
||||
@GetMapping("/authUser/getRoleList")
|
||||
public AjaxResult getRoleList()
|
||||
{
|
||||
LoginUser loginUser = tokenService.getLoginUser();
|
||||
SysRole role = new SysRole();
|
||||
role.setTenantId(loginUser.getTenantId());
|
||||
List<SysRole> sysRoles = roleService.selectRoleList(role);
|
||||
return AjaxResult.success(sysRoles);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -19,6 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
<result property="remark" column="remark" />
|
||||
<result property="tenantId" column="tenant_id" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectRoleVo">
|
||||
@ -32,6 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
r.status,
|
||||
r.del_flag,
|
||||
r.create_time,
|
||||
r.tenant_id,
|
||||
r.remark
|
||||
from sys_role r
|
||||
left join sys_user_role ur on ur.role_id = r.role_id
|
||||
@ -48,6 +50,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
<if test="status != null and status != ''">
|
||||
AND r.status = #{status}
|
||||
</if>
|
||||
<if test="tenantId != null and tenantId != ''">
|
||||
AND r.tenant_id = #{tenantId}
|
||||
</if>
|
||||
<if test="roleKey != null and roleKey != ''">
|
||||
AND r.role_key like concat('%', #{roleKey}, '%')
|
||||
</if>
|
||||
|
||||
@ -10,7 +10,9 @@ import com.xhpc.common.core.web.page.TableDataInfo;
|
||||
import com.xhpc.common.log.annotation.Log;
|
||||
import com.xhpc.common.log.enums.BusinessType;
|
||||
import com.xhpc.common.security.annotation.PreAuthorize;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.system.api.domain.SysUser;
|
||||
import com.xhpc.system.api.model.LoginUser;
|
||||
import com.xhpc.user.domain.XhpcOperator;
|
||||
import com.xhpc.user.service.IXhpcOperatorService;
|
||||
import com.xhpc.user.service.IXhpcUserService;
|
||||
@ -38,6 +40,8 @@ public class XhpcOperatorController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IXhpcUserService iXhpcUserService;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 新增运营商
|
||||
@ -47,6 +51,9 @@ public class XhpcOperatorController extends BaseController {
|
||||
@RequiresRoles("admin")
|
||||
@PostMapping("/add")
|
||||
public AjaxResult add(@Valid @RequestBody XhpcOperator xhpcOperator) {
|
||||
|
||||
LoginUser loginUser = tokenService.getLoginUser();
|
||||
xhpcOperator.setTenantId(loginUser.getTenantId());
|
||||
SysUser sysUser = new SysUser();
|
||||
BigDecimal t3 =new BigDecimal(100);
|
||||
BigDecimal t4 =new BigDecimal(0);
|
||||
@ -76,20 +83,24 @@ public class XhpcOperatorController extends BaseController {
|
||||
return AjaxResult.error("充电终止的soc不能小于80");
|
||||
}
|
||||
}
|
||||
if(xhpcOperator.getRoleId()==null){
|
||||
return AjaxResult.error("请选择角色");
|
||||
}
|
||||
|
||||
sysUser.setUserName(xhpcOperator.getPhone());
|
||||
sysUser.setNickName(xhpcOperator.getName());
|
||||
sysUser.setEmail(xhpcOperator.getEmail());
|
||||
sysUser.setPhonenumber(xhpcOperator.getPhone());
|
||||
sysUser.setDeptId(103L);
|
||||
sysUser.setDeptId(loginUser.getSysUser().getDeptId());
|
||||
sysUser.setSex("0");
|
||||
sysUser.setUserType(StatusConstants.OPERATION_USER_TYPE);
|
||||
sysUser.setDataPowerType(1);
|
||||
sysUser.setCreateBy(SecurityUtils.getUsername());
|
||||
sysUser.setAvatar("https://xhpc-bucket1.oss-cn-hangzhou.aliyuncs.com/avatar/logo.png");
|
||||
sysUser.setPassword("123456");
|
||||
sysUser.setTenantId(xhpcOperator.getTenantId());
|
||||
Long[] roleIds = new Long[1];
|
||||
roleIds[0] = 3L;
|
||||
roleIds[0] = xhpcOperator.getRoleId();
|
||||
sysUser.setRoleIds(roleIds);
|
||||
if (iXhpcUserService.checkUserNameUnique(sysUser.getUserName(),null) > 0) {
|
||||
return AjaxResult.error("新增用户'" + sysUser.getUserName() + "'失败,登录账号已存在");
|
||||
|
||||
@ -19,6 +19,8 @@ public class SysUserRole {
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
private String tenantId;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
@ -35,11 +37,20 @@ public class SysUserRole {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
|
||||
public String getTenantId() {
|
||||
return tenantId;
|
||||
}
|
||||
|
||||
public void setTenantId(String tenantId) {
|
||||
this.tenantId = tenantId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("userId", getUserId())
|
||||
.append("roleId", getRoleId())
|
||||
.append("tenantId", getTenantId())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -165,6 +165,12 @@ public class XhpcOperator extends BaseEntity {
|
||||
*/
|
||||
private String operatorIdEvcs;
|
||||
|
||||
/**
|
||||
* 角色id
|
||||
*/
|
||||
private Long roleId;
|
||||
|
||||
|
||||
public String getOperatorIdEvcs() {
|
||||
|
||||
return operatorIdEvcs;
|
||||
@ -358,4 +364,12 @@ public class XhpcOperator extends BaseEntity {
|
||||
public void setDetailedAddress(String detailedAddress) {
|
||||
this.detailedAddress = detailedAddress;
|
||||
}
|
||||
|
||||
public Long getRoleId() {
|
||||
return roleId;
|
||||
}
|
||||
|
||||
public void setRoleId(Long roleId) {
|
||||
this.roleId = roleId;
|
||||
}
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ public interface XhpcOperatorMapper {
|
||||
* @param contactPhone 联系人电话
|
||||
* @return 结果
|
||||
*/
|
||||
public List<Map<String, Object>> selectOperatorList(@Param("name") String name, @Param("contactName") String contactName, @Param("contactPhone") String contactPhone, @Param("createTimeStart") String createTimeStart, @Param("createTimeEnd") String createTimeEnd);
|
||||
public List<Map<String, Object>> selectOperatorList(@Param("name") String name, @Param("contactName") String contactName, @Param("contactPhone") String contactPhone, @Param("createTimeStart") String createTimeStart, @Param("createTimeEnd") String createTimeEnd,@Param("tenantId")String tenantId);
|
||||
|
||||
/**
|
||||
* 通过用户ID删除用户和角色关联
|
||||
|
||||
@ -2,7 +2,9 @@ package com.xhpc.user.service.impl;
|
||||
|
||||
import com.xhpc.common.core.constant.UserConstants;
|
||||
import com.xhpc.common.core.utils.StringUtils;
|
||||
import com.xhpc.common.security.service.TokenService;
|
||||
import com.xhpc.system.api.domain.SysUser;
|
||||
import com.xhpc.system.api.model.LoginUser;
|
||||
import com.xhpc.user.domain.XhpcOperator;
|
||||
import com.xhpc.user.mapper.XhpcOperatorMapper;
|
||||
import com.xhpc.user.mapper.XhpcUserMapper;
|
||||
@ -27,6 +29,8 @@ public class XhpcOperatorServiceImpl implements IXhpcOperatorService {
|
||||
|
||||
@Autowired
|
||||
private XhpcUserMapper xhpcUserMapper;
|
||||
@Autowired
|
||||
private TokenService tokenService;
|
||||
|
||||
/**
|
||||
* 新增任务
|
||||
@ -106,7 +110,8 @@ public class XhpcOperatorServiceImpl implements IXhpcOperatorService {
|
||||
*/
|
||||
@Override
|
||||
public List<Map<String, Object>> selectOperatorList(String name, String contactName, String contactPhone, String createTimeStart, String createTimeEnd) {
|
||||
return xhpcOperatorMapper.selectOperatorList(name, contactName, contactPhone, createTimeStart, createTimeEnd);
|
||||
LoginUser loginUser = tokenService.getLoginUser();
|
||||
return xhpcOperatorMapper.selectOperatorList(name, contactName, contactPhone, createTimeStart, createTimeEnd,loginUser.getTenantId());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -186,6 +186,7 @@ public class XhpcUserServiceImpl extends BaseService implements IXhpcUserService
|
||||
SysUserRole ur = new SysUserRole();
|
||||
ur.setUserId(user.getUserId());
|
||||
ur.setRoleId(roleId);
|
||||
ur.setTenantId(user.getTenantId());
|
||||
list.add(ur);
|
||||
}
|
||||
if (list.size() > 0) {
|
||||
|
||||
@ -134,7 +134,10 @@
|
||||
remark,
|
||||
</if>
|
||||
<if test="null != operatorIdEvcs and '' != operatorIdEvcs">
|
||||
operator_id_evcs
|
||||
operator_id_evcs,
|
||||
</if>
|
||||
<if test="null != tenantId and '' != tenantId">
|
||||
tenant_id,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
@ -220,7 +223,10 @@
|
||||
#{remark},
|
||||
</if>
|
||||
<if test="null != operatorIdEvcs and '' != operatorIdEvcs">
|
||||
#{operatorIdEvcs}
|
||||
#{operatorIdEvcs},
|
||||
</if>
|
||||
<if test="null != tenantId and '' != tenantId">
|
||||
#{tenantId},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
@ -313,6 +319,9 @@
|
||||
<if test="createTimeEnd != null and createTimeEnd != ''"><!-- 结束时间检索 -->
|
||||
AND xo.create_time <= #{createTimeEnd}
|
||||
</if>
|
||||
<if test="tenantId != null and tenantId != ''"><!-- 结束时间检索 -->
|
||||
AND xo.tenant_id= #{tenantId}
|
||||
</if>
|
||||
group by xo.operator_id
|
||||
ORDER BY xo.update_time DESC
|
||||
</select>
|
||||
|
||||
@ -251,6 +251,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="tenantId != null and tenantId != ''">tenant_id,</if>
|
||||
create_time
|
||||
)values(
|
||||
<if test="userId != null and userId != ''">#{userId},</if>
|
||||
@ -269,14 +270,15 @@
|
||||
<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="tenantId != null and tenantId != ''">#{tenantId},</if>
|
||||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<insert id="batchUserRole">
|
||||
insert into sys_user_role(user_id, role_id) values
|
||||
insert into sys_user_role(user_id, role_id,tenant_id) values
|
||||
<foreach item="item" index="index" collection="list" separator=",">
|
||||
(#{item.userId},#{item.roleId})
|
||||
(#{item.userId},#{item.roleId},#{item.tenantId})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user