diff --git a/src/main/java/com/glxp/api/controller/system/SMenuController.java b/src/main/java/com/glxp/api/controller/system/SMenuController.java new file mode 100644 index 0000000..8ba930a --- /dev/null +++ b/src/main/java/com/glxp/api/controller/system/SMenuController.java @@ -0,0 +1,89 @@ +package com.glxp.api.controller.system; + +import cn.hutool.core.util.IdUtil; +import com.github.pagehelper.PageInfo; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.entity.auth.Smenu; +import com.glxp.api.req.system.LicenseRequest; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.service.auth.SmenuService; +import org.apache.commons.collections.CollectionUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/24 11:46 + * @modyified By : + */ +@RestController +public class SMenuController { + + @Resource + SmenuService sysmenuService; + + @GetMapping("system/license/List") + public BaseResponse getSortList(LicenseRequest licenseRequest){ + + List licenseRequests = sysmenuService.selecLicentList(licenseRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(licenseRequests); + PageSimpleResponse objectPageSimpleResponse = new PageSimpleResponse<>(); + objectPageSimpleResponse.setTotal(pageInfo.getTotal()); + objectPageSimpleResponse.setList(licenseRequests); + + return ResultVOUtils.success(objectPageSimpleResponse); + } + + @PostMapping("system/license/insert") + public BaseResponse insert(@RequestBody LicenseRequest licenseRequest){ + + + Smenu authLicense = new Smenu(); + BeanUtils.copyProperties(licenseRequest,authLicense); + authLicense.setId(IdUtil.getSnowflakeNextId()); + boolean insert = sysmenuService.insert(authLicense); + + return ResultVOUtils.success(); + } + + @PostMapping("system/license/delete") + public BaseResponse delete(@RequestBody LicenseRequest licenseRequest){ + + LicenseRequest licenseRequest1 = new LicenseRequest(); + Smenu authLicense = new Smenu(); + //删除接口类型 先判断下面是否有子接口 + if(licenseRequest.getParentId()==0){ + //判断下面是否有子接口 + licenseRequest1.setParentId(licenseRequest.getId()); + List licenseRequests = sysmenuService.selecLicentList(licenseRequest1); + if(CollectionUtils.isNotEmpty(licenseRequests)){ + return ResultVOUtils.error(500,"此接口类型下存在接口,不能删除!"); + } + } + BeanUtils.copyProperties(licenseRequest,authLicense); + sysmenuService.delete(authLicense); + + return ResultVOUtils.success(); + } + + @PostMapping("system/license/update") + public BaseResponse update(@RequestBody LicenseRequest licenseRequest){ + Smenu authLicense = new Smenu(); + BeanUtils.copyProperties(licenseRequest,authLicense); + authLicense.setUpdateTime(new Date()); + sysmenuService.updateById(authLicense); + + return ResultVOUtils.success(); + } + + +} diff --git a/src/main/java/com/glxp/api/controller/system/sroleController.java b/src/main/java/com/glxp/api/controller/system/sroleController.java new file mode 100644 index 0000000..a702685 --- /dev/null +++ b/src/main/java/com/glxp/api/controller/system/sroleController.java @@ -0,0 +1,111 @@ +package com.glxp.api.controller.system; + +import cn.hutool.core.lang.tree.Tree; +import cn.hutool.core.util.IdUtil; +import com.github.pagehelper.PageInfo; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.dto.SysRoleMenuModel; +import com.glxp.api.entity.auth.Smenu; +import com.glxp.api.entity.auth.Syrole; +import com.glxp.api.entity.auth.sroleMenu; +import com.glxp.api.req.auth.sroleRequest; +import com.glxp.api.req.system.LicenseRequest; +import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.auth.sroleResponse; +import com.glxp.api.service.auth.SmenuService; +import com.glxp.api.service.auth.sroleMenuService; +import com.glxp.api.service.auth.sroleService; +import org.springframework.beans.BeanUtils; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Date; +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:38 + * @modyified By : + */ +@RestController +public class sroleController { + @Resource + sroleService sroleService; + + @Resource + SmenuService service; + + @Resource + sroleMenuService sroleMenuService; + + @GetMapping("system/srole/list") + public BaseResponse getRoleList(sroleRequest sroleRequest){ + + List sroleResponses = sroleService.selectRoleList(sroleRequest); + PageInfo pageInfo; + pageInfo = new PageInfo<>(sroleResponses); + PageSimpleResponse objectPageSimpleResponse = new PageSimpleResponse<>(); + objectPageSimpleResponse.setTotal(pageInfo.getTotal()); + objectPageSimpleResponse.setList(sroleResponses); + + return ResultVOUtils.success(objectPageSimpleResponse); + } + + + + @PostMapping("system/srole/insert") + public BaseResponse insertRole(@RequestBody sroleRequest sroleRequest){ + + Syrole syrole = new Syrole(); + BeanUtils.copyProperties(sroleRequest,syrole); + syrole.setId(IdUtil.getSnowflakeNextId()); + syrole.setCreateTime(new Date()); + boolean insert = sroleService.insert(syrole); + return ResultVOUtils.success(); + } + + @PostMapping("system/srole/update") + public BaseResponse updateRole(@RequestBody sroleRequest sroleRequest){ + Syrole syrole = new Syrole(); + BeanUtils.copyProperties(sroleRequest,syrole); + sroleService.update(syrole); + + return ResultVOUtils.success(); + } + + + @PostMapping("system/srole/delete") + public BaseResponse deleteRole(@RequestBody sroleRequest sroleRequest){ + Syrole syrole = new Syrole(); + BeanUtils.copyProperties(sroleRequest,syrole); + boolean delete = sroleService.delete(syrole); + //同时删除关联表 + sroleMenu sroleMenu = new sroleMenu(); + sroleMenu.setRoleId(sroleRequest.getId()); + sroleMenuService.delete(sroleMenu); + return ResultVOUtils.success(); + } + + + @GetMapping("system/srole/treeselect") + public BaseResponse treeselect(Long roleId){ + return ResultVOUtils.success(sroleMenuService.getRoleMenu(roleId)); + } + + + @PostMapping("system/srole/saveRoleMenu") + public BaseResponse saveRoleMenu(@RequestBody SysRoleMenuModel model){ + + return sroleMenuService.saveRoleMenu(model); + } + + + + + + +} diff --git a/src/main/java/com/glxp/api/dao/auth/AuthLicenseDao.java b/src/main/java/com/glxp/api/dao/auth/AuthLicenseDao.java index c93de62..17b30a5 100644 --- a/src/main/java/com/glxp/api/dao/auth/AuthLicenseDao.java +++ b/src/main/java/com/glxp/api/dao/auth/AuthLicenseDao.java @@ -4,8 +4,9 @@ import com.glxp.api.entity.auth.AuthLicense; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + @Mapper -public interface AuthLicenseDao { +public interface AuthLicenseDao{ AuthLicense get(String id); diff --git a/src/main/java/com/glxp/api/dao/auth/SmenuDao.java b/src/main/java/com/glxp/api/dao/auth/SmenuDao.java new file mode 100644 index 0000000..ddd9989 --- /dev/null +++ b/src/main/java/com/glxp/api/dao/auth/SmenuDao.java @@ -0,0 +1,19 @@ +package com.glxp.api.dao.auth; + +import com.glxp.api.dao.BaseMapperPlus; +import com.glxp.api.entity.auth.Smenu; +import com.glxp.api.req.system.LicenseRequest; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 11:07 + * @modyified By : + */ +@Mapper +public interface SmenuDao extends BaseMapperPlus { + List selecLicentList(LicenseRequest licenseRequest); + List selectActiveAll(); +} diff --git a/src/main/java/com/glxp/api/dao/auth/sroleDao.java b/src/main/java/com/glxp/api/dao/auth/sroleDao.java new file mode 100644 index 0000000..6ecc0d3 --- /dev/null +++ b/src/main/java/com/glxp/api/dao/auth/sroleDao.java @@ -0,0 +1,21 @@ +package com.glxp.api.dao.auth; + +import com.glxp.api.dao.BaseMapperPlus; +import com.glxp.api.entity.auth.Syrole; +import com.glxp.api.req.auth.sroleRequest; +import com.glxp.api.res.auth.sroleResponse; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:29 + * @modyified By : + */ +@Mapper +public interface sroleDao extends BaseMapperPlus { + + List selectRoleList(sroleRequest sroleRequest); + +} diff --git a/src/main/java/com/glxp/api/dao/auth/sroleMenuDao.java b/src/main/java/com/glxp/api/dao/auth/sroleMenuDao.java new file mode 100644 index 0000000..62076c4 --- /dev/null +++ b/src/main/java/com/glxp/api/dao/auth/sroleMenuDao.java @@ -0,0 +1,26 @@ +package com.glxp.api.dao.auth; + +import com.glxp.api.dao.BaseMapperPlus; +import com.glxp.api.entity.auth.Smenu; +import com.glxp.api.entity.auth.sroleMenu; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 15:57 + * @modyified By : + */ +@Mapper +public interface sroleMenuDao extends BaseMapperPlus { + + List selectByRoleId(@Param("roleId") Long roleId); + + int deleteByRoleId(@Param("roleId") Long roleId); + + int insertrm(sroleMenu sroleMenu); + + +} diff --git a/src/main/java/com/glxp/api/dto/MenuTreeModel.java b/src/main/java/com/glxp/api/dto/MenuTreeModel.java new file mode 100644 index 0000000..a034920 --- /dev/null +++ b/src/main/java/com/glxp/api/dto/MenuTreeModel.java @@ -0,0 +1,43 @@ +package com.glxp.api.dto; + +import lombok.Data; + +import java.util.Date; +import java.util.List; + +@Data +public class MenuTreeModel { + /** + * 编号 + */ + private Long id; + + /** + * 菜单名称 + */ + private String name; + /** + * 菜单类型M: 目录, C: 菜单,F: 资源 + */ + private String type; + + /** + * 权限标识 + */ + private String perms; + /** + * 排序 + */ + private Integer sort; + + /** + * 状态(0启用 1禁用) + */ + private String status; + + /** + * 创建时间 + */ + private Date createTime; + private List children; +} diff --git a/src/main/java/com/glxp/api/dto/RoleMenuTreeModel.java b/src/main/java/com/glxp/api/dto/RoleMenuTreeModel.java new file mode 100644 index 0000000..de4039d --- /dev/null +++ b/src/main/java/com/glxp/api/dto/RoleMenuTreeModel.java @@ -0,0 +1,13 @@ +package com.glxp.api.dto; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; + +@Data +@Builder +public class RoleMenuTreeModel { + private List menuTrees; + private List roleMenuIds; +} diff --git a/src/main/java/com/glxp/api/dto/SysRoleMenuModel.java b/src/main/java/com/glxp/api/dto/SysRoleMenuModel.java new file mode 100644 index 0000000..ec023b1 --- /dev/null +++ b/src/main/java/com/glxp/api/dto/SysRoleMenuModel.java @@ -0,0 +1,11 @@ +package com.glxp.api.dto; + +import lombok.Data; + +import java.util.List; + +@Data +public class SysRoleMenuModel { + private Long roleId; + private List menuIds; +} diff --git a/src/main/java/com/glxp/api/entity/auth/AuthLicense.java b/src/main/java/com/glxp/api/entity/auth/AuthLicense.java index 0ebdae9..c9d98a6 100644 --- a/src/main/java/com/glxp/api/entity/auth/AuthLicense.java +++ b/src/main/java/com/glxp/api/entity/auth/AuthLicense.java @@ -1,11 +1,14 @@ package com.glxp.api.entity.auth; +import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import java.util.Date; @Data +@TableName(value = "auth_license") public class AuthLicense { + private String id; // 名称 private String name; diff --git a/src/main/java/com/glxp/api/entity/auth/Smenu.java b/src/main/java/com/glxp/api/entity/auth/Smenu.java new file mode 100644 index 0000000..a51814a --- /dev/null +++ b/src/main/java/com/glxp/api/entity/auth/Smenu.java @@ -0,0 +1,47 @@ +package com.glxp.api.entity.auth; + +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 lombok.Data; + +import java.util.Date; + +@Data +@TableName(value = "sys_menu") +public class Smenu { + @TableId(value = "id", type = IdType.INPUT) + private Long id; + + // 接口分类名称 + @TableField(value = "name") + private String name; + + + // 接口地址 + @TableField(value = "path") + private String path; + @TableField(value = "parentId") + private Long parentId; + + //权限标识 + @TableField(value = "perms") + private String perms; + + // 接口文档地址 + @TableField(value = "docUrl") + private String docUrl; + + + // 创建时间 + @TableField(value = "createTime") + private Date createTime; + + // 更新时间 + @TableField(value = "updateTime") + private Date updateTime; + @TableField(value = "remark") + private String remark; + +} diff --git a/src/main/java/com/glxp/api/entity/auth/Syrole.java b/src/main/java/com/glxp/api/entity/auth/Syrole.java new file mode 100644 index 0000000..b036749 --- /dev/null +++ b/src/main/java/com/glxp/api/entity/auth/Syrole.java @@ -0,0 +1,37 @@ +package com.glxp.api.entity.auth; + +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 lombok.Data; + +import java.util.Date; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:19 + * @modyified By : + */ +@Data +@TableName(value = "sys_role") +public class Syrole { + + @TableId(value = "id", type = IdType.INPUT) + private Long id; + + @TableField(value = "name") + private String name; + + @TableField(value = "code") + private String code; + + + // 0正常 1停用 + @TableField(value = "status") + private String status; + + // 创建时间 + @TableField(value = "createTime") + private Date createTime; +} diff --git a/src/main/java/com/glxp/api/entity/auth/sroleMenu.java b/src/main/java/com/glxp/api/entity/auth/sroleMenu.java new file mode 100644 index 0000000..c75fa7e --- /dev/null +++ b/src/main/java/com/glxp/api/entity/auth/sroleMenu.java @@ -0,0 +1,20 @@ +package com.glxp.api.entity.auth; + +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.Data; + +@Data +@TableName(value = "sys_role_menu") +public class sroleMenu { + + /** + * 角色ID + */ + private Long roleId; + + /** + * 接口菜单ID + */ + private Long menuId; + +} diff --git a/src/main/java/com/glxp/api/req/auth/sroleRequest.java b/src/main/java/com/glxp/api/req/auth/sroleRequest.java new file mode 100644 index 0000000..adb595a --- /dev/null +++ b/src/main/java/com/glxp/api/req/auth/sroleRequest.java @@ -0,0 +1,33 @@ +package com.glxp.api.req.auth; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.glxp.api.util.page.ListPageRequest; +import lombok.Data; + +import java.util.Date; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:25 + * @modyified By : + */ +@Data +public class sroleRequest extends ListPageRequest { + + private Long id; + + private String name; + + private String code; + + + // 0正常 1停用 + private String status; + + // 创建时间 + private Date createTime; + + +} diff --git a/src/main/java/com/glxp/api/req/system/LicenseRequest.java b/src/main/java/com/glxp/api/req/system/LicenseRequest.java new file mode 100644 index 0000000..bf44a50 --- /dev/null +++ b/src/main/java/com/glxp/api/req/system/LicenseRequest.java @@ -0,0 +1,70 @@ +package com.glxp.api.req.system; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.glxp.api.util.page.ListPageRequest; +import lombok.Data; + +import java.util.Date; + +/** + * @author : zhangsan + * @date : 2023/5/24 11:51 + * @modyified By : + */ + +@Data +public class LicenseRequest extends ListPageRequest { + + private Long id; + + // 接口分类名称 + + private String name; + + + // 接口地址 + + private String path; + + private Long parentId; + + //权限标识 + private String perms; + + // 接口文档地址 + private String docUrl; + + + // 创建时间 + private Date createTime; + + // 更新时间 + private Date updateTime; + private String remark; + + + /** + * 创建开始时间 + */ + private String startTime; + + /** + * 创建结束时间 + */ + private String endTime; + + + /** + * 更新开始时间 + */ + private String startAduditTime; + + /** + * 跟新结束时间 + */ + private String endAduditTime; + + +} diff --git a/src/main/java/com/glxp/api/res/auth/sroleResponse.java b/src/main/java/com/glxp/api/res/auth/sroleResponse.java new file mode 100644 index 0000000..c75438d --- /dev/null +++ b/src/main/java/com/glxp/api/res/auth/sroleResponse.java @@ -0,0 +1,26 @@ +package com.glxp.api.res.auth; + +import lombok.Data; + +import java.util.Date; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:26 + * @modyified By : + */ +@Data +public class sroleResponse { + + private Long id; + + private String name; + + private String code; + + // 0正常 1停用 + private String status; + + // 创建时间 + private Date createTime; +} diff --git a/src/main/java/com/glxp/api/service/auth/SmenuService.java b/src/main/java/com/glxp/api/service/auth/SmenuService.java new file mode 100644 index 0000000..97490bd --- /dev/null +++ b/src/main/java/com/glxp/api/service/auth/SmenuService.java @@ -0,0 +1,27 @@ +package com.glxp.api.service.auth; + +import cn.hutool.core.lang.tree.Tree; +import com.baomidou.mybatisplus.extension.service.IService; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.entity.auth.Smenu; +import com.glxp.api.entity.auth.SysMenu; +import com.glxp.api.req.system.LicenseRequest; + +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/24 11:54 + * @modyified By : + */ + +public interface SmenuService extends IService { + + List selecLicentList(LicenseRequest licenseRequest); + + BaseResponse getMenuTreeActive(); + + boolean insert(Smenu authLicense); + + boolean delete(Smenu authLicense); +} diff --git a/src/main/java/com/glxp/api/service/auth/impl/SMenuServiceImpl.java b/src/main/java/com/glxp/api/service/auth/impl/SMenuServiceImpl.java new file mode 100644 index 0000000..27e2a1a --- /dev/null +++ b/src/main/java/com/glxp/api/service/auth/impl/SMenuServiceImpl.java @@ -0,0 +1,84 @@ +package com.glxp.api.service.auth.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.tree.Tree; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.dao.auth.SmenuDao; +import com.glxp.api.dto.MenuTreeModel; +import com.glxp.api.entity.auth.Smenu; +import com.glxp.api.entity.auth.SysMenu; +import com.glxp.api.req.system.LicenseRequest; +import com.glxp.api.service.auth.SmenuService; +import com.glxp.api.util.TreeBuildUtils; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.stream.Collectors; + +/** + * @author : zhangsan + * @date : 2023/5/24 11:55 + * @modyified By : + */ +@Service +public class SMenuServiceImpl extends ServiceImpl implements SmenuService { + + @Resource + SmenuDao smenuDao; + + + @Override + public List selecLicentList(LicenseRequest licenseRequest) { + if (null == licenseRequest) { + return Collections.emptyList(); + } + if (null != licenseRequest.getPage() && null != licenseRequest.getLimit()) { + PageHelper.offsetPage((licenseRequest.getPage() - 1) * licenseRequest.getLimit(), licenseRequest.getLimit()); + } + + return smenuDao.selecLicentList(licenseRequest); + } + + @Override + public BaseResponse getMenuTreeActive() { + List smenus = smenuDao.selectActiveAll(); + List child = getChild(smenus, 0l); + return ResultVOUtils.success(child); + + } + + + @Override + public boolean insert(Smenu authLicense) { + return smenuDao.insert(authLicense)>0; + } + + @Override + public boolean delete(Smenu authLicense) { + return smenuDao.deleteById(authLicense)>0; + } + + private List getChild(List menus, Long pId) { + List result = new ArrayList<>(); + List list = menus.stream().filter(p -> p.getParentId().equals(pId)).collect(Collectors.toList()); + if (list != null && list.size() > 0) { + for (Smenu item : list) { + MenuTreeModel treeModel = new MenuTreeModel(); + BeanUtils.copyProperties(item, treeModel); + List child = getChild(menus, treeModel.getId()); + if (child != null && child.size() > 0) + treeModel.setChildren(child); + result.add(treeModel); + } + } + return result; + } +} diff --git a/src/main/java/com/glxp/api/service/auth/impl/sroleMenuServiceImpl.java b/src/main/java/com/glxp/api/service/auth/impl/sroleMenuServiceImpl.java new file mode 100644 index 0000000..ad9d704 --- /dev/null +++ b/src/main/java/com/glxp/api/service/auth/impl/sroleMenuServiceImpl.java @@ -0,0 +1,67 @@ +package com.glxp.api.service.auth.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.common.util.ResultVOUtils; +import com.glxp.api.dao.auth.sroleMenuDao; +import com.glxp.api.dto.MenuTreeModel; +import com.glxp.api.dto.RoleMenuTreeModel; +import com.glxp.api.dto.SysRoleMenuModel; +import com.glxp.api.entity.auth.sroleMenu; +import com.glxp.api.service.auth.SmenuService; +import com.glxp.api.service.auth.sroleMenuService; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 16:06 + * @modyified By : + */ +@Service +public class sroleMenuServiceImpl extends ServiceImpl implements sroleMenuService { + + @Resource + sroleMenuDao sroleMenuDao; + + @Resource + SmenuService service; + + @Override + public boolean delete(sroleMenu sroleMenu) { + + return sroleMenuDao.delete(new QueryWrapper().eq("role_id",sroleMenu.getRoleId()))>0; + } + + @Override + public boolean insert(sroleMenu sroleMenu) { + return sroleMenuDao.insert(sroleMenu)>0; + } + + @Override + public BaseResponse getRoleMenu(Long roleId) { + List menuTree = (List) service.getMenuTreeActive().getData(); + List longs = sroleMenuDao.selectByRoleId(roleId); + + return ResultVOUtils.success(RoleMenuTreeModel.builder().menuTrees(menuTree).roleMenuIds(longs).build()); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public BaseResponse saveRoleMenu(SysRoleMenuModel model) { + sroleMenuDao.deleteByRoleId(model.getRoleId()); + for (Long menuId : model.getMenuIds()) { + sroleMenu sroleMenu = new sroleMenu(); + sroleMenu.setRoleId(model.getRoleId()); + sroleMenu.setMenuId(menuId); + sroleMenuDao.insertrm(sroleMenu); + + } + + return ResultVOUtils.success(); + } +} diff --git a/src/main/java/com/glxp/api/service/auth/impl/sroleServiceImpl.java b/src/main/java/com/glxp/api/service/auth/impl/sroleServiceImpl.java new file mode 100644 index 0000000..d0345f8 --- /dev/null +++ b/src/main/java/com/glxp/api/service/auth/impl/sroleServiceImpl.java @@ -0,0 +1,53 @@ +package com.glxp.api.service.auth.impl; + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.github.pagehelper.PageHelper; +import com.glxp.api.dao.auth.sroleDao; +import com.glxp.api.entity.auth.Syrole; +import com.glxp.api.req.auth.sroleRequest; +import com.glxp.api.res.auth.sroleResponse; +import com.glxp.api.service.auth.sroleService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.Collections; +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:36 + * @modyified By : + */ +@Service +public class sroleServiceImpl extends ServiceImpl implements sroleService { + + @Resource + sroleDao sroleDao; + + @Override + public List selectRoleList(sroleRequest sroleRequest) { + if (null == sroleRequest) { + return Collections.emptyList(); + } + if (null != sroleRequest.getPage() && null != sroleRequest.getLimit()) { + PageHelper.offsetPage((sroleRequest.getPage() - 1) * sroleRequest.getLimit(), sroleRequest.getLimit()); + } + + return sroleDao.selectRoleList(sroleRequest); + } + + @Override + public boolean insert(Syrole syrole) { + return sroleDao.insert(syrole)>0; + } + + @Override + public boolean update(Syrole syrole) { + return sroleDao.updateById(syrole)>0; + } + + @Override + public boolean delete(Syrole syrole) { + return sroleDao.deleteById(syrole)>0; + } +} diff --git a/src/main/java/com/glxp/api/service/auth/sroleMenuService.java b/src/main/java/com/glxp/api/service/auth/sroleMenuService.java new file mode 100644 index 0000000..4318455 --- /dev/null +++ b/src/main/java/com/glxp/api/service/auth/sroleMenuService.java @@ -0,0 +1,24 @@ +package com.glxp.api.service.auth; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.glxp.api.common.res.BaseResponse; +import com.glxp.api.dto.SysRoleMenuModel; +import com.glxp.api.entity.auth.sroleMenu; + +/** + * @author : zhangsan + * @date : 2023/5/25 16:05 + * @modyified By : + */ + +public interface sroleMenuService extends IService { + + + boolean delete(sroleMenu sroleMenu); + + boolean insert(sroleMenu sroleMenu); + + BaseResponse getRoleMenu(Long roleId); + + BaseResponse saveRoleMenu(SysRoleMenuModel model); +} diff --git a/src/main/java/com/glxp/api/service/auth/sroleService.java b/src/main/java/com/glxp/api/service/auth/sroleService.java new file mode 100644 index 0000000..9e094e1 --- /dev/null +++ b/src/main/java/com/glxp/api/service/auth/sroleService.java @@ -0,0 +1,25 @@ +package com.glxp.api.service.auth; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.glxp.api.entity.auth.Syrole; +import com.glxp.api.req.auth.sroleRequest; +import com.glxp.api.res.auth.sroleResponse; + +import java.util.List; + +/** + * @author : zhangsan + * @date : 2023/5/25 14:35 + * @modyified By : + */ + +public interface sroleService extends IService { + + List selectRoleList(sroleRequest sroleRequest); + + boolean insert(Syrole syrole); + + boolean update(Syrole syrole); + + boolean delete(Syrole syrole); +} diff --git a/src/main/resources/mybatis/mapper/auth/AuthLicenseDao.xml b/src/main/resources/mybatis/mapper/auth/AuthLicenseDao.xml index f9160c5..573c152 100644 --- a/src/main/resources/mybatis/mapper/auth/AuthLicenseDao.xml +++ b/src/main/resources/mybatis/mapper/auth/AuthLicenseDao.xml @@ -2,6 +2,7 @@ + + select * + from sys_menu + + + and name =#{name} + + + and parentId =#{parentId} + + + AND date_format(createTime, '%Y-%m-%d') between date_format(#{startTime}, '%Y-%m-%d') and date_format(#{endTime}, '%Y-%m-%d') + + + AND date_format(updateTime, '%Y-%m-%d') between date_format(#{startAduditTime}, '%Y-%m-%d') and date_format(#{endAduditTime}, '%Y-%m-%d') + + + + + + + + + diff --git a/src/main/resources/mybatis/mapper/auth/sroleDao.xml b/src/main/resources/mybatis/mapper/auth/sroleDao.xml new file mode 100644 index 0000000..6382eaa --- /dev/null +++ b/src/main/resources/mybatis/mapper/auth/sroleDao.xml @@ -0,0 +1,24 @@ + + + + + + + + diff --git a/src/main/resources/mybatis/mapper/auth/sroleMenuMapper.xml b/src/main/resources/mybatis/mapper/auth/sroleMenuMapper.xml new file mode 100644 index 0000000..7fd9a12 --- /dev/null +++ b/src/main/resources/mybatis/mapper/auth/sroleMenuMapper.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + delete + from sys_role_menu + where role_id=#{roleId} + + + + insert into sys_role_menu (role_id, menu_id) + values (#{roleId}, #{menuId}) + + +