登录账号添加场站并赋予该站权限

This commit is contained in:
yuyang 2021-12-20 09:28:46 +08:00
parent 83783db947
commit 913dce9225
4 changed files with 37 additions and 3 deletions

View File

@ -167,7 +167,7 @@ public class XhpcChargingStationController extends BaseController {
/**
* 添加场
* 添加场
*
* @param xhpcChargingStationDto
* @return

View File

@ -261,7 +261,9 @@ public interface XhpcChargingStationMapper {
*/
Map<String, Object> getLandUser(@Param("userId") Long userId);
/**
* 添加场站数据权限
*/
void addXhpcUserPrivilege(@Param("userId") Long userId,@Param("chargingStationId") Long chargingStationId);
}

View File

@ -595,6 +595,21 @@ public class XhpcChargingStationServiceImpl implements IXhpcChargingStationServi
//修改桩和终端的模板id
xhpcChargingStationMapper.updateXhpcChargingPile(chargingStationId,rateModelId);
xhpcChargingStationMapper.updateXhpcTerminal(chargingStationId,rateModelId);
try{
//获取登陆用户
Long logUserId = SecurityUtils.getUserId();
if(logUserId !=1){
Map<String, Object> landUser = xhpcChargingStationMapper.getLandUser(logUserId);
if(landUser !=null){
if(landUser.get("userType") !=null && "02".equals(landUser.get("userType").toString())){
xhpcChargingStationMapper.addXhpcUserPrivilege(logUserId,chargingStationId);
}
}
}
}catch (Exception e){
logger.info("添加场站权限失败");
}
return AjaxResult.success();
}

View File

@ -890,4 +890,21 @@
select user_id as userId,user_type as userType,operator_id as operatorId from sys_user where user_id =#{userId}
</select>
<insert id="addXhpcUserPrivilege">
insert into xhpc_user_privilege(
<if test="null != userId and '' != userId">
user_id,
</if>
<if test="null != chargingStationId and '' != chargingStationId">
charging_station_id
</if>
)values(
<if test="null != userId and '' != userId">
#{userId},
</if>
<if test="null != chargingStationId and '' != chargingStationId">
#{chargingStationId}
</if>
)
</insert>
</mapper>