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.QinlinApiLog;
import org.springblade.third.doordevice.vo.QinlinApiLogVO;
import org.springblade.third.doordevice.wrapper.QinlinApiLogWrapper;
import org.springblade.third.doordevice.service.IQinlinApiLogService;

import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-04-27
 */

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

public class QinlinApiLogClient implements IQinlinApiLogClient {

    private final IQinlinApiLogService qinlinApiLogService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public QinlinApiLogVO detail(@SpringQueryMap QinlinApiLog qinlinApiLog) {
        QinlinApiLog detail = qinlinApiLogService.getOne(Condition.getQueryWrapper(qinlinApiLog));
        return QinlinApiLogWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<QinlinApiLogVO> list(QinlinApiLog qinlinApiLog) {
        return QinlinApiLogWrapper.build().listVO(qinlinApiLogService.list(Condition.getQueryWrapper(qinlinApiLog)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody QinlinApiLog qinlinApiLog) {
        return qinlinApiLogService.save(qinlinApiLog);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody QinlinApiLog qinlinApiLog) {
        return qinlinApiLogService.updateById(qinlinApiLog);
        }

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


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


}
