package com.dayou.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dayou.common.PullDownModel;
import com.dayou.entity.Team;
import com.dayou.utils.ConvertUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.service.ISortedDepartmentService;
import com.dayou.entity.SortedDepartment;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 轮单部门
 *
 * @author wucl
 * @since 2023-10-31
 */
@RestController
@RequestMapping("sortedDepartment")
@Slf4j
public class SortedDepartmentController extends BaseController {
    @Autowired
    private ISortedDepartmentService sortedDepartmentService;

    /**
    * 轮单部门列表
    */
    @GetMapping("")
    public RestResponse<Page<SortedDepartment>> page(SortedDepartment sortedDepartment, Page page){
        Page<SortedDepartment> pages=sortedDepartmentService.selectPage(page,sortedDepartment);
        return RestResponse.data(pages);
    }

    /**
     * 轮单部门详情
     */
    @GetMapping("/{id}")
    public RestResponse<SortedDepartment> detail(@PathVariable Long id){
        SortedDepartment xSortedDepartment =sortedDepartmentService.detail(id);
        return RestResponse.data(xSortedDepartment);
     }

    /**
     * 轮单部门新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody SortedDepartment sortedDepartment) {
        Boolean ret = sortedDepartmentService.add(sortedDepartment);
        return RestResponse.data(ret);
    }

    /**
     * 轮单部门更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody SortedDepartment sortedDepartment) {
        Boolean ret = sortedDepartmentService.update(sortedDepartment);
        return RestResponse.data(ret);
    }

    /**
     * 轮单部门删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = sortedDepartmentService.delete(id);
        return RestResponse.data(ret);
    }

    /**
     * 下拉列表
     */
    @GetMapping("/simpleAll/{businessType}")
    public RestResponse<List<PullDownModel>> simpleAll(@PathVariable("businessType") String businessType){
        List<PullDownModel> list= sortedDepartmentService.simpleAll(businessType);
        return RestResponse.data(list);
    }

}

