package org.springblade.person.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.person.entity.EstablishFilecard;
import org.springblade.person.vo.EstablishFilecardVO;
import org.springblade.person.wrapper.EstablishFilecardWrapper;
import org.springblade.person.service.IEstablishFilecardService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-05-28
 */

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

public class EstablishFilecardClient implements IEstablishFilecardClient {

    private final IEstablishFilecardService establishFilecardService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public EstablishFilecardVO detail(@SpringQueryMap EstablishFilecard establishFilecard) {
        EstablishFilecard detail = establishFilecardService.getOne(Condition.getQueryWrapper(establishFilecard));
        return EstablishFilecardWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<EstablishFilecardVO> list(EstablishFilecard establishFilecard) {
        return EstablishFilecardWrapper.build().listVO(establishFilecardService.list(Condition.getQueryWrapper(establishFilecard)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody EstablishFilecard establishFilecard) {
        return establishFilecardService.save(establishFilecard);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody EstablishFilecard establishFilecard) {
        return establishFilecardService.updateById(establishFilecard);
        }

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


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


}
