优惠券、首页品牌、首页新品接口添加
This commit is contained in:
@@ -62,7 +62,7 @@ public class SmsCouponController {
|
||||
@RequestParam(value = "name",required = false) String name,
|
||||
@RequestParam(value = "type",required = false) Integer type,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<SmsCoupon> couponList = couponService.list(name,type,pageSize,pageNum);
|
||||
return new CommonResult().pageSuccess(couponList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.SmsCouponHistory;
|
||||
import com.macro.mall.service.SmsCouponHistoryService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.ResponseBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券领取记录管理Controller
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "SmsCouponHistoryController",description = "优惠券领取记录管理")
|
||||
@RequestMapping("/couponHistory")
|
||||
public class SmsCouponHistoryController {
|
||||
@Autowired
|
||||
private SmsCouponHistoryService historyService;
|
||||
@ApiOperation("根据优惠券id,使用状态,订单编号分页获取领取记录")
|
||||
@RequestMapping(value = "/list",method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object list(@RequestParam(value = "couponId",required = false) Long couponId,
|
||||
@RequestParam(value = "useStatus",required = false) Integer useStatus,
|
||||
@RequestParam(value = "orderSn",required = false) String orderSn,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
|
||||
List<SmsCouponHistory> historyList = historyService.list(couponId,useStatus,orderSn,pageSize,pageNum);
|
||||
return new CommonResult().pageSuccess(historyList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.SmsHomeBrand;
|
||||
import com.macro.mall.service.SmsHomeBrandService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页品牌管理Controller
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "SmsHomeBrandController", description = "首页品牌管理")
|
||||
@RequestMapping("/home/brand")
|
||||
public class SmsHomeBrandController {
|
||||
@Autowired
|
||||
private SmsHomeBrandService homeBrandService;
|
||||
@ApiOperation("添加首页推荐品牌")
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object create(@RequestBody List<SmsHomeBrand> homeBrandList) {
|
||||
int count = homeBrandService.create(homeBrandList);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("修改品牌排序")
|
||||
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateSort(@PathVariable Long id, Integer sort) {
|
||||
int count = homeBrandService.updateSort(id,sort);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除推荐品牌")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object delete(@RequestParam("ids") List<Long> ids) {
|
||||
int count = homeBrandService.delete(ids);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改推荐状态")
|
||||
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
|
||||
int count = homeBrandService.updateRecommendStatus(ids,recommendStatus);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询推荐品牌")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object list(@RequestParam(value = "brandName", required = false) String brandName,
|
||||
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<SmsHomeBrand> homeBrandList = homeBrandService.list(brandName,recommendStatus,pageSize,pageNum);
|
||||
return new CommonResult().pageSuccess(homeBrandList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.macro.mall.controller;
|
||||
|
||||
import com.macro.mall.dto.CommonResult;
|
||||
import com.macro.mall.model.SmsHomeNewProduct;
|
||||
import com.macro.mall.service.SmsHomeNewProductService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页品牌管理Controller
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Controller
|
||||
@Api(tags = "SmsHomeNewProductController", description = "首页新品管理")
|
||||
@RequestMapping("/home/newProduct")
|
||||
public class SmsHomeNewProductController {
|
||||
@Autowired
|
||||
private SmsHomeNewProductService homeNewProductService;
|
||||
@ApiOperation("添加首页推荐品牌")
|
||||
@RequestMapping(value = "/create", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object create(@RequestBody List<SmsHomeNewProduct> homeBrandList) {
|
||||
int count = homeNewProductService.create(homeBrandList);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("修改推荐排序")
|
||||
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateSort(@PathVariable Long id, Integer sort) {
|
||||
int count = homeNewProductService.updateSort(id,sort);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量删除推荐")
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object delete(@RequestParam("ids") List<Long> ids) {
|
||||
int count = homeNewProductService.delete(ids);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("批量修改推荐状态")
|
||||
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public Object updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
|
||||
int count = homeNewProductService.updateRecommendStatus(ids,recommendStatus);
|
||||
if(count>0){
|
||||
return new CommonResult().success(count);
|
||||
}
|
||||
return new CommonResult().failed();
|
||||
}
|
||||
|
||||
@ApiOperation("分页查询推荐")
|
||||
@RequestMapping(value = "/list", method = RequestMethod.GET)
|
||||
@ResponseBody
|
||||
public Object list(@RequestParam(value = "productName", required = false) String productName,
|
||||
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
|
||||
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
|
||||
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
|
||||
List<SmsHomeNewProduct> homeBrandList = homeNewProductService.list(productName,recommendStatus,pageSize,pageNum);
|
||||
return new CommonResult().pageSuccess(homeBrandList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.SmsCouponHistory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券领取记录管理Service
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
public interface SmsCouponHistoryService {
|
||||
/**
|
||||
* 分页查询优惠券领取记录
|
||||
* @param couponId 优惠券id
|
||||
* @param useStatus 使用状态
|
||||
* @param orderSn 使用订单号码
|
||||
*/
|
||||
List<SmsCouponHistory> list(Long couponId, Integer useStatus, String orderSn, Integer pageSize, Integer pageNum);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.SmsHomeBrand;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页品牌管理Service
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
public interface SmsHomeBrandService {
|
||||
/**
|
||||
* 添加首页品牌推荐
|
||||
*/
|
||||
@Transactional
|
||||
int create(List<SmsHomeBrand> homeBrandList);
|
||||
|
||||
/**
|
||||
* 修改品牌推荐排序
|
||||
*/
|
||||
int updateSort(Long id, Integer sort);
|
||||
|
||||
/**
|
||||
* 批量删除品牌推荐
|
||||
*/
|
||||
int delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 更新推荐状态
|
||||
*/
|
||||
int updateRecommendStatus(List<Long> ids, Integer recommendStatus);
|
||||
|
||||
/**
|
||||
* 分页查询品牌推荐
|
||||
*/
|
||||
List<SmsHomeBrand> list(String brandName, Integer recommendStatus, Integer pageSize, Integer pageNum);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.macro.mall.service;
|
||||
|
||||
import com.macro.mall.model.SmsHomeNewProduct;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页新品管理Service
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
public interface SmsHomeNewProductService {
|
||||
/**
|
||||
* 添加首页推荐
|
||||
*/
|
||||
@Transactional
|
||||
int create(List<SmsHomeNewProduct> homeBrandList);
|
||||
|
||||
/**
|
||||
* 修改推荐排序
|
||||
*/
|
||||
int updateSort(Long id, Integer sort);
|
||||
|
||||
/**
|
||||
* 批量删除推荐
|
||||
*/
|
||||
int delete(List<Long> ids);
|
||||
|
||||
/**
|
||||
* 更新推荐状态
|
||||
*/
|
||||
int updateRecommendStatus(List<Long> ids, Integer recommendStatus);
|
||||
|
||||
/**
|
||||
* 分页查询推荐
|
||||
*/
|
||||
List<SmsHomeNewProduct> list(String productName, Integer recommendStatus, Integer pageSize, Integer pageNum);
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.mapper.SmsCouponHistoryMapper;
|
||||
import com.macro.mall.model.SmsCouponHistory;
|
||||
import com.macro.mall.model.SmsCouponHistoryExample;
|
||||
import com.macro.mall.service.SmsCouponHistoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 优惠券领取记录管理Service实现类
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Service
|
||||
public class SmsCouponHistoryServiceImpl implements SmsCouponHistoryService {
|
||||
@Autowired
|
||||
private SmsCouponHistoryMapper historyMapper;
|
||||
@Override
|
||||
public List<SmsCouponHistory> list(Long couponId, Integer useStatus, String orderSn, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
SmsCouponHistoryExample example = new SmsCouponHistoryExample();
|
||||
SmsCouponHistoryExample.Criteria criteria = example.createCriteria();
|
||||
if(couponId!=null){
|
||||
criteria.andCouponIdEqualTo(couponId);
|
||||
}
|
||||
if(useStatus!=null){
|
||||
criteria.andUseStatusEqualTo(useStatus);
|
||||
}
|
||||
if(!StringUtils.isEmpty(orderSn)){
|
||||
criteria.andOrderSnEqualTo(orderSn);
|
||||
}
|
||||
return historyMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.mapper.SmsHomeBrandMapper;
|
||||
import com.macro.mall.model.SmsHomeBrand;
|
||||
import com.macro.mall.model.SmsHomeBrandExample;
|
||||
import com.macro.mall.service.SmsHomeBrandService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页品牌管理Service实现类
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Service
|
||||
public class SmsHomeBrandServiceImpl implements SmsHomeBrandService {
|
||||
@Autowired
|
||||
private SmsHomeBrandMapper homeBrandMapper;
|
||||
@Override
|
||||
public int create(List<SmsHomeBrand> homeBrandList) {
|
||||
for (SmsHomeBrand smsHomeBrand : homeBrandList) {
|
||||
smsHomeBrand.setRecommendStatus(1);
|
||||
smsHomeBrand.setSort(0);
|
||||
homeBrandMapper.insert(smsHomeBrand);
|
||||
}
|
||||
return homeBrandList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSort(Long id, Integer sort) {
|
||||
SmsHomeBrand homeBrand = new SmsHomeBrand();
|
||||
homeBrand.setId(id);
|
||||
homeBrand.setSort(sort);
|
||||
return homeBrandMapper.updateByPrimaryKeySelective(homeBrand);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(List<Long> ids) {
|
||||
SmsHomeBrandExample example = new SmsHomeBrandExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return homeBrandMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
|
||||
SmsHomeBrandExample example = new SmsHomeBrandExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
SmsHomeBrand record = new SmsHomeBrand();
|
||||
record.setRecommendStatus(recommendStatus);
|
||||
return homeBrandMapper.updateByExampleSelective(record,example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsHomeBrand> list(String brandName, Integer recommendStatus, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
SmsHomeBrandExample example = new SmsHomeBrandExample();
|
||||
SmsHomeBrandExample.Criteria criteria = example.createCriteria();
|
||||
if(!StringUtils.isEmpty(brandName)){
|
||||
criteria.andBrandNameLike("%"+brandName+"%");
|
||||
}
|
||||
if(recommendStatus!=null){
|
||||
criteria.andRecommendStatusEqualTo(recommendStatus);
|
||||
}
|
||||
example.setOrderByClause("sort desc");
|
||||
return homeBrandMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.macro.mall.service.impl;
|
||||
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.macro.mall.mapper.SmsHomeNewProductMapper;
|
||||
import com.macro.mall.model.SmsHomeNewProduct;
|
||||
import com.macro.mall.model.SmsHomeNewProductExample;
|
||||
import com.macro.mall.service.SmsHomeNewProductService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 首页新品推荐管理Service实现类
|
||||
* Created by macro on 2018/11/6.
|
||||
*/
|
||||
@Service
|
||||
public class SmsHomeNewProductServiceImpl implements SmsHomeNewProductService {
|
||||
@Autowired
|
||||
private SmsHomeNewProductMapper homeNewProductMapper;
|
||||
@Override
|
||||
public int create(List<SmsHomeNewProduct> homeNewProductList) {
|
||||
for (SmsHomeNewProduct SmsHomeNewProduct : homeNewProductList) {
|
||||
SmsHomeNewProduct.setRecommendStatus(1);
|
||||
SmsHomeNewProduct.setSort(0);
|
||||
homeNewProductMapper.insert(SmsHomeNewProduct);
|
||||
}
|
||||
return homeNewProductList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateSort(Long id, Integer sort) {
|
||||
SmsHomeNewProduct homeNewProduct = new SmsHomeNewProduct();
|
||||
homeNewProduct.setId(id);
|
||||
homeNewProduct.setSort(sort);
|
||||
return homeNewProductMapper.updateByPrimaryKeySelective(homeNewProduct);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(List<Long> ids) {
|
||||
SmsHomeNewProductExample example = new SmsHomeNewProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
return homeNewProductMapper.deleteByExample(example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int updateRecommendStatus(List<Long> ids, Integer recommendStatus) {
|
||||
SmsHomeNewProductExample example = new SmsHomeNewProductExample();
|
||||
example.createCriteria().andIdIn(ids);
|
||||
SmsHomeNewProduct record = new SmsHomeNewProduct();
|
||||
record.setRecommendStatus(recommendStatus);
|
||||
return homeNewProductMapper.updateByExampleSelective(record,example);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SmsHomeNewProduct> list(String productName, Integer recommendStatus, Integer pageSize, Integer pageNum) {
|
||||
PageHelper.startPage(pageNum,pageSize);
|
||||
SmsHomeNewProductExample example = new SmsHomeNewProductExample();
|
||||
SmsHomeNewProductExample.Criteria criteria = example.createCriteria();
|
||||
if(!StringUtils.isEmpty(productName)){
|
||||
criteria.andProductNameLike("%"+productName+"%");
|
||||
}
|
||||
if(recommendStatus!=null){
|
||||
criteria.andRecommendStatusEqualTo(recommendStatus);
|
||||
}
|
||||
example.setOrderByClause("sort desc");
|
||||
return homeNewProductMapper.selectByExample(example);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user