系统用户改造
parent
9490d7aa7c
commit
e892f77673
|
@ -0,0 +1,78 @@
|
||||||
|
package com.yanzhu.system.domain;
|
||||||
|
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import Excel;
|
||||||
|
import BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户扩展对象 sys_user_ext
|
||||||
|
*
|
||||||
|
* @author yanzhu
|
||||||
|
* @date 2025-01-09
|
||||||
|
*/
|
||||||
|
public class SysUserExt extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 用户ID */
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/** 项目ID */
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/** 状态 */
|
||||||
|
@Excel(name = "状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
/** 用户类型(00系统用户) */
|
||||||
|
@Excel(name = "用户类型", readConverterExp = "0=0系统用户")
|
||||||
|
private String userType;
|
||||||
|
|
||||||
|
public void setUserId(Long userId)
|
||||||
|
{
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getUserId()
|
||||||
|
{
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
public void setProjectId(Long projectId)
|
||||||
|
{
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProjectId()
|
||||||
|
{
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
public void setStatus(String status)
|
||||||
|
{
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus()
|
||||||
|
{
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
public void setUserType(String userType)
|
||||||
|
{
|
||||||
|
this.userType = userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserType()
|
||||||
|
{
|
||||||
|
return userType;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("userId", getUserId())
|
||||||
|
.append("projectId", getProjectId())
|
||||||
|
.append("status", getStatus())
|
||||||
|
.append("userType", getUserType())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,6 +16,16 @@ public class SysUserPost
|
||||||
/** 岗位ID */
|
/** 岗位ID */
|
||||||
private Long postId;
|
private Long postId;
|
||||||
|
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
public Long getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectId(Long projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
|
||||||
public Long getUserId()
|
public Long getUserId()
|
||||||
{
|
{
|
||||||
return userId;
|
return userId;
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.yanzhu.system.mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.yanzhu.system.domain.SysUserExt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户扩展Mapper接口
|
||||||
|
*
|
||||||
|
* @author yanzhu
|
||||||
|
* @date 2025-01-09
|
||||||
|
*/
|
||||||
|
public interface SysUserExtMapper
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userId 系统用户扩展主键
|
||||||
|
* @return 系统用户扩展
|
||||||
|
*/
|
||||||
|
public SysUserExt selectSysUserExtByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统用户扩展列表
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 系统用户扩展集合
|
||||||
|
*/
|
||||||
|
public List<SysUserExt> selectSysUserExtList(SysUserExt sysUserExt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增系统用户扩展
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysUserExt(SysUserExt sysUserExt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改系统用户扩展
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysUserExt(SysUserExt sysUserExt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userId 系统用户扩展主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserExtByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserExtByUserIds(Long[] userIds);
|
||||||
|
}
|
|
@ -45,6 +45,7 @@ public interface SysUserMapper
|
||||||
*/
|
*/
|
||||||
public SysUser selectUserByUserName(String userName);
|
public SysUser selectUserByUserName(String userName);
|
||||||
|
|
||||||
|
public SysUser selectByPhone(String phone);
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,67 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper
|
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.yanzhu.system.mapper.SysUserExtMapper">
|
||||||
|
|
||||||
|
<resultMap type="SysUserExt" id="SysUserExtResult">
|
||||||
|
<result property="userId" column="user_id" />
|
||||||
|
<result property="projectId" column="project_id" />
|
||||||
|
<result property="status" column="status" />
|
||||||
|
<result property="userType" column="user_type" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectSysUserExtVo">
|
||||||
|
select user_id, project_id, status, user_type from sys_user_ext
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectSysUserExtList" parameterType="SysUserExt" resultMap="SysUserExtResult">
|
||||||
|
<include refid="selectSysUserExtVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="status != null and status != ''"> and status = #{status}</if>
|
||||||
|
<if test="userType != null and userType != ''"> and user_type = #{userType}</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectSysUserExtByUserId" parameterType="Long" resultMap="SysUserExtResult">
|
||||||
|
<include refid="selectSysUserExtVo"/>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertSysUserExt" parameterType="SysUserExt">
|
||||||
|
insert into sys_user_ext
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">user_id,</if>
|
||||||
|
<if test="projectId != null">project_id,</if>
|
||||||
|
<if test="status != null">status,</if>
|
||||||
|
<if test="userType != null">user_type,</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="userId != null">#{userId},</if>
|
||||||
|
<if test="projectId != null">#{projectId},</if>
|
||||||
|
<if test="status != null">#{status},</if>
|
||||||
|
<if test="userType != null">#{userType},</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateSysUserExt" parameterType="SysUserExt">
|
||||||
|
update sys_user_ext
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="projectId != null">project_id = #{projectId},</if>
|
||||||
|
<if test="status != null">status = #{status},</if>
|
||||||
|
<if test="userType != null">user_type = #{userType},</if>
|
||||||
|
</trim>
|
||||||
|
where user_id = #{userId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteSysUserExtByUserId" parameterType="Long">
|
||||||
|
delete from sys_user_ext where user_id = #{userId}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteSysUserExtByUserIds" parameterType="String">
|
||||||
|
delete from sys_user_ext where user_id in
|
||||||
|
<foreach item="userId" collection="array" open="(" separator="," close=")">
|
||||||
|
#{userId}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
</mapper>
|
|
@ -61,12 +61,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select u.user_id, uc.com_id, com.dept_name as com_name, u.dept_id, u.user_name, u.nick_name, u.user_type, u.card_code, u.email
|
select u.user_id, u.com_id, com.dept_name as com_name, u.dept_id, u.user_name, u.nick_name, u.user_type, u.card_code, u.email
|
||||||
, u.avatar, u.phonenumber, u.password, u.sex, uc.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
||||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_short_name, d.dept_code, d.dept_type, d.order_num, d.leader, d.status as dept_status,
|
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.dept_short_name, d.dept_code, d.dept_type, d.order_num, d.leader, d.status as dept_status,
|
||||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,com.dept_name com_dept_name,uc.is_active is_active
|
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status,com.dept_name com_dept_name
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_user_com uc on u.user_id=uc.user_id
|
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_dept com on u.com_id = com.dept_id
|
left join sys_dept com on u.com_id = com.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
|
@ -74,11 +73,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUserList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select u.user_id, uc.com_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, uc.status,
|
select u.user_id, u.com_id, u.dept_id, u.nick_name, u.user_name, u.email, u.avatar, u.phonenumber, u.sex, u.status,
|
||||||
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader,
|
u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark, d.dept_name, d.leader
|
||||||
uc.is_active is_active
|
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_user_com uc on u.user_id=uc.user_id
|
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
where u.del_flag = '0'
|
where u.del_flag = '0'
|
||||||
<if test="userId != null and userId != 0">
|
<if test="userId != null and userId != 0">
|
||||||
|
@ -113,9 +110,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectAllocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select distinct u.user_id, uc.com_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, uc.status, u.create_time,uc.is_active is_active
|
select distinct u.user_id, u.com_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_user_com uc on u.user_id=uc.user_id
|
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
|
@ -131,9 +127,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
<select id="selectUnallocatedList" parameterType="SysUser" resultMap="SysUserResult">
|
||||||
select distinct u.user_id, uc.com_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, uc.status, u.create_time,uc.is_active is_active
|
select distinct u.user_id, u.com_id, u.dept_id, u.user_name, u.nick_name, u.email, u.phonenumber, u.status, u.create_time
|
||||||
from sys_user u
|
from sys_user u
|
||||||
left join sys_user_com uc on u.user_id=uc.user_id
|
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
|
@ -182,6 +177,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkPhoneUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
select user_id, phonenumber from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectByPhone" parameterType="String" resultMap="SysUserResult">
|
||||||
|
select * from sys_user where phonenumber = #{phonenumber} and del_flag = '0' limit 1
|
||||||
|
</select>
|
||||||
|
|
||||||
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
<select id="checkEmailUnique" parameterType="String" resultMap="SysUserResult">
|
||||||
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
select user_id, email from sys_user where email = #{email} and del_flag = '0' limit 1
|
||||||
|
@ -230,8 +228,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
<if test="deptId != null and deptId != 0">dept_id = #{deptId},</if>
|
||||||
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
<if test="userName != null and userName != ''">user_name = #{userName},</if>
|
||||||
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
<if test="nickName != null and nickName != ''">nick_name = #{nickName},</if>
|
||||||
<if test="userType != null ">userType = #{userType},</if>
|
<if test="userType != null ">user_Type = #{userType},</if>
|
||||||
<if test="cardCode != null ">cardCode = #{cardCode},</if>
|
<if test="cardCode != null ">card_Code = #{cardCode},</if>
|
||||||
<if test="email != null ">email = #{email},</if>
|
<if test="email != null ">email = #{email},</if>
|
||||||
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
<if test="phonenumber != null ">phonenumber = #{phonenumber},</if>
|
||||||
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
<if test="sex != null and sex != ''">sex = #{sex},</if>
|
||||||
|
@ -282,17 +280,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<insert id="insertUserCom" parameterType="SysUser" >
|
<insert id="insertUserCom" parameterType="SysUser" >
|
||||||
insert into sys_user(
|
insert into sys_user_com(
|
||||||
<if test="userId != null and userId != 0">user_id,</if>
|
<if test="userId != null and userId != 0">user_id,</if>
|
||||||
<if test="comId != null and comId != 0">com_id,</if>
|
<if test="comId != null and comId != 0">com_id,</if>
|
||||||
<if test="status != null and status != 0">status,</if>
|
<if test="status != null and status!=''">status,</if>
|
||||||
<if test="isActive != null and isActive != 0">is_active,</if>
|
is_active
|
||||||
|
|
||||||
)values(
|
)values(
|
||||||
<if test="userId != null and userId != 0">#{userId},</if>
|
<if test="userId != null and userId != 0">#{userId},</if>
|
||||||
<if test="comId != null and comId != 0">#{comId},</if>
|
<if test="comId != null and comId != 0">#{comId},</if>
|
||||||
<if test="status != null and status != 0">#{status},</if>
|
<if test="status != null and status!=''">#{status},</if>
|
||||||
<if test="isActive != null and isActive != ''">#{isActive},</if>
|
#{isActive}
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
<delete id="deleteUserCom" parameterType="SysUser">
|
<delete id="deleteUserCom" parameterType="SysUser">
|
||||||
|
|
|
@ -159,6 +159,17 @@ public class SysUserController extends BaseController {
|
||||||
return R.ok(sysUserVo);
|
return R.ok(sysUserVo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按电话号码查询用户信息
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequiresPermissions("system:user:list")
|
||||||
|
@GetMapping("/selectByPhone/{phone}")
|
||||||
|
public R<SysUser> selectByPhone(@PathVariable("phone") String phone) {
|
||||||
|
SysUser sysUser = userService.selectByPhone(phone);
|
||||||
|
return R.ok(sysUser);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 获取当前用户信息
|
* 获取当前用户信息
|
||||||
*/
|
*/
|
||||||
|
@ -286,13 +297,14 @@ public class SysUserController extends BaseController {
|
||||||
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
@Log(title = "用户管理", businessType = BusinessType.INSERT)
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
public AjaxResult add(@Validated @RequestBody SysUser user) {
|
||||||
|
/*
|
||||||
if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkUserNameUnique(user)) {
|
if (StringUtils.isNotEmpty(user.getUserName()) && !userService.checkUserNameUnique(user)) {
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
|
||||||
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
} else if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
|
||||||
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
||||||
}
|
}*/
|
||||||
user.setCreateBy(SecurityUtils.getUsername());
|
user.setCreateBy(SecurityUtils.getUsername());
|
||||||
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
||||||
return toAjax(userService.insertUser(user));
|
return toAjax(userService.insertUser(user));
|
||||||
|
|
|
@ -0,0 +1,61 @@
|
||||||
|
package com.yanzhu.system.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.yanzhu.system.domain.SysUserExt;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户扩展Service接口
|
||||||
|
*
|
||||||
|
* @author yanzhu
|
||||||
|
* @date 2025-01-09
|
||||||
|
*/
|
||||||
|
public interface ISysUserExtService
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* 查询系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userId 系统用户扩展主键
|
||||||
|
* @return 系统用户扩展
|
||||||
|
*/
|
||||||
|
public SysUserExt selectSysUserExtByUserId(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统用户扩展列表
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 系统用户扩展集合
|
||||||
|
*/
|
||||||
|
public List<SysUserExt> selectSysUserExtList(SysUserExt sysUserExt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增系统用户扩展
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int insertSysUserExt(SysUserExt sysUserExt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改系统用户扩展
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int updateSysUserExt(SysUserExt sysUserExt);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的系统用户扩展主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserExtByUserIds(Long[] userIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除系统用户扩展信息
|
||||||
|
*
|
||||||
|
* @param userId 系统用户扩展主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
public int deleteSysUserExtByUserId(Long userId);
|
||||||
|
}
|
|
@ -45,6 +45,12 @@ public interface ISysUserService
|
||||||
*/
|
*/
|
||||||
public SysUser selectUserByUserName(String userName);
|
public SysUser selectUserByUserName(String userName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过电话号码查询用户信息
|
||||||
|
* @param phone
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public SysUser selectByPhone(String phone);
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
|
|
|
@ -0,0 +1,93 @@
|
||||||
|
package com.yanzhu.system.service.impl;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.yanzhu.system.mapper.SysUserExtMapper;
|
||||||
|
import com.yanzhu.system.domain.SysUserExt;
|
||||||
|
import com.yanzhu.system.service.ISysUserExtService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 系统用户扩展Service业务层处理
|
||||||
|
*
|
||||||
|
* @author yanzhu
|
||||||
|
* @date 2025-01-09
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class SysUserExtServiceImpl implements ISysUserExtService
|
||||||
|
{
|
||||||
|
@Autowired
|
||||||
|
private SysUserExtMapper sysUserExtMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userId 系统用户扩展主键
|
||||||
|
* @return 系统用户扩展
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public SysUserExt selectSysUserExtByUserId(Long userId)
|
||||||
|
{
|
||||||
|
return sysUserExtMapper.selectSysUserExtByUserId(userId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询系统用户扩展列表
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 系统用户扩展
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<SysUserExt> selectSysUserExtList(SysUserExt sysUserExt)
|
||||||
|
{
|
||||||
|
return sysUserExtMapper.selectSysUserExtList(sysUserExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增系统用户扩展
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertSysUserExt(SysUserExt sysUserExt)
|
||||||
|
{
|
||||||
|
return sysUserExtMapper.insertSysUserExt(sysUserExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改系统用户扩展
|
||||||
|
*
|
||||||
|
* @param sysUserExt 系统用户扩展
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int updateSysUserExt(SysUserExt sysUserExt)
|
||||||
|
{
|
||||||
|
return sysUserExtMapper.updateSysUserExt(sysUserExt);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除系统用户扩展
|
||||||
|
*
|
||||||
|
* @param userIds 需要删除的系统用户扩展主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysUserExtByUserIds(Long[] userIds)
|
||||||
|
{
|
||||||
|
return sysUserExtMapper.deleteSysUserExtByUserIds(userIds);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除系统用户扩展信息
|
||||||
|
*
|
||||||
|
* @param userId 系统用户扩展主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteSysUserExtByUserId(Long userId)
|
||||||
|
{
|
||||||
|
return sysUserExtMapper.deleteSysUserExtByUserId(userId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -131,6 +131,11 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
return userMapper.selectUserByUserName(userName);
|
return userMapper.selectUserByUserName(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SysUser selectByPhone(String phone) {
|
||||||
|
return userMapper.selectByPhone(phone);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过用户名查询用户
|
* 通过用户名查询用户
|
||||||
*
|
*
|
||||||
|
@ -317,7 +322,36 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
throw new ServiceException("所属单位选择异常,必须选择子公司及下属单位");
|
throw new ServiceException("所属单位选择异常,必须选择子公司及下属单位");
|
||||||
}
|
}
|
||||||
user.setComId(dept.getComId());
|
user.setComId(dept.getComId());
|
||||||
int rows = userMapper.insertUser(user);
|
int rows=0;
|
||||||
|
SysUser sysUser = userMapper.selectByPhone(user.getPhonenumber());
|
||||||
|
if(Objects.nonNull(sysUser)){//此电话号码已注册
|
||||||
|
SysUser where=new SysUser();
|
||||||
|
where.setUserId(sysUser.getUserId());
|
||||||
|
where.setComId(user.getComId());
|
||||||
|
SysUser oldUserCom=userMapper.selectUserCom(where);
|
||||||
|
if(Objects.nonNull(oldUserCom)){
|
||||||
|
throw new ServiceException("此用户己在此项目中!");
|
||||||
|
}
|
||||||
|
user.setUserId(sysUser.getUserId());
|
||||||
|
user.setIsActive(0l);
|
||||||
|
user.setStatus("0");
|
||||||
|
userMapper.insertUserCom(user);
|
||||||
|
sysUser.setUserName(user.getUserName());
|
||||||
|
sysUser.setPhonenumber(user.getUserName());
|
||||||
|
sysUser.setNickName(user.getNickName());
|
||||||
|
sysUser.setUpdateBy(user.getUpdateBy());
|
||||||
|
sysUser.setUpdateTime(user.getUpdateTime());
|
||||||
|
sysUser.setPassword(user.getPassword());
|
||||||
|
rows=userMapper.updateUser(sysUser);
|
||||||
|
}else{//此电话号码未注册
|
||||||
|
user.setCreateBy(user.getUpdateBy());
|
||||||
|
user.setCreateTime(user.getUpdateTime());
|
||||||
|
user.setUserType("99");
|
||||||
|
rows=userMapper.insertUser(user);
|
||||||
|
user.setIsActive(1l);
|
||||||
|
userMapper.insertUserCom(user);
|
||||||
|
}
|
||||||
|
//int rows = userMapper.insertUser(user);
|
||||||
// 新增用户岗位关联
|
// 新增用户岗位关联
|
||||||
insertUserPost(user);
|
insertUserPost(user);
|
||||||
// 新增用户与角色管理
|
// 新增用户与角色管理
|
||||||
|
@ -370,7 +404,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
@Override
|
@Override
|
||||||
public Long registerUser(SysUser user) throws ServiceException
|
public Long registerUser(SysUser user) throws ServiceException
|
||||||
{
|
{
|
||||||
SysUser sysUser = userMapper.checkUserNameUnique(user.getUserName());
|
SysUser sysUser = userMapper.selectByPhone(user.getPhonenumber());
|
||||||
if(Objects.nonNull(sysUser)){
|
if(Objects.nonNull(sysUser)){
|
||||||
if(user.getComId().equals(sysUser.getOldComId())){
|
if(user.getComId().equals(sysUser.getOldComId())){
|
||||||
SysUser where=new SysUser();
|
SysUser where=new SysUser();
|
||||||
|
@ -701,6 +735,7 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
SysUserPost up = new SysUserPost();
|
SysUserPost up = new SysUserPost();
|
||||||
up.setUserId(user.getUserId());
|
up.setUserId(user.getUserId());
|
||||||
up.setPostId(postId);
|
up.setPostId(postId);
|
||||||
|
|
||||||
list.add(up);
|
list.add(up);
|
||||||
}
|
}
|
||||||
userPostMapper.batchUserPost(list);
|
userPostMapper.batchUserPost(list);
|
||||||
|
|
|
@ -18,6 +18,15 @@ export function getUser(userId) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 按手机号码查询用户
|
||||||
|
export function selectByPhone(phone) {
|
||||||
|
return request({
|
||||||
|
url: '/system/user/selectByPhone/' + phone,
|
||||||
|
method: 'get'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 新增用户
|
// 新增用户
|
||||||
export function addUser(data) {
|
export function addUser(data) {
|
||||||
return request({
|
return request({
|
||||||
|
|
|
@ -144,7 +144,8 @@
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="手机号码" prop="phonenumber">
|
<el-form-item label="手机号码" prop="phonenumber">
|
||||||
<el-input v-model="form.phonenumber" :disabled="form.userId" placeholder="请输入手机号码"
|
<el-input v-model="form.phonenumber" :disabled="form.userId" placeholder="请输入手机号码"
|
||||||
maxlength="11" />
|
maxlength="11" style="width: 150px;"/>
|
||||||
|
<el-button type="primary" style="margin-left: 10px;" @click="doQueryUser">查询</el-button>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
|
@ -236,7 +237,7 @@
|
||||||
<script setup name="User">
|
<script setup name="User">
|
||||||
import { getToken } from "@/utils/auth";
|
import { getToken } from "@/utils/auth";
|
||||||
import { getDeptRole } from "@/api/system/role";
|
import { getDeptRole } from "@/api/system/role";
|
||||||
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser, deptTreeSelect } from "@/api/system/user";
|
import { changeUserStatus, listUser, resetUserPwd, delUser, getUser, updateUser, addUser,selectByPhone, deptTreeSelect } from "@/api/system/user";
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { proxy } = getCurrentInstance();
|
const { proxy } = getCurrentInstance();
|
||||||
|
@ -331,6 +332,12 @@ function getDeptTree() {
|
||||||
defaultEK.value.push(response.data[0].id);
|
defaultEK.value.push(response.data[0].id);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
//用于用户增加的查询
|
||||||
|
function doQueryUser(){
|
||||||
|
selectByPhone(form.value.phonenumber).then(d=>{{
|
||||||
|
debugger
|
||||||
|
}});
|
||||||
|
}
|
||||||
function doRoleChange(){
|
function doRoleChange(){
|
||||||
if(form.value.userType==99){
|
if(form.value.userType==99){
|
||||||
data.rules={
|
data.rules={
|
||||||
|
@ -509,6 +516,7 @@ function handleAdd() {
|
||||||
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }],
|
password: [{ required: true, message: "用户密码不能为空", trigger: "blur" }, { min: 5, max: 20, message: "用户密码长度必须介于 5 和 20 之间", trigger: "blur" }],
|
||||||
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
|
phonenumber: [{ required: true, message: "手机号码不能为空", trigger: "blur" }, { pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, message: "请输入正确的手机号码", trigger: "blur" }]
|
||||||
}
|
}
|
||||||
|
roleOptions.value=[];
|
||||||
postOptions.value = response.posts;
|
postOptions.value = response.posts;
|
||||||
open.value = true;
|
open.value = true;
|
||||||
title.value = "添加用户";
|
title.value = "添加用户";
|
||||||
|
|
Loading…
Reference in New Issue