默认初始化页面权限

This commit is contained in:
张松
2025-04-02 16:13:26 +08:00
parent 989945d85e
commit 7d311bb3a0
3 changed files with 37 additions and 5 deletions

View File

@@ -1,10 +1,22 @@
package com.czg.service.account.service.impl;
import com.czg.account.entity.ShopStaffPagePermission;
import com.czg.account.service.ShopStaffPagePermissionService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
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 jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 服务层实现。
@@ -14,5 +26,24 @@ import org.springframework.stereotype.Service;
*/
@Service
public class ShopPagePathServiceImpl extends ServiceImpl<ShopPagePathMapper, ShopPagePath> implements ShopPagePathService{
@Resource
private ShopStaffPagePermissionService shopStaffPagePermissionService;
@Override
public List<ShopPagePath> detail(Long staffId) {
Set<Long> pageIdList = shopStaffPagePermissionService.list(new QueryWrapper().eq(ShopStaffPagePermission::getShopId,
StpKit.USER.getShopId()).eq(ShopStaffPagePermission::getStaffId, staffId)).stream().map(ShopStaffPagePermission::getPagePathId).collect(Collectors.toSet());
if (pageIdList.isEmpty()) {
list().forEach(item -> {
ShopStaffPagePermission permission = new ShopStaffPagePermission();
permission.setShopId(StpKit.USER.getShopId());
permission.setStaffId(staffId);
permission.setPagePathId(item.getId());
shopStaffPagePermissionService.save(permission);
pageIdList.add(permission.getPagePathId());
});
}
return list(new QueryWrapper().in(ShopPagePath::getId, pageIdList));
}
}