package com.sptg.estate.biz.controller;

import com.baomidou.mybatisplus.enums.SqlLike;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.sptg.common.core.beans.ResultBean;
import com.sptg.common.core.beans.ResultEnum;
import com.sptg.common.core.constant.OperationConstant;
import com.sptg.estate.api.entity.NoticePush;
import com.sptg.estate.api.entity.NoticePushDeviceDetails;
import com.sptg.estate.api.feigns.NoticePushDetailsFeign;
import com.sptg.estate.api.feigns.NoticePushDeviceDetailsFeign;
import com.sptg.estate.biz.service.NoticePushDeviceDetailsServiceInterface;
import com.sptg.estate.biz.service.NoticePushServiceInterface;
import lombok.RequiredArgsConstructor;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.*;

/**
 * title: NoticePushDetailsController
 * package: com.sptg.estate.biz.controller
 * description:
 *
 *
 *
 */
@RestController
@RequiredArgsConstructor
public class NoticePushDeviceDetailsController implements NoticePushDeviceDetailsFeign {

    private final NoticePushDeviceDetailsServiceInterface noticePushDeviceDetailsServiceInterface;

    @Override
    @PostMapping(value = "/noticePushDeviceDetails/list")
    public ResultBean<Page<NoticePushDeviceDetails>> showNoticePushDeviceDetailsList(@RequestBody NoticePushDeviceDetails noticePushDeviceDetails) {
        Page<NoticePushDeviceDetails> page = noticePushDeviceDetailsServiceInterface.showNoticePushDeviceDetailsList(noticePushDeviceDetails);
        return new ResultBean<>(ResultEnum.SUCCESS,page);
    }

    @Override
    @PostMapping(value = "/noticePushDeviceDetails/delete/{id}")
    public ResultBean<Boolean> deleteNoticePushDevice(@PathVariable(value = "id") Long id) {
        //删除广告
        Wrapper<NoticePushDeviceDetails> wrapper = new EntityWrapper<>();
        wrapper.eq("l_id", id);
        boolean result = noticePushDeviceDetailsServiceInterface.delete(wrapper);
        return new ResultBean<>(ResultEnum.SUCCESS, result);
    }

    @Override
    @GetMapping(value = "/noticePushDeviceDetails/get/{id}")
    public ResultBean<NoticePushDeviceDetails> getNoticePushDevice(@PathVariable(value = "id") Long id) {
        //删除广告
        Wrapper<NoticePushDeviceDetails> wrapper = new EntityWrapper<>();
        wrapper.eq("l_id", id);
        NoticePushDeviceDetails result = noticePushDeviceDetailsServiceInterface.selectOne(wrapper);
        return new ResultBean<>(ResultEnum.SUCCESS, result);
    }
}
