| | |
| | | import com.ruoyi.common.core.web.domain.AjaxResult; |
| | | import com.ruoyi.common.core.web.page.PageInfo; |
| | | 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 org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.Arrays; |
| | | import java.util.HashSet; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Set; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | |
| | | @Resource |
| | | private IPartnerService partnerService; |
| | | |
| | | @Resource |
| | | private UserSiteClient userSiteClient; |
| | | |
| | | @Resource |
| | | private RoleSiteClient roleSiteClient; |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | public PageInfo<TChargingGunVO> pageList(TChargingGunQuery query) { |
| | | List<Integer> siteIds = null; |
| | | Set<Integer> siteIds = null; |
| | | //校验合作商权限 |
| | | SysUser sysUser = sysUserClient.getSysUser(SecurityUtils.getUserId()).getData(); |
| | | Integer roleType = sysUser.getRoleType(); |
| | |
| | | //合作商 |
| | | if(roleType == 2){ |
| | | siteIds = partnerService.authSite(objectId, SiteMenu.CHARGING_GUN); |
| | | }else{ |
| | | //非管理员需要根据角色和用户配置查询允许的站点数据 |
| | | if(!SecurityUtils.isAdmin(SecurityUtils.getUserId())){ |
| | | List<Integer> data = userSiteClient.getSiteIds(sysUser.getUserId()).getData(); |
| | | List<Integer> data1 = roleSiteClient.getSiteIds(sysUser.getRoleId()).getData(); |
| | | data.addAll(data1); |
| | | siteIds = new HashSet<>(data); |
| | | } |
| | | } |
| | | PageInfo<TChargingGunVO> pageInfo = new PageInfo<>(query.getPageCurr(),query.getPageSize()); |
| | | List<TChargingGunVO> list = this.baseMapper.pageList(query,pageInfo, siteIds); |
| | |
| | | if(ajaxResult.isError()){ |
| | | return ajaxResult; |
| | | } |
| | | long count = this.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()).eq(TChargingGun::getDelFlag, 0)); |
| | | long count = this.count(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()) |
| | | .eq(TChargingGun::getDelFlag, 0)); |
| | | if(count > 0){ |
| | | return AjaxResult.error("接口编码已存在"); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public AjaxResult update(TChargingGunDTO dto) { |
| | | TChargingGun chargingGun = this.getById(dto.getId()); |
| | | if(Arrays.asList(3,4,5,6).contains(chargingGun.getStatus())){ |
| | | return AjaxResult.error("接口占用中,无法编辑!"); |
| | | } |
| | | AjaxResult ajaxResult = addVerify(dto); |
| | | if(ajaxResult.isError()){ |
| | | return ajaxResult; |
| | | } |
| | | TChargingGun one = this.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()).eq(TChargingGun::getDelFlag, 0)); |
| | | TChargingGun one = this.getOne(new LambdaQueryWrapper<TChargingGun>().eq(TChargingGun::getCode, dto.getCode()) |
| | | .eq(TChargingGun::getDelFlag, 0)); |
| | | if(null != one && !dto.getId().equals(one.getId())){ |
| | | return AjaxResult.error("接口编码已存在"); |
| | | } |