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.WorkOrderGroup;
import org.springblade.estate.vo.WorkOrderGroupVO;
import org.springblade.estate.wrapper.WorkOrderGroupWrapper;
import org.springblade.estate.service.IWorkOrderGroupService;
import org.springblade.core.boot.ctrl.BladeController;
import java.util.List;
/**
 * 工单团队 client
 *
 * @author lianghanqiang
 * @since 2022-01-19
 */

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

public class WorkOrderGroupClient implements IWorkOrderGroupClient {

    private final IWorkOrderGroupService workOrderGroupService;

        /**
     * 详情
     */
    @Override
    @GetMapping("/detail")
    public WorkOrderGroupVO detail(WorkOrderGroup workOrderGroup) {
        WorkOrderGroup detail = workOrderGroupService.getOne(Condition.getQueryWrapper(workOrderGroup));
        return WorkOrderGroupWrapper.build().entityVO(detail);
        }

    /**
     * 查询 工单团队
     */
    @Override
    @GetMapping("/list")
    public List<WorkOrderGroupVO> list(WorkOrderGroup workOrderGroup) {
        return WorkOrderGroupWrapper.build().listVO(workOrderGroupService.list(Condition.getQueryWrapper(workOrderGroup)));
        }



    /**
     * 新增 工单团队
     */
    @Override
    @PostMapping("/save")
    public boolean save(@Valid @RequestBody WorkOrderGroup workOrderGroup) {
        return workOrderGroupService.save(workOrderGroup);
        }

    /**
     * 修改 工单团队
     */
    @Override
    @PostMapping("/update")
    public boolean update(@Valid @RequestBody WorkOrderGroup workOrderGroup) {
        return workOrderGroupService.updateById(workOrderGroup);
        }

    /**
     * 新增或修改 工单团队
     */
    @Override
    @PostMapping("/submit")
    public boolean submit(@Valid @RequestBody WorkOrderGroup workOrderGroup) {
        return workOrderGroupService.saveOrUpdate(workOrderGroup);
        }


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


}
