From 2cb11615cdd5d9044dc02cb2a83915effed2a9d0 Mon Sep 17 00:00:00 2001 From: liuchengqian Date: Thu, 12 May 2022 09:04:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=B3=BB=E7=BB=9F=E7=94=A8?= =?UTF-8?q?=E6=88=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xkrs/controller/SysUserController.java | 6 +++ .../java/com/xkrs/service/SysUserService.java | 53 +++++++++++++------ .../xkrs/service/impl/SysUserServiceImpl.java | 8 +++ 3 files changed, 52 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java index 498f579..ab18beb 100644 --- a/src/main/java/com/xkrs/controller/SysUserController.java +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -88,6 +88,12 @@ public class SysUserController { return sysUserService.addUser(userQo); } + @RequestMapping(value = "/general/deletesysuser", method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')") + public String deleteSysUser(@RequestParam(value = "userName") String userName) { + return sysUserService.deleteSysUser(userName); + } + /** * 软删除指定id的普通用户 * diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java index ed30ea6..442802f 100644 --- a/src/main/java/com/xkrs/service/SysUserService.java +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -3,39 +3,44 @@ package com.xkrs.service; import com.xkrs.model.entity.SysUserEntity; import com.xkrs.model.qo.SysUserQo; import com.xkrs.model.vo.SysUserVo; -import org.springframework.data.jpa.repository.Query; import java.util.List; import java.util.Map; /** * 系统用户服务接口 + * * @author tajochen */ public interface SysUserService { /** * 检查用户名 + * * @param userName * @return */ boolean checkUserName(String userName); - /** - * 获取所有用户 - * @return - */ - //Iterable getAllSysUser(); - /** * 保存用户 + * * @param sysUserQo * @return */ String addUser(SysUserQo sysUserQo); + /** + * 删除系统用户 + * + * @param userName + * @return + */ + String deleteSysUser(String userName); + /** * 获取系统用户实体根据用户名 + * * @param userName * @return */ @@ -43,6 +48,7 @@ public interface SysUserService { /** * 用户登录更新 + * * @param userName * @param ipAddress * @return @@ -51,6 +57,7 @@ public interface SysUserService { /** * 系统用户更新 + * * @param sysUserQo * @return */ @@ -58,6 +65,7 @@ public interface SysUserService { /** * 软删除系统用户 + * * @param id * @return */ @@ -65,43 +73,49 @@ public interface SysUserService { /** * 查询用户的信息 + * * @return */ List selectAllUser(); /** * 启用 + * * @param userId */ void updateEnable(Integer userId); /** * 禁用 + * * @param userId */ void updateDisable(Integer userId); /** * 用户修改密码 + * * @param oldPassword * @param newPassword * @param confirmPassword * @param sysUserEntity * @return */ - String updatePassword(String oldPassword,String newPassword,String confirmPassword,SysUserEntity sysUserEntity); + String updatePassword(String oldPassword, String newPassword, String confirmPassword, SysUserEntity sysUserEntity); /** * 管理员修改用户的密码 + * * @param userId * @param newPassword * @param confirmPassword * @return */ - String adminUpdatePassword(Integer userId,String newPassword,String confirmPassword); + String adminUpdatePassword(Integer userId, String newPassword, String confirmPassword); /** * 获取系统用户实体根据用户名 + * * @param userName * @return */ @@ -109,6 +123,7 @@ public interface SysUserService { /** * 按天数修改账号到期时间 + * * @param userId * @param dayNum * @return @@ -117,6 +132,7 @@ public interface SysUserService { /** * 按月份修改账号到期时间 + * * @param userId * @param dayNum * @return @@ -125,6 +141,7 @@ public interface SysUserService { /** * 按年份修改账号到期时间 + * * @param userId * @param dayNum * @return @@ -133,6 +150,7 @@ public interface SysUserService { /** * 设置账号时间永久有效 + * * @param userId * @return */ @@ -140,40 +158,45 @@ public interface SysUserService { /** * 修改账号到期时间 + * * @param userId * @param overTime * @return */ - String updateOverTime(Integer userId,String overTime); + String updateOverTime(Integer userId, String overTime); /** * 记录用户登录次数 + * * @param userId * @param loginNum */ - void updateLoginNum(Integer userId,Integer loginNum); + void updateLoginNum(Integer userId, Integer loginNum); /** * 记录用户登录时间 + * * @param userId * @param loginLastTime */ - void updateLoginLastTime(Integer userId,String loginLastTime); + void updateLoginLastTime(Integer userId, String loginLastTime); - List> findCityByProCode(String proCode); + List> findCityByProCode(String proCode); /** * 通过省编码查询县名称和编码 + * * @param proCode * @return */ - List> findCountyByProCode(String proCode); + List> findCountyByProCode(String proCode); /** * 通过市编码查询区县名称和编码 + * * @param cityCode * @return */ - List> findCountyByCityCode(String cityCode); + List> findCountyByCityCode(String cityCode); } diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java index 023b26e..48f78cc 100644 --- a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -181,6 +181,14 @@ public class SysUserServiceImpl implements SysUserService { return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "注册成功!", locale); } + @Transactional(rollbackFor = Exception.class) + @Override + public String deleteSysUser(String userName) { + Locale locale = LocaleContextHolder.getLocale(); + int deleteCount = sysUserDao.deleteSysUser(userName); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS, "删除" + deleteCount + "个账户", locale); + } + /** * 查询所有用户Vo *