package com.zkqy.web.controller.mobilepage;

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

import com.zkqy.system.entity.MobilePageData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.zkqy.common.annotation.Log;
import com.zkqy.common.core.controller.BaseController;
import com.zkqy.common.core.domain.AjaxResult;
import com.zkqy.common.enums.BusinessType;
import com.zkqy.system.service.IMobilePageDataService;
import com.zkqy.common.utils.poi.ExcelUtil;
import com.zkqy.common.core.page.TableDataInfo;

/**
 * 移动端数据Controller
 *
 * @author zkqy
 * @date 2024-04-18
 */
@RestController
@RequestMapping("/system/mobilePageData")
@Api(value = "/system/data", description = "移动端数据-接口")
public class MobilePageDataController extends BaseController {

    @Autowired
    private IMobilePageDataService mobilePageDataService;

    /**
     * 查询移动端数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:data:list')")
    @GetMapping("/list")
    @ApiOperation(value = "查询移动端数据列表")
    public TableDataInfo list(MobilePageData mobilePageData) {
        startPage();
        List<MobilePageData> list = mobilePageDataService.selectMobilePageDataList(mobilePageData);
        return getDataTable(list);
    }

    /**
     * 导出移动端数据列表
     */
    @PreAuthorize("@ss.hasPermi('system:data:export')")
    @Log(title = "移动端数据", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ApiOperation(value = "导出移动端数据列表")
    public void export(HttpServletResponse response, MobilePageData mobilePageData) {
        List<MobilePageData> list = mobilePageDataService.selectMobilePageDataList(mobilePageData);
        ExcelUtil<MobilePageData> util = new ExcelUtil<MobilePageData>(MobilePageData.class);
        util.exportExcel(response, list, "移动端数据数据");
    }

    /**
     * 获取移动端数据详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:data:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation(value = "获取移动端数据详细信息")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(mobilePageDataService.selectMobilePageDataById(id));
    }

    /**
     * 新增移动端数据
     */
    @PreAuthorize("@ss.hasPermi('system:data:add')")
    @Log(title = "移动端数据", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation(value = "新增移动端数据")
    public AjaxResult add(@RequestBody MobilePageData mobilePageData) {
        return toAjax(mobilePageDataService.insertMobilePageData(mobilePageData));
    }

    /**
     * 修改移动端数据
     */
    @PreAuthorize("@ss.hasPermi('system:data:edit')")
    @Log(title = "移动端数据", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value = "修改移动端数据")
    public AjaxResult edit(@RequestBody MobilePageData mobilePageData) {
        return toAjax(mobilePageDataService.updateMobilePageData(mobilePageData));
    }

    /**
     * 删除移动端数据
     */
    @PreAuthorize("@ss.hasPermi('system:data:remove')")
    @Log(title = "移动端数据", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    @ApiOperation(value = "删除移动端数据")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(mobilePageDataService.deleteMobilePageDataByIds(ids));
    }
}
