package org.springblade.estate.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.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestParam;
import org.springblade.estate.entity.WorkOrderGroupUser;
import org.springblade.estate.vo.WorkOrderGroupUserVO;
import org.springblade.estate.wrapper.WorkOrderGroupUserWrapper;
import org.springblade.estate.service.IWorkOrderGroupUserService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 工单团队和用户关联表 client
 *
 * @author lianghanqiang
 * @since 2022-01-19
 */

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

public class WorkOrderGroupUserClient implements IWorkOrderGroupUserClient {

    private final IWorkOrderGroupUserService workOrderGroupUserService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public WorkOrderGroupUserVO detail(WorkOrderGroupUser workOrderGroupUser) {
        WorkOrderGroupUser detail = workOrderGroupUserService.getOne(Condition.getQueryWrapper(workOrderGroupUser));
        return WorkOrderGroupUserWrapper.build().entityVO(detail);
        }

    /**
     * 查询 工单团队和用户关联表
     */
    @Override
    @GetMapping("/list")
    public List<WorkOrderGroupUserVO> list(WorkOrderGroupUser workOrderGroupUser) {
        return WorkOrderGroupUserWrapper.build().listVO(workOrderGroupUserService.list(Condition.getQueryWrapper(workOrderGroupUser)));
        }



    /**
     * 新增 工单团队和用户关联表
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody WorkOrderGroupUser workOrderGroupUser) {
        return workOrderGroupUserService.save(workOrderGroupUser);
        }

    /**
     * 修改 工单团队和用户关联表
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody WorkOrderGroupUser workOrderGroupUser) {
        return workOrderGroupUserService.updateById(workOrderGroupUser);
        }

    /**
     * 新增或修改 工单团队和用户关联表
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody WorkOrderGroupUser workOrderGroupUser) {
        return workOrderGroupUserService.saveOrUpdate(workOrderGroupUser);
        }


    /**
     * 删除 工单团队和用户关联表
     */
    @Override
    @PostMapping("/remove")
    public boolean remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
        return workOrderGroupUserService.deleteLogic(Func.toLongList(ids));
        }


}
