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.TemperatureRecord;
import org.springblade.estate.vo.TemperatureRecordVO;
import org.springblade.estate.wrapper.TemperatureRecordWrapper;
import org.springblade.estate.service.ITemperatureRecordService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-12-16
 */

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

public class TemperatureRecordClient implements ITemperatureRecordClient {

    private final ITemperatureRecordService temperatureRecordService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public TemperatureRecordVO detail(TemperatureRecord temperatureRecord) {
        TemperatureRecord detail = temperatureRecordService.getOne(Condition.getQueryWrapper(temperatureRecord));
        return TemperatureRecordWrapper.build().entityVO(detail);
        }

    /**
     * 查询 
     */
    @Override
    @GetMapping("/list")
    public List<TemperatureRecordVO> list(TemperatureRecord temperatureRecord) {
        return TemperatureRecordWrapper.build().listVO(temperatureRecordService.list(Condition.getQueryWrapper(temperatureRecord)));
        }

    

    /**
     * 新增 
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody TemperatureRecord temperatureRecord) {
        return temperatureRecordService.save(temperatureRecord);
        }

    /**
     * 修改 
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody TemperatureRecord temperatureRecord) {
        return temperatureRecordService.updateById(temperatureRecord);
        }

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

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

    
}
