package com.huijy.web.controller.management;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
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.huijy.common.annotation.Log;
import com.huijy.common.core.controller.BaseController;
import com.huijy.common.core.domain.AjaxResult;
import com.huijy.common.enums.BusinessType;
import com.huijy.management.domain.AboutUs;
import com.huijy.management.service.IAboutUsService;
import com.huijy.common.utils.poi.ExcelUtil;
import com.huijy.common.core.page.TableDataInfo;

/**
 * 关于我们Controller
 *
 * @author luobo
 * @date 2021-09-20
 */
@RestController
@RequestMapping("/management/aboutUs")
public class AboutUsController extends BaseController
{
    @Autowired
    private IAboutUsService aboutUsService;

    /**
     * 查询关于我们列表
     */
    @PreAuthorize("@ss.hasPermi('management:aboutUs:list')")
    @GetMapping("/list")
    public TableDataInfo list(AboutUs aboutUs)
    {
        startPage();
        List<AboutUs> list = aboutUsService.selectAboutUsList(aboutUs);
        return getDataTable(list);
    }

    /**
     * 导出关于我们列表
     */
    @PreAuthorize("@ss.hasPermi('management:aboutUs:export')")
    @Log(title = "关于我们", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(AboutUs aboutUs)
    {
        List<AboutUs> list = aboutUsService.selectAboutUsList(aboutUs);
        ExcelUtil<AboutUs> util = new ExcelUtil<AboutUs>(AboutUs.class);
        return util.exportExcel(list, "关于我们数据");
    }

    /**
     * 获取关于我们详细信息
     */
    @PreAuthorize("@ss.hasPermi('management:aboutUs:query')")
    @GetMapping(value = "/{aboutUsId}")
    public AjaxResult getInfo(@PathVariable("aboutUsId") Long aboutUsId)
    {
        return AjaxResult.success(aboutUsService.selectAboutUsByAboutUsId(aboutUsId));
    }

    /**
     * 新增关于我们
     */
    @PreAuthorize("@ss.hasPermi('management:aboutUs:add')")
    @Log(title = "关于我们", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AboutUs aboutUs)
    {
        return toAjax(aboutUsService.insertAboutUs(aboutUs));
    }

    /**
     * 修改关于我们
     */
    @PreAuthorize("@ss.hasPermi('management:aboutUs:edit')")
    @Log(title = "关于我们", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AboutUs aboutUs)
    {
        return toAjax(aboutUsService.updateAboutUs(aboutUs));
    }

    /**
     * 删除关于我们
     */
    @PreAuthorize("@ss.hasPermi('management:aboutUs:remove')")
    @Log(title = "关于我们", businessType = BusinessType.DELETE)
	@DeleteMapping("/{aboutUsIds}")
    public AjaxResult remove(@PathVariable Long[] aboutUsIds)
    {
        return toAjax(aboutUsService.deleteAboutUsByAboutUsIds(aboutUsIds));
    }
}
