package com.ruoyi.chargingPile.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ruoyi.chargingPile.api.model.Site;
|
import com.ruoyi.chargingPile.api.model.TChargingPileNotification;
|
import com.ruoyi.chargingPile.domain.SiteMenu;
|
import com.ruoyi.chargingPile.mapper.TChargingPileNotificationMapper;
|
import com.ruoyi.chargingPile.service.IPartnerService;
|
import com.ruoyi.chargingPile.service.TChargingPileNotificationService;
|
import com.ruoyi.common.core.web.page.BasePage;
|
import com.ruoyi.common.core.web.page.PageInfo;
|
import com.ruoyi.common.security.service.TokenService;
|
import com.ruoyi.common.security.utils.SecurityUtils;
|
import com.ruoyi.other.api.feignClient.RoleSiteClient;
|
import com.ruoyi.other.api.feignClient.UserSiteClient;
|
import com.ruoyi.system.api.domain.SysUser;
|
import com.ruoyi.system.api.feignClient.SysUserClient;
|
import com.ruoyi.system.api.feignClient.SysUserRoleClient;
|
import com.ruoyi.system.api.model.SysUserRoleVo;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.HashSet;
|
import java.util.List;
|
import java.util.Set;
|
|
/**
|
* <p>
|
* 服务实现类
|
* </p>
|
*
|
* @author xiaochen
|
* @since 2024-08-08
|
*/
|
@Service
|
public class TChargingPileNotificationServiceImpl extends ServiceImpl<TChargingPileNotificationMapper, TChargingPileNotification> implements TChargingPileNotificationService {
|
|
@Resource
|
private SysUserClient sysUserClient;
|
|
@Resource
|
private IPartnerService partnerService;
|
|
@Resource
|
private UserSiteClient userSiteClient;
|
|
@Resource
|
private RoleSiteClient roleSiteClient;
|
|
@Resource
|
private SysUserRoleClient sysUserRoleClient;
|
|
@Resource
|
private TokenService tokenService;
|
|
|
|
|
/**
|
* 获取系统通知列表数据
|
* @param siteId
|
* @param basePage
|
* @return
|
*/
|
@Override
|
public PageInfo<TChargingPileNotification> chargingPileNotificationPageList(Integer siteId, BasePage basePage) {
|
//校验当前账户站点权限
|
Set<Integer> siteIds = null;
|
if(null == siteId){
|
SysUser sysUser = sysUserClient.getSysUser(tokenService.getLoginUser().getUserid()).getData();
|
Integer roleType = sysUser.getRoleType();
|
Integer objectId = sysUser.getObjectId();
|
LambdaQueryWrapper<Site> wrapper = new LambdaQueryWrapper<Site>().eq(Site::getDelFlag, 0);
|
if(2 == roleType){
|
siteIds = partnerService.authSite(objectId, SiteMenu.SITE_LIST);
|
}else{
|
//非管理员需要根据角色和用户配置查询允许的站点数据
|
if(!SecurityUtils.isAdmin(tokenService.getLoginUser().getUserid())){
|
List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData();
|
List<SysUserRoleVo> data2 = sysUserRoleClient.getRoleByUserId(sysUser.getUserId()).getData();
|
List<Integer> data1 = roleSiteClient.getSiteIds(data2.get(0).getRoleId()).getData();
|
data.addAll(data1);
|
siteIds = new HashSet<>(data);
|
}
|
}
|
}else{
|
siteIds = new HashSet<>();
|
siteIds.add(siteId);
|
}
|
PageInfo<TChargingPileNotification> pageInfo = new PageInfo<>(basePage.getPageCurr(), basePage.getPageSize());
|
List<TChargingPileNotification> list = this.baseMapper.chargingPileNotificationPageList(pageInfo, siteIds);
|
pageInfo.setRecords(list);
|
return pageInfo;
|
}
|
|
@Override
|
public void saveData(Integer type,Integer siteId,Integer chargingPileId, String phone, String data) {
|
TChargingPileNotification notification = new TChargingPileNotification();
|
notification.setSiteId(siteId);
|
notification.setChargingPileId(chargingPileId);
|
notification.setPhone(phone);
|
notification.setContent(data);
|
this.save(notification);
|
}
|
|
}
|