package com.whyc.controller;
|
|
import com.github.pagehelper.PageInfo;
|
import com.whyc.dto.Response;
|
import com.whyc.pojo.PowerInf;
|
import com.whyc.pojo.UserInf;
|
import com.whyc.service.PowerInfService;
|
import com.whyc.util.ActionUtil;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import java.util.List;
|
|
@RequestMapping("powerInf")
|
@RestController
|
@Api(tags = "电源管理")
|
public class PowerInfController {
|
@Autowired
|
private PowerInfService service;
|
|
@PostMapping
|
@ApiOperation(value = "添加电源")
|
public Response add(@RequestBody PowerInf powerInf){
|
service.add(powerInf);
|
return new Response().setII(1,"添加成功");
|
}
|
@PutMapping
|
@ApiOperation(value = "更新电源")
|
public Response update(@RequestBody PowerInf powerInf){
|
service.updateByPowerDeviceId(powerInf);
|
return new Response().setII(1,"更新成功");
|
}
|
@DeleteMapping
|
@ApiOperation(value = "删除电源")
|
public Response delete(@RequestParam Integer powerDeviceId){
|
service.deleteByPowerDeviceId(powerDeviceId);
|
return new Response().setII(1,"删除成功");
|
}
|
|
|
|
@GetMapping("/getProvincesContainBatt")
|
@ApiOperation(value = "获取包含电池的省份")
|
public Response getProvincesContainBatt(){
|
return service.getProvincesContainBatt();
|
}
|
|
@GetMapping("/getCitiesContainBatt")
|
@ApiOperation(value = "获取某省下的城市")
|
public Response getCitiesContainBatt(@RequestParam String stationName1){
|
return service.getCitiesContainBatt(stationName1);
|
}
|
|
@GetMapping("/getDistrictsContainBatt")
|
@ApiOperation(value = "获取某省某城市下的地区")
|
public Response getDistrictsContainBatt(@RequestParam String stationName1,@RequestParam String stationName2){
|
return service.getDistrictsContainBatt(stationName1,stationName2);
|
}
|
|
@GetMapping("/getProvinces")
|
@ApiOperation(value = "用户管理的机房省份")
|
public Response getProvinces(){
|
UserInf userInf = (UserInf) ActionUtil.getUser();
|
return service.getProvinces(userInf.getUId());
|
}
|
@GetMapping("/getCities")
|
@ApiOperation(value = "用户管理的省份的城市")
|
public Response getCities(@RequestParam(required = false) String stationName1){
|
UserInf userInf = (UserInf) ActionUtil.getUser();
|
return service.getCities(userInf.getUId(),stationName1);
|
}
|
@GetMapping("/getDistricts")
|
@ApiOperation(value = "用户管理的地区")
|
public Response getDistricts(@RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2){
|
UserInf userInf = (UserInf) ActionUtil.getUser();
|
return service.getDistricts(userInf.getUId(),stationName1,stationName2);
|
}
|
|
|
@GetMapping("/getExistStations")
|
@ApiOperation(value = "获取机房")
|
public Response getExistStations( @RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2,@RequestParam(required = false) String stationName5){
|
return service.getExistStations(stationName1,stationName2,stationName5);
|
}
|
|
@GetMapping("/getPowerDevicesPage")
|
@ApiOperation(value = "用户管理的电源信息分页")
|
public PageInfo<PowerInf> getPowerDevicesPage(@RequestParam(required = false) String stationId, @RequestParam(required = false) String stationName1,@RequestParam(required = false) String stationName2,@RequestParam(required = false) String stationName5){
|
UserInf userInf = (UserInf) ActionUtil.getUser();
|
PageInfo<PowerInf> list = service.getPowerDevicesPage(userInf.getUId(),stationId, stationName1,stationName2,stationName5);
|
return list;
|
}
|
}
|