package org.springblade.device.feign;

import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import javax.validation.Valid;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.device.entity.ElectricMeterRecord;
import org.springblade.device.vo.ElectricMeterRecordVO;
import org.springblade.device.wrapper.ElectricMeterRecordWrapper;
import org.springblade.device.service.IElectricMeterRecordService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-05-17
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/electricmeterrecord")

public class ElectricMeterRecordClient implements IElectricMeterRecordClient {

    private final IElectricMeterRecordService electricMeterRecordService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public ElectricMeterRecordVO detail(@SpringQueryMap ElectricMeterRecord electricMeterRecord) {
        ElectricMeterRecord detail = electricMeterRecordService.getOne(Condition.getQueryWrapper(electricMeterRecord));
        return ElectricMeterRecordWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<ElectricMeterRecordVO> list(@SpringQueryMap ElectricMeterRecord electricMeterRecord) {
        return ElectricMeterRecordWrapper.build().listVO(electricMeterRecordService.list(Condition.getQueryWrapper(electricMeterRecord)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody ElectricMeterRecord electricMeterRecord) {
        return electricMeterRecordService.save(electricMeterRecord);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody ElectricMeterRecord electricMeterRecord) {
        return electricMeterRecordService.updateById(electricMeterRecord);
        }

    /**
     * 新增或修改
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody ElectricMeterRecord electricMeterRecord) {
        return electricMeterRecordService.saveOrUpdate(electricMeterRecord);
        }


    /**
     * 删除
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return electricMeterRecordService.deleteLogic(Func.toLongList(ids));
        }


}
