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.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.estate.entity.NoticePushRecord;
import org.springblade.estate.vo.NoticePushRecordVO;
import org.springblade.estate.wrapper.NoticePushRecordWrapper;
import org.springblade.estate.service.INoticePushRecordService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-04-29
 */

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

public class NoticePushRecordClient implements INoticePushRecordClient {

    private final INoticePushRecordService noticePushRecordService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public NoticePushRecordVO detail(@SpringQueryMap NoticePushRecord noticePushRecord) {
        NoticePushRecord detail = noticePushRecordService.getOne(Condition.getQueryWrapper(noticePushRecord));
        return NoticePushRecordWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<NoticePushRecordVO> list(@SpringQueryMap NoticePushRecord noticePushRecord) {
        return NoticePushRecordWrapper.build().listVO(noticePushRecordService.list(Condition.getQueryWrapper(noticePushRecord)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody NoticePushRecord noticePushRecord) {
        return noticePushRecordService.save(noticePushRecord);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody NoticePushRecord noticePushRecord) {
        return noticePushRecordService.updateById(noticePushRecord);
        }

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


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


}
