feat(新增): 修改用户
This commit is contained in:
parent
598e1652a6
commit
ca5926e068
|
@ -17,6 +17,6 @@ public class MessageConstant {
|
||||||
public static final String PASSWORD_EDIT_FAILED = "密码修改失败";
|
public static final String PASSWORD_EDIT_FAILED = "密码修改失败";
|
||||||
public static final String ALREADY_EXISTS = "已存在";
|
public static final String ALREADY_EXISTS = "已存在";
|
||||||
public static final String REQUEST_NOT_EMPTY = "请求不为空";
|
public static final String REQUEST_NOT_EMPTY = "请求不为空";
|
||||||
public static final String UPDATE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空";
|
||||||
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
|
@ -32,4 +32,11 @@ public class SysUserController {
|
||||||
sysUserService.saveSysUser(sysUser);
|
sysUserService.saveSysUser(sysUser);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改用户", description = "修改用户信息")
|
||||||
|
@PutMapping("updateSysUser")
|
||||||
|
public Result updateSysUser(@RequestBody SysUser sysUser) {
|
||||||
|
sysUserService.updateSysUser(sysUser);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -30,4 +30,11 @@ public interface SysUserMapper {
|
||||||
* @param sysUser 系统用户实体类
|
* @param sysUser 系统用户实体类
|
||||||
*/
|
*/
|
||||||
void save(SysUser sysUser);
|
void save(SysUser sysUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*
|
||||||
|
* @param sysUser 系统用户实体类
|
||||||
|
*/
|
||||||
|
void updateSysUser(SysUser sysUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,4 +38,11 @@ public interface SysUserService {
|
||||||
* @param sysUser 系统用户实体类
|
* @param sysUser 系统用户实体类
|
||||||
*/
|
*/
|
||||||
void saveSysUser(SysUser sysUser);
|
void saveSysUser(SysUser sysUser);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*
|
||||||
|
* @param sysUser 系统用户实体类
|
||||||
|
*/
|
||||||
|
void updateSysUser(SysUser sysUser);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atguigu.spzx.manger.service.impl;
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
import com.atguigu.constant.ExceptionConstant;
|
import com.atguigu.constant.ExceptionConstant;
|
||||||
|
import com.atguigu.constant.MessageConstant;
|
||||||
import com.atguigu.exception.BunnyException;
|
import com.atguigu.exception.BunnyException;
|
||||||
import com.atguigu.lib.MD5;
|
import com.atguigu.lib.MD5;
|
||||||
import com.atguigu.spzx.manger.mapper.SysUserMapper;
|
import com.atguigu.spzx.manger.mapper.SysUserMapper;
|
||||||
|
@ -130,4 +131,15 @@ public class SysUserServiceImpl implements SysUserService {
|
||||||
// 插入数据
|
// 插入数据
|
||||||
sysUserMapper.save(sysUser);
|
sysUserMapper.save(sysUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改用户
|
||||||
|
*
|
||||||
|
* @param sysUser 系统用户实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateSysUser(SysUser sysUser) {
|
||||||
|
stringEmptyUtil.isEmpty(sysUser.getId(), MessageConstant.UPDATE_ID_IS_NOT_EMPTY);
|
||||||
|
sysUserMapper.updateSysUser(sysUser);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,32 @@
|
||||||
values (#{id}, #{userName}, #{password}, #{name}, #{phone}, #{avatar}, #{description}, #{status});
|
values (#{id}, #{userName}, #{password}, #{name}, #{phone}, #{avatar}, #{description}, #{status});
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改用户 -->
|
||||||
|
<update id="updateSysUser">
|
||||||
|
update sys_user
|
||||||
|
set
|
||||||
|
<if test="userName != null and userName != ''">
|
||||||
|
username = #{userName},
|
||||||
|
</if>
|
||||||
|
<if test="password != null and password != ''">
|
||||||
|
password = #{password},
|
||||||
|
</if>
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="phone != null and phone != ''">
|
||||||
|
phone = #{phone},
|
||||||
|
</if>
|
||||||
|
<if test="description != null and description != ''">
|
||||||
|
description = #{description},
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
status = #{status},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
<!-- 根据username查询用户信息 -->
|
<!-- 根据username查询用户信息 -->
|
||||||
<select id="selectByUsername" resultType="com.atguigu.spzx.model.entity.system.SysUser">
|
<select id="selectByUsername" resultType="com.atguigu.spzx.model.entity.system.SysUser">
|
||||||
select
|
select
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -6,20 +6,11 @@
|
||||||
id,username userName ,password,name,phone,avatar,description,status,create_time,update_time,is_deleted
|
id,username userName ,password,name,phone,avatar,description,status,create_time,update_time,is_deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<sql id="findPageWhere">
|
<!-- 添加用户 -->
|
||||||
<where>
|
<insert id="save">
|
||||||
<if test="keyword != null and keyword != ''">
|
insert into sys_user (id, username, password, name, phone, avatar, description, status)
|
||||||
and username like CONCAT('%',#{keyword},'%')
|
values (#{id}, #{userName}, #{password}, #{name}, #{phone}, #{avatar}, #{description}, #{status});
|
||||||
</if>
|
</insert>
|
||||||
<if test="createTimeBegin != null and createTimeBegin != ''">
|
|
||||||
and create_time >= #{createTimeBegin}
|
|
||||||
</if>
|
|
||||||
<if test="createTimeEnd != null and createTimeEnd != ''">
|
|
||||||
and create_time <= #{createTimeEnd}
|
|
||||||
</if>
|
|
||||||
and is_deleted = 0
|
|
||||||
</where>
|
|
||||||
</sql>
|
|
||||||
|
|
||||||
<!-- 根据username查询用户信息 -->
|
<!-- 根据username查询用户信息 -->
|
||||||
<select id="selectByUsername" resultType="com.atguigu.spzx.model.entity.system.SysUser">
|
<select id="selectByUsername" resultType="com.atguigu.spzx.model.entity.system.SysUser">
|
||||||
|
@ -34,7 +25,18 @@
|
||||||
select
|
select
|
||||||
<include refid="columns"/>
|
<include refid="columns"/>
|
||||||
from sys_user
|
from sys_user
|
||||||
<include refid="findPageWhere"/>
|
<where>
|
||||||
|
<if test="keyword != null and keyword != ''">
|
||||||
|
and username like CONCAT('%',#{keyword},'%')
|
||||||
|
</if>
|
||||||
|
<if test="createTimeBegin != null and createTimeBegin != ''">
|
||||||
|
and create_time >= #{createTimeBegin}
|
||||||
|
</if>
|
||||||
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
||||||
|
and create_time <= #{createTimeEnd}
|
||||||
|
</if>
|
||||||
|
and is_deleted = 0
|
||||||
|
</where>
|
||||||
order by id desc
|
order by id desc
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue