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.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.estate.dto.SnapRecordDTO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.estate.entity.SnapRecord;
import org.springblade.estate.vo.SnapRecordVO;
import org.springblade.estate.wrapper.SnapRecordWrapper;
import org.springblade.estate.service.ISnapRecordService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2022-01-05
 */

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

public class SnapRecordClient implements ISnapRecordClient {

    private final ISnapRecordService snapRecordService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public SnapRecordVO detail(SnapRecord snapRecord) {
        SnapRecord detail = snapRecordService.getOne(Condition.getQueryWrapper(snapRecord));
        return SnapRecordWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<SnapRecordVO> list(SnapRecord snapRecord) {
        return SnapRecordWrapper.build().listVO(snapRecordService.list(Condition.getQueryWrapper(snapRecord)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody SnapRecord snapRecord) {
        return snapRecordService.save(snapRecord);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody SnapRecord snapRecord) {
        return snapRecordService.updateById(snapRecord);
        }

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


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

	@Override
	@PostMapping("/generateSnapRecord")
	public R generateSnapRecord(@RequestBody SnapRecordDTO snapRecordDTO) {
		return snapRecordService.generateSnapRecord(snapRecordDTO);
	}


}
