请求员工权限
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.controller;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@Slf4j
|
||||||
|
@RequestMapping("staffPermission")
|
||||||
|
public class StaffPermissionController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbShopPermissionService permissionService;
|
||||||
|
|
||||||
|
@GetMapping
|
||||||
|
public Result getStaffPermission(String staffId, String code) {
|
||||||
|
return permissionService.getStaffPermission(staffId, code);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (TbShopPermission)表数据库访问层
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:08:48
|
||||||
|
*/
|
||||||
|
public interface TbShopPermissionDao extends BaseMapper<TbShopPermission> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.dao;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺员工权限关联表(TbShopStaffPermission)表数据库访问层
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:07:33
|
||||||
|
*/
|
||||||
|
public interface TbShopStaffPermissionDao extends BaseMapper<TbShopStaffPermission> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (TbShopPermission)表实体类
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:08:48
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class TbShopPermission extends Model<TbShopPermission> {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
//权限类型:staff 员工,
|
||||||
|
private String type;
|
||||||
|
//权限名称
|
||||||
|
private String label;
|
||||||
|
//权限code,为了区分采用汉语拼音
|
||||||
|
private String code;
|
||||||
|
//层级
|
||||||
|
private Integer level;
|
||||||
|
//上级ID
|
||||||
|
private Integer parentId;
|
||||||
|
//是否重要: 重要对应页面红色
|
||||||
|
private Integer isImportant;
|
||||||
|
//排序
|
||||||
|
private Integer sort;
|
||||||
|
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLabel() {
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLabel(String label) {
|
||||||
|
this.label = label;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCode(String code) {
|
||||||
|
this.code = code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getLevel() {
|
||||||
|
return level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLevel(Integer level) {
|
||||||
|
this.level = level;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParentId() {
|
||||||
|
return parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParentId(Integer parentId) {
|
||||||
|
this.parentId = parentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIsImportant() {
|
||||||
|
return isImportant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsImportant(Integer isImportant) {
|
||||||
|
this.isImportant = isImportant;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSort() {
|
||||||
|
return sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSort(Integer sort) {
|
||||||
|
this.sort = sort;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCreateTime() {
|
||||||
|
return createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreateTime(Date createTime) {
|
||||||
|
this.createTime = createTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getUpdateTime() {
|
||||||
|
return updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUpdateTime(Date updateTime) {
|
||||||
|
this.updateTime = updateTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主键值
|
||||||
|
*
|
||||||
|
* @return 主键值
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Serializable pkVal() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺员工权限关联表(TbShopStaffPermission)表实体类
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:07:33
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("serial")
|
||||||
|
public class TbShopStaffPermission extends Model<TbShopStaffPermission> {
|
||||||
|
|
||||||
|
private Integer id;
|
||||||
|
//权限ID
|
||||||
|
private Integer permissionId;
|
||||||
|
//员工ID
|
||||||
|
private Integer staffId;
|
||||||
|
//店铺ID
|
||||||
|
private Integer shopId;
|
||||||
|
//用户ID
|
||||||
|
private Integer userId;
|
||||||
|
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPermissionId() {
|
||||||
|
return permissionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPermissionId(Integer permissionId) {
|
||||||
|
this.permissionId = permissionId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStaffId() {
|
||||||
|
return staffId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStaffId(Integer staffId) {
|
||||||
|
this.staffId = staffId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getShopId() {
|
||||||
|
return shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopId(Integer shopId) {
|
||||||
|
this.shopId = shopId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(Integer userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取主键值
|
||||||
|
*
|
||||||
|
* @return 主键值
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected Serializable pkVal() {
|
||||||
|
return this.id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (TbShopPermission)表服务接口
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:08:48
|
||||||
|
*/
|
||||||
|
public interface TbShopPermissionService extends IService<TbShopPermission> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询员工是否拥有某个权限
|
||||||
|
*/
|
||||||
|
Result getStaffPermission(String staffId, String code);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺员工权限关联表(TbShopStaffPermission)表服务接口
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:07:33
|
||||||
|
*/
|
||||||
|
public interface TbShopStaffPermissionService extends IService<TbShopStaffPermission> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.dao.TbShopPermissionDao;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopPermission;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* (TbShopPermission)表服务实现类
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:08:49
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Primary
|
||||||
|
public class TbShopPermissionServiceImpl extends ServiceImpl<TbShopPermissionDao, TbShopPermission> implements TbShopPermissionService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TbShopStaffPermissionService shopStaffPermissionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result getStaffPermission(String staffId, String code) {
|
||||||
|
QueryWrapper<TbShopPermission> queryWrapper = new QueryWrapper<>();
|
||||||
|
queryWrapper.eq("code", code);
|
||||||
|
TbShopPermission permission = this.getOne(queryWrapper);
|
||||||
|
if (permission == null) {
|
||||||
|
return Result.fail("权限不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<TbShopStaffPermission> staffPermissionQueryWrapper = new QueryWrapper<>();
|
||||||
|
staffPermissionQueryWrapper.eq("staff_id", staffId);
|
||||||
|
staffPermissionQueryWrapper.eq("permission_id", permission.getId());
|
||||||
|
TbShopStaffPermission staffPermission = shopStaffPermissionService.getOne(staffPermissionQueryWrapper);
|
||||||
|
|
||||||
|
return Result.success(CodeEnum.SUCCESS, staffPermission != null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.chaozhanggui.system.cashierservice.dao.TbShopStaffPermissionDao;
|
||||||
|
import com.chaozhanggui.system.cashierservice.entity.TbShopStaffPermission;
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbShopStaffPermissionService;
|
||||||
|
import org.springframework.context.annotation.Primary;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店铺员工权限关联表(TbShopStaffPermission)表服务实现类
|
||||||
|
*
|
||||||
|
* @author makejava
|
||||||
|
* @since 2024-09-14 17:07:33
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@Primary
|
||||||
|
public class TbShopStaffPermissionServiceImpl extends ServiceImpl<TbShopStaffPermissionDao, TbShopStaffPermission> implements TbShopStaffPermissionService {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
package com.chaozhanggui.system.cashierservice;
|
||||||
|
|
||||||
|
import com.chaozhanggui.system.cashierservice.service.TbShopPermissionService;
|
||||||
|
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
import org.springframework.test.context.ActiveProfiles;
|
||||||
|
|
||||||
|
@ActiveProfiles("dev")
|
||||||
|
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
|
||||||
|
public class StaffPermissionTest {
|
||||||
|
@Autowired
|
||||||
|
private TbShopPermissionService tbShopPermissionService;
|
||||||
|
@Test
|
||||||
|
public void testStaffPermission() {
|
||||||
|
|
||||||
|
Result yunXuTuiKuan = tbShopPermissionService.getStaffPermission("128", "yun_xu_tui_kuan2");
|
||||||
|
System.out.println(yunXuTuiKuan);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user