收音机页面路径配置
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
package com.czg.controller.admin;
|
||||
|
||||
import com.czg.account.dto.pagepath.PagePathPermissionAddDTO;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
import com.czg.account.entity.ShopStaffPagePermission;
|
||||
import com.czg.account.service.ShopPagePathService;
|
||||
import com.czg.account.service.ShopStaffPagePermissionService;
|
||||
import com.czg.resp.CzgResult;
|
||||
import com.czg.sa.StpKit;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 收银机页面权限相关
|
||||
* @author Administrator
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/admin/shopPagePermission")
|
||||
public class ShopPagePermissionController {
|
||||
@Resource
|
||||
private ShopPagePathService shopPagePathService;
|
||||
@Resource
|
||||
private ShopStaffPagePermissionService shopStaffPagePermissionService;
|
||||
|
||||
/**
|
||||
* 获取所有页面路径
|
||||
* @return 页面路径
|
||||
*/
|
||||
@GetMapping
|
||||
public CzgResult<List<ShopPagePath>> page() {
|
||||
return CzgResult.success(shopPagePathService.list());
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存修改权限
|
||||
* @return 是否成功
|
||||
*/
|
||||
@PostMapping
|
||||
public CzgResult<Boolean> add(PagePathPermissionAddDTO pagePathPermissionAddDTO) {
|
||||
if (StpKit.USER.isStaff()) {
|
||||
return CzgResult.failure("员工无权限");
|
||||
}
|
||||
return CzgResult.success(shopStaffPagePermissionService.add(StpKit.USER.getShopId(), pagePathPermissionAddDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前用户已拥有页面路径
|
||||
*/
|
||||
@GetMapping("/mine")
|
||||
public CzgResult<List<ShopPagePath>> mine() {
|
||||
Set<Long> pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId, StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, StpKit.USER.getLoginIdAsLong())).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet());
|
||||
if (pageIdList.isEmpty()) {
|
||||
return CzgResult.success(new ArrayList<>());
|
||||
}
|
||||
return CzgResult.success(shopPagePathService.list(new QueryWrapper().in(ShopPagePath::getId, pageIdList)));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
|
||||
package com.czg.account.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import com.alibaba.fastjson2.annotation.JSONField;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopPagePathDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
|
||||
package com.czg.account.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.Serial;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ShopStaffPagePermissionDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
private Long shopId;
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
*/
|
||||
private Long pagePathId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.account.dto.pagepath;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
*/
|
||||
@Data
|
||||
public class PagePathPermissionAddDTO {
|
||||
private List<Long> pagePathIdList;
|
||||
private Long staffId;
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_page_path")
|
||||
public class ShopPagePath implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Id(keyType = KeyType.Auto)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
*/
|
||||
private String path;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 修改时间
|
||||
*/
|
||||
@Column(onInsertValue = "now()", onUpdateValue = "now()")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.czg.account.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.io.Serial;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 实体类。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Table("tb_shop_staff_page_permission")
|
||||
public class ShopStaffPagePermission implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 店铺id
|
||||
*/
|
||||
@Id
|
||||
private Long shopId;
|
||||
private Long staffId;
|
||||
|
||||
/**
|
||||
* 页面路径
|
||||
*/
|
||||
private Long pagePathId;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.account.service;
|
||||
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
public interface ShopPagePathService extends IService<ShopPagePath> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.czg.account.service;
|
||||
|
||||
import com.czg.account.dto.pagepath.PagePathPermissionAddDTO;
|
||||
import com.mybatisflex.core.service.IService;
|
||||
import com.czg.account.entity.ShopStaffPagePermission;
|
||||
|
||||
/**
|
||||
* 服务层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
public interface ShopStaffPagePermissionService extends IService<ShopStaffPagePermission> {
|
||||
|
||||
Boolean add(Long shopId, PagePathPermissionAddDTO pagePathPermissionAddDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
public interface ShopPagePathMapper extends BaseMapper<ShopPagePath> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.czg.service.account.mapper;
|
||||
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import com.czg.account.entity.ShopStaffPagePermission;
|
||||
|
||||
/**
|
||||
* 映射层。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
public interface ShopStaffPagePermissionMapper extends BaseMapper<ShopStaffPagePermission> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
import com.czg.account.service.ShopPagePathService;
|
||||
import com.czg.service.account.mapper.ShopPagePathMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
@Service
|
||||
public class ShopPagePathServiceImpl extends ServiceImpl<ShopPagePathMapper, ShopPagePath> implements ShopPagePathService{
|
||||
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.czg.service.account.service.impl;
|
||||
|
||||
import com.czg.account.dto.pagepath.PagePathPermissionAddDTO;
|
||||
import com.czg.account.entity.ShopPagePath;
|
||||
import com.czg.account.entity.ShopStaff;
|
||||
import com.czg.account.service.ShopPagePathService;
|
||||
import com.czg.account.service.ShopStaffService;
|
||||
import com.czg.exception.ApiNotPrintException;
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.mybatisflex.spring.service.impl.ServiceImpl;
|
||||
import com.czg.account.entity.ShopStaffPagePermission;
|
||||
import com.czg.account.service.ShopStaffPagePermissionService;
|
||||
import com.czg.service.account.mapper.ShopStaffPagePermissionMapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* 服务层实现。
|
||||
*
|
||||
* @author zs
|
||||
* @since 2025-04-02
|
||||
*/
|
||||
@Service
|
||||
public class ShopStaffPagePermissionServiceImpl extends ServiceImpl<ShopStaffPagePermissionMapper, ShopStaffPagePermission> implements ShopStaffPagePermissionService{
|
||||
@Resource
|
||||
private ShopPagePathService shopPagePathService;
|
||||
@Resource
|
||||
private ShopStaffService shopStaffService;
|
||||
|
||||
@Override
|
||||
public Boolean add(Long shopId, PagePathPermissionAddDTO pagePathPermissionAddDTO) {
|
||||
ShopStaff shopStaff = shopStaffService.getOne(new QueryWrapper().eq(ShopStaff::getId, pagePathPermissionAddDTO.getStaffId()).eq(ShopStaff::getShopId, shopId));
|
||||
if (shopStaff == null) {
|
||||
throw new ApiNotPrintException("员工不存在");
|
||||
}
|
||||
|
||||
long count = shopPagePathService.count(new QueryWrapper().in(ShopPagePath::getId, pagePathPermissionAddDTO.getPagePathIdList()));
|
||||
if (count != pagePathPermissionAddDTO.getPagePathIdList().size()) {
|
||||
throw new ApiNotPrintException("存在错误id");
|
||||
}
|
||||
|
||||
ArrayList<ShopStaffPagePermission> pagePermissions = new ArrayList<>();
|
||||
pagePathPermissionAddDTO.getPagePathIdList().forEach(item -> {
|
||||
ShopStaffPagePermission permission = new ShopStaffPagePermission();
|
||||
permission.setShopId(shopId);
|
||||
permission.setPagePathId(item);
|
||||
permission.setStaffId(pagePathPermissionAddDTO.getStaffId());
|
||||
pagePermissions.add(permission);
|
||||
});
|
||||
return saveBatch(pagePermissions);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopPagePathMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.czg.service.account.mapper.ShopStaffPagePermissionMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user