package com.community.huiju.controller;


import com.community.commom.mode.ResponseBean;
import com.community.commom.session.UserElement;
import com.community.huiju.common.base.BaseController;
import com.community.huiju.service.ITpShopSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * <p>
 * 商铺开关设置 前端控制器
 * </p>
 *
 * @author jobob
 * @since 2019-05-09
 */
@RestController
@RequestMapping("/")
@RefreshScope
@Api(value = "商铺配置API", description = "商铺配置API")
public class TpShopSettingController extends BaseController {

	@Autowired
	private ITpShopSettingService shopSettingService;
	
	@ApiOperation(value = "商铺配置启动和关闭", notes = "商铺配置启动和关闭")
	@ApiImplicitParams({
			@ApiImplicitParam(paramType = "body", dataType = "String", name = "jsonString", value = "商铺配置值"),
			@ApiImplicitParam(paramType = "header", dataTypeClass = String.class, name = "X-Auth-Token", value = "Token")
	})
	@RequestMapping(value = "/shop/add/setting",method = RequestMethod.POST)
	public ResponseBean changeShopSetting(@RequestBody String jsonString, HttpSession session){
		ResponseBean responseBean = new ResponseBean();
		UserElement userElement = getUserElement(session);
		responseBean = shopSettingService.changeShopSetting(userElement,jsonString);
		return responseBean;
	}
}
