package com.nmgs.controller;

import com.nmgs.config.ResultData;
import com.nmgs.service.impl.RotationServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping(value="rotation")
@Api(tags = "轮播图")
public class RotationController {

    public RotationServiceImpl rotationServiceImpl;
@Autowired
    public void setRotationServiceImpl(RotationServiceImpl rotationServiceImplT) {
        this.rotationServiceImpl = rotationServiceImplT;
    }

    @ApiOperation(value="查询轮播图列表数据",httpMethod = "POST")
    @RequestMapping(value = "getRotationList",
            method = {RequestMethod.POST}
    )
    public ResultData<List> getRotationList(
                                        @RequestParam(value = "PICTYPE",required = true) String PICTYPE){
        List userByOpenId = rotationServiceImpl.getRotationList(PICTYPE);
        if(userByOpenId ==null){
            return ResultData.fail("查询失败");
        }else if(userByOpenId !=null){
            return ResultData.success("查询成功",userByOpenId,userByOpenId.size());
        }
        return ResultData.success(1,"查询成功");
    }
}
