package com.xinelu.manage.controller.systemsettingsinfo;

import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.custominterface.Insert;
import com.xinelu.common.custominterface.Update;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.systemsettingsinfo.SystemSettingsInfo;
import com.xinelu.manage.service.systemsettingsinfo.ISystemSettingsInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 泉医到家平台系统业务设置信息Controller
 *
 * @author xinyilu
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/system/settings")
public class SystemSettingsInfoController extends BaseController {
    @Resource
    private ISystemSettingsInfoService systemSettingsInfoService;

    /**
     * 查询泉医到家平台系统业务设置信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:settings:list')")
    @GetMapping("/list")
    public TableDataInfo list(SystemSettingsInfo systemSettingsInfo) {
        startPage();
        List<SystemSettingsInfo> list = systemSettingsInfoService.selectSystemSettingsInfoList(systemSettingsInfo);
        return getDataTable(list);
    }

    /**
     * 导出泉医到家平台系统业务设置信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:settings:export')")
    @Log(title = "泉医到家平台系统业务设置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SystemSettingsInfo systemSettingsInfo) {
        List<SystemSettingsInfo> list = systemSettingsInfoService.selectSystemSettingsInfoList(systemSettingsInfo);
        ExcelUtil<SystemSettingsInfo> util = new ExcelUtil<>(SystemSettingsInfo.class);
        util.exportExcel(response, list, "泉医到家平台系统业务设置信息数据");
    }

    /**
     * 获取泉医到家平台系统业务设置信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(systemSettingsInfoService.selectSystemSettingsInfoById(id));
    }

    /**
     * 新增泉医到家平台系统业务设置信息
     */
    @PreAuthorize("@ss.hasPermi('system:settings:add')")
    @Log(title = "泉医到家平台系统业务设置信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated(Insert.class) @RequestBody SystemSettingsInfo systemSettingsInfo) {
        return systemSettingsInfoService.insertSystemSettingsInfo(systemSettingsInfo);
    }

    /**
     * 修改泉医到家平台系统业务设置信息
     */
    @PreAuthorize("@ss.hasPermi('system:settings:edit')")
    @Log(title = "泉医到家平台系统业务设置信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated(Update.class) @RequestBody SystemSettingsInfo systemSettingsInfo) {
        return systemSettingsInfoService.updateSystemSettingsInfo(systemSettingsInfo);
    }

    /**
     * 删除泉医到家平台系统业务设置信息
     */
    @PreAuthorize("@ss.hasPermi('system:settings:remove')")
    @Log(title = "泉医到家平台系统业务设置信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(systemSettingsInfoService.deleteSystemSettingsInfoByIds(ids));
    }
}
