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.FertileWoman;
import org.springblade.person.vo.FertileWomanVO;
import org.springblade.person.wrapper.FertileWomanWrapper;
import org.springblade.person.service.IFertileWomanService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-05-28
 */

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

public class FertileWomanClient implements IFertileWomanClient {

    private final IFertileWomanService fertileWomanService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public FertileWomanVO detail(@SpringQueryMap FertileWoman fertileWoman) {
        FertileWoman detail = fertileWomanService.getOne(Condition.getQueryWrapper(fertileWoman));
        return FertileWomanWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<FertileWomanVO> list(FertileWoman fertileWoman) {
        return FertileWomanWrapper.build().listVO(fertileWomanService.list(Condition.getQueryWrapper(fertileWoman)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody FertileWoman fertileWoman) {
        return fertileWomanService.save(fertileWoman);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody FertileWoman fertileWoman) {
        return fertileWomanService.updateById(fertileWoman);
        }

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


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


}
