package com.xunmei.system.controller;

import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import com.xunmei.common.core.web.page.TableDataInfo;
import com.xunmei.common.log.annotation.Log;
import com.xunmei.common.log.enums.BusinessType;
import com.xunmei.common.security.annotation.RequiresPermissions;
import com.xunmei.system.domain.SysOrgExtend;
import com.xunmei.system.service.ISysOrgExtendService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 机构扩展Controller
 *
 * @author xunmei
 * @date 2023-08-16
 */
@Api(tags = {"SysOrgExtend"})
@RestController
@RequestMapping("/extend")
public class SysOrgExtendController extends BaseController {
    @Autowired
    private ISysOrgExtendService sysOrgExtendService;

    /**
     * 查询机构扩展列表
     */
    @ApiOperation(value = "查询SysOrgExtend列表")
    @RequiresPermissions("system:extend:list")
    @GetMapping("/list")
    public TableDataInfo<SysOrgExtend> list(SysOrgExtend sysOrgExtend) {

        return sysOrgExtendService.selectPage(sysOrgExtend);
    }


    /**
     * 获取机构扩展详细信息
     */
    @ApiOperation(value = "获取SysOrgExtend详细信息")
    @RequiresPermissions("system:extend:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysOrgExtendService.selectSysOrgExtendById(id));
    }
    /**
     * 获取机构扩展详细信息
     */
    @ApiOperation(value = "获取SysOrgExtend详细信息")
    @RequiresPermissions("system:extend:query")
    @GetMapping(value = "/org/{id}")
    public AjaxResult getInfoByOrgId(@PathVariable("id") Long id) {
        return success(sysOrgExtendService.selectSysOrgExtendByOrgId(id));
    }
    /**
     * 新增机构扩展
     */
    @ApiOperation(value = "新增SysOrgExtend")
    @RequiresPermissions("system:extend:add")
    @Log(title = "机构扩展", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysOrgExtend sysOrgExtend) {
        return success(sysOrgExtendService.insertSysOrgExtend(sysOrgExtend));
    }

    /**
     * 修改机构扩展
     */
    @ApiOperation(value = "修改SysOrgExtend")
    @RequiresPermissions("system:extend:edit")
    @Log(title = "机构扩展", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysOrgExtend sysOrgExtend) {
        return toAjax(sysOrgExtendService.updateSysOrgExtend(sysOrgExtend));
    }

    /**
     * 删除机构扩展
     */
    @ApiOperation(value = "删除SysOrgExtend")
    @RequiresPermissions("system:extend:remove")
    @Log(title = "机构扩展", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysOrgExtendService.deleteSysOrgExtendByIds(ids));
    }
}
