mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-04-20 02:55:04 +08:00
update 权限
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
package com.jsowell.common.core.domain;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -12,7 +14,7 @@ import java.util.Map;
|
||||
*
|
||||
* @author jsowell
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -53,6 +55,11 @@ public class BaseEntity implements Serializable {
|
||||
*/
|
||||
private Map<String, Object> params;
|
||||
|
||||
// 有权限的运营商
|
||||
private List<String> merchantDeptIds;
|
||||
// 有权限的站点
|
||||
private List<String> stationDeptIds;
|
||||
|
||||
public String getSearchValue() {
|
||||
return searchValue;
|
||||
}
|
||||
|
||||
@@ -3,9 +3,11 @@ package com.jsowell.pile.service.impl;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.jsowell.common.annotation.DataScope;
|
||||
import com.jsowell.common.constant.Constants;
|
||||
import com.jsowell.common.core.domain.entity.SysDept;
|
||||
import com.jsowell.common.core.domain.entity.SysRole;
|
||||
import com.jsowell.common.core.domain.entity.SysUser;
|
||||
import com.jsowell.common.core.domain.model.LoginUser;
|
||||
import com.jsowell.common.core.page.PageResponse;
|
||||
import com.jsowell.common.util.DateUtils;
|
||||
import com.jsowell.common.util.DistanceUtils;
|
||||
@@ -24,8 +26,10 @@ import com.jsowell.pile.vo.base.ConnectorInfoVO;
|
||||
import com.jsowell.pile.vo.base.MerchantInfoVO;
|
||||
import com.jsowell.pile.vo.base.StationInfoVO;
|
||||
import com.jsowell.pile.vo.uniapp.CurrentTimePriceDetails;
|
||||
import com.jsowell.pile.vo.web.AuthorizedDeptVO;
|
||||
import com.jsowell.pile.vo.web.PileStationVO;
|
||||
import com.jsowell.system.service.SysDeptService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -40,6 +44,7 @@ import java.util.Map;
|
||||
* @author jsowell
|
||||
* @date 2022-08-30
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
||||
@Autowired
|
||||
@@ -123,6 +128,45 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
||||
return pileStationInfoMapper.selectPileStationInfoList(pileStationInfo);
|
||||
}
|
||||
|
||||
// 查询登录用户权限id
|
||||
private AuthorizedDeptVO getAuthorizedMap() {
|
||||
// 登录用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
if (loginUser == null) {
|
||||
return null;
|
||||
}
|
||||
// 用户
|
||||
SysUser user = loginUser.getUser();
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
AuthorizedDeptVO resultVO = AuthorizedDeptVO.builder().build();
|
||||
// 登录用户所属部门(运营商或站点 根据父级id判断)
|
||||
SysDept dept = user.getDept();
|
||||
if (dept == null) {
|
||||
return null;
|
||||
}
|
||||
// 登录用户角色
|
||||
List<SysRole> roles = user.getRoles();
|
||||
log.info("登录用户deptIds", roles.get(0).getDeptIds());
|
||||
Long parentId = dept.getParentId();
|
||||
List<String> merchantDeptIds = Lists.newArrayList();
|
||||
List<String> stationDeptIds = Lists.newArrayList();
|
||||
if (parentId == 0L) {
|
||||
// 父级id是0,表明是该账号挂在平台下面,是系统管理员
|
||||
|
||||
} else if (parentId == 100L) {
|
||||
// 父级id是100,表明是该账号挂在运营商下面,是运营商管理员
|
||||
merchantDeptIds.add(String.valueOf(dept.getDeptId()));
|
||||
resultVO.setMerchantDeptIds(merchantDeptIds);
|
||||
} else {
|
||||
// 其他情况,表明是站点管理员
|
||||
stationDeptIds.add(String.valueOf(dept.getDeptId()));
|
||||
resultVO.setStationDeptIds(stationDeptIds);
|
||||
}
|
||||
return resultVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过运营商id查询站点信息
|
||||
*
|
||||
@@ -225,15 +269,16 @@ public class PileStationInfoServiceImpl implements IPileStationInfoService {
|
||||
* @return 充电站对象集合
|
||||
*/
|
||||
@Override
|
||||
@DataScope(deptAlias = "t3")
|
||||
// @DataScope(deptAlias = "t3")
|
||||
public List<PileStationVO> queryStationInfos(QueryStationDTO dto) {
|
||||
AuthorizedDeptVO authorizedMap = getAuthorizedMap();
|
||||
if (authorizedMap == null) {
|
||||
// 为空表示没有权限,返回空数组
|
||||
return Lists.newArrayList();
|
||||
}
|
||||
dto.setStationDeptIds(authorizedMap.getStationDeptIds());
|
||||
dto.setMerchantDeptIds(authorizedMap.getMerchantDeptIds());
|
||||
List<PileStationVO> list = pileStationInfoMapper.queryStationInfos(dto);
|
||||
// if (Objects.nonNull(list)){
|
||||
// for (PileStationVO p:list) {
|
||||
// String station_type = p.getStationType();
|
||||
// p.setStationType(DictUtils.getDictLabel("station_type", station_type));
|
||||
// }
|
||||
// }
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.jsowell.pile.vo.web;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class AuthorizedDeptVO {
|
||||
// 有权限的运营商
|
||||
private List<String> merchantDeptIds;
|
||||
// 有权限的站点
|
||||
private List<String> stationDeptIds;
|
||||
}
|
||||
@@ -318,8 +318,19 @@
|
||||
<if test="stationDTO.publicFlag != null and stationDTO.publicFlag != ''">
|
||||
and t1.public_flag = #{stationDTO.publicFlag,jdbcType=VARCHAR}
|
||||
</if>
|
||||
<!-- 数据范围过滤 -->
|
||||
${stationDTO.params.dataScope}
|
||||
<!-- 数据范围过滤 -->
|
||||
<if test="stationDTO.merchantDeptIds != null and stationDTO.merchantDeptIds.size() != 0">
|
||||
and t3.dept_id in
|
||||
<foreach collection="stationDTO.merchantDeptIds" item="merchantDeptId" open="(" separator="," close=")">
|
||||
#{merchantDeptId}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="stationDTO.stationDeptIds != null and stationDTO.stationDeptIds.size() != 0">
|
||||
and t1.dept_id in
|
||||
<foreach collection="stationDTO.stationDeptIds" item="stationDeptId" open="(" separator="," close=")">
|
||||
#{stationDeptId}
|
||||
</foreach>
|
||||
</if>
|
||||
GROUP BY
|
||||
t1.id,
|
||||
t1.station_name,
|
||||
|
||||
Reference in New Issue
Block a user