package com.xunmei.system.controller;

import com.xunmei.system.api.domain.SysUserInformation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
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.service.ISysUserInformationService;
import com.xunmei.common.core.web.controller.BaseController;
import com.xunmei.common.core.web.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.xunmei.common.core.web.page.TableDataInfo;

/**
 * 【请填写功能名称】Controller
 *
 * @author xunmei
 * @date 2023-08-18
 */
@Api(tags = {"SysUserInformation"})
@RestController
@RequestMapping("/information")
public class SysUserInformationController extends BaseController {
    @Autowired
    private ISysUserInformationService sysUserInformationService;

    /**
     * 查询【请填写功能名称】列表
     */
    @ApiOperation(value = "查询SysUserInformation列表")
    @RequiresPermissions("system:information:list")
    @GetMapping("/list")
    public TableDataInfo<SysUserInformation> list(SysUserInformation sysUserInformation) {

        return sysUserInformationService.selectPage(sysUserInformation);
    }


    /**
     * 获取【请填写功能名称】详细信息
     */
    @ApiOperation(value = "获取SysUserInformation详细信息")
    @RequiresPermissions("system:information:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(sysUserInformationService.selectSysUserInformationById(id));
    }

    @RequiresPermissions("system:information:query")
    @GetMapping(value = {"/getInformationByUserId", "/{userId}"})
    public AjaxResult getInformationByUserId(@PathVariable(value = "userId", required = false) Long userId) {
        return success(sysUserInformationService.getInformationByUserId(userId));
    }

    @RequiresPermissions("system:information:edit")
    @Log(title = "人员管理扩展", businessType = BusinessType.UPDATE)
    @PutMapping("/extendUser")
    public AjaxResult extendUser(@RequestBody SysUserInformation sysUserInformation) {
        return toAjax(sysUserInformationService.extendUser(sysUserInformation));
    }

    /**
     * 新增【请填写功能名称】
     */
    @ApiOperation(value = "新增SysUserInformation")
    @RequiresPermissions("system:information:add")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysUserInformation sysUserInformation) {
        return toAjax(sysUserInformationService.insertSysUserInformation(sysUserInformation));
    }

    /**
     * 修改【请填写功能名称】
     */
    @ApiOperation(value = "修改SysUserInformation")
    @RequiresPermissions("system:information:edit")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysUserInformation sysUserInformation) {
        return toAjax(sysUserInformationService.updateSysUserInformation(sysUserInformation));
    }

    /**
     * 删除【请填写功能名称】
     */
    @ApiOperation(value = "删除SysUserInformation")
    @RequiresPermissions("system:information:remove")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sysUserInformationService.deleteSysUserInformationByIds(ids));
    }
}
