diff --git a/springboot-role/src/main/java/com/tiesheng/role/controller/CommRoleController.java b/springboot-role/src/main/java/com/tiesheng/role/controller/CommRoleController.java new file mode 100644 index 0000000..aeeb775 --- /dev/null +++ b/springboot-role/src/main/java/com/tiesheng/role/controller/CommRoleController.java @@ -0,0 +1,104 @@ +package com.tiesheng.role.controller; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.tiesheng.role.pojos.dao.CoreRoleAuthority; +import com.tiesheng.role.pojos.dao.CoreRoleServer; +import com.tiesheng.role.pojos.dto.OwnerMenuDTO; +import com.tiesheng.role.pojos.dto.OwnerPointDTO; +import com.tiesheng.role.pojos.vo.ServiceMenuVO; +import com.tiesheng.role.service.CoreRoleService; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.TokenBean; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@RestController +@RequestMapping("/comm/role") +public class CommRoleController { + + @Resource + CoreRoleService coreRoleService; + + + /** + * 获取自己拥有的服务 + * + * @return + */ + @GetMapping("/owner/server") + public ApiResp> ownerServer(TokenBean tokenBean) { + List allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId()); + List list = allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList()); + + List roleServerList = new ArrayList<>(); + if (CollUtil.isNotEmpty(list)) { + roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper() + .in("id", list) + .eq(CoreRoleServer.IS_DELETED, 0) + .eq("is_open", 1) + ); + } + + return ApiResp.respOK(roleServerList); + } + + + /** + * 获取自己拥有的菜单 + * + * @return + */ + @GetMapping("/owner/menu") + public ApiResp> ownerMenu(@Valid OwnerMenuDTO dto, TokenBean tokenBean) { + List ownerMenus = coreRoleService.getOwnerMenus(tokenBean.getId(), tokenBean.getRoleId(), dto); + return ApiResp.respOK(ownerMenus); + } + + /** + * 获取自己拥有的功能点 + * + * @return + */ + @GetMapping("/owner/point") + public ApiResp> ownerPoint(@Valid OwnerPointDTO dto, TokenBean tokenBean) { + + List allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId()); + + String parentId; + if (StrUtil.isNotEmpty(dto.getParentNo())) { + CoreRoleAuthority selected = coreRoleService.getAuthorityMapper().selectOne(new QueryWrapper() + .eq("no", dto.getParentNo()) + .eq("is_deleted", 0) + .last("limit 1") + ); + parentId = selected == null ? "" : selected.getId(); + } else { + parentId = ""; + } + + List collect = allOwnerMenus.stream() + .filter(it -> Objects.equals(it.getType(), "point")) + .filter(it -> it.getService().equals(dto.getService())) + .filter(it -> it.getPlatform().equals(dto.getPlatform())) + .filter(it -> { + if (StrUtil.isNotEmpty(parentId)) { + return parentId.equals(it.getParent()); + } + return true; + }).collect(Collectors.toList()); + + return ApiResp.respOK(collect); + } + + +} diff --git a/springboot-role/src/main/java/com/tiesheng/role/controller/RoleController.java b/springboot-role/src/main/java/com/tiesheng/role/controller/RoleController.java deleted file mode 100644 index e7c9b5d..0000000 --- a/springboot-role/src/main/java/com/tiesheng/role/controller/RoleController.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.tiesheng.role.controller; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.tiesheng.annotation.role.RoleAuthority; -import com.tiesheng.role.pojos.dao.*; -import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO; -import com.tiesheng.role.pojos.dto.MenuListDTO; -import com.tiesheng.role.pojos.dto.OwnerMenuDTO; -import com.tiesheng.role.pojos.dto.OwnerPointDTO; -import com.tiesheng.role.pojos.vo.GroupTypeDTO; -import com.tiesheng.role.pojos.vo.RoleUserPageVO; -import com.tiesheng.role.pojos.vo.ServiceMenuVO; -import com.tiesheng.role.service.CoreRoleService; -import com.tiesheng.util.exception.ApiException; -import com.tiesheng.util.pojos.ApiResp; -import com.tiesheng.util.pojos.IdDTO; -import com.tiesheng.util.pojos.PageDTO; -import com.tiesheng.util.pojos.TokenBean; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.validation.Valid; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.stream.Collectors; - -@RestController -@RequestMapping("/role") -@RoleAuthority(value = "role", group = "role") -public class RoleController { - - @Resource - CoreRoleService coreRoleService; - - - /** - * 角色列表 - * - * @return - */ - @GetMapping("/group/list") - @RoleAuthority(value = "groupList") - public ApiResp> groupList(@Valid GroupTypeDTO dto) { - return ApiResp.respOK(coreRoleService.list( - new QueryWrapper() - .eq("is_deleted", 0) - .eq("type", dto.getType()) - .orderByAsc("sort") - )); - } - - - /** - * 角色编辑 - * - * @param roleGroup - * @return - */ - @PostMapping("/group/update") - @RoleAuthority(value = "groupUpdate") - public ApiResp groupUpdate(@RequestBody CoreRoleGroup roleGroup) { - - if (StrUtil.isNotEmpty(roleGroup.getId())) { - roleGroup.setType(null); - roleGroup.setIsSystem(null); - } - - coreRoleService.saveOrUpdate(roleGroup); - return ApiResp.respOK(""); - } - - - /** - * 角色-删除 - * - * @return - */ - @PostMapping("/group/deleted") - @RoleAuthority(value = "groupDeleted") - public ApiResp groupDeleted(@RequestBody @Valid IdDTO dto) { - - CoreRoleGroup byId = coreRoleService.getById(dto.getId()); - if (byId == null || byId.getIsDeleted() != 0) { - throw new ApiException("角色不存在或已删除"); - } - - if (byId.getIsSystem() == 1) { - throw new ApiException(StrUtil.format("该{}无法删除", - Objects.equals(byId.getType(), "role") ? "角色" : "职位")); - } - - CoreRoleGroup coreServiceMenu = new CoreRoleGroup(); - coreServiceMenu.setId(dto.getId()); - coreServiceMenu.setIsDeleted(1); - coreRoleService.updateById(coreServiceMenu); - return ApiResp.respOK(""); - } - - - /** - * 获取角色的权限 - * - * @return - */ - @GetMapping("/group/rx/list") - public ApiResp> groupRxList(@Valid IdDTO dto) { - List list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper() - .eq(CoreRoleGroupRx.IS_DELETED, 0) - .eq("group_id", dto.getId()) - ); - return ApiResp.respOK(list); - } - - - /** - * 角色的权限编辑 - * - * @return - */ - @PostMapping("/group/rx/update") - @RoleAuthority(value = "groupRxUpdate") - public ApiResp groupRxUpdate(@RequestBody @Valid GroupRxUpdateDTO dto) { - coreRoleService.updateGroupRx(dto); - return ApiResp.respOK(""); - } - - - /** - * 授权列表 - * - * @return - */ - @GetMapping("/user/page") - @RoleAuthority(value = "userPage") - public ApiResp> userPage(PageDTO dto) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("cru.is_deleted", 0); - dto.likeColumns(queryWrapper, "cru.ext1", "cru.ext2", "cru.ext3"); - queryWrapper.orderByAsc("cru.user_id"); - - Page page = dto.pageObj(); - coreRoleService.getUserMapper().page(page, queryWrapper); - - return ApiResp.respOK(page.getRecords(), page.getTotal()); - } - - - /** - * 授权调整 - * - * @return - */ - @PostMapping("/user/update") - @RoleAuthority(value = "userUpdate") - public ApiResp userUpdate(@RequestBody CoreRoleUser roleUser) { - coreRoleService.roleUserUpdate(roleUser); - return ApiResp.respOK(""); - } - - - /** - * 授权-删除 - * - * @return - */ - @PostMapping("/user/deleted") - @RoleAuthority(value = "userDeleted") - public ApiResp userDeleted(@RequestBody @Valid IdDTO dto) { - coreRoleService.roleUserDeleted(dto.getId()); - return ApiResp.respOK(""); - } - - - /** - * 获取服务列表 - * - * @return - */ - @GetMapping("/server/list") - @RoleAuthority(value = "serverList") - public ApiResp> list() { - return ApiResp.respOK(coreRoleService.getServerMapper().selectList(new QueryWrapper() - .eq(CoreRoleServer.IS_DELETED, 0) - .eq("is_open", 1) - )); - } - - - /** - * 修改服务 - * - * @param coreService - * @return - */ - @PostMapping("/server/update") - @RoleAuthority(value = "serverUpdate") - public ApiResp update(@RequestBody CoreRoleServer coreService) { - if (StrUtil.isNotEmpty(coreService.getId())) { - coreRoleService.getServerMapper().updateById(coreService); - } else { - coreRoleService.getServerMapper().insert(coreService); - } - return ApiResp.respOK(""); - } - - - /** - * 权限-列出 - * - * @return - */ - @GetMapping("/authority/list") - public ApiResp> menuList(@Valid MenuListDTO dto) { - - List list = coreRoleService.getAuthorityMapper().selectList(new QueryWrapper() - .eq(CoreRoleAuthority.IS_DELETED, 0) - .eq("service", dto.getService()) - .eq(StrUtil.isNotEmpty(dto.getPlatform()), "platform", dto.getPlatform()) - .orderByAsc("sort") - ); - - List collect = coreRoleService.menuChildrenWrap(list, null); - - return ApiResp.respOK(collect); - } - - - /** - * 权限-编辑 - * - * @return - */ - @PostMapping("/authority/update") - @RoleAuthority(value = "authorityUpdate") - public ApiResp menuUpdate(@RequestBody CoreRoleAuthority serviceMenu) { - serviceMenu.setParent(StrUtil.emptyToDefault(serviceMenu.getParent(), null)); - if (StrUtil.isEmpty(serviceMenu.getId())) { - coreRoleService.getAuthorityMapper().insert(serviceMenu); - } else { - serviceMenu.setNo(null); - coreRoleService.getAuthorityMapper().updateById(serviceMenu); - } - return ApiResp.respOK(""); - } - - - /** - * 获取自己拥有的服务 - * - * @return - */ - @GetMapping("/owner/server") - public ApiResp> ownerServer(TokenBean tokenBean) { - List allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId()); - List list = allOwnerMenus.stream().map(CoreRoleAuthority::getService).collect(Collectors.toList()); - - List roleServerList = new ArrayList<>(); - if (CollUtil.isNotEmpty(list)) { - roleServerList = coreRoleService.getServerMapper().selectList(new QueryWrapper() - .in("id", list) - .eq(CoreRoleServer.IS_DELETED, 0) - .eq("is_open", 1) - ); - } - - return ApiResp.respOK(roleServerList); - } - - - /** - * 获取自己拥有的菜单 - * - * @return - */ - @GetMapping("/owner/menu") - public ApiResp> ownerMenu(TokenBean tokenBean, @Valid OwnerMenuDTO dto) { - List ownerMenus = coreRoleService.getOwnerMenus(tokenBean.getId(), tokenBean.getRoleId(), dto); - return ApiResp.respOK(ownerMenus); - } - - /** - * 获取自己拥有的功能点 - * - * @return - */ - @GetMapping("/owner/point") - public ApiResp> ownerPoint(TokenBean tokenBean, @Valid OwnerPointDTO dto) { - - List allOwnerMenus = coreRoleService.getOwnerAuthorityLeafList(tokenBean.getId(), tokenBean.getRoleId()); - - String parentId; - if (StrUtil.isNotEmpty(dto.getParentNo())) { - CoreRoleAuthority selected = coreRoleService.getAuthorityMapper().selectOne(new QueryWrapper() - .eq("no", dto.getParentNo()) - .eq("is_deleted", 0) - .last("limit 1") - ); - parentId = selected == null ? "" : selected.getId(); - } else { - parentId = ""; - } - - List collect = allOwnerMenus.stream() - .filter(it -> Objects.equals(it.getType(), "point")) - .filter(it -> it.getService().equals(dto.getService())) - .filter(it -> it.getPlatform().equals(dto.getPlatform())) - .filter(it -> { - if (StrUtil.isNotEmpty(parentId)) { - return parentId.equals(it.getParent()); - } - return true; - }).collect(Collectors.toList()); - - return ApiResp.respOK(collect); - } - -} diff --git a/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleGroupController.java b/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleGroupController.java new file mode 100644 index 0000000..0738a74 --- /dev/null +++ b/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleGroupController.java @@ -0,0 +1,122 @@ +package com.tiesheng.role.controller.role; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.role.pojos.dao.CoreRoleGroup; +import com.tiesheng.role.pojos.dao.CoreRoleGroupRx; +import com.tiesheng.role.pojos.dto.GroupRxUpdateDTO; +import com.tiesheng.role.pojos.vo.GroupTypeDTO; +import com.tiesheng.role.service.CoreRoleService; +import com.tiesheng.util.exception.ApiException; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.IdDTO; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.List; +import java.util.Objects; + +@RestController +@RequestMapping("/role/group") +@RoleAuthority(value = "group", group = "role") +public class RoleGroupController { + + @Resource + CoreRoleService coreRoleService; + + /** + * 角色列表 + * + * @return + */ + @GetMapping("/page") + public ApiResp> groupPage(@Valid GroupTypeDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper() + .eq("is_deleted", 0) + .eq(StrUtil.isNotEmpty(dto.getType()), "type", dto.getType()) + .orderByAsc("sort"); + dto.likeColumns(queryWrapper, "name"); + + Page page = dto.pageObj(); + coreRoleService.page(page, queryWrapper); + + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + + + /** + * 角色编辑 + * + * @param roleGroup + * @return + */ + @PostMapping("/update") + public ApiResp groupUpdate(@RequestBody CoreRoleGroup roleGroup) { + + if (StrUtil.isNotEmpty(roleGroup.getId())) { + roleGroup.setType(null); + roleGroup.setIsSystem(null); + } + + coreRoleService.saveOrUpdate(roleGroup); + return ApiResp.respOK(""); + } + + + /** + * 角色-删除 + * + * @return + */ + @PostMapping("/deleted") + public ApiResp groupDeleted(@RequestBody @Valid IdDTO dto) { + + CoreRoleGroup byId = coreRoleService.getById(dto.getId()); + if (byId == null || byId.getIsDeleted() != 0) { + throw new ApiException("角色不存在或已删除"); + } + + if (byId.getIsSystem() == 1) { + throw new ApiException(StrUtil.format("该{}无法删除", + Objects.equals(byId.getType(), "role") ? "角色" : "职位")); + } + + CoreRoleGroup coreServiceMenu = new CoreRoleGroup(); + coreServiceMenu.setId(dto.getId()); + coreServiceMenu.setIsDeleted(1); + coreRoleService.updateById(coreServiceMenu); + return ApiResp.respOK(""); + } + + + /** + * 获取角色的权限 + * + * @return + */ + @GetMapping("/rx/list") + public ApiResp> groupRxList(@Valid IdDTO dto) { + List list = coreRoleService.getGroupRxMapper().selectList(new QueryWrapper() + .eq(CoreRoleGroupRx.IS_DELETED, 0) + .eq("group_id", dto.getId()) + ); + return ApiResp.respOK(list); + } + + + /** + * 角色的权限编辑 + * + * @return + */ + @PostMapping("/rx/update") + public ApiResp groupRxUpdate(@RequestBody @Valid GroupRxUpdateDTO dto) { + coreRoleService.updateGroupRx(dto); + return ApiResp.respOK(""); + } + +} diff --git a/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleServerController.java b/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleServerController.java new file mode 100644 index 0000000..eeb3033 --- /dev/null +++ b/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleServerController.java @@ -0,0 +1,95 @@ +package com.tiesheng.role.controller.role; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.role.pojos.dao.CoreRoleAuthority; +import com.tiesheng.role.pojos.dao.CoreRoleServer; +import com.tiesheng.role.pojos.dto.MenuListDTO; +import com.tiesheng.role.pojos.vo.ServiceMenuVO; +import com.tiesheng.role.service.CoreRoleService; +import com.tiesheng.util.pojos.ApiResp; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/role") +@RoleAuthority(value = "server", group = "role") +public class RoleServerController { + + @Resource + CoreRoleService coreRoleService; + + /** + * 获取服务列表 + * + * @return + */ + @GetMapping("/server/list") + public ApiResp> list() { + return ApiResp.respOK(coreRoleService.getServerMapper().selectList(new QueryWrapper() + .eq(CoreRoleServer.IS_DELETED, 0) + .eq("is_open", 1) + )); + } + + + /** + * 修改服务 + * + * @param coreService + * @return + */ + @PostMapping("/server/update") + public ApiResp update(@RequestBody CoreRoleServer coreService) { + if (StrUtil.isNotEmpty(coreService.getId())) { + coreRoleService.getServerMapper().updateById(coreService); + } else { + coreRoleService.getServerMapper().insert(coreService); + } + return ApiResp.respOK(""); + } + + + /** + * 权限-列出 + * + * @return + */ + @GetMapping("/authority/list") + public ApiResp> menuList(@Valid MenuListDTO dto) { + + List list = coreRoleService.getAuthorityMapper().selectList(new QueryWrapper() + .eq(CoreRoleAuthority.IS_DELETED, 0) + .eq("service", dto.getService()) + .eq(StrUtil.isNotEmpty(dto.getPlatform()), "platform", dto.getPlatform()) + .orderByAsc("sort") + ); + + List collect = coreRoleService.menuChildrenWrap(list, null); + + return ApiResp.respOK(collect); + } + + + /** + * 权限-编辑 + * + * @return + */ + @PostMapping("/authority/update") + public ApiResp menuUpdate(@RequestBody CoreRoleAuthority serviceMenu) { + serviceMenu.setParent(StrUtil.emptyToDefault(serviceMenu.getParent(), null)); + if (StrUtil.isEmpty(serviceMenu.getId())) { + coreRoleService.getAuthorityMapper().insert(serviceMenu); + } else { + serviceMenu.setNo(null); + coreRoleService.getAuthorityMapper().updateById(serviceMenu); + } + return ApiResp.respOK(""); + } + +} diff --git a/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleUserController.java b/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleUserController.java new file mode 100644 index 0000000..c7f729c --- /dev/null +++ b/springboot-role/src/main/java/com/tiesheng/role/controller/role/RoleUserController.java @@ -0,0 +1,69 @@ +package com.tiesheng.role.controller.role; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.role.pojos.dao.CoreRoleUser; +import com.tiesheng.role.pojos.vo.RoleUserPageVO; +import com.tiesheng.role.service.CoreRoleService; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.IdDTO; +import com.tiesheng.util.pojos.PageDTO; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/role/user") +@RoleAuthority(value = "user", group = "role") +public class RoleUserController { + + @Resource + CoreRoleService coreRoleService; + + /** + * 授权列表 + * + * @return + */ + @GetMapping("/page") + public ApiResp> userPage(PageDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("cru.is_deleted", 0); + dto.likeColumns(queryWrapper, "cru.ext1", "cru.ext2", "cru.ext3"); + queryWrapper.orderByAsc("cru.user_id"); + + Page page = dto.pageObj(); + coreRoleService.getUserMapper().page(page, queryWrapper); + + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + + + /** + * 授权调整 + * + * @return + */ + @PostMapping("/update") + public ApiResp userUpdate(@RequestBody CoreRoleUser roleUser) { + coreRoleService.roleUserUpdate(roleUser); + return ApiResp.respOK(""); + } + + + /** + * 授权-删除 + * + * @return + */ + @PostMapping("/deleted") + public ApiResp userDeleted(@RequestBody @Valid IdDTO dto) { + coreRoleService.roleUserDeleted(dto.getId()); + return ApiResp.respOK(""); + } + +} diff --git a/springboot-role/src/main/java/com/tiesheng/role/mapper/CoreRoleAuthorityMapper.java b/springboot-role/src/main/java/com/tiesheng/role/mapper/CoreRoleAuthorityMapper.java index f87dee3..ae47556 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/mapper/CoreRoleAuthorityMapper.java +++ b/springboot-role/src/main/java/com/tiesheng/role/mapper/CoreRoleAuthorityMapper.java @@ -6,13 +6,10 @@ import com.tiesheng.role.pojos.dao.CoreRoleAuthority; import java.util.List; public interface CoreRoleAuthorityMapper extends BaseMapper { - - /** * 批量插入数据 * * @param coreRoleAuthorities */ void batchInsert(List coreRoleAuthorities); - -} +} \ No newline at end of file diff --git a/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java b/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java index baa66b3..40ca8ed 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java +++ b/springboot-role/src/main/java/com/tiesheng/role/pojos/dao/CoreRoleAuthority.java @@ -1,11 +1,8 @@ package com.tiesheng.role.pojos.dao; -import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.tiesheng.util.pojos.DaoBase; -import java.util.Date; /** * 角色-权限 @@ -78,6 +75,12 @@ public class CoreRoleAuthority extends DaoBase { @TableField(value = "platform") private String platform; + /** + * 版本号 + */ + @TableField(value = "version") + private String version; + /** * 扩展1 */ @@ -294,6 +297,24 @@ public class CoreRoleAuthority extends DaoBase { this.platform = platform; } + /** + * 获取版本号 + * + * @return version - 版本号 + */ + public String getVersion() { + return version; + } + + /** + * 设置版本号 + * + * @param version 版本号 + */ + public void setVersion(String version) { + this.version = version; + } + /** * 获取扩展1 * @@ -347,4 +368,4 @@ public class CoreRoleAuthority extends DaoBase { public void setExt3(String ext3) { this.ext3 = ext3; } -} \ No newline at end of file +} diff --git a/springboot-role/src/main/java/com/tiesheng/role/pojos/vo/GroupTypeDTO.java b/springboot-role/src/main/java/com/tiesheng/role/pojos/vo/GroupTypeDTO.java index 2084335..234c60e 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/pojos/vo/GroupTypeDTO.java +++ b/springboot-role/src/main/java/com/tiesheng/role/pojos/vo/GroupTypeDTO.java @@ -1,10 +1,9 @@ package com.tiesheng.role.pojos.vo; -import javax.validation.constraints.NotEmpty; +import com.tiesheng.util.pojos.PageDTO; -public class GroupTypeDTO { +public class GroupTypeDTO extends PageDTO { - @NotEmpty(message = "请选择一个类型") private String type; /////////////////////////////////////////////////////////////////////////// diff --git a/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java b/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java index 644a231..ca1d1bb 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java +++ b/springboot-role/src/main/java/com/tiesheng/role/service/CoreRoleService.java @@ -3,6 +3,7 @@ package com.tiesheng.role.service; import cn.hutool.core.annotation.AnnotationUtil; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.date.DateUtil; import cn.hutool.core.lang.Validator; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -221,6 +222,9 @@ public class CoreRoleService extends TsServiceBase beansOfType = applicationContext.getBeansWithAnnotation(RoleAuthority.class); + + String version = DateUtil.format(new Date(), "yyyyMMddHHmmss"); + for (Map.Entry entry : beansOfType.entrySet()) { Class targetClass = AopUtils.getTargetClass(entry.getValue()); @@ -235,8 +239,13 @@ public class CoreRoleService extends TsServiceBase() + .ne("version", version) + ); + } } diff --git a/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java b/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java index 1afd5ce..faca656 100644 --- a/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java +++ b/springboot-role/src/main/java/com/tiesheng/role/service/RoleAuthorityHandler.java @@ -27,7 +27,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { @Override - public void addRoleAuthority(RoleAuthority menu, List points) { + public void addRoleAuthority(String version, RoleAuthority menu, List points) { if (menu.group().length == 0) { return; } @@ -54,6 +54,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { groupAuthority.setLevel(level); groupAuthority.setPlatform(menu.platform()); groupAuthority.setParent(parentId); + groupAuthority.setVersion(version); groupAuthority.setId(StrUtil.join("_", groupAuthority.getService(), groupAuthority.getNo())); list.add(groupAuthority); } @@ -68,6 +69,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { menuAuthority.setLevel(groupAuthority.getLevel() + 1); menuAuthority.setParent(groupAuthority.getId()); menuAuthority.setPlatform(menu.platform()); + menuAuthority.setVersion(version); menuAuthority.setId(StrUtil.join("_", menuAuthority.getService(), menuAuthority.getNo())); list.add(menuAuthority); @@ -80,6 +82,7 @@ public class RoleAuthorityHandler implements TsAuthorityHandler { point.setType("point"); point.setLevel(menuAuthority.getLevel() + 1); point.setParent(menuAuthority.getId()); + point.setVersion(version); point.setPlatform(StrUtil.emptyToDefault(authority.platform(), menu.platform())); point.setId(StrUtil.join("_", point.getService(), point.getNo())); list.add(point); diff --git a/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql b/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql index 51e79d0..6063669 100644 --- a/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql +++ b/springboot-role/src/main/resources/db/migration/tiesheng_init_role.sql @@ -1,3 +1,6 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + create table core_role_authority ( id varchar(50) not null @@ -93,3 +96,7 @@ create table core_role_user DEFAULT CHARSET = utf8mb4 comment '角色-用户'; +alter table core_role_authority + add version varchar(50) null comment '版本号' after platform; + +SET FOREIGN_KEY_CHECKS = 1; diff --git a/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml b/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml index 3ef75d8..2fe38b7 100644 --- a/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml +++ b/springboot-role/src/main/resources/mapper/CoreRoleAuthorityMapper.xml @@ -19,6 +19,7 @@ + @@ -26,14 +27,14 @@ id, create_time, update_time, is_deleted, service, `no`, `name`, sort, `level`, parent, - remark, is_open, `type`, link, platform, ext1, ext2, ext3 + remark, is_open, `type`, link, platform, version, ext1, ext2, ext3 insert into core_role_authority(id, create_time, update_time, is_deleted, service, no, name, level, parent, - type, platform, is_open) + type, platform, is_open, version) values - + (#{item.id}, now(), now(), 0, #{item.service}, #{item.no}, @@ -41,7 +42,7 @@ #{item.level}, #{item.parent}, #{item.type}, - #{item.platform}, 1) + #{item.platform}, 1, #{item.version}) on duplicate key update update_time=now(), @@ -49,7 +50,8 @@ level=values(level), parent=values(parent), type=values(type), - platform=values(platform) + platform=values(platform), + version=values(version) diff --git a/springboot-util/src/main/java/com/tiesheng/util/service/role/TsAuthorityHandler.java b/springboot-util/src/main/java/com/tiesheng/util/service/role/TsAuthorityHandler.java index 80308af..8988547 100644 --- a/springboot-util/src/main/java/com/tiesheng/util/service/role/TsAuthorityHandler.java +++ b/springboot-util/src/main/java/com/tiesheng/util/service/role/TsAuthorityHandler.java @@ -19,7 +19,7 @@ public interface TsAuthorityHandler { * @param pointAuthorityList * @return */ - void addRoleAuthority(RoleAuthority groupAuthority, List pointAuthorityList); + void addRoleAuthority(String version, RoleAuthority groupAuthority, List pointAuthorityList); /** diff --git a/springboot-web/src/main/java/com/tiesheng/web/config/role/RoleAuthorityAspect.java b/springboot-web/src/main/java/com/tiesheng/web/config/role/RoleAuthorityAspect.java index 058a20d..1ee8a06 100644 --- a/springboot-web/src/main/java/com/tiesheng/web/config/role/RoleAuthorityAspect.java +++ b/springboot-web/src/main/java/com/tiesheng/web/config/role/RoleAuthorityAspect.java @@ -61,17 +61,21 @@ public class RoleAuthorityAspect { } } + boolean isAuthorized; String authority = StrUtil.join("_", classAnnotation.group(), classAnnotation.value()); RoleAuthority annotation = signature.getMethod().getAnnotation(RoleAuthority.class); - if(annotation == null) { - return; + if (annotation != null) { + // 检查是否是功能点的权限 + isAuthorized = CollUtil.contains(authorityList, StrUtil.join("_", authority, annotation.value())); + } else { + // 检查是否有menu的权限 + isAuthorized = !authorityList.stream().filter(it -> StrUtil.startWith(it, authority)) + .collect(Collectors.toList()).isEmpty(); } - // 检查是否是功能点的权限 - if (CollUtil.contains(authorityList, StrUtil.join("_", authority, annotation.value()))) { + if (isAuthorized) { return; } - throw new ApiException(403, "您无权访问"); } diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/LogController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/LogController.java deleted file mode 100644 index 3cc26a5..0000000 --- a/springboot-web/src/main/java/com/tiesheng/web/controller/LogController.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.tiesheng.web.controller; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.tiesheng.annotation.role.RoleAuthority; -import com.tiesheng.login.pojos.dao.CoreLogLogin; -import com.tiesheng.util.pojos.ApiResp; -import com.tiesheng.util.pojos.PageDTO; -import com.tiesheng.web.pojos.dao.CoreLogApi; -import com.tiesheng.web.pojos.dao.CoreLogOperation; -import com.tiesheng.web.pojos.dao.CoreLogProcess; -import com.tiesheng.web.pojos.vo.ProcessDetailVo; -import com.tiesheng.web.service.CoreLogService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.validation.Valid; -import java.util.List; - -/** - * @author hao - */ -@RestController -@RequestMapping("/manager/log") -@RoleAuthority(value = "log", group = "system") -public class LogController { - - @Autowired - CoreLogService coreLogService; - - - /** - * 操作日志列表 - * - * @return - */ - @GetMapping("/operation/page") - @RoleAuthority(value = "operation") - public ApiResp> operationPage(@Valid PageDTO dto) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("is_deleted", 0); - dto.likeColumns(queryWrapper, "user_name", "title", "subject"); - queryWrapper.orderByDesc("create_time"); - - Page page = dto.pageObj(); - coreLogService.getBaseMapper().page(page, queryWrapper); - - return ApiResp.respOK(page.getRecords(), page.getTotal()); - } - - - /** - * 登录日志列表 - * - * @return - */ - @GetMapping("/login/page") - @RoleAuthority(value = "login") - public ApiResp> loginPage(@Valid PageDTO dto) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("is_deleted", 0); - dto.likeColumns(queryWrapper, "user_name", "ip", "address"); - queryWrapper.orderByDesc("create_time"); - - Page page = dto.pageObj(); - coreLogService.getLogLoginMapper().selectPage(page, queryWrapper); - return ApiResp.respOK(page.getRecords(), page.getTotal()); - } - - - /** - * 调用日志 - * - * @return - */ - @GetMapping("/api/page") - @RoleAuthority(value = "api") - public ApiResp> apiPage(String result, @Valid PageDTO dto) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("is_deleted", 0); - if (!StrUtil.isEmpty(result)) { - queryWrapper.eq("result", result); - } - dto.likeColumns(queryWrapper, "type", "content"); - queryWrapper.orderByDesc("create_time"); - - Page page = dto.pageObj(); - coreLogService.getLogApiMapper().selectPage(page, queryWrapper); - return ApiResp.respOK(page.getRecords(), page.getTotal()); - } - - - /** - * 过程日志列表 - * - * @return - */ - @GetMapping("/process/page") - public ApiResp> processPage(String type, @Valid PageDTO dto) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("is_deleted", 0); - if (!StrUtil.isEmpty(type)) { - queryWrapper.eq("type", type); - } - dto.likeColumns(queryWrapper, "title"); - queryWrapper.orderByDesc("create_time"); - - Page page = dto.pageObj(); - coreLogService.getCoreLogProcessMapper().selectPage(page, queryWrapper); - return ApiResp.respOK(page.getRecords(), page.getTotal()); - } - - /** - * 过程日志详情 - * - * @return - */ - @GetMapping("/process/detail") - public ApiResp processPage(String id) { - ProcessDetailVo processDetail = coreLogService.getProcessDetail(id); - return ApiResp.respOK(processDetail); - } -} diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/comm/CommWebController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/comm/CommWebController.java new file mode 100644 index 0000000..111d135 --- /dev/null +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/comm/CommWebController.java @@ -0,0 +1,83 @@ +package com.tiesheng.web.controller.comm; + + +import cn.hutool.core.lang.Validator; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.tiesheng.annotation.token.TokenIgnore; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.IdDTO; +import com.tiesheng.web.pojos.dao.CoreConfigEnum; +import com.tiesheng.web.pojos.dao.CoreConfigSystem; +import com.tiesheng.web.pojos.dto.config.EnumTypeDTO; +import com.tiesheng.web.pojos.vo.ProcessDetailVo; +import com.tiesheng.web.service.CoreConfigService; +import com.tiesheng.web.service.CoreLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +@RestController +@RequestMapping("/comm/web") +public class CommWebController { + + @Autowired + CoreLogService coreLogService; + @Autowired + CoreConfigService coreConfigService; + + /** + * 系统配置列表 + * + * @return + */ + @GetMapping("/system/page") + @TokenIgnore + public ApiResp> systemPage(String keyword) { + + Validator.validateNotEmpty(keyword, "请上传关键字"); + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + queryWrapper.likeRight("config_key", keyword); + queryWrapper.orderByAsc("config_key"); + List list = coreConfigService.list(queryWrapper); + + return ApiResp.respOK(list); + } + + + /** + * 获取枚举列表 + * + * @param dto + * @return + */ + @GetMapping("/enum/list") + @TokenIgnore + public ApiResp> enumList(EnumTypeDTO dto) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + queryWrapper.eq("type", dto.getType()); + List selectList = coreConfigService.getEnumMapper().selectList(queryWrapper); + + return ApiResp.respOK(selectList); + } + + + /** + * 过程日志详情 + * + * @return + */ + @GetMapping("/process/detail") + @TokenIgnore + public ApiResp processPage(@Valid IdDTO dto) { + ProcessDetailVo processDetail = coreLogService.getProcessDetail(dto.getId()); + return ApiResp.respOK(processDetail); + } + +} diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/ToolController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/comm/ToolController.java similarity index 99% rename from springboot-web/src/main/java/com/tiesheng/web/controller/ToolController.java rename to springboot-web/src/main/java/com/tiesheng/web/controller/comm/ToolController.java index 8966601..945b911 100644 --- a/springboot-web/src/main/java/com/tiesheng/web/controller/ToolController.java +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/comm/ToolController.java @@ -1,4 +1,4 @@ -package com.tiesheng.web.controller; +package com.tiesheng.web.controller.comm; import cn.hutool.captcha.LineCaptcha; diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/system/ConfigEnumController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/system/ConfigEnumController.java new file mode 100644 index 0000000..b3c46f4 --- /dev/null +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/system/ConfigEnumController.java @@ -0,0 +1,49 @@ +package com.tiesheng.web.controller.system; + + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.web.pojos.dao.CoreConfigEnum; +import com.tiesheng.web.pojos.dto.config.EnumTypeDTO; +import com.tiesheng.web.service.CoreConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author hao + */ +@RestController +@RequestMapping("/config") +@RoleAuthority(value = "enum", group = "system") +public class ConfigEnumController { + + @Autowired + CoreConfigService coreConfigService; + + + /** + * 获取枚举列表 + * + * @param dto + * @return + */ + @GetMapping("/enum/list") + public ApiResp> enumList(EnumTypeDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + if (!StrUtil.isEmpty(dto.getType())) { + queryWrapper.eq("type", dto.getType()); + } + List selectList = coreConfigService.getEnumMapper().selectList(queryWrapper); + + return ApiResp.respOK(selectList); + } + +} diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/ConfigController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/system/ConfigSystemController.java similarity index 71% rename from springboot-web/src/main/java/com/tiesheng/web/controller/ConfigController.java rename to springboot-web/src/main/java/com/tiesheng/web/controller/system/ConfigSystemController.java index e2a1025..1c41fc6 100644 --- a/springboot-web/src/main/java/com/tiesheng/web/controller/ConfigController.java +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/system/ConfigSystemController.java @@ -1,18 +1,14 @@ -package com.tiesheng.web.controller; +package com.tiesheng.web.controller.system; -import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.tiesheng.annotation.role.RoleAuthority; -import com.tiesheng.annotation.token.TokenIgnore; import com.tiesheng.util.exception.ApiException; import com.tiesheng.util.pojos.ApiResp; import com.tiesheng.util.pojos.PageDTO; -import com.tiesheng.web.pojos.dao.CoreConfigEnum; import com.tiesheng.web.pojos.dao.CoreConfigSystem; import com.tiesheng.web.pojos.dto.config.ConfigSystemDTO; -import com.tiesheng.web.pojos.dto.config.EnumTypeDTO; import com.tiesheng.web.service.CoreConfigService; import com.tiesheng.web.service.TieshengWebConfigurer; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +22,7 @@ import java.util.List; @RestController @RequestMapping("/config") @RoleAuthority(value = "config", group = "system") -public class ConfigController { +public class ConfigSystemController { @Autowired CoreConfigService coreConfigService; @@ -40,7 +36,6 @@ public class ConfigController { * @return */ @GetMapping("/system/page") - @TokenIgnore public ApiResp> systemPage(PageDTO dto) { QueryWrapper queryWrapper = new QueryWrapper<>(); @@ -61,7 +56,6 @@ public class ConfigController { * @return */ @PostMapping("/system/update") - @RoleAuthority(value = "systemUpdate") public ApiResp systemUpdate(@RequestBody ConfigSystemDTO dto) { CoreConfigSystem configKey = coreConfigService.getOneByColumn("config_key", dto.getConfigKey()); @@ -81,25 +75,4 @@ public class ConfigController { return ApiResp.respOK(""); } - - /** - * 获取枚举列表 - * - * @param dto - * @return - */ - @GetMapping("/enum/list") - @TokenIgnore - public ApiResp> enumList(EnumTypeDTO dto) { - - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("is_deleted", 0); - if (!StrUtil.isEmpty(dto.getType())) { - queryWrapper.eq("type", dto.getType()); - } - List selectList = coreConfigService.getEnumMapper().selectList(queryWrapper); - - return ApiResp.respOK(selectList); - } - } diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogApiController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogApiController.java new file mode 100644 index 0000000..b6f3aca --- /dev/null +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogApiController.java @@ -0,0 +1,52 @@ +package com.tiesheng.web.controller.system; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.PageDTO; +import com.tiesheng.web.pojos.dao.CoreLogApi; +import com.tiesheng.web.service.CoreLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author hao + */ +@RestController +@RequestMapping("/manager/log") +@RoleAuthority(value = "api", group = "system") +public class LogApiController { + + @Autowired + CoreLogService coreLogService; + + + /** + * 调用日志 + * + * @return + */ + @GetMapping("/api/page") + public ApiResp> apiPage(String result, @Valid PageDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + if (!StrUtil.isEmpty(result)) { + queryWrapper.eq("result", result); + } + dto.likeColumns(queryWrapper, "type", "content"); + queryWrapper.orderByDesc("create_time"); + + Page page = dto.pageObj(); + coreLogService.getLogApiMapper().selectPage(page, queryWrapper); + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + +} diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogLoginController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogLoginController.java new file mode 100644 index 0000000..ffd4312 --- /dev/null +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogLoginController.java @@ -0,0 +1,48 @@ +package com.tiesheng.web.controller.system; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.login.pojos.dao.CoreLogLogin; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.PageDTO; +import com.tiesheng.web.service.CoreLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author hao + */ +@RestController +@RequestMapping("/manager/log") +@RoleAuthority(value = "login", group = "system") +public class LogLoginController { + + @Autowired + CoreLogService coreLogService; + + /** + * 登录日志列表 + * + * @return + */ + @GetMapping("/login/page") + public ApiResp> loginPage(@Valid PageDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + dto.likeColumns(queryWrapper, "user_name", "ip", "address"); + queryWrapper.orderByDesc("create_time"); + + Page page = dto.pageObj(); + coreLogService.getLogLoginMapper().selectPage(page, queryWrapper); + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + + +} diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogOperationController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogOperationController.java new file mode 100644 index 0000000..6c241e4 --- /dev/null +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogOperationController.java @@ -0,0 +1,50 @@ +package com.tiesheng.web.controller.system; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.PageDTO; +import com.tiesheng.web.pojos.dao.CoreLogOperation; +import com.tiesheng.web.service.CoreLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author hao + */ +@RestController +@RequestMapping("/manager/log") +@RoleAuthority(value = "operation", group = "system") +public class LogOperationController { + + @Autowired + CoreLogService coreLogService; + + + /** + * 操作日志列表 + * + * @return + */ + @GetMapping("/operation/page") + public ApiResp> operationPage(@Valid PageDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + dto.likeColumns(queryWrapper, "user_name", "title", "subject"); + queryWrapper.orderByDesc("create_time"); + + Page page = dto.pageObj(); + coreLogService.getBaseMapper().page(page, queryWrapper); + + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + + +} diff --git a/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogProcessController.java b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogProcessController.java new file mode 100644 index 0000000..82a541a --- /dev/null +++ b/springboot-web/src/main/java/com/tiesheng/web/controller/system/LogProcessController.java @@ -0,0 +1,51 @@ +package com.tiesheng.web.controller.system; + +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.tiesheng.annotation.role.RoleAuthority; +import com.tiesheng.util.pojos.ApiResp; +import com.tiesheng.util.pojos.PageDTO; +import com.tiesheng.web.pojos.dao.CoreLogProcess; +import com.tiesheng.web.service.CoreLogService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.validation.Valid; +import java.util.List; + +/** + * @author hao + */ +@RestController +@RequestMapping("/manager/log") +@RoleAuthority(value = "process", group = "system") +public class LogProcessController { + + @Autowired + CoreLogService coreLogService; + + /** + * 过程日志列表 + * + * @return + */ + @GetMapping("/process/page") + public ApiResp> processPage(String type, @Valid PageDTO dto) { + + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("is_deleted", 0); + if (!StrUtil.isEmpty(type)) { + queryWrapper.eq("type", type); + } + dto.likeColumns(queryWrapper, "title"); + queryWrapper.orderByDesc("create_time"); + + Page page = dto.pageObj(); + coreLogService.getCoreLogProcessMapper().selectPage(page, queryWrapper); + return ApiResp.respOK(page.getRecords(), page.getTotal()); + } + +}