package com.neusoft.smart.pos.gateway.controller;

import com.alibaba.fastjson.JSONObject;
import com.neusoft.smart.pos.framework.dto.ResponseData;
import com.neusoft.smart.pos.gateway.service.AdvertisementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/unionService/adv")
public class AdvertisementController {
	
	@Autowired
	private AdvertisementService advertisementService;
	
	@GetMapping("/mediaResourceStrategy/relation/{groupId}")
	public ResponseData<JSONObject> getRelation(@PathVariable Integer groupId) {
		return new ResponseData<>(advertisementService.getStrategyList(groupId));
	}
	
	@PutMapping("/mediaResourceStrategy/cancel/{groupId}")
	public ResponseData<?> cancel(@PathVariable Integer groupId) {
		advertisementService.cancel(groupId);
		return new ResponseData<>();
	}
}
