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

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

public class AidsClient implements IAidsClient {

    private final IAidsService aidsService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public AidsVO detail(@SpringQueryMap Aids aids) {
        Aids detail = aidsService.getOne(Condition.getQueryWrapper(aids));
        return AidsWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<AidsVO> list(Aids aids) {
        return AidsWrapper.build().listVO(aidsService.list(Condition.getQueryWrapper(aids)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody Aids aids) {
        return aidsService.save(aids);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody Aids aids) {
        return aidsService.updateById(aids);
        }

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


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


}
