BatteryController.java 1.64 KB
package cn.com.glsx.stdinterface.modules.controller;

import cn.com.glsx.stdinterface.api.BatteryClient;
import cn.com.glsx.stdinterface.dto.DevicePowerDTO;
import cn.com.glsx.stdinterface.modules.service.BatteryService;
import com.glsx.plat.core.web.R;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Collection;
import java.util.List;

/**
 * @author xiangyanlin
 * @date 2022/4/12
 */
@RestController
@RequestMapping("/battery")
public class BatteryController implements BatteryClient {

    @Resource
    private BatteryService batteryService;

    @PostMapping("/save")
    @Override
    public R saveBatteryInfo(@RequestBody DevicePowerDTO devicePowerDTO) {
        batteryService.saveBatteryInfo(devicePowerDTO);
        return R.ok();
    }

    @PostMapping("/initDataFromOld")
    public R moveDataFromOldDatabase() {
        batteryService.initDataFromOld();
        return R.ok();
    }

    @GetMapping("/queryOneBySn")
    @Override
    public R<DevicePowerDTO> getDevicePowerBySn(@RequestParam("sn")String sn) {
        return R.ok().data(batteryService.getDevicePowerBySn(sn));
    }

    @GetMapping("/queryListBySn")
    @Override
    public R<List<DevicePowerDTO>> getDevicePowerListBySn(Collection<String> sn) {
        return R.ok().data(batteryService.getDevicePowerListBySn(sn));
    }
}