package org.springblade.system.expand.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.system.expand.entity.OrgPosition;
import org.springblade.system.expand.vo.OrgPositionVO;
import org.springblade.system.expand.wrapper.OrgPositionWrapper;
import org.springblade.system.expand.service.IOrgPositionService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 *  client
 *
 * @author lianghanqiang
 * @since 2021-03-29
 */

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

public class OrgPositionClient implements IOrgPositionClient {

    private final IOrgPositionService orgPositionService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public OrgPositionVO detail(@SpringQueryMap OrgPosition orgPosition) {
        OrgPosition detail = orgPositionService.getOne(Condition.getQueryWrapper(orgPosition));
        return OrgPositionWrapper.build().entityVO(detail);
        }

    /**
     * 查询
     */
    @Override
    @GetMapping("/list")
    public List<OrgPositionVO> list(@SpringQueryMap OrgPosition orgPosition) {
        return OrgPositionWrapper.build().listVO(orgPositionService.list(Condition.getQueryWrapper(orgPosition)));
        }



    /**
     * 新增
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody OrgPosition orgPosition) {
        return orgPositionService.save(orgPosition);
        }

    /**
     * 修改
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody OrgPosition orgPosition) {
        return orgPositionService.updateById(orgPosition);
        }

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


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


}
