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.ServerUserBak;
import org.springblade.person.vo.ServerUserBakVO;
import org.springblade.person.wrapper.ServerUserBakWrapper;
import org.springblade.person.service.IServerUserBakService;

import java.util.List;
/**
 * 服务人员 client
 *
 * @author lianghanqiang
 * @since 2021-05-19
 */

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

public class ServerUserBakClient implements IServerUserBakClient {

    private final IServerUserBakService serverUserService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public ServerUserBakVO detail(@SpringQueryMap ServerUserBak serverUserBak) {
        ServerUserBak detail = serverUserService.getOne(Condition.getQueryWrapper(serverUserBak));
        return ServerUserBakWrapper.build().entityVO(detail);
        }

    /**
     * 查询 服务人员
     */
    @Override
    @GetMapping("/list")
    public List<ServerUserBakVO> list(ServerUserBak serverUserBak) {
        return ServerUserBakWrapper.build().listVO(serverUserService.list(Condition.getQueryWrapper(serverUserBak)));
        }



    /**
     * 新增 服务人员
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody ServerUserBak serverUserBak) {
        return serverUserService.save(serverUserBak);
        }

    /**
     * 修改 服务人员
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody ServerUserBak serverUserBak) {
        return serverUserService.updateById(serverUserBak);
        }

    /**
     * 新增或修改 服务人员
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody ServerUserBak serverUserBak) {
        return serverUserService.saveOrUpdate(serverUserBak);
        }


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


}
