parent
46cf0e7aa7
commit
015e8c7a61
@ -0,0 +1,75 @@ |
||||
package com.cweb.controller.discount; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.security.SessionObject; |
||||
import com.hfkj.common.security.UserCenter; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.CouponDiscount; |
||||
import com.hfkj.entity.CouponDiscountGoodsRel; |
||||
import com.hfkj.entity.GoodsMsg; |
||||
import com.hfkj.entity.GoodsSpecs; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.model.SecUserSessionObject; |
||||
import com.hfkj.model.UserSessionObject; |
||||
import com.hfkj.model.discount.DiscountGoodsModel; |
||||
import com.hfkj.service.discount.CouponDiscountService; |
||||
import com.hfkj.service.discount.CouponDiscountUserRelService; |
||||
import com.hfkj.service.goods.impl.GoodsMsgServiceImpl; |
||||
import com.hfkj.service.goods.impl.GoodsSpecsServiceImpl; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.BeanUtils; |
||||
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.*; |
||||
|
||||
@Controller |
||||
@RequestMapping(value="/discount") |
||||
@Api(value="优惠券") |
||||
public class DiscountController { |
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(DiscountController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private CouponDiscountUserRelService discountUserRelService; |
||||
|
||||
@RequestMapping(value = "/getListUserDiscount", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取用户优惠券列表") |
||||
public ResponseData getListUserDiscount(@RequestParam(value = "status", required = true) Integer status) { |
||||
try { |
||||
|
||||
// 用户session
|
||||
UserSessionObject userSession = userCenter.getSessionModel(UserSessionObject.class); |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
|
||||
map.put("userId", userSession.getUser().getId()); |
||||
map.put("status", status); |
||||
|
||||
return ResponseMsgUtil.success(discountUserRelService.getList(map)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("GoodsDetailController --> getListUser() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
} |
@ -0,0 +1,30 @@ |
||||
package com.hfkj.service.discount; |
||||
|
||||
import com.hfkj.entity.CouponDiscount; |
||||
import com.hfkj.entity.CouponDiscountUserRel; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
public interface CouponDiscountUserRelService { |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name create |
||||
* @Description // 创建
|
||||
* @Date 15:11 2024/4/19 |
||||
* @Param CouponDiscount |
||||
* @return void |
||||
*/ |
||||
void create(CouponDiscountUserRel couponDiscountUserRel); |
||||
|
||||
/** |
||||
* @Author Sum1Dream |
||||
* @Name getList |
||||
* @Description // 根据多条件查询列表
|
||||
* @Date 15:13 2024/4/19 |
||||
* @Param map |
||||
* @return java.util.List<com.hfkj.entity.CouponDiscount> |
||||
*/ |
||||
List<CouponDiscountUserRel> getList(Map<String , Object> map); |
||||
} |
@ -0,0 +1,46 @@ |
||||
package com.hfkj.service.discount.impl; |
||||
|
||||
import com.hfkj.dao.CouponDiscountUserRelMapper; |
||||
import com.hfkj.entity.CouponDiscountExample; |
||||
import com.hfkj.entity.CouponDiscountUserRel; |
||||
import com.hfkj.entity.CouponDiscountUserRelExample; |
||||
import com.hfkj.service.discount.CouponDiscountUserRelService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Collections; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Service("couponDiscountUserRelService") |
||||
public class CouponDiscountUserRelServiceImpl implements CouponDiscountUserRelService { |
||||
|
||||
@Resource |
||||
private CouponDiscountUserRelMapper couponDiscountUserRelMapper; |
||||
|
||||
@Override |
||||
public void create(CouponDiscountUserRel couponDiscountUserRel) { |
||||
couponDiscountUserRelMapper.insert(couponDiscountUserRel); |
||||
} |
||||
|
||||
@Override |
||||
public List<CouponDiscountUserRel> getList(Map<String, Object> map) { |
||||
CouponDiscountUserRelExample example = new CouponDiscountUserRelExample(); |
||||
CouponDiscountUserRelExample.Criteria criteria = example.createCriteria(); |
||||
|
||||
|
||||
if (MapUtils.getInteger(map, "userId") != null) { |
||||
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId")); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(map, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status")); |
||||
} |
||||
|
||||
return couponDiscountUserRelMapper.selectByExample(example); |
||||
} |
||||
|
||||
|
||||
} |
Loading…
Reference in new issue