Authored by 张帅

Merge branch 'dev-csm-split-1126' of http://git.yoho.cn/platform/platform-cms in…

…to dev-csm-split-1126
package com.yohobuy.platform.operations.restapi;
import com.yoho.core.config.ConfigReader;
import com.yoho.core.config.ZKConfigWriter;
import com.yohobuy.platform.common.restapi.ApiResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
/**
* Created by x.wang on 2017/8/21.
*/
@Controller
@RequestMapping("/PushController")
public class MessageCenterController {
private static Logger logger = LoggerFactory.getLogger(MessageCenterController.class);
@Resource(name = "core-config-reader")
private ConfigReader configReader;
@Resource(name = "core-config-writer")
private ZKConfigWriter configWriter;
@RequestMapping("/getPushLimit")
@ResponseBody
public ApiResponse getPushLimit() {
int limit = configReader.getInt("push.degrade.userSendLimit", 0);
return new ApiResponse.ApiResponseBuilder().code(200).data(limit).message("").build();
}
@RequestMapping("/setPushLimit")
@ResponseBody
public ApiResponse setPushLimit(int limit) {
if (limit <= 0) {
return new ApiResponse.ApiResponseBuilder().code(500).message("参数非法").build();
}
logger.info("Update push.degrade.userSendLimit, old value = {}, new value = {}",
configReader.getInt("push.degrade.userSendLimit", 0), limit);
configWriter.setConfig("push.degrade.userSendLimit", String.valueOf(limit));
return new ApiResponse.ApiResponseBuilder().code(200).message("设置成功").build();
}
}
//package com.yohobuy.platform.operations.restapi;
//
//import com.yoho.core.config.ConfigReader;
//import com.yoho.core.config.ZKConfigWriter;
//import com.yohobuy.platform.common.restapi.ApiResponse;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//import javax.annotation.Resource;
//
///**
// * Created by x.wang on 2017/8/21.
// */
//@Controller
//@RequestMapping("/PushController")
//public class MessageCenterController {
//
// private static Logger logger = LoggerFactory.getLogger(MessageCenterController.class);
//
// @Resource(name = "core-config-reader")
// private ConfigReader configReader;
//
// @Resource(name = "core-config-writer")
// private ZKConfigWriter configWriter;
//
// @RequestMapping("/getPushLimit")
// @ResponseBody
// public ApiResponse getPushLimit() {
// int limit = configReader.getInt("push.degrade.userSendLimit", 0);
// return new ApiResponse.ApiResponseBuilder().code(200).data(limit).message("").build();
// }
//
// @RequestMapping("/setPushLimit")
// @ResponseBody
// public ApiResponse setPushLimit(int limit) {
// if (limit <= 0) {
// return new ApiResponse.ApiResponseBuilder().code(500).message("参数非法").build();
// }
// logger.info("Update push.degrade.userSendLimit, old value = {}, new value = {}",
// configReader.getInt("push.degrade.userSendLimit", 0), limit);
//
// configWriter.setConfig("push.degrade.userSendLimit", String.valueOf(limit));
// return new ApiResponse.ApiResponseBuilder().code(200).message("设置成功").build();
// }
//}
... ...