码迷,mamicode.com
首页 > Web开发 > 详细

一个ajax的后台controller

时间:2016-04-06 18:41:20      阅读:128      评论:0      收藏:0      [点我收藏+]

标签:

@RequestMapping("/api/merBrand")
@ResponseBody
public ResultBrand merBrand(HttpServletRequest request,
@RequestParam("brandId") Long brandId,
@RequestParam("oldBrandId") Long oldBrandId) {
try {
ItemApiContext context=ItemApiContextUtil.getItemApiContext(request);
BrandClient brandClient = BrandTools.getBrandClient();
int resultCode= brandClient.combineBrand(context, oldBrandId, brandId);
if(resultCode ==1){
return new ResultBrand(1,"合并品牌成功!");
}else if(resultCode ==-1){
return new ResultBrand(2,"合并的品牌未认证通过或已删除");
}else if(resultCode == -2){
return new ResultBrand(2,"合并的品牌Id不存在");
}

} catch (Exception e) {
logger.error("合并品牌异常!", e);
}
return new ResultBrand(2,"合并品牌异常");

}

结果集封装类

class ResultBrand{

public ResultBrand(int num,String message){
this.num=num;
this.message=message;
}

private int num;

private String message;

public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}

}

一个ajax的后台controller

标签:

原文地址:http://www.cnblogs.com/zhaoblog/p/5360236.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!