嗨森逛服务
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hai-server/hai-cweb/src/main/java/com/cweb/controller/HighCouponController.java

103 lines
3.8 KiB

package com.cweb.controller;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
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.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/11 22:16
*/
@Controller
@RequestMapping(value = "/coupon")
@Api(value = "卡卷接口")
public class HighCouponController {
private static Logger log = LoggerFactory.getLogger(HighCouponController.class);
@Autowired
private UserCenter userCenter;
@Resource
private HighMerchantService highMerchantService;
@Resource
private HighCouponService highCouponService;
@Resource
private HighCouponHandselService highCouponHandselService;
@Resource
private HighCouponCodeService highCouponCodeService;
@Resource
private HighApproveService highApproveService;
@RequestMapping(value="/getCouponList",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "卡卷列表")
public ResponseData getCouponList(@RequestParam(name = "regionId", required = true) Long regionId,
@RequestParam(name = "merchantId", required = false) Long merchantId,
@RequestParam(name = "couponName", required = false) String couponName,
@RequestParam(name = "couponType", required = false) Integer couponType,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request) {
try {
Map<String, Object> map = new HashMap<>();
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getBsCompany() == null) {
log.error("HighCouponController -> getCouponList() error!","权限不足");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
map.put("regionId", regionId);
map.put("merchantId", merchantId);
map.put("couponName", couponName);
map.put("couponType", couponType);
map.put("status", 2);
PageHelper.startPage(pageNum, pageSize);
return ResponseMsgUtil.success(new PageInfo<>(highCouponService.getCouponList(map)));
} catch (Exception e) {
log.error("HighCouponController -> getCouponList() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/getCouponById",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "卡卷信息")
public ResponseData getCouponById(@RequestParam(name = "couponId", required = true) Long couponId) {
try {
return ResponseMsgUtil.success(highCouponService.getCouponById(couponId));
} catch (Exception e) {
log.error("HighCouponController -> getCouponById() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}