package org.springblade.estate.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.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.estate.entity.EnergyStatistics;
import org.springblade.estate.vo.EnergyStatisticsVO;
import org.springblade.estate.wrapper.EnergyStatisticsWrapper;
import org.springblade.estate.service.IEnergyStatisticsService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-12-29
 */

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

public class EnergyStatisticsClient implements IEnergyStatisticsClient {

    private final IEnergyStatisticsService energyStatisticsService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public EnergyStatisticsVO detail(EnergyStatistics energyStatistics) {
        EnergyStatistics detail = energyStatisticsService.getOne(Condition.getQueryWrapper(energyStatistics));
        return EnergyStatisticsWrapper.build().entityVO(detail);
        }

    /**
     * 查询 
     */
    @Override
    @GetMapping("/list")
    public List<EnergyStatisticsVO> list(EnergyStatistics energyStatistics) {
        return EnergyStatisticsWrapper.build().listVO(energyStatisticsService.list(Condition.getQueryWrapper(energyStatistics)));
        }

    

    /**
     * 新增 
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody EnergyStatistics energyStatistics) {
        return energyStatisticsService.save(energyStatistics);
        }

    /**
     * 修改 
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody EnergyStatistics energyStatistics) {
        return energyStatisticsService.updateById(energyStatistics);
        }

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

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

    
}
