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