package com.cm.common.plugin.oauth.controller.app.apis.department;

import com.alibaba.fastjson.JSONArray;
import com.cm.common.base.AbstractController;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.plugin.oauth.service.department.IDepartmentService;
import com.cm.common.result.ErrorResult;
import io.swagger.annotations.*;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * When you feel like quitting. Think about why you started
 * 当你想要放弃的时候，想想当初你为何开始
 *
 * @ClassName: DepartmentAppController
 * @Description: 组织部门管理
 * @Author: WangGeng
 * @Date: 2020/2/9 12:05 下午
 * @Version: 1.0
 **/
@Api(tags = ISystemConstant.API_TAGS_APP_PREFIX + "组织部门管理")
@RestController
@RequestMapping(ISystemConstant.APP_PREFIX + "/department")
public class DepartmentAppController extends AbstractController {

    @Autowired
    private IDepartmentService departmentService;

    @ApiOperation(value = "部门人员列表", notes = "部门人员列表接口")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "上级部门ID", paramType = "query")
    })
    @ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
    @GetMapping("listztreedepartmentwithuser")
    public JSONArray listZTreeDepartmentWithUser(@RequestParam(required = false) String id) {
        String departmentParentId = "0";
        if (!StringUtils.isBlank(id)) {
            departmentParentId = id;
        }
        return departmentService.listZTreeDepartmentWithUser(departmentParentId);
    }


}
