package org.springblade.estate.feign;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.estate.entity.ServerUser;
import org.springblade.estate.vo.ServerUserVO;
import org.springblade.estate.wrapper.ServerUserWrapper;
import org.springblade.estate.service.IServerUserService;
import java.util.List;
/**
 * 服务人员 client
 *
 * @author lianghanqiang
 * @since 2022-01-04
 */

@AllArgsConstructor
@RestController
@RequestMapping("/feign/serveruser")
public class ServerUserClient implements IServerUserClient {

    private final IServerUserService serverUserService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public ServerUserVO detail(ServerUser serverUser) {
        ServerUser detail = serverUserService.getOne(Condition.getQueryWrapper(serverUser));
        return ServerUserWrapper.build().entityVO(detail);
        }

    /**
     * 查询 服务人员
     */
    @Override
    @GetMapping("/list")
    public List<ServerUserVO> list(ServerUser serverUser) {
        return ServerUserWrapper.build().listVO(serverUserService.list(Condition.getQueryWrapper(serverUser)));
        }



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

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

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


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

	@Override
	@GetMapping("/count")
	public Integer count(@RequestParam(value = "tenantId", required = false) String tenantId) {
		return serverUserService.count();
	}

}
