/*
 */
package com.unis.basic.info.modular.orgInfo.controller;


import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.unis.common.annotation.CommonLog;
import com.unis.common.pojo.CommonResult;
import com.unis.common.pojo.CommonValidList;
import com.unis.basic.info.modular.orgInfo.entity.OrgInfo;
import com.unis.basic.info.modular.orgInfo.param.OrgInfoAddParam;
import com.unis.basic.info.modular.orgInfo.param.OrgInfoEditParam;
import com.unis.basic.info.modular.orgInfo.param.OrgInfoIdParam;
import com.unis.basic.info.modular.orgInfo.param.OrgInfoPageParam;
import com.unis.basic.info.modular.orgInfo.service.OrgInfoService;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;

/**
 * 组织机构信息表控制器
 *
 * @author shine
 * @date  2024/04/28 11:47
 */
@Api(tags = "组织机构信息表控制器")
@ApiSupport(author = "UNIS_TEAM", order = 1)
@RestController
@Validated
public class OrgInfoController {

    @Resource
    private OrgInfoService orgInfoService;

    /**
     * 获取组织机构信息表分页
     *
     * @author shine
     * @date  2024/04/28 11:47
     */
    @ApiOperationSupport(order = 1)
    @ApiOperation("获取组织机构信息表分页")
    //@SaCheckPermission("/orgInfo/info/page")
    @GetMapping("/orgInfo/info/page")
    public CommonResult<Page<OrgInfo>> page(OrgInfoPageParam orgInfoPageParam) {
        return CommonResult.data(orgInfoService.page(orgInfoPageParam));
    }

    /**
     * 添加组织机构信息表
     *
     * @author shine
     * @date  2024/04/28 11:47
     */
    @ApiOperationSupport(order = 2)
    @ApiOperation("添加组织机构信息表")
    @CommonLog("添加组织机构信息表")
    //@SaCheckPermission("/orgInfo/info/add")
    @PostMapping("/orgInfo/info/add")
    public CommonResult<String> add(@RequestBody @Valid OrgInfoAddParam orgInfoAddParam) {
        orgInfoService.add(orgInfoAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑组织机构信息表
     *
     * @author shine
     * @date  2024/04/28 11:47
     */
    @ApiOperationSupport(order = 3)
    @ApiOperation("编辑组织机构信息表")
    @CommonLog("编辑组织机构信息表")
    //@SaCheckPermission("/orgInfo/info/edit")
    @PostMapping("/orgInfo/info/edit")
    public CommonResult<String> edit(@RequestBody @Valid OrgInfoEditParam orgInfoEditParam) {
        orgInfoService.edit(orgInfoEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除组织机构信息表
     *
     * @author shine
     * @date  2024/04/28 11:47
     */
    @ApiOperationSupport(order = 4)
    @ApiOperation("删除组织机构信息表")
    @CommonLog("删除组织机构信息表")
    //@SaCheckPermission("/orgInfo/info/delete")
    @PostMapping("/orgInfo/info/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   CommonValidList<OrgInfoIdParam> orgInfoIdParamList) {
        orgInfoService.delete(orgInfoIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取组织机构信息表详情
     *
     * @author shine
     * @date  2024/04/28 11:47
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation("获取组织机构信息表详情")
    //@SaCheckPermission("/orgInfo/info/detail")
    @GetMapping("/orgInfo/info/detail")
    public CommonResult<OrgInfo> detail(@Valid OrgInfoIdParam orgInfoIdParam) {
        return CommonResult.data(orgInfoService.detail(orgInfoIdParam));
    }
}
