package org.springblade.third.doordevice.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.third.doordevice.entity.InstructPublishLog;
import org.springblade.third.doordevice.vo.InstructPublishLogVO;
import org.springblade.third.doordevice.wrapper.InstructPublishLogWrapper;
import org.springblade.third.doordevice.service.IInstructPublishLogService;

import java.util.List;
/**
 * 指令推送记录 client
 *
 * @author lianghanqiang
 * @since 2021-04-27
 */

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

public class InstructPublishLogClient implements IInstructPublishLogClient {

    private final IInstructPublishLogService instructPublishLogService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public InstructPublishLogVO detail(@SpringQueryMap InstructPublishLog instructPublishLog) {
        InstructPublishLog detail = instructPublishLogService.getOne(Condition.getQueryWrapper(instructPublishLog));
        return InstructPublishLogWrapper.build().entityVO(detail);
        }

    /**
     * 查询 指令推送记录
     */
    @Override
    @GetMapping("/list")
    public List<InstructPublishLogVO> list(InstructPublishLog instructPublishLog) {
        return InstructPublishLogWrapper.build().listVO(instructPublishLogService.list(Condition.getQueryWrapper(instructPublishLog)));
        }



    /**
     * 新增 指令推送记录
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody InstructPublishLog instructPublishLog) {
        return instructPublishLogService.save(instructPublishLog);
        }

    /**
     * 修改 指令推送记录
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody InstructPublishLog instructPublishLog) {
        return instructPublishLogService.updateById(instructPublishLog);
        }

    /**
     * 新增或修改 指令推送记录
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody InstructPublishLog instructPublishLog) {
        return instructPublishLogService.saveOrUpdate(instructPublishLog);
        }


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


}
