package com.weather.controller;



import com.weather.common.AjaxResult;
import com.weather.common.BaseController;
import com.weather.entity.SysDept;

import com.weather.service.ISysDeptService;

import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;



/**
 * <p>
 * 部门表 前端控制器
 * </p>
 *
 * @author feng
 * @since 2023-09-01
 */
@RestController
@RequestMapping("/sys-dept")
public class SysDeptController extends BaseController {

    @Autowired
    ISysDeptService deptService;




    /**
     * 获取部门列表
     */
    @ApiOperation(value = "获取部门列表")
    @GetMapping("/list")

    public AjaxResult list(SysDept dept)
    {
        List<SysDept> depts = deptService.selectDeptList(dept);
        return success(depts);
    }


    /**
     * 根据部门编号获取详细信息
     */
    @ApiOperation(value = "根据部门编号获取详细信息")
    @GetMapping(value = "/{deptId}")
    public AjaxResult getInfo(@PathVariable Long deptId)
    {

        return success(deptService.selectDeptById(deptId));
    }

    /**
     * 新增部门
     */

    @ApiOperation(value = "新增部门")
    @PostMapping
    public AjaxResult add(@Validated @RequestBody SysDept dept)
    {

        return toAjax(deptService.insertDept(dept));
    }

    /**
     * 修改部门
     */
    @ApiOperation(value = "修改部门")
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody SysDept dept)
    {

        return toAjax(deptService.updateDept(dept));
    }


     /*  @GetMapping("list")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询系统部门")
    public ApiResult list() {
       *//* QueryWrapper<SysUser> wrapper=new QueryWrapper<>();
        wrapper.lambda().orderByAsc(SysUser::getUserId);*//*
        List<SysDept> list = deptService.list();
        if (list==null||list.size()<=0){
            return ApiResult.noData();
        }

        return ApiResult.success(list);
    }*/

}

