From 9605e6d252a8df1b93118811ca60aed0bbfeaae6 Mon Sep 17 00:00:00 2001 From: pcm Date: Mon, 25 Nov 2024 17:20:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EsaToken=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E5=B7=A5=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/pancm/config/SaTokenConfigure.java | 50 +++++ .../com/pancm/constant/UserConstants.java | 6 + .../com/pancm/controller/LoginController.java | 91 ++++++++ ...ller.java => SysPermissionController.java} | 52 ++--- .../controller/SysUserInfoController.java | 103 +++++++++ .../controller/SysUserRoleController.java | 103 +++++++++ .../SysUserRolePermissionController.java | 103 +++++++++ .../com/pancm/controller/UserController.java | 103 --------- .../java/com/pancm/dao/SysPermissionDao.java | 87 ++++++++ .../java/com/pancm/dao/SysUserInfoDao.java | 86 ++++++++ .../java/com/pancm/dao/SysUserRoleDao.java | 86 ++++++++ .../pancm/dao/SysUserRolePermissionDao.java | 86 ++++++++ .../java/com/pancm/enums/PcmYesNoEnum.java | 85 ++++++++ .../interceptors/PermissionInterceptor.java | 65 ++++++ .../java/com/pancm/model/SysPermission.java | 81 +++++++ .../java/com/pancm/model/SysUserInfo.java | 96 +++++++++ .../java/com/pancm/model/SysUserRole.java | 71 +++++++ .../pancm/model/SysUserRolePermission.java | 71 +++++++ .../pancm/service/ISysPermissionService.java | 61 ++++++ .../pancm/service/ISysUserInfoService.java | 61 ++++++ .../ISysUserRolePermissionService.java | 60 ++++++ .../pancm/service/ISysUserRoleService.java | 60 ++++++ .../impl/SysPermissionServiceImpl.java | 105 ++++++++++ .../service/impl/SysUserInfoServiceImpl.java | 106 ++++++++++ .../SysUserRolePermissionServiceImpl.java | 96 +++++++++ .../service/impl/SysUserRoleServiceImpl.java | 96 +++++++++ .../java/com/pancm/vo/SysPermissionVO.java | 81 +++++++ .../main/java/com/pancm/vo/SysUserInfoVO.java | 103 +++++++++ .../com/pancm/vo/SysUserRolePermissionVO.java | 71 +++++++ .../main/java/com/pancm/vo/SysUserRoleVO.java | 71 +++++++ .../pancm/mapper/SysPermissionMapper.xml | 185 ++++++++++++++++ .../pancm/mapper/SysUserInfoMapper.xml | 198 ++++++++++++++++++ .../pancm/mapper/SysUserRoleMapper.xml | 148 +++++++++++++ .../mapper/SysUserRolePermissionMapper.xml | 148 +++++++++++++ 34 files changed, 2946 insertions(+), 129 deletions(-) create mode 100644 springboot-saToken/src/main/java/com/pancm/config/SaTokenConfigure.java create mode 100644 springboot-saToken/src/main/java/com/pancm/constant/UserConstants.java create mode 100644 springboot-saToken/src/main/java/com/pancm/controller/LoginController.java rename springboot-saToken/src/main/java/com/pancm/controller/{TSysUserController.java => SysPermissionController.java} (51%) create mode 100644 springboot-saToken/src/main/java/com/pancm/controller/SysUserInfoController.java create mode 100644 springboot-saToken/src/main/java/com/pancm/controller/SysUserRoleController.java create mode 100644 springboot-saToken/src/main/java/com/pancm/controller/SysUserRolePermissionController.java delete mode 100644 springboot-saToken/src/main/java/com/pancm/controller/UserController.java create mode 100644 springboot-saToken/src/main/java/com/pancm/dao/SysPermissionDao.java create mode 100644 springboot-saToken/src/main/java/com/pancm/dao/SysUserInfoDao.java create mode 100644 springboot-saToken/src/main/java/com/pancm/dao/SysUserRoleDao.java create mode 100644 springboot-saToken/src/main/java/com/pancm/dao/SysUserRolePermissionDao.java create mode 100644 springboot-saToken/src/main/java/com/pancm/enums/PcmYesNoEnum.java create mode 100644 springboot-saToken/src/main/java/com/pancm/interceptors/PermissionInterceptor.java create mode 100644 springboot-saToken/src/main/java/com/pancm/model/SysPermission.java create mode 100644 springboot-saToken/src/main/java/com/pancm/model/SysUserInfo.java create mode 100644 springboot-saToken/src/main/java/com/pancm/model/SysUserRole.java create mode 100644 springboot-saToken/src/main/java/com/pancm/model/SysUserRolePermission.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/ISysPermissionService.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/ISysUserInfoService.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/ISysUserRolePermissionService.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/ISysUserRoleService.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/impl/SysPermissionServiceImpl.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/impl/SysUserInfoServiceImpl.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRolePermissionServiceImpl.java create mode 100644 springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRoleServiceImpl.java create mode 100644 springboot-saToken/src/main/java/com/pancm/vo/SysPermissionVO.java create mode 100644 springboot-saToken/src/main/java/com/pancm/vo/SysUserInfoVO.java create mode 100644 springboot-saToken/src/main/java/com/pancm/vo/SysUserRolePermissionVO.java create mode 100644 springboot-saToken/src/main/java/com/pancm/vo/SysUserRoleVO.java create mode 100644 springboot-saToken/src/main/resources/pancm/mapper/SysPermissionMapper.xml create mode 100644 springboot-saToken/src/main/resources/pancm/mapper/SysUserInfoMapper.xml create mode 100644 springboot-saToken/src/main/resources/pancm/mapper/SysUserRoleMapper.xml create mode 100644 springboot-saToken/src/main/resources/pancm/mapper/SysUserRolePermissionMapper.xml diff --git a/springboot-saToken/src/main/java/com/pancm/config/SaTokenConfigure.java b/springboot-saToken/src/main/java/com/pancm/config/SaTokenConfigure.java new file mode 100644 index 0000000..a1a8aed --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/config/SaTokenConfigure.java @@ -0,0 +1,50 @@ +package com.pancm.config; + + +import cn.dev33.satoken.interceptor.SaRouteInterceptor; +import cn.dev33.satoken.stp.StpUtil; + +import com.pancm.interceptors.PermissionInterceptor; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import javax.annotation.Resource; + +/*** + * 登录权限验证 + */ +@Configuration +public class SaTokenConfigure implements WebMvcConfigurer { + + + @Resource + private PermissionInterceptor permissionInterceptor; + + // 需要排除的路径 + private static final String[] EXCLUDE_PATHS = {"/login/**"}; + + // 注册拦截器 + @Override + public void addInterceptors(InterceptorRegistry registry) { + registerSaTokenInterceptor(registry); + registerPermissionInterceptor(registry); + } + + // 注册 Sa-Token 拦截器 + private void registerSaTokenInterceptor(InterceptorRegistry registry) { + registry.addInterceptor(new SaRouteInterceptor((r, s, o) -> StpUtil.checkLogin())) + .addPathPatterns("/**") + .excludePathPatterns(EXCLUDE_PATHS); + } + + // 注册权限拦截器 + private void registerPermissionInterceptor(InterceptorRegistry registry) { + registry.addInterceptor(permissionInterceptor) + .addPathPatterns("/**") + .excludePathPatterns(EXCLUDE_PATHS); + } + + + +} diff --git a/springboot-saToken/src/main/java/com/pancm/constant/UserConstants.java b/springboot-saToken/src/main/java/com/pancm/constant/UserConstants.java new file mode 100644 index 0000000..aa111e2 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/constant/UserConstants.java @@ -0,0 +1,6 @@ +package com.pancm.constant; + +public interface UserConstants { + + String CURRENT_USER = "current_user"; +} diff --git a/springboot-saToken/src/main/java/com/pancm/controller/LoginController.java b/springboot-saToken/src/main/java/com/pancm/controller/LoginController.java new file mode 100644 index 0000000..a61c569 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/controller/LoginController.java @@ -0,0 +1,91 @@ +package com.pancm.controller; + + +import cn.dev33.satoken.stp.StpUtil; + +import com.pancm.constant.UserConstants; +import com.pancm.enums.PcmYesNoEnum; +import com.pancm.service.ISysPermissionService; +import com.pancm.service.ISysUserInfoService; +import com.pancm.service.ISysUserRoleService; +import com.pancm.vo.ApiResult; +import com.pancm.vo.SysPermissionVO; +import com.pancm.vo.SysUserInfoVO; +import com.pancm.vo.SysUserRoleVO; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; +import java.util.Objects; + +/** + *

+ * 用户登录 controller + *

+ * + * @author pcm + * @menu 用户登录 + * @since 2024-11-20 + */ +@Api(tags = "REST - 用户登录") +@RestController +@RequestMapping("/login") +public class LoginController { + + @Resource + private ISysUserInfoService sysUserInfoService; + @Resource + private ISysUserRoleService userRoleService; + @Resource + private ISysPermissionService permissionService; + + + @PostMapping("/login") + @ApiOperation(value = "登录", notes = "登录") + public ApiResult login(@RequestParam(value = "username") String username, @RequestParam(value = "password") String password) { + SysUserInfoVO userInfoVO = sysUserInfoService.queryByUserName(username); + if (userInfoVO == null || !Objects.equals(userInfoVO.getPassword(), password)) { + return ApiResult.error("用户名或密码错误!"); + } + if(Objects.equals(userInfoVO.getUserEnable(), PcmYesNoEnum.NO.getIndex())){ + return ApiResult.error("该用户已被禁用!请联系管理员!"); + } + SysUserRoleVO roleDTO = userRoleService.queryById(userInfoVO.getRoleId()); + if(roleDTO == null || Objects.equals(roleDTO.getUserEnable(), PcmYesNoEnum.NO.getIndex())){ + return ApiResult.error("该用户所属角色已被禁用或已删除!请联系管理员!"); + } + List list = permissionService.queryRolePermissionByRoleId(userInfoVO.getRoleId()); + if(list == null || list.isEmpty()){ + return ApiResult.error("该用户所属角色未配置权限!请联系管理员!"); + } + userInfoVO.setPermissionDTOLists(list); + userInfoVO.setPassword(null); + StpUtil.login(username); + StpUtil.getSession().set(UserConstants.CURRENT_USER, userInfoVO); + return ApiResult.success(userInfoVO); + } + + @ApiOperation(value = "登录校验", notes = "登录校验") + @RequestMapping("/isLogin") + public ApiResult isLogin() { + return ApiResult.success(StpUtil.isLogin()); + } + + @ApiOperation(value = "登出", notes = "登出") + @PostMapping("/logout") + public ApiResult logout() { + StpUtil.getSession().clear(); + StpUtil.logout(); + return ApiResult.success(); + } + + +} + + diff --git a/springboot-saToken/src/main/java/com/pancm/controller/TSysUserController.java b/springboot-saToken/src/main/java/com/pancm/controller/SysPermissionController.java similarity index 51% rename from springboot-saToken/src/main/java/com/pancm/controller/TSysUserController.java rename to springboot-saToken/src/main/java/com/pancm/controller/SysPermissionController.java index 8483569..f790581 100644 --- a/springboot-saToken/src/main/java/com/pancm/controller/TSysUserController.java +++ b/springboot-saToken/src/main/java/com/pancm/controller/SysPermissionController.java @@ -1,7 +1,7 @@ package com.pancm.controller; -import com.pancm.vo.TSysUserVO; -import com.pancm.service.ITSysUserService; +import com.pancm.vo.SysPermissionVO; +import com.pancm.service.ISysPermissionService; import org.springframework.web.bind.annotation.*; @@ -19,34 +19,34 @@ /** -* @Title: 用户表(TSysUser)表控制层 +* @Title: 权限表(SysPermission)表控制层 * @Description: * @Version:1.0.0 * @Since:jdk1.8 * @author pancm -* @date 2024-04-01 09:30:51 +* @date 2024-11-23 09:31:42 */ -@Api(tags = "用户表(TSysUser)") +@Api(tags = "权限表(SysPermission)") @RestController -@RequestMapping("tSysUser") -public class TSysUserController { +@RequestMapping("sysPermission") +public class SysPermissionController { /** * 服务对象 */ @Autowired - private ITSysUserService tSysUserService; + private ISysPermissionService sysPermissionService; /** * 新增一条数据 * - * @param tSysUserVO 实体类 + * @param sysPermissionVO 实体类 * @return Response对象 */ - @ApiOperation(value = "用户表新增",notes = "用户表新增") + @ApiOperation(value = "权限表新增",notes = "权限表新增") @RequestMapping(value = "save", method = RequestMethod.POST) - public ApiResult insert(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest httpRequest) { - int result = tSysUserService.insert(tSysUserVO); + public ApiResult insert(@RequestBody SysPermissionVO sysPermissionVO, HttpServletRequest httpRequest) { + int result = sysPermissionService.insert(sysPermissionVO); if (result > 0) { return ApiResult.success(); } @@ -56,26 +56,26 @@ public ApiResult insert(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest h /** * 修改一条数据 * - * @param tSysUserVO 实体类 + * @param sysPermissionVO 实体类 * @return Response对象 */ - @ApiOperation(value = "用户表修改",notes = "用户表修改") + @ApiOperation(value = "权限表修改",notes = "权限表修改") @RequestMapping(value = "edit", method = RequestMethod.POST) - public ApiResult update(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest httpRequest) { - tSysUserService.update(tSysUserVO); + public ApiResult update(@RequestBody SysPermissionVO sysPermissionVO, HttpServletRequest httpRequest) { + sysPermissionService.update(sysPermissionVO); return ApiResult.success(); } /** * 删除一条数据 * - * @param tSysUserVO 参数对象 + * @param sysPermissionVO 参数对象 * @return Response对象 */ - @ApiOperation(value = "用户表删除",notes = "用户表删除") + @ApiOperation(value = "权限表删除",notes = "权限表删除") @RequestMapping(value = "del", method = RequestMethod.POST) - public ApiResult delete(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest httpRequest) { - tSysUserService.deleteById(tSysUserVO.getId()); + public ApiResult delete(@RequestBody SysPermissionVO sysPermissionVO, HttpServletRequest httpRequest) { + sysPermissionService.deleteById(sysPermissionVO.getId()); return ApiResult.success(); } @@ -85,19 +85,19 @@ public ApiResult delete(@RequestBody TSysUserVO tSysUserVO, HttpServletRequest h * 分页查询 * */ - @ApiOperation(value = "用户表查询",notes = "用户表查询") + @ApiOperation(value = "权限表查询",notes = "权限表查询") @RequestMapping(value = "list", method = RequestMethod.POST) - public ApiResult list(@RequestBody TSysUserVO tSysUserVO) { - return tSysUserService.list(tSysUserVO); + public ApiResult list(@RequestBody SysPermissionVO sysPermissionVO) { + return sysPermissionService.list(sysPermissionVO); } /** * 详情查询 * */ - @ApiOperation(value = "用户表详情",notes = "用户表详情") + @ApiOperation(value = "权限表详情",notes = "权限表详情") @RequestMapping(value = "view", method = RequestMethod.GET) - public ApiResult view( @RequestParam("id") String id) { - return ApiResult.success(tSysUserService.queryById(id)); + public ApiResult view( @RequestParam("id") Integer id) { + return ApiResult.success(sysPermissionService.queryById(id)); } } diff --git a/springboot-saToken/src/main/java/com/pancm/controller/SysUserInfoController.java b/springboot-saToken/src/main/java/com/pancm/controller/SysUserInfoController.java new file mode 100644 index 0000000..2b223bd --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/controller/SysUserInfoController.java @@ -0,0 +1,103 @@ +package com.pancm.controller; + +import com.pancm.vo.SysUserInfoVO; +import com.pancm.service.ISysUserInfoService; +import org.springframework.web.bind.annotation.*; + + +import com.pancm.vo.ApiResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + + + +/** +* @Title: 系统用户表(SysUserInfo)表控制层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Api(tags = "系统用户表(SysUserInfo)") +@RestController +@RequestMapping("sysUserInfo") +public class SysUserInfoController { + /** + * 服务对象 + */ + @Autowired + private ISysUserInfoService sysUserInfoService; + + + /** + * 新增一条数据 + * + * @param sysUserInfoVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "系统用户表新增",notes = "系统用户表新增") + @RequestMapping(value = "save", method = RequestMethod.POST) + public ApiResult insert(@RequestBody SysUserInfoVO sysUserInfoVO, HttpServletRequest httpRequest) { + int result = sysUserInfoService.insert(sysUserInfoVO); + if (result > 0) { + return ApiResult.success(); + } + return ApiResult.error("新增失败"); + } + + /** + * 修改一条数据 + * + * @param sysUserInfoVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "系统用户表修改",notes = "系统用户表修改") + @RequestMapping(value = "edit", method = RequestMethod.POST) + public ApiResult update(@RequestBody SysUserInfoVO sysUserInfoVO, HttpServletRequest httpRequest) { + sysUserInfoService.update(sysUserInfoVO); + return ApiResult.success(); + } + + /** + * 删除一条数据 + * + * @param sysUserInfoVO 参数对象 + * @return Response对象 + */ + @ApiOperation(value = "系统用户表删除",notes = "系统用户表删除") + @RequestMapping(value = "del", method = RequestMethod.POST) + public ApiResult delete(@RequestBody SysUserInfoVO sysUserInfoVO, HttpServletRequest httpRequest) { + sysUserInfoService.deleteById(sysUserInfoVO.getId()); + return ApiResult.success(); + } + + + + /** + * 分页查询 + * + */ + @ApiOperation(value = "系统用户表查询",notes = "系统用户表查询") + @RequestMapping(value = "list", method = RequestMethod.POST) + public ApiResult list(@RequestBody SysUserInfoVO sysUserInfoVO) { + return sysUserInfoService.list(sysUserInfoVO); + } + + /** + * 详情查询 + * + */ + @ApiOperation(value = "系统用户表详情",notes = "系统用户表详情") + @RequestMapping(value = "view", method = RequestMethod.GET) + public ApiResult view( @RequestParam("id") Integer id) { + return ApiResult.success(sysUserInfoService.queryById(id)); + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/controller/SysUserRoleController.java b/springboot-saToken/src/main/java/com/pancm/controller/SysUserRoleController.java new file mode 100644 index 0000000..f88247f --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/controller/SysUserRoleController.java @@ -0,0 +1,103 @@ +package com.pancm.controller; + +import com.pancm.vo.SysUserRoleVO; +import com.pancm.service.ISysUserRoleService; +import org.springframework.web.bind.annotation.*; + + +import com.pancm.vo.ApiResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + + + +/** +* @Title: 用户角色表(SysUserRole)表控制层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Api(tags = "用户角色表(SysUserRole)") +@RestController +@RequestMapping("sysUserRole") +public class SysUserRoleController { + /** + * 服务对象 + */ + @Autowired + private ISysUserRoleService sysUserRoleService; + + + /** + * 新增一条数据 + * + * @param sysUserRoleVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户角色表新增",notes = "用户角色表新增") + @RequestMapping(value = "save", method = RequestMethod.POST) + public ApiResult insert(@RequestBody SysUserRoleVO sysUserRoleVO, HttpServletRequest httpRequest) { + int result = sysUserRoleService.insert(sysUserRoleVO); + if (result > 0) { + return ApiResult.success(); + } + return ApiResult.error("新增失败"); + } + + /** + * 修改一条数据 + * + * @param sysUserRoleVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户角色表修改",notes = "用户角色表修改") + @RequestMapping(value = "edit", method = RequestMethod.POST) + public ApiResult update(@RequestBody SysUserRoleVO sysUserRoleVO, HttpServletRequest httpRequest) { + sysUserRoleService.update(sysUserRoleVO); + return ApiResult.success(); + } + + /** + * 删除一条数据 + * + * @param sysUserRoleVO 参数对象 + * @return Response对象 + */ + @ApiOperation(value = "用户角色表删除",notes = "用户角色表删除") + @RequestMapping(value = "del", method = RequestMethod.POST) + public ApiResult delete(@RequestBody SysUserRoleVO sysUserRoleVO, HttpServletRequest httpRequest) { + sysUserRoleService.deleteById(sysUserRoleVO.getId()); + return ApiResult.success(); + } + + + + /** + * 分页查询 + * + */ + @ApiOperation(value = "用户角色表查询",notes = "用户角色表查询") + @RequestMapping(value = "list", method = RequestMethod.POST) + public ApiResult list(@RequestBody SysUserRoleVO sysUserRoleVO) { + return sysUserRoleService.list(sysUserRoleVO); + } + + /** + * 详情查询 + * + */ + @ApiOperation(value = "用户角色表详情",notes = "用户角色表详情") + @RequestMapping(value = "view", method = RequestMethod.GET) + public ApiResult view( @RequestParam("id") Integer id) { + return ApiResult.success(sysUserRoleService.queryById(id)); + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/controller/SysUserRolePermissionController.java b/springboot-saToken/src/main/java/com/pancm/controller/SysUserRolePermissionController.java new file mode 100644 index 0000000..bda5cfd --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/controller/SysUserRolePermissionController.java @@ -0,0 +1,103 @@ +package com.pancm.controller; + +import com.pancm.vo.SysUserRolePermissionVO; +import com.pancm.service.ISysUserRolePermissionService; +import org.springframework.web.bind.annotation.*; + + +import com.pancm.vo.ApiResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.servlet.http.HttpServletRequest; + + + +/** +* @Title: 用户角色权限表(SysUserRolePermission)表控制层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Api(tags = "用户角色权限表(SysUserRolePermission)") +@RestController +@RequestMapping("sysUserRolePermission") +public class SysUserRolePermissionController { + /** + * 服务对象 + */ + @Autowired + private ISysUserRolePermissionService sysUserRolePermissionService; + + + /** + * 新增一条数据 + * + * @param sysUserRolePermissionVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户角色权限表新增",notes = "用户角色权限表新增") + @RequestMapping(value = "save", method = RequestMethod.POST) + public ApiResult insert(@RequestBody SysUserRolePermissionVO sysUserRolePermissionVO, HttpServletRequest httpRequest) { + int result = sysUserRolePermissionService.insert(sysUserRolePermissionVO); + if (result > 0) { + return ApiResult.success(); + } + return ApiResult.error("新增失败"); + } + + /** + * 修改一条数据 + * + * @param sysUserRolePermissionVO 实体类 + * @return Response对象 + */ + @ApiOperation(value = "用户角色权限表修改",notes = "用户角色权限表修改") + @RequestMapping(value = "edit", method = RequestMethod.POST) + public ApiResult update(@RequestBody SysUserRolePermissionVO sysUserRolePermissionVO, HttpServletRequest httpRequest) { + sysUserRolePermissionService.update(sysUserRolePermissionVO); + return ApiResult.success(); + } + + /** + * 删除一条数据 + * + * @param sysUserRolePermissionVO 参数对象 + * @return Response对象 + */ + @ApiOperation(value = "用户角色权限表删除",notes = "用户角色权限表删除") + @RequestMapping(value = "del", method = RequestMethod.POST) + public ApiResult delete(@RequestBody SysUserRolePermissionVO sysUserRolePermissionVO, HttpServletRequest httpRequest) { + sysUserRolePermissionService.deleteById(sysUserRolePermissionVO.getId()); + return ApiResult.success(); + } + + + + /** + * 分页查询 + * + */ + @ApiOperation(value = "用户角色权限表查询",notes = "用户角色权限表查询") + @RequestMapping(value = "list", method = RequestMethod.POST) + public ApiResult list(@RequestBody SysUserRolePermissionVO sysUserRolePermissionVO) { + return sysUserRolePermissionService.list(sysUserRolePermissionVO); + } + + /** + * 详情查询 + * + */ + @ApiOperation(value = "用户角色权限表详情",notes = "用户角色权限表详情") + @RequestMapping(value = "view", method = RequestMethod.GET) + public ApiResult view( @RequestParam("id") Integer id) { + return ApiResult.success(sysUserRolePermissionService.queryById(id)); + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/controller/UserController.java b/springboot-saToken/src/main/java/com/pancm/controller/UserController.java deleted file mode 100644 index 94fa064..0000000 --- a/springboot-saToken/src/main/java/com/pancm/controller/UserController.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.pancm.controller; - -import com.pancm.vo.UserVO; -import com.pancm.service.IUserService; -import org.springframework.web.bind.annotation.*; - - -import com.pancm.vo.ApiResult; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; - - - -/** -* @Title: 用户表(User)表控制层 -* @Description: -* @Version:1.0.0 -* @Since:jdk1.8 -* @author pancm -* @date 2024-01-15 15:27:02 -*/ -@Api(tags = "用户表(User)") -@RestController -@RequestMapping("user") -public class UserController { - /** - * 服务对象 - */ - @Autowired - private IUserService userService; - - - /** - * 新增一条数据 - * - * @param userVO 实体类 - * @return Response对象 - */ - @ApiOperation(value = "用户表新增",notes = "用户表新增") - @RequestMapping(value = "save", method = RequestMethod.POST) - public ApiResult insert(@RequestBody UserVO userVO, HttpServletRequest httpRequest) { - int result = userService.insert(userVO); - if (result > 0) { - return ApiResult.success(); - } - return ApiResult.error("新增失败"); - } - - /** - * 修改一条数据 - * - * @param userVO 实体类 - * @return Response对象 - */ - @ApiOperation(value = "用户表修改",notes = "用户表修改") - @RequestMapping(value = "edit", method = RequestMethod.POST) - public ApiResult update(@RequestBody UserVO userVO, HttpServletRequest httpRequest) { - userService.update(userVO); - return ApiResult.success(); - } - - /** - * 删除一条数据 - * - * @param userVO 参数对象 - * @return Response对象 - */ - @ApiOperation(value = "用户表删除",notes = "用户表删除") - @RequestMapping(value = "del", method = RequestMethod.POST) - public ApiResult delete(@RequestBody UserVO userVO, HttpServletRequest httpRequest) { - userService.deleteById(userVO.getId()); - return ApiResult.success(); - } - - - - /** - * 分页查询 - * - */ - @ApiOperation(value = "用户表查询",notes = "用户表查询") - @RequestMapping(value = "list", method = RequestMethod.POST) - public ApiResult list(@RequestBody UserVO userVO) { - return userService.list(userVO); - } - - /** - * 详情查询 - * - */ - @ApiOperation(value = "用户表详情",notes = "用户表详情") - @RequestMapping(value = "view", method = RequestMethod.GET) - public ApiResult view( @RequestParam("id") Long id) { - return ApiResult.success(userService.queryById(id)); - } -} diff --git a/springboot-saToken/src/main/java/com/pancm/dao/SysPermissionDao.java b/springboot-saToken/src/main/java/com/pancm/dao/SysPermissionDao.java new file mode 100644 index 0000000..53c4c61 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/dao/SysPermissionDao.java @@ -0,0 +1,87 @@ +package com.pancm.dao; + +import com.pancm.model.SysPermission; +import com.pancm.vo.SysPermissionVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; +import java.util.List; + + /** +* @Title: 权限表(SysPermission)表数据库访问层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Mapper +public interface SysPermissionDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysPermissionVO queryById(Integer id); + + + /** + * 通过实体查询一条数据 + * + * @param sysPermissionVO 实例对象 + * @return 对象列表 + */ + SysPermissionVO findOne(SysPermissionVO sysPermissionVO); + + /** + * 通过实体作为筛选条件查询 + * + * @param sysPermissionVO 实例对象 + * @return 对象列表 + */ + List queryAll(SysPermissionVO sysPermissionVO); + + /** + * 新增数据 + * + * @param sysPermission 实例对象 + * @return 影响行数 + */ + int insert(SysPermission sysPermission); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param sysPermission 实例对象 + * @return 影响行数 + */ + int update(SysPermission sysPermission); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + + List queryRolePermissionByRoleId(Integer roleId); + } + diff --git a/springboot-saToken/src/main/java/com/pancm/dao/SysUserInfoDao.java b/springboot-saToken/src/main/java/com/pancm/dao/SysUserInfoDao.java new file mode 100644 index 0000000..5a64cc5 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/dao/SysUserInfoDao.java @@ -0,0 +1,86 @@ +package com.pancm.dao; + +import com.pancm.model.SysUserInfo; +import com.pancm.vo.SysUserInfoVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; +import java.util.List; + + /** +* @Title: 系统用户表(SysUserInfo)表数据库访问层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Mapper +public interface SysUserInfoDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysUserInfoVO queryById(Integer id); + + + /** + * 通过实体查询一条数据 + * + * @param sysUserInfoVO 实例对象 + * @return 对象列表 + */ + SysUserInfoVO findOne(SysUserInfoVO sysUserInfoVO); + + /** + * 通过实体作为筛选条件查询 + * + * @param sysUserInfoVO 实例对象 + * @return 对象列表 + */ + List queryAll(SysUserInfoVO sysUserInfoVO); + + /** + * 新增数据 + * + * @param sysUserInfo 实例对象 + * @return 影响行数 + */ + int insert(SysUserInfo sysUserInfo); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param sysUserInfo 实例对象 + * @return 影响行数 + */ + int update(SysUserInfo sysUserInfo); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/springboot-saToken/src/main/java/com/pancm/dao/SysUserRoleDao.java b/springboot-saToken/src/main/java/com/pancm/dao/SysUserRoleDao.java new file mode 100644 index 0000000..e758e31 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/dao/SysUserRoleDao.java @@ -0,0 +1,86 @@ +package com.pancm.dao; + +import com.pancm.model.SysUserRole; +import com.pancm.vo.SysUserRoleVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; +import java.util.List; + + /** +* @Title: 用户角色表(SysUserRole)表数据库访问层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Mapper +public interface SysUserRoleDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysUserRoleVO queryById(Integer id); + + + /** + * 通过实体查询一条数据 + * + * @param sysUserRoleVO 实例对象 + * @return 对象列表 + */ + SysUserRoleVO findOne(SysUserRoleVO sysUserRoleVO); + + /** + * 通过实体作为筛选条件查询 + * + * @param sysUserRoleVO 实例对象 + * @return 对象列表 + */ + List queryAll(SysUserRoleVO sysUserRoleVO); + + /** + * 新增数据 + * + * @param sysUserRole 实例对象 + * @return 影响行数 + */ + int insert(SysUserRole sysUserRole); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param sysUserRole 实例对象 + * @return 影响行数 + */ + int update(SysUserRole sysUserRole); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/springboot-saToken/src/main/java/com/pancm/dao/SysUserRolePermissionDao.java b/springboot-saToken/src/main/java/com/pancm/dao/SysUserRolePermissionDao.java new file mode 100644 index 0000000..f9a2caf --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/dao/SysUserRolePermissionDao.java @@ -0,0 +1,86 @@ +package com.pancm.dao; + +import com.pancm.model.SysUserRolePermission; +import com.pancm.vo.SysUserRolePermissionVO; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Mapper; +import java.util.List; + + /** +* @Title: 用户角色权限表(SysUserRolePermission)表数据库访问层 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Mapper +public interface SysUserRolePermissionDao { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysUserRolePermissionVO queryById(Integer id); + + + /** + * 通过实体查询一条数据 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 对象列表 + */ + SysUserRolePermissionVO findOne(SysUserRolePermissionVO sysUserRolePermissionVO); + + /** + * 通过实体作为筛选条件查询 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 对象列表 + */ + List queryAll(SysUserRolePermissionVO sysUserRolePermissionVO); + + /** + * 新增数据 + * + * @param sysUserRolePermission 实例对象 + * @return 影响行数 + */ + int insert(SysUserRolePermission sysUserRolePermission); + + /** + * 批量新增数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertBatch(@Param("entities") List entities); + + /** + * 批量新增或按主键更新数据(MyBatis原生foreach方法) + * + * @param entities List 实例对象列表 + * @return 影响行数 + */ + int insertOrUpdateBatch(@Param("entities") List entities); + + /** + * 修改数据 + * + * @param sysUserRolePermission 实例对象 + * @return 影响行数 + */ + int update(SysUserRolePermission sysUserRolePermission); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 影响行数 + */ + int deleteById(Integer id); + +} + diff --git a/springboot-saToken/src/main/java/com/pancm/enums/PcmYesNoEnum.java b/springboot-saToken/src/main/java/com/pancm/enums/PcmYesNoEnum.java new file mode 100644 index 0000000..c8f6c60 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/enums/PcmYesNoEnum.java @@ -0,0 +1,85 @@ +package com.pancm.enums; + +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; + +/** + * 是否判断 + * + */ +public enum PcmYesNoEnum { + + YES(1, "是"), + + NO(0, "否"), + ; + + private Integer index; + private String name; + + PcmYesNoEnum(Integer index, String name) { + this.index = index; + this.name = name; + } + + public Integer getIndex() { + return index; + } + + public String getName() { + return name; + } + + public static List getAllIndexes() { + PcmYesNoEnum[] values = values(); + List indexes = new ArrayList<>(); + for (PcmYesNoEnum value : values) { + indexes.add(value.index); + } + return indexes; + } + + public static List> getEnumList() { + List> list = new ArrayList<>(); + LinkedHashMap map; + for (PcmYesNoEnum item : values()) { + map = new LinkedHashMap<>(); + map.put("code", item.index); + map.put("name", item.name); + list.add(map); + } + return list; + } + + public static String getNameByIndex(Integer index) { + PcmYesNoEnum[] values = values(); + for (PcmYesNoEnum value : values) { + if (value.index.equals(index)) { + return value.name; + } + } + return null; + } + + public static Integer getIndexByName(String name) { + PcmYesNoEnum[] values = values(); + for (PcmYesNoEnum value : values) { + if (value.name.equals(name)) { + return value.index; + } + } + return null; + } + + public static List getAllNames(){ + List names=new ArrayList<>(); + PcmYesNoEnum[] values = values(); + for (PcmYesNoEnum value : values) { + names.add(value.name); + } + return names; + } + + +} diff --git a/springboot-saToken/src/main/java/com/pancm/interceptors/PermissionInterceptor.java b/springboot-saToken/src/main/java/com/pancm/interceptors/PermissionInterceptor.java new file mode 100644 index 0000000..ed55a55 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/interceptors/PermissionInterceptor.java @@ -0,0 +1,65 @@ +package com.pancm.interceptors; + +import cn.dev33.satoken.stp.StpUtil; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.support.spring.FastJsonJsonView; + +import com.pancm.constant.UserConstants; +import com.pancm.vo.ApiResult; +import com.pancm.vo.SysPermissionVO; +import com.pancm.vo.SysUserInfoVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.Collectors; + + +/** + * 权限拦截器 + */ +@Slf4j +@Component +public class PermissionInterceptor extends HandlerInterceptorAdapter { + + + + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + if (verify(request,handler)) { + return true; + } + response.setCharacterEncoding(StandardCharsets.UTF_8.name()); + response.getWriter().write( + JSONObject.toJSONString(ApiResult.error("该用户没有配置该操作权限,请联系管理员!"))); + response.setContentType(FastJsonJsonView.DEFAULT_CONTENT_TYPE); + return false; + } + + + + private boolean verify(HttpServletRequest request, Object handler) { + String uri = request.getRequestURI(); + HandlerMethod handlerMethod = (HandlerMethod) handler; + // 获取类名 + String className = handlerMethod.getBeanType().getSimpleName(); + // 获取方法名 + String methodName = handlerMethod.getMethod().getName(); + String path = className.concat("#").concat(methodName); + SysUserInfoVO userInfoDTO = (SysUserInfoVO) StpUtil.getSession().get(UserConstants.CURRENT_USER); + if(userInfoDTO == null){ + return false; + } + List permissionDTOLists = userInfoDTO.getPermissionDTOLists(); + List permissionList = permissionDTOLists.stream().map(SysPermissionVO::getPermissionCode).collect(Collectors.toList()); + boolean valid = permissionList.contains(path); + log.info("api_path:{}, {}", path, valid); + return valid; + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/model/SysPermission.java b/springboot-saToken/src/main/java/com/pancm/model/SysPermission.java new file mode 100644 index 0000000..7a4d57e --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/model/SysPermission.java @@ -0,0 +1,81 @@ +package com.pancm.model; + + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Table; +import java.io.Serializable; +import java.sql.Date; + + /** +* @Title: 权限表(SysPermission)实体类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Data +@Table(name = "sys_permission") +public class SysPermission implements Serializable { + private static final long serialVersionUID = -66914156987259247L; + /** + * 主键ID + */ + @Column(name = "id") + private Integer id; + /** + * 父ID + */ + @Column(name = "parent_id") + private Integer parentId; + /** + * 权限编码 + */ + @Column(name = "permission_code") + private String permissionCode; + /** + * 权限名称 + */ + @Column(name = "permission_name") + private String permissionName; + /** + * 权限路由 + */ + @Column(name = "permission_route") + private String permissionRoute; + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + /** + * 创建人 + */ + @Column(name = "creator_user") + private String creatorUser; + /** + * 更新时间 + */ + @Column(name = "modify_time") + private Date modifyTime; + /** + * 更新人 + */ + @Column(name = "modifier_user") + private String modifierUser; + /** + * 删除状态 + */ + @Column(name = "deleted") + private Integer deleted; + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/model/SysUserInfo.java b/springboot-saToken/src/main/java/com/pancm/model/SysUserInfo.java new file mode 100644 index 0000000..ce7e6c0 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/model/SysUserInfo.java @@ -0,0 +1,96 @@ +package com.pancm.model; + + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Table; +import java.io.Serializable; +import java.sql.Date; + + /** +* @Title: 系统用户表(SysUserInfo)实体类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Data +@Table(name = "sys_user_info") +public class SysUserInfo implements Serializable { + private static final long serialVersionUID = 542441098648270310L; + /** + * 主键ID + */ + @Column(name = "id") + private Integer id; + /** + * 用户名 + */ + @Column(name = "user_name") + private String userName; + /** + * 昵称 + */ + @Column(name = "nick_name") + private String nickName; + /** + * 密码 + */ + @Column(name = "password") + private String password; + /** + * 启用状态 0 否 1是 + */ + @Column(name = "user_enable") + private Integer userEnable; + /** + * 角色ID 1 管理员 2 普通用户 + */ + @Column(name = "role_id") + private Integer roleId; + /** + * 工号 + */ + @Column(name = "job_no") + private String jobNo; + /** + * 员工联系方式 + */ + @Column(name = "mobile") + private String mobile; + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + /** + * 创建人 + */ + @Column(name = "creator_user") + private String creatorUser; + /** + * 更新时间 + */ + @Column(name = "modify_time") + private Date modifyTime; + /** + * 更新人 + */ + @Column(name = "modifier_user") + private String modifierUser; + /** + * 删除状态 + */ + @Column(name = "deleted") + private Integer deleted; + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/model/SysUserRole.java b/springboot-saToken/src/main/java/com/pancm/model/SysUserRole.java new file mode 100644 index 0000000..a9e1c6a --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/model/SysUserRole.java @@ -0,0 +1,71 @@ +package com.pancm.model; + + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Table; +import java.io.Serializable; +import java.sql.Date; + + /** +* @Title: 用户角色表(SysUserRole)实体类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Data +@Table(name = "sys_user_role") +public class SysUserRole implements Serializable { + private static final long serialVersionUID = 497044291679355487L; + /** + * 主键ID + */ + @Column(name = "id") + private Integer id; + /** + * 角色名 + */ + @Column(name = "role_name") + private String roleName; + /** + * 启用状态 0 否 1是 + */ + @Column(name = "user_enable") + private Integer userEnable; + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + /** + * 创建人 + */ + @Column(name = "creator_user") + private String creatorUser; + /** + * 更新时间 + */ + @Column(name = "modify_time") + private Date modifyTime; + /** + * 更新人 + */ + @Column(name = "modifier_user") + private String modifierUser; + /** + * 删除状态 + */ + @Column(name = "deleted") + private Integer deleted; + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/model/SysUserRolePermission.java b/springboot-saToken/src/main/java/com/pancm/model/SysUserRolePermission.java new file mode 100644 index 0000000..ce627d7 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/model/SysUserRolePermission.java @@ -0,0 +1,71 @@ +package com.pancm.model; + + +import com.alibaba.fastjson.JSONObject; +import lombok.Data; + +import javax.persistence.Column; +import javax.persistence.Table; +import java.io.Serializable; +import java.sql.Date; + + /** +* @Title: 用户角色权限表(SysUserRolePermission)实体类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Data +@Table(name = "sys_user_role_permission") +public class SysUserRolePermission implements Serializable { + private static final long serialVersionUID = -16015545300523438L; + /** + * 主键ID + */ + @Column(name = "id") + private Integer id; + /** + * 角色ID + */ + @Column(name = "role_id") + private Integer roleId; + /** + * 权限ID + */ + @Column(name = "permission_id") + private Integer permissionId; + /** + * 创建时间 + */ + @Column(name = "create_time") + private Date createTime; + /** + * 创建人 + */ + @Column(name = "creator_user") + private String creatorUser; + /** + * 更新时间 + */ + @Column(name = "modify_time") + private Date modifyTime; + /** + * 更新人 + */ + @Column(name = "modifier_user") + private String modifierUser; + /** + * 删除状态 + */ + @Column(name = "deleted") + private Integer deleted; + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/service/ISysPermissionService.java b/springboot-saToken/src/main/java/com/pancm/service/ISysPermissionService.java new file mode 100644 index 0000000..e692918 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/ISysPermissionService.java @@ -0,0 +1,61 @@ +package com.pancm.service; + +import com.pancm.vo.SysPermissionVO; +import com.pancm.vo.ApiResult; +import java.util.List; + + + /** +* @Title: 权限表(SysPermission)表服务接口 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +public interface ISysPermissionService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysPermissionVO queryById(Integer id); + + + /** + * 通过实体作为筛选条件查询 + * + * @param sysPermissionVO 实例对象 + * @return 对象列表 + */ + ApiResult list(SysPermissionVO sysPermissionVO); + + + /** + * 新增数据 + * + * @param sysPermissionVO 实例对象 + * @return 实例对象 + */ + int insert(SysPermissionVO sysPermissionVO); + + /** + * 修改数据 + * + * @param sysPermissionVO 实例对象 + * @return 实例对象 + */ + int update(SysPermissionVO sysPermissionVO); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + + List queryRolePermissionByRoleId(Integer roleId); + } diff --git a/springboot-saToken/src/main/java/com/pancm/service/ISysUserInfoService.java b/springboot-saToken/src/main/java/com/pancm/service/ISysUserInfoService.java new file mode 100644 index 0000000..6dbbcc3 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/ISysUserInfoService.java @@ -0,0 +1,61 @@ +package com.pancm.service; + +import com.pancm.vo.SysUserInfoVO; +import com.pancm.vo.ApiResult; +import java.util.List; + + + /** +* @Title: 系统用户表(SysUserInfo)表服务接口 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +public interface ISysUserInfoService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysUserInfoVO queryById(Integer id); + + + /** + * 通过实体作为筛选条件查询 + * + * @param sysUserInfoVO 实例对象 + * @return 对象列表 + */ + ApiResult list(SysUserInfoVO sysUserInfoVO); + + + /** + * 新增数据 + * + * @param sysUserInfoVO 实例对象 + * @return 实例对象 + */ + int insert(SysUserInfoVO sysUserInfoVO); + + /** + * 修改数据 + * + * @param sysUserInfoVO 实例对象 + * @return 实例对象 + */ + int update(SysUserInfoVO sysUserInfoVO); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + + SysUserInfoVO queryByUserName(String username); + } diff --git a/springboot-saToken/src/main/java/com/pancm/service/ISysUserRolePermissionService.java b/springboot-saToken/src/main/java/com/pancm/service/ISysUserRolePermissionService.java new file mode 100644 index 0000000..fb43ea3 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/ISysUserRolePermissionService.java @@ -0,0 +1,60 @@ +package com.pancm.service; + +import com.pancm.vo.SysUserRolePermissionVO; +import com.pancm.vo.ApiResult; +import java.util.List; + + + /** +* @Title: 用户角色权限表(SysUserRolePermission)表服务接口 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +public interface ISysUserRolePermissionService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysUserRolePermissionVO queryById(Integer id); + + + /** + * 通过实体作为筛选条件查询 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 对象列表 + */ + ApiResult list(SysUserRolePermissionVO sysUserRolePermissionVO); + + + /** + * 新增数据 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 实例对象 + */ + int insert(SysUserRolePermissionVO sysUserRolePermissionVO); + + /** + * 修改数据 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 实例对象 + */ + int update(SysUserRolePermissionVO sysUserRolePermissionVO); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/springboot-saToken/src/main/java/com/pancm/service/ISysUserRoleService.java b/springboot-saToken/src/main/java/com/pancm/service/ISysUserRoleService.java new file mode 100644 index 0000000..cafb4d4 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/ISysUserRoleService.java @@ -0,0 +1,60 @@ +package com.pancm.service; + +import com.pancm.vo.SysUserRoleVO; +import com.pancm.vo.ApiResult; +import java.util.List; + + + /** +* @Title: 用户角色表(SysUserRole)表服务接口 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +public interface ISysUserRoleService { + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + SysUserRoleVO queryById(Integer id); + + + /** + * 通过实体作为筛选条件查询 + * + * @param sysUserRoleVO 实例对象 + * @return 对象列表 + */ + ApiResult list(SysUserRoleVO sysUserRoleVO); + + + /** + * 新增数据 + * + * @param sysUserRoleVO 实例对象 + * @return 实例对象 + */ + int insert(SysUserRoleVO sysUserRoleVO); + + /** + * 修改数据 + * + * @param sysUserRoleVO 实例对象 + * @return 实例对象 + */ + int update(SysUserRoleVO sysUserRoleVO); + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + boolean deleteById(Integer id); + +} diff --git a/springboot-saToken/src/main/java/com/pancm/service/impl/SysPermissionServiceImpl.java b/springboot-saToken/src/main/java/com/pancm/service/impl/SysPermissionServiceImpl.java new file mode 100644 index 0000000..e063747 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/impl/SysPermissionServiceImpl.java @@ -0,0 +1,105 @@ +package com.pancm.service.impl; + + +import com.pancm.vo.SysPermissionVO; +import com.pancm.model.SysPermission; +import com.pancm.dao.SysPermissionDao; +import com.pancm.service.ISysPermissionService; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.pancm.vo.ApiResult; +import com.pancm.vo.PageResult; +import org.springframework.stereotype.Service; +import org.springframework.beans.BeanUtils; +import javax.annotation.Resource; +import java.util.List; + + + +/** +* @Title: 权限表(SysPermission)表服务实现类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Service("sysPermissionService") +public class SysPermissionServiceImpl implements ISysPermissionService { + @Resource + private SysPermissionDao sysPermissionDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SysPermissionVO queryById(Integer id) { + return this.sysPermissionDao.queryById(id); + } + + + /** + * 根据条件查询 + * + * @return 实例对象的集合 + */ + @Override + public ApiResult list(SysPermissionVO sysPermission) { + int pageNum = sysPermission.getPageNum(); + int pageSize = sysPermission.getPageSize(); + Page page = PageHelper.startPage(pageNum, pageSize); + List result = sysPermissionDao.queryAll(sysPermission); + return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum)); + + } + + /** + * 新增数据 + * + * @param sysPermissionVO 实例对象 + * @return 实例对象 + */ + @Override + public int insert(SysPermissionVO sysPermissionVO) { + SysPermission sysPermission = new SysPermission(); + BeanUtils.copyProperties(sysPermissionVO,sysPermission); + return sysPermissionDao.insert(sysPermission); + } + + /** + * 修改数据 + * + * @param sysPermissionVO 实例对象 + * @return 实例对象 + */ + @Override + public int update(SysPermissionVO sysPermissionVO) { + SysPermission sysPermission = new SysPermission(); + BeanUtils.copyProperties(sysPermissionVO,sysPermission); + return sysPermissionDao.update(sysPermission); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.sysPermissionDao.deleteById(id) > 0; + } + + /** + * @param roleId + * @return + */ + @Override + public List queryRolePermissionByRoleId(Integer roleId) { + return sysPermissionDao.queryRolePermissionByRoleId(roleId); + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserInfoServiceImpl.java b/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserInfoServiceImpl.java new file mode 100644 index 0000000..e150a35 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserInfoServiceImpl.java @@ -0,0 +1,106 @@ +package com.pancm.service.impl; + + +import com.pancm.enums.PcmYesNoEnum; +import com.pancm.vo.SysUserInfoVO; +import com.pancm.model.SysUserInfo; +import com.pancm.dao.SysUserInfoDao; +import com.pancm.service.ISysUserInfoService; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.pancm.vo.ApiResult; +import com.pancm.vo.PageResult; +import org.springframework.stereotype.Service; +import org.springframework.beans.BeanUtils; +import javax.annotation.Resource; +import java.util.List; + + + +/** +* @Title: 系统用户表(SysUserInfo)表服务实现类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@Service("sysUserInfoService") +public class SysUserInfoServiceImpl implements ISysUserInfoService { + @Resource + private SysUserInfoDao sysUserInfoDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SysUserInfoVO queryById(Integer id) { + return this.sysUserInfoDao.queryById(id); + } + + + /** + * 根据条件查询 + * + * @return 实例对象的集合 + */ + @Override + public ApiResult list(SysUserInfoVO sysUserInfo) { + int pageNum = sysUserInfo.getPageNum(); + int pageSize = sysUserInfo.getPageSize(); + Page page = PageHelper.startPage(pageNum, pageSize); + List result = sysUserInfoDao.queryAll(sysUserInfo); + return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum)); + + } + + /** + * 新增数据 + * + * @param sysUserInfoVO 实例对象 + * @return 实例对象 + */ + @Override + public int insert(SysUserInfoVO sysUserInfoVO) { + SysUserInfo sysUserInfo = new SysUserInfo(); + BeanUtils.copyProperties(sysUserInfoVO,sysUserInfo); + return sysUserInfoDao.insert(sysUserInfo); + } + + /** + * 修改数据 + * + * @param sysUserInfoVO 实例对象 + * @return 实例对象 + */ + @Override + public int update(SysUserInfoVO sysUserInfoVO) { + SysUserInfo sysUserInfo = new SysUserInfo(); + BeanUtils.copyProperties(sysUserInfoVO,sysUserInfo); + return sysUserInfoDao.update(sysUserInfo); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.sysUserInfoDao.deleteById(id) > 0; + } + + /** + * @param username + * @return + */ + @Override + public SysUserInfoVO queryByUserName(String username) { + return sysUserInfoDao.findOne(SysUserInfoVO.of().setUserName(username).setDeleted(PcmYesNoEnum.NO.getIndex())); + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRolePermissionServiceImpl.java b/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRolePermissionServiceImpl.java new file mode 100644 index 0000000..cf4e56d --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRolePermissionServiceImpl.java @@ -0,0 +1,96 @@ +package com.pancm.service.impl; + + +import com.pancm.vo.SysUserRolePermissionVO; +import com.pancm.model.SysUserRolePermission; +import com.pancm.dao.SysUserRolePermissionDao; +import com.pancm.service.ISysUserRolePermissionService; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.pancm.vo.ApiResult; +import com.pancm.vo.PageResult; +import org.springframework.stereotype.Service; +import org.springframework.beans.BeanUtils; +import javax.annotation.Resource; +import java.util.List; + + + +/** +* @Title: 用户角色权限表(SysUserRolePermission)表服务实现类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Service("sysUserRolePermissionService") +public class SysUserRolePermissionServiceImpl implements ISysUserRolePermissionService { + @Resource + private SysUserRolePermissionDao sysUserRolePermissionDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SysUserRolePermissionVO queryById(Integer id) { + return this.sysUserRolePermissionDao.queryById(id); + } + + + /** + * 根据条件查询 + * + * @return 实例对象的集合 + */ + @Override + public ApiResult list(SysUserRolePermissionVO sysUserRolePermission) { + int pageNum = sysUserRolePermission.getPageNum(); + int pageSize = sysUserRolePermission.getPageSize(); + Page page = PageHelper.startPage(pageNum, pageSize); + List result = sysUserRolePermissionDao.queryAll(sysUserRolePermission); + return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum)); + + } + + /** + * 新增数据 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 实例对象 + */ + @Override + public int insert(SysUserRolePermissionVO sysUserRolePermissionVO) { + SysUserRolePermission sysUserRolePermission = new SysUserRolePermission(); + BeanUtils.copyProperties(sysUserRolePermissionVO,sysUserRolePermission); + return sysUserRolePermissionDao.insert(sysUserRolePermission); + } + + /** + * 修改数据 + * + * @param sysUserRolePermissionVO 实例对象 + * @return 实例对象 + */ + @Override + public int update(SysUserRolePermissionVO sysUserRolePermissionVO) { + SysUserRolePermission sysUserRolePermission = new SysUserRolePermission(); + BeanUtils.copyProperties(sysUserRolePermissionVO,sysUserRolePermission); + return sysUserRolePermissionDao.update(sysUserRolePermission); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.sysUserRolePermissionDao.deleteById(id) > 0; + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRoleServiceImpl.java b/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRoleServiceImpl.java new file mode 100644 index 0000000..4146d4f --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/service/impl/SysUserRoleServiceImpl.java @@ -0,0 +1,96 @@ +package com.pancm.service.impl; + + +import com.pancm.vo.SysUserRoleVO; +import com.pancm.model.SysUserRole; +import com.pancm.dao.SysUserRoleDao; +import com.pancm.service.ISysUserRoleService; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import com.pancm.vo.ApiResult; +import com.pancm.vo.PageResult; +import org.springframework.stereotype.Service; +import org.springframework.beans.BeanUtils; +import javax.annotation.Resource; +import java.util.List; + + + +/** +* @Title: 用户角色表(SysUserRole)表服务实现类 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@Service("sysUserRoleService") +public class SysUserRoleServiceImpl implements ISysUserRoleService { + @Resource + private SysUserRoleDao sysUserRoleDao; + + /** + * 通过ID查询单条数据 + * + * @param id 主键 + * @return 实例对象 + */ + @Override + public SysUserRoleVO queryById(Integer id) { + return this.sysUserRoleDao.queryById(id); + } + + + /** + * 根据条件查询 + * + * @return 实例对象的集合 + */ + @Override + public ApiResult list(SysUserRoleVO sysUserRole) { + int pageNum = sysUserRole.getPageNum(); + int pageSize = sysUserRole.getPageSize(); + Page page = PageHelper.startPage(pageNum, pageSize); + List result = sysUserRoleDao.queryAll(sysUserRole); + return ApiResult.success(new PageResult<>(page.getTotal(), result, pageSize, pageNum)); + + } + + /** + * 新增数据 + * + * @param sysUserRoleVO 实例对象 + * @return 实例对象 + */ + @Override + public int insert(SysUserRoleVO sysUserRoleVO) { + SysUserRole sysUserRole = new SysUserRole(); + BeanUtils.copyProperties(sysUserRoleVO,sysUserRole); + return sysUserRoleDao.insert(sysUserRole); + } + + /** + * 修改数据 + * + * @param sysUserRoleVO 实例对象 + * @return 实例对象 + */ + @Override + public int update(SysUserRoleVO sysUserRoleVO) { + SysUserRole sysUserRole = new SysUserRole(); + BeanUtils.copyProperties(sysUserRoleVO,sysUserRole); + return sysUserRoleDao.update(sysUserRole); + } + + /** + * 通过主键删除数据 + * + * @param id 主键 + * @return 是否成功 + */ + @Override + public boolean deleteById(Integer id) { + return this.sysUserRoleDao.deleteById(id) > 0; + } +} diff --git a/springboot-saToken/src/main/java/com/pancm/vo/SysPermissionVO.java b/springboot-saToken/src/main/java/com/pancm/vo/SysPermissionVO.java new file mode 100644 index 0000000..9692abc --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/vo/SysPermissionVO.java @@ -0,0 +1,81 @@ +package com.pancm.vo; + +import java.io.Serializable; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.sql.Date; +import com.pancm.vo.BasePage; + +/** +* @Title: 权限表(SysPermission)请求响应对象 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@ApiModel(value = "SysPermission", description = "权限表") +@Data +public class SysPermissionVO extends BasePage implements Serializable { + private static final long serialVersionUID = 424918937095450507L; + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + private Integer id; + /** + * 父ID + */ + @ApiModelProperty(value = "父ID") + private Integer parentId; + /** + * 权限编码 + */ + @ApiModelProperty(value = "权限编码") + private String permissionCode; + /** + * 权限名称 + */ + @ApiModelProperty(value = "权限名称") + private String permissionName; + /** + * 权限路由 + */ + @ApiModelProperty(value = "权限路由") + private String permissionRoute; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String creatorUser; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date modifyTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String modifierUser; + /** + * 删除状态 + */ + @ApiModelProperty(value = "删除状态") + private Integer deleted; + + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/vo/SysUserInfoVO.java b/springboot-saToken/src/main/java/com/pancm/vo/SysUserInfoVO.java new file mode 100644 index 0000000..ac50d20 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/vo/SysUserInfoVO.java @@ -0,0 +1,103 @@ +package com.pancm.vo; + +import java.io.Serializable; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.sql.Date; +import java.util.List; + +import com.pancm.vo.BasePage; +import lombok.EqualsAndHashCode; +import lombok.experimental.Accessors; + +/** +* @Title: 系统用户表(SysUserInfo)请求响应对象 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:42 +*/ +@ApiModel(value = "SysUserInfo", description = "系统用户表") +@EqualsAndHashCode(callSuper = true) +@Accessors(chain = true) +@Data(staticConstructor = "of") +public class SysUserInfoVO extends BasePage implements Serializable { + private static final long serialVersionUID = 606535805692267915L; + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + private Integer id; + /** + * 用户名 + */ + @ApiModelProperty(value = "用户名") + private String userName; + /** + * 昵称 + */ + @ApiModelProperty(value = "昵称") + private String nickName; + /** + * 密码 + */ + @ApiModelProperty(value = "密码") + private String password; + /** + * 启用状态 0 否 1是 + */ + @ApiModelProperty(value = "启用状态 0 否 1是") + private Integer userEnable; + /** + * 角色ID 1 管理员 2 普通用户 + */ + @ApiModelProperty(value = "角色ID 1 管理员 2 普通用户") + private Integer roleId; + /** + * 工号 + */ + @ApiModelProperty(value = "工号") + private String jobNo; + /** + * 员工联系方式 + */ + @ApiModelProperty(value = "员工联系方式") + private String mobile; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String creatorUser; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date modifyTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String modifierUser; + /** + * 删除状态 + */ + @ApiModelProperty(value = "删除状态") + private Integer deleted; + + @ApiModelProperty(value = "权限列表") + private List permissionDTOLists; + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/vo/SysUserRolePermissionVO.java b/springboot-saToken/src/main/java/com/pancm/vo/SysUserRolePermissionVO.java new file mode 100644 index 0000000..d4f8a56 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/vo/SysUserRolePermissionVO.java @@ -0,0 +1,71 @@ +package com.pancm.vo; + +import java.io.Serializable; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.sql.Date; +import com.pancm.vo.BasePage; + +/** +* @Title: 用户角色权限表(SysUserRolePermission)请求响应对象 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@ApiModel(value = "SysUserRolePermission", description = "用户角色权限表") +@Data +public class SysUserRolePermissionVO extends BasePage implements Serializable { + private static final long serialVersionUID = -48855880536661833L; + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + private Integer id; + /** + * 角色ID + */ + @ApiModelProperty(value = "角色ID") + private Integer roleId; + /** + * 权限ID + */ + @ApiModelProperty(value = "权限ID") + private Integer permissionId; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String creatorUser; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date modifyTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String modifierUser; + /** + * 删除状态 + */ + @ApiModelProperty(value = "删除状态") + private Integer deleted; + + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/java/com/pancm/vo/SysUserRoleVO.java b/springboot-saToken/src/main/java/com/pancm/vo/SysUserRoleVO.java new file mode 100644 index 0000000..80d1251 --- /dev/null +++ b/springboot-saToken/src/main/java/com/pancm/vo/SysUserRoleVO.java @@ -0,0 +1,71 @@ +package com.pancm.vo; + +import java.io.Serializable; +import com.alibaba.fastjson.JSONObject; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import java.sql.Date; +import com.pancm.vo.BasePage; + +/** +* @Title: 用户角色表(SysUserRole)请求响应对象 +* @Description: +* @Version:1.0.0 +* @Since:jdk1.8 +* @author pancm +* @date 2024-11-23 09:31:43 +*/ +@ApiModel(value = "SysUserRole", description = "用户角色表") +@Data +public class SysUserRoleVO extends BasePage implements Serializable { + private static final long serialVersionUID = 226114050325384071L; + /** + * 主键ID + */ + @ApiModelProperty(value = "主键ID") + private Integer id; + /** + * 角色名 + */ + @ApiModelProperty(value = "角色名") + private String roleName; + /** + * 启用状态 0 否 1是 + */ + @ApiModelProperty(value = "启用状态 0 否 1是") + private Integer userEnable; + /** + * 创建时间 + */ + @ApiModelProperty(value = "创建时间") + private Date createTime; + /** + * 创建人 + */ + @ApiModelProperty(value = "创建人") + private String creatorUser; + /** + * 更新时间 + */ + @ApiModelProperty(value = "更新时间") + private Date modifyTime; + /** + * 更新人 + */ + @ApiModelProperty(value = "更新人") + private String modifierUser; + /** + * 删除状态 + */ + @ApiModelProperty(value = "删除状态") + private Integer deleted; + + + + @Override + public String toString(){ + return JSONObject.toJSONString(this); + } + +} diff --git a/springboot-saToken/src/main/resources/pancm/mapper/SysPermissionMapper.xml b/springboot-saToken/src/main/resources/pancm/mapper/SysPermissionMapper.xml new file mode 100644 index 0000000..3ba524c --- /dev/null +++ b/springboot-saToken/src/main/resources/pancm/mapper/SysPermissionMapper.xml @@ -0,0 +1,185 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into sys_permission(parent_id, permission_code, permission_name, permission_route, create_time, creator_user, modify_time, modifier_user, deleted) + values (#{parentId}, #{permissionCode}, #{permissionName}, #{permissionRoute}, #{createTime}, #{creatorUser}, #{modifyTime}, #{modifierUser}, #{deleted}) + + + + insert into sys_permission(parent_id, permission_code, permission_name, permission_route, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.parentId}, #{entity.permissionCode}, #{entity.permissionName}, #{entity.permissionRoute}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + + + + insert into sys_permission(parent_id, permission_code, permission_name, permission_route, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.parentId}, #{entity.permissionCode}, #{entity.permissionName}, #{entity.permissionRoute}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + on duplicate key update +parent_id = values(parent_id) , permission_code = values(permission_code) , permission_name = values(permission_name) , permission_route = values(permission_route) , create_time = values(create_time) , creator_user = values(creator_user) , modify_time = values(modify_time) , modifier_user = values(modifier_user) , deleted = values(deleted) + + + + update sys_permission + + + parent_id = #{parentId}, + + + permission_code = #{permissionCode}, + + + permission_name = #{permissionName}, + + + permission_route = #{permissionRoute}, + + + create_time = #{createTime}, + + + creator_user = #{creatorUser}, + + + modify_time = #{modifyTime}, + + + modifier_user = #{modifierUser}, + + + deleted = #{deleted}, + + + where id = #{id} + + + + + delete from sys_permission where id = #{id} + + + + diff --git a/springboot-saToken/src/main/resources/pancm/mapper/SysUserInfoMapper.xml b/springboot-saToken/src/main/resources/pancm/mapper/SysUserInfoMapper.xml new file mode 100644 index 0000000..9341085 --- /dev/null +++ b/springboot-saToken/src/main/resources/pancm/mapper/SysUserInfoMapper.xml @@ -0,0 +1,198 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into sys_user_info(user_name, nick_name, password, user_enable, role_id, job_no, mobile, create_time, creator_user, modify_time, modifier_user, deleted) + values (#{userName}, #{nickName}, #{password}, #{userEnable}, #{roleId}, #{jobNo}, #{mobile}, #{createTime}, #{creatorUser}, #{modifyTime}, #{modifierUser}, #{deleted}) + + + + insert into sys_user_info(user_name, nick_name, password, user_enable, role_id, job_no, mobile, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.userName}, #{entity.nickName}, #{entity.password}, #{entity.userEnable}, #{entity.roleId}, #{entity.jobNo}, #{entity.mobile}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + + + + insert into sys_user_info(user_name, nick_name, password, user_enable, role_id, job_no, mobile, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.userName}, #{entity.nickName}, #{entity.password}, #{entity.userEnable}, #{entity.roleId}, #{entity.jobNo}, #{entity.mobile}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + on duplicate key update +user_name = values(user_name) , nick_name = values(nick_name) , password = values(password) , user_enable = values(user_enable) , role_id = values(role_id) , job_no = values(job_no) , mobile = values(mobile) , create_time = values(create_time) , creator_user = values(creator_user) , modify_time = values(modify_time) , modifier_user = values(modifier_user) , deleted = values(deleted) + + + + update sys_user_info + + + user_name = #{userName}, + + + nick_name = #{nickName}, + + + password = #{password}, + + + user_enable = #{userEnable}, + + + role_id = #{roleId}, + + + job_no = #{jobNo}, + + + mobile = #{mobile}, + + + create_time = #{createTime}, + + + creator_user = #{creatorUser}, + + + modify_time = #{modifyTime}, + + + modifier_user = #{modifierUser}, + + + deleted = #{deleted}, + + + where id = #{id} + + + + + delete from sys_user_info where id = #{id} + + + + diff --git a/springboot-saToken/src/main/resources/pancm/mapper/SysUserRoleMapper.xml b/springboot-saToken/src/main/resources/pancm/mapper/SysUserRoleMapper.xml new file mode 100644 index 0000000..88e4a05 --- /dev/null +++ b/springboot-saToken/src/main/resources/pancm/mapper/SysUserRoleMapper.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into sys_user_role(role_name, user_enable, create_time, creator_user, modify_time, modifier_user, deleted) + values (#{roleName}, #{userEnable}, #{createTime}, #{creatorUser}, #{modifyTime}, #{modifierUser}, #{deleted}) + + + + insert into sys_user_role(role_name, user_enable, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.roleName}, #{entity.userEnable}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + + + + insert into sys_user_role(role_name, user_enable, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.roleName}, #{entity.userEnable}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + on duplicate key update +role_name = values(role_name) , user_enable = values(user_enable) , create_time = values(create_time) , creator_user = values(creator_user) , modify_time = values(modify_time) , modifier_user = values(modifier_user) , deleted = values(deleted) + + + + update sys_user_role + + + role_name = #{roleName}, + + + user_enable = #{userEnable}, + + + create_time = #{createTime}, + + + creator_user = #{creatorUser}, + + + modify_time = #{modifyTime}, + + + modifier_user = #{modifierUser}, + + + deleted = #{deleted}, + + + where id = #{id} + + + + + delete from sys_user_role where id = #{id} + + + + diff --git a/springboot-saToken/src/main/resources/pancm/mapper/SysUserRolePermissionMapper.xml b/springboot-saToken/src/main/resources/pancm/mapper/SysUserRolePermissionMapper.xml new file mode 100644 index 0000000..471f174 --- /dev/null +++ b/springboot-saToken/src/main/resources/pancm/mapper/SysUserRolePermissionMapper.xml @@ -0,0 +1,148 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into sys_user_role_permission(role_id, permission_id, create_time, creator_user, modify_time, modifier_user, deleted) + values (#{roleId}, #{permissionId}, #{createTime}, #{creatorUser}, #{modifyTime}, #{modifierUser}, #{deleted}) + + + + insert into sys_user_role_permission(role_id, permission_id, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.roleId}, #{entity.permissionId}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + + + + insert into sys_user_role_permission(role_id, permission_id, create_time, creator_user, modify_time, modifier_user, deleted) + values + + (#{entity.roleId}, #{entity.permissionId}, #{entity.createTime}, #{entity.creatorUser}, #{entity.modifyTime}, #{entity.modifierUser}, #{entity.deleted}) + + on duplicate key update +role_id = values(role_id) , permission_id = values(permission_id) , create_time = values(create_time) , creator_user = values(creator_user) , modify_time = values(modify_time) , modifier_user = values(modifier_user) , deleted = values(deleted) + + + + update sys_user_role_permission + + + role_id = #{roleId}, + + + permission_id = #{permissionId}, + + + create_time = #{createTime}, + + + creator_user = #{creatorUser}, + + + modify_time = #{modifyTime}, + + + modifier_user = #{modifierUser}, + + + deleted = #{deleted}, + + + where id = #{id} + + + + + delete from sys_user_role_permission where id = #{id} + + + +