Commit 79afe702 authored by leizhan's avatar leizhan

优化电站管理列表接口,区分经销商和管理员角色查询

parent 04a4e56f
...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.hygf.biz.controller; ...@@ -3,6 +3,8 @@ package com.yeejoin.amos.boot.module.hygf.biz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto; import com.yeejoin.amos.boot.module.hygf.api.dto.PowerStationDto;
import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PowerStationServiceImpl; import com.yeejoin.amos.boot.module.hygf.biz.service.impl.PowerStationServiceImpl;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.RoleModel;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -10,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
...@@ -20,7 +23,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -20,7 +23,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
/** /**
* *
* *
* @author system_generator * @author system_generator
* @date 2023-07-15 * @date 2023-07-15
...@@ -96,12 +99,20 @@ public class PowerStationController extends BaseController { ...@@ -96,12 +99,20 @@ public class PowerStationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/page") @GetMapping(value = "/page")
@ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询") @ApiOperation(httpMethod = "GET",value = "分页查询", notes = "分页查询")
public ResponseModel<Page<PowerStationDto>> queryForPage(@RequestParam(value = "current") int current, @RequestParam public ResponseModel<Page<PowerStationDto>> queryForPage(@RequestParam(value = "current") int current,
(value = "size") int size) { @RequestParam(value = "size") int size,
@RequestParam(value = "powerStationCode",required = false)String powerStationCode,
@RequestParam(value = "ownersName",required = false)String ownersName) {
Page<PowerStationDto> page = new Page<PowerStationDto>(); Page<PowerStationDto> page = new Page<PowerStationDto>();
page.setCurrent(current); page.setCurrent(current);
page.setSize(size); page.setSize(size);
return ResponseHelper.buildResponse(powerStationServiceImpl.queryForPowerStationPage(page)); String serviceAgent = "";
AgencyUserModel userInfo = getUserInfo();
Map<Long, List<RoleModel>> orgRoles = userInfo.getOrgRoles();
List<RoleModel> roleModels = orgRoles.get(userInfo.getCompanys().get(0).getSequenceNbr());
List<String> roleTypes = roleModels.stream().map(RoleModel::getRoleType).collect(Collectors.toList());
serviceAgent = !roleTypes.contains("HYGFGLY") ? roleTypes.contains("HYGFJXS") ? userInfo.getCompanys().get(0).getCompanyName() : null : null ;
return ResponseHelper.buildResponse(powerStationServiceImpl.queryForPowerStationPage(page,powerStationCode,ownersName,serviceAgent));
} }
/** /**
......
...@@ -30,6 +30,8 @@ import org.apache.commons.lang.StringUtils; ...@@ -30,6 +30,8 @@ import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
...@@ -71,8 +73,8 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS ...@@ -71,8 +73,8 @@ public class PowerStationServiceImpl extends BaseService<PowerStationDto, PowerS
/** /**
* 分页查询 * 分页查询
*/ */
public Page<PowerStationDto> queryForPowerStationPage(Page<PowerStationDto> page) { public Page<PowerStationDto> queryForPowerStationPage(Page<PowerStationDto> page,@Condition(Operator.like) String powerStationCode,@Condition(Operator.like) String ownersName,String serviceAgent) {
return this.queryForPage(page, null, false); return this.queryForPage(page, null, false,powerStationCode,ownersName,serviceAgent);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment