Merge remote-tracking branch 'origin/master'

This commit is contained in:
haozq 2024-02-23 18:36:07 +08:00
commit aad4ad488a
5 changed files with 73 additions and 3 deletions

View File

@ -56,4 +56,10 @@ public class UserController extends BaseController {
public AjaxResult delUser(UserDto dto){ public AjaxResult delUser(UserDto dto){
return service.delUser(dto); return service.delUser(dto);
} }
@ApiOperation(value = "重置密码")
@PostMapping("editPwd")
public AjaxResult editPwd(@RequestBody UserVo vo){
return service.editPwd(vo);
}
} }

View File

@ -47,9 +47,19 @@ public interface IUserMapper {
/** /**
* 新增/修改用户 * 新增/修改用户
*
* @param vo * @param vo
* @author cwchen * @author cwchen
* @date 2024/2/20 17:39 * @date 2024/2/20 17:39
*/ */
void addOrUpdateUser(UserVo vo); void addOrUpdateUser(UserVo vo);
/**
* 重置密码
* @param vo
* @description 重置密码
* @author cwchen
* @date 2024/2/23 13:50
*/
void editPwd(UserVo vo);
} }

View File

@ -48,6 +48,7 @@ public interface IUserService {
/** /**
* 用户详情 * 用户详情
*
* @param dto * @param dto
* @return AjaxResult * @return AjaxResult
* @description * @description
@ -55,4 +56,14 @@ public interface IUserService {
* @date 2024/2/20 17:31 * @date 2024/2/20 17:31
*/ */
AjaxResult getUserById(UserDto dto); AjaxResult getUserById(UserDto dto);
/**
* 重置密码
* @param vo
* @return AjaxResult
* @description 重置密码
* @author cwchen
* @date 2024/2/23 13:47
*/
AjaxResult editPwd(UserVo vo);
} }

View File

@ -1,5 +1,6 @@
package com.securitycontrol.system.base.service.impl; package com.securitycontrol.system.base.service.impl;
import com.securitycontrol.common.core.utils.StringUtils;
import com.securitycontrol.common.core.utils.aes.DateTimeHelper; import com.securitycontrol.common.core.utils.aes.DateTimeHelper;
import com.securitycontrol.common.core.web.domain.AjaxResult; import com.securitycontrol.common.core.web.domain.AjaxResult;
import com.securitycontrol.common.security.utils.SecurityUtils; import com.securitycontrol.common.security.utils.SecurityUtils;
@ -26,6 +27,12 @@ import java.util.List;
@Slf4j @Slf4j
public class UserServiceImpl implements IUserService { public class UserServiceImpl implements IUserService {
private static String[] constantArr;
static {
constantArr = new String[]{"管理员"};
}
@Resource(name = "IUserMapper") @Resource(name = "IUserMapper")
private IUserMapper mapper; private IUserMapper mapper;
@ -40,6 +47,13 @@ public class UserServiceImpl implements IUserService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public AjaxResult addOrUpdateUser(UserVo vo) { public AjaxResult addOrUpdateUser(UserVo vo) {
try { try {
if(StringUtils.isNotEmpty(vo.getRoleName())){
if (vo.getRoleName().contains(constantArr[0])) {
vo.setIsAdmin(1);
}else {
vo.setIsAdmin(0);
}
}
if (vo.getUserId() != null) { if (vo.getUserId() != null) {
vo.setType(2); vo.setType(2);
} else { } else {
@ -70,4 +84,20 @@ public class UserServiceImpl implements IUserService {
vo = mapper.getUserById(dto); vo = mapper.getUserById(dto);
return AjaxResult.success(vo); return AjaxResult.success(vo);
} }
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult editPwd(UserVo vo) {
try {
if(vo.getUserId() == null || StringUtils.isBlank(vo.getPassword())){
return AjaxResult.error("参数不完整");
}
vo.setPassword(SecurityUtils.encryptPassword(vo.getPassword()));
mapper.editPwd(vo);
} catch (Exception e) {
log.error("重置密码",e);
return AjaxResult.error();
}
return AjaxResult.success();
}
} }

View File

@ -16,8 +16,9 @@
<if test="phone != null and phone != ''">phone,</if> <if test="phone != null and phone != ''">phone,</if>
<if test="loginType != null and loginType != ''">login_type,</if> <if test="loginType != null and loginType != ''">login_type,</if>
<if test="userType != null">user_type,</if> <if test="userType != null">user_type,</if>
<if test="isAdmin != null and isAdmin != ''">is_admin,</if> <if test="isAdmin != null">is_admin,</if>
<if test="roleId != null and roleId != ''">role_id,</if> <if test="roleId != null and roleId != ''">role_id,</if>
<if test="roleName != null and roleName != ''">role_name,</if>
<if test="accountStatus != null">status,</if> <if test="accountStatus != null">status,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
@ -31,8 +32,9 @@
<if test="phone != null and phone != ''">#{phone},</if> <if test="phone != null and phone != ''">#{phone},</if>
<if test="loginType != null and loginType != ''">#{loginType},</if> <if test="loginType != null and loginType != ''">#{loginType},</if>
<if test="userType != null">#{userType},</if> <if test="userType != null">#{userType},</if>
<if test="isAdmin != null and isAdmin != ''">#{isAdmin},</if> <if test="isAdmin != null">#{isAdmin},</if>
<if test="roleId != null and roleId != ''">#{roleId},</if> <if test="roleId != null and roleId != ''">#{roleId},</if>
<if test="roleName != null and roleName != ''">#{roleName},</if>
<if test="accountStatus != null">#{accountStatus},</if> <if test="accountStatus != null">#{accountStatus},</if>
</trim> </trim>
</if> </if>
@ -42,7 +44,13 @@
<if test="userName != null and userName != ''">user_name = #{userName},</if> <if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="orgId != null and orgId != ''">org_id = #{orgId},</if> <if test="orgId != null and orgId != ''">org_id = #{orgId},</if>
<if test="orgName != null and orgName != ''">org_name = #{orgName},</if> <if test="orgName != null and orgName != ''">org_name = #{orgName},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if> <if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="loginType != null and loginType != ''">login_type = #{loginType},</if>
<if test="userType != null and userType != ''">user_type = #{userType},</if>
<if test="isAdmin != null">is_admin = #{isAdmin},</if>
<if test="roleId != null and roleId != ''">role_id = #{roleId},</if>
<if test="roleName != null and roleName != ''">role_name = #{roleName},</if>
<if test="accountStatus != null">status = #{accountStatus},</if>
</set> </set>
WHERE user_id = #{userId} WHERE user_id = #{userId}
</if> </if>
@ -51,6 +59,10 @@
<update id="delUser"> <update id="delUser">
UPDATE sys_user SET del_flag = '1' WHERE user_id = #{userId} UPDATE sys_user SET del_flag = '1' WHERE user_id = #{userId}
</update> </update>
<!--重置密码-->
<update id="editPwd">
UPDATE sys_user SET password = #{password} WHERE user_id = #{userId}
</update>
<!--获取用户列表--> <!--获取用户列表-->
<select id="getUserLists" resultType="com.securitycontrol.entity.system.vo.UserVo"> <select id="getUserLists" resultType="com.securitycontrol.entity.system.vo.UserVo">
@ -85,6 +97,7 @@
su.login_type AS loginType, su.login_type AS loginType,
su.user_type AS userType, su.user_type AS userType,
su.role_id AS roleId, su.role_id AS roleId,
su.role_name AS roleName,
su.status AS accountStatus su.status AS accountStatus
FROM sys_user su FROM sys_user su
WHERE user_id = #{userId} WHERE user_id = #{userId}