package com.ssm.controller;


import com.ssm.manage.response.GenericResponse;
import com.ssm.manage.entity.Platform;
import com.ssm.manage.query.PlatformRequest;
import com.ssm.manage.response.ResponseCode;
import com.ssm.manage.service.SsmPlatformService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
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.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.List;

@Api(value="对接平台",tags={"对接各大平台相关接口"})
@RestController
@RequestMapping("/demay/ssm/Platform")
@Slf4j
public class SsmPlatformController {

    @Autowired
    private SsmPlatformService ssmPlatformService;

    @ApiOperation(value = "对接平台查询", notes = "对接平台查询全部", response = GenericResponse.class)
    @RequestMapping(path="/selectAll", method= RequestMethod.POST)
    public GenericResponse selectAll(@RequestBody PlatformRequest platformRequest, HttpSession session) {
        GenericResponse<Platform> genericResponse = new GenericResponse<>();
        List<Platform> list = new ArrayList<>();
        try{
            list=ssmPlatformService.selectAll(platformRequest);
        }catch (Exception e){
            log.error("SsmPlatformController.selecrAll:", e);
            genericResponse.setCodeAndMsg(ResponseCode.FAILED);
            return genericResponse;
        }
        genericResponse.setRows(list);
        genericResponse.setCodeAndMsg(ResponseCode.OK);
        return genericResponse;
    }
}
