package com.ruoyi.web.controller.shate;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.service_shate.IAustraliaMiddleEastService;
import com.ruoyi.system.domain_shate.AustraliaMiddleEastVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.List;

/**
 *  澳大利亚中东部地区
 */
@RestController
@RequestMapping(value = "/business-service/api/Australia", produces = "application/json;charset=UTF-8")
@Api(tags = "澳大利亚中东部地区")
public class AustraliaMiddleEastController
{
    @Resource
    private IAustraliaMiddleEastService australiaMiddleEastService;

    /**
     * 查询方法
     * @return  实体类
     */
    @ApiOperation(value = "查询方法",httpMethod = "GET")
    @RequestMapping(value = "/SelectAustralia",method = {RequestMethod.GET})
    public AjaxResult SelectAustralia(/*@RequestBody AustraliaMiddleEastVO eastVO*/ )
    {
        AustraliaMiddleEastVO eastVO=null;
        List<AustraliaMiddleEastVO> eastVOSList= australiaMiddleEastService.selectAustralia(eastVO.getYearMonth(),eastVO.getMonth());
             return AjaxResult.success(eastVOSList);
    }

    /**
     * 删除方法
     * @param ID id
     * @return 状态码
     */
    @RequestMapping(value = "/DelAustralia",method = {RequestMethod.DELETE})
    @ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
    @ApiOperation(value = "删除方法",httpMethod = "DELETE")
    public AjaxResult DelAustralia(@Param("ID") String ID)
    {
        int NUM = australiaMiddleEastService.DelAustralia(ID);
        if (NUM>0)
        {
            return AjaxResult.success();
        }
        return  AjaxResult.error();

    }

    /**
     * 新增方法
     * @param eastVOS 新增实体类
     * @return 状态码
     */
    @RequestMapping(value = "/IntoAustralia",method = {RequestMethod.POST})
    @ApiOperation(value = "新增方法",httpMethod = "POST")
    public AjaxResult IntoAustralia(@RequestBody AustraliaMiddleEastVO eastVOS)
    {
        eastVOS.setCreateTime(LocalDateTime.now());
        int NUM =  australiaMiddleEastService.IntoAustralia(eastVOS);
        if (NUM>0)
        {
            return AjaxResult.success();
        }
        return  AjaxResult.error();
    }
}
