package org.springblade.third.iotdevice.feign;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.iotdevice.entity.IotAepProduct;
import org.springblade.third.iotdevice.vo.IotAepProductVO;
import org.springblade.third.iotdevice.wrapper.IotAepProductWrapper;
import org.springblade.third.iotdevice.service.IIotAepProductService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-07-13
 */

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

public class IotAepProductClient implements IIotAepProductClient {

    private final IIotAepProductService iotAepProductService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public IotAepProductVO detail(@SpringQueryMap IotAepProduct iotAepProduct) {
        IotAepProduct detail = iotAepProductService.getOne(Condition.getQueryWrapper(iotAepProduct));
        return IotAepProductWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<IotAepProductVO> list(IotAepProduct iotAepProduct) {
        return IotAepProductWrapper.build().listVO(iotAepProductService.list(Condition.getQueryWrapper(iotAepProduct)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody IotAepProduct iotAepProduct) {
        return iotAepProductService.save(iotAepProduct);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody IotAepProduct iotAepProduct) {
        return iotAepProductService.updateById(iotAepProduct);
        }

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


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

	@Override
	@GetMapping("/getByProductId")
	public IotAepProduct getByProductId(@RequestParam String productId) {
		return this.iotAepProductService.getBaseMapper().selectOne(new QueryWrapper<>(
			new IotAepProduct()).lambda().eq(IotAepProduct::getProductId,productId));
	}


}
