package com.miaxis.web.controller;

import com.miaxis.common.constant.Constants;
import java.util.List;
import java.util.Arrays;
import io.swagger.annotations.*;
import com.miaxis.common.core.domain.Response;
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 org.springframework.web.bind.annotation.ModelAttribute;
import com.miaxis.common.annotation.Log;
import com.miaxis.common.core.controller.BaseController;
import com.miaxis.common.enums.BusinessTypeEnum;
import com.miaxis.web.domain.WebNote;
import com.miaxis.web.service.IWebNoteService;
import com.miaxis.common.utils.poi.ExcelUtil;
import com.miaxis.common.core.page.ResponsePageInfo;

/**
 * 【【请填写功能名称】】Controller
 *
 * @author miaxis
 * @date 2022-08-01
 */
@RestController
@RequestMapping("/web/note")
@Api(tags={"【H5-【请填写功能名称】】"})
public class WebNoteController extends BaseController{
    @Autowired
    private IWebNoteService webNoteService;

    /**
     * 查询【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('web:note:list')")
    @GetMapping("/list")
    @ApiOperation("查询【请填写功能名称】列表")
        @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<WebNote> list(@ModelAttribute WebNote webNote){
        startPage();
        List<WebNote> list = webNoteService.selectWebNoteList(webNote);
        return toResponsePageInfo(list);
    }
    
    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('web:note:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessTypeEnum.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出【请填写功能名称】列表Excel")
    public Response<String> export(@ModelAttribute WebNote webNote){
        List<WebNote> list = webNoteService.selectWebNoteList(webNote);
        ExcelUtil<WebNote> util = new ExcelUtil<WebNote>(WebNote.class);
        return util.exportExcel(list, "note");
    }

    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('web:note:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取【请填写功能名称】详细信息")
    public Response<WebNote> getInfo(
            @ApiParam(name = "id", value = "【请填写功能名称】参数", required = true)
            @PathVariable("id") Long id
    ){
        return Response.success(webNoteService.getById(id));
    }

    /**
     * 新增【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('web:note:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    @ApiOperation("新增【请填写功能名称】")
    public Response<Integer> add(@RequestBody WebNote webNote){
        return toResponse(webNoteService.save(webNote) ? 1 : 0);
    }

    /**
     * 修改【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('web:note:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    @ApiOperation("修改【请填写功能名称】")
    public Response<Integer> edit(@RequestBody WebNote webNote){
        return toResponse(webNoteService.updateById(webNote) ? 1 : 0);
    }

    /**
     * 删除【请填写功能名称】
     */
    @PreAuthorize("@ss.hasPermi('web:note:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除【请填写功能名称】")
    public  Response<Integer> remove(
            @ApiParam(name = "ids", value = "【请填写功能名称】ids参数", required = true)
            @PathVariable Long[] ids
    ){
        return toResponse(webNoteService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
