parent
f44cf3eb71
commit
428435bdcb
@ -0,0 +1,114 @@ |
|||||||
|
package com.bweb.controller; |
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.hai.common.exception.ErrorCode; |
||||||
|
import com.hai.common.exception.ErrorHelp; |
||||||
|
import com.hai.common.exception.SysCode; |
||||||
|
import com.hai.common.security.SessionObject; |
||||||
|
import com.hai.common.security.UserCenter; |
||||||
|
import com.hai.common.utils.ResponseMsgUtil; |
||||||
|
import com.hai.entity.HighActivityInfo; |
||||||
|
import com.hai.model.HighUserModel; |
||||||
|
import com.hai.model.ResponseData; |
||||||
|
import com.hai.service.HighActivityAwardService; |
||||||
|
import com.hai.service.HighActivityInfoService; |
||||||
|
import com.hai.service.HighActivityUserLotteryNumService; |
||||||
|
import io.swagger.annotations.Api; |
||||||
|
import io.swagger.annotations.ApiOperation; |
||||||
|
import org.apache.commons.collections4.MapUtils; |
||||||
|
import org.slf4j.Logger; |
||||||
|
import org.slf4j.LoggerFactory; |
||||||
|
import org.springframework.stereotype.Controller; |
||||||
|
import org.springframework.web.bind.annotation.*; |
||||||
|
|
||||||
|
import javax.annotation.Resource; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* @author hurui |
||||||
|
*/ |
||||||
|
@Controller |
||||||
|
@RequestMapping(value = "/activity") |
||||||
|
@Api(value = "活动业务接口") |
||||||
|
public class HighActivityController { |
||||||
|
|
||||||
|
private static Logger log = LoggerFactory.getLogger(HighActivityController.class); |
||||||
|
|
||||||
|
@Resource |
||||||
|
private UserCenter userCenter; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighActivityInfoService highActivityInfoService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighActivityAwardService highActivityAwardService; |
||||||
|
|
||||||
|
@Resource |
||||||
|
private HighActivityUserLotteryNumService highActivityUserLotteryNumService; |
||||||
|
|
||||||
|
@RequestMapping(value="/edit",method = RequestMethod.POST) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "用户抽奖业务") |
||||||
|
public ResponseData userLottery(@RequestBody JSONObject body, HttpServletRequest request) { |
||||||
|
try { |
||||||
|
// 用户
|
||||||
|
SessionObject sessionObject = userCenter.getSessionObject(request); |
||||||
|
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); |
||||||
|
|
||||||
|
if (body == null || body.getLong("activityId") == null) { |
||||||
|
log.error("HighActivityController --> lottery() error!", "参数错误"); |
||||||
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||||
|
} |
||||||
|
|
||||||
|
return ResponseMsgUtil.success(highActivityUserLotteryNumService.userLottery(body.getLong("activityId"),userInfoModel.getHighUser().getId())); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighActivityController -> userLottery() error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/getActivityByCoupon",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "根据卡券查询活动信息") |
||||||
|
public ResponseData getActivityByCoupon(@RequestParam(name = "couponId", required = true) Long couponId) { |
||||||
|
try { |
||||||
|
// 查询活动
|
||||||
|
Map<String, Object> activity = highActivityInfoService.getNewActivityByCouponId(couponId); |
||||||
|
if (activity != null) { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("activityInfo", activity); |
||||||
|
map.put("activityAward", highActivityAwardService.getListByActivityId(MapUtils.getLong(activity, "id"))); |
||||||
|
return ResponseMsgUtil.success(map); |
||||||
|
} |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
|
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighActivityController -> getActivityByCoupon() error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@RequestMapping(value="/getDetail",method = RequestMethod.GET) |
||||||
|
@ResponseBody |
||||||
|
@ApiOperation(value = "查询活动详情") |
||||||
|
public ResponseData getDetail(@RequestParam(name = "activityId", required = true) Long activityId) { |
||||||
|
try { |
||||||
|
// 查询活动
|
||||||
|
HighActivityInfo detail = highActivityInfoService.getDetailById(activityId); |
||||||
|
if (detail != null) { |
||||||
|
Map<String,Object> map = new HashMap<>(); |
||||||
|
map.put("activityInfo", detail); |
||||||
|
map.put("activityAward", highActivityAwardService.getListByActivityId(detail.getId())); |
||||||
|
return ResponseMsgUtil.success(map); |
||||||
|
} |
||||||
|
return ResponseMsgUtil.success(null); |
||||||
|
} catch (Exception e) { |
||||||
|
log.error("HighActivityController -> getDetail() error!",e); |
||||||
|
return ResponseMsgUtil.exception(e); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue