package com.miaxis.fdj.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.fdj.domain.Fdj60hzInfo;
import com.miaxis.fdj.service.IFdj60hzInfoService;
import com.miaxis.common.utils.poi.ExcelUtil;
import com.miaxis.common.core.page.ResponsePageInfo;

/**
 * 【发电机60hz报价】Controller
 *
 * @author miaxis
 * @date 2023-02-09
 */
@RestController
@RequestMapping("/fdj/info")
@Api(tags={"【小程序-发电机60hz报价】"})
public class Fdj60hzInfoController extends BaseController{
    @Autowired
    private IFdj60hzInfoService fdj60hzInfoService;

    /**
     * 查询发电机60hz报价列表
     */
    @PreAuthorize("@ss.hasPermi('fdj:info:list')")
    @GetMapping("/list")
    @ApiOperation("查询发电机60hz报价列表")
        @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码" ,dataType = "int", paramType = "query", required = false),
            @ApiImplicitParam(name = "pageSize",value = "每页数据量" , dataType = "int", paramType = "query", required = false),
    })
    public ResponsePageInfo<Fdj60hzInfo> list(@ModelAttribute Fdj60hzInfo fdj60hzInfo){
        startPage();
        List<Fdj60hzInfo> list = fdj60hzInfoService.selectFdj60hzInfoList(fdj60hzInfo);
        return toResponsePageInfo(list);
    }
    
    /**
     * 导出发电机60hz报价列表
     */
    @PreAuthorize("@ss.hasPermi('fdj:info:export')")
    @Log(title = "发电机60hz报价", businessType = BusinessTypeEnum.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出发电机60hz报价列表Excel")
    public Response<String> export(@ModelAttribute Fdj60hzInfo fdj60hzInfo){
        List<Fdj60hzInfo> list = fdj60hzInfoService.selectFdj60hzInfoList(fdj60hzInfo);
        ExcelUtil<Fdj60hzInfo> util = new ExcelUtil<Fdj60hzInfo>(Fdj60hzInfo.class);
        return util.exportExcel(list, "info");
    }

    /**
     * 获取发电机60hz报价详细信息
     */
    @PreAuthorize("@ss.hasPermi('fdj:info:query')")
    @GetMapping(value = "/{id}")
    @ApiOperation("获取发电机60hz报价详细信息")
    public Response<Fdj60hzInfo> getInfo(
            @ApiParam(name = "id", value = "发电机60hz报价参数", required = true)
            @PathVariable("id") Long id
    ){
        return Response.success(fdj60hzInfoService.getById(id));
    }

    /**
     * 新增发电机60hz报价
     */
    @PreAuthorize("@ss.hasPermi('fdj:info:add')")
    @Log(title = "发电机60hz报价", businessType = BusinessTypeEnum.INSERT)
    @PostMapping
    @ApiOperation("新增发电机60hz报价")
    public Response<Integer> add(@RequestBody Fdj60hzInfo fdj60hzInfo){
        return toResponse(fdj60hzInfoService.save(fdj60hzInfo) ? 1 : 0);
    }

    /**
     * 修改发电机60hz报价
     */
    @PreAuthorize("@ss.hasPermi('fdj:info:edit')")
    @Log(title = "发电机60hz报价", businessType = BusinessTypeEnum.UPDATE)
    @PutMapping
    @ApiOperation("修改发电机60hz报价")
    public Response<Integer> edit(@RequestBody Fdj60hzInfo fdj60hzInfo){
        return toResponse(fdj60hzInfoService.updateById(fdj60hzInfo) ? 1 : 0);
    }

    /**
     * 删除发电机60hz报价
     */
    @PreAuthorize("@ss.hasPermi('fdj:info:remove')")
    @Log(title = "发电机60hz报价", businessType = BusinessTypeEnum.DELETE)
	@DeleteMapping("/{ids}")
    @ApiOperation("删除发电机60hz报价")
    public  Response<Integer> remove(
            @ApiParam(name = "ids", value = "发电机60hz报价ids参数", required = true)
            @PathVariable Long[] ids
    ){
        return toResponse(fdj60hzInfoService.removeByIds(Arrays.asList(ids)) ? 1 : 0);
    }
}
