限时购接口添加

This commit is contained in:
zhh 2018-11-16 14:51:50 +08:00
parent 2f79e06b24
commit 313e0cded0
13 changed files with 606 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="1542180981" Name="mall" Objects="1167" Symbols="148" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?> <?PowerDesigner AppLocale="UTF16" ID="{7BB41C87-EFE8-409A-A86E-B1C3FCE34F8C}" Label="" LastModificationDate="1542349350" Name="mall" Objects="1138" Symbols="145" Target="MySQL 5.0" Type="{CDE44E21-9669-11D1-9914-006097355D9B}" signature="PDM_DATA_MODEL_XML" version="16.5.0.3982"?>
<!-- do not edit this file --> <!-- do not edit this file -->
<Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object"> <Model xmlns:a="attribute" xmlns:c="collection" xmlns:o="object">
@ -17071,10 +17071,11 @@ LABL 0 新宋体,8,N</a:FontList>
<a:Code>id</a:Code> <a:Code>id</a:Code>
<a:CreationDate>1542179066</a:CreationDate> <a:CreationDate>1542179066</a:CreationDate>
<a:Creator>zhenghong</a:Creator> <a:Creator>zhenghong</a:Creator>
<a:ModificationDate>1542179149</a:ModificationDate> <a:ModificationDate>1542349350</a:ModificationDate>
<a:Modifier>zhenghong</a:Modifier> <a:Modifier>zhenghong</a:Modifier>
<a:Comment>编号</a:Comment> <a:Comment>编号</a:Comment>
<a:DataType>bigint</a:DataType> <a:DataType>bigint</a:DataType>
<a:Identity>1</a:Identity>
<a:Column.Mandatory>1</a:Column.Mandatory> <a:Column.Mandatory>1</a:Column.Mandatory>
</o:Column> </o:Column>
<o:Column Id="o1013"> <o:Column Id="o1013">

View File

@ -0,0 +1,85 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.SmsFlashPromotion;
import com.macro.mall.service.SmsFlashPromotionService;
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/16.
*/
@Controller
@Api(tags = "SmsFlashPromotionController",description = "限时购活动管理")
@RequestMapping("/flash")
public class SmsFlashPromotionController {
@Autowired
private SmsFlashPromotionService flashPromotionService;
@ApiOperation("添加活动")
@RequestMapping(value = "/create",method = RequestMethod.POST)
@ResponseBody
public Object create(@RequestBody SmsFlashPromotion flashPromotion){
int count = flashPromotionService.create(flashPromotion);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("编辑活动信息")
@RequestMapping(value = "/update/{id}",method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id, @RequestBody SmsFlashPromotion flashPromotion){
int count = flashPromotionService.update(id,flashPromotion);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("删除活动信息")
@RequestMapping(value = "/delete/{id}",method = RequestMethod.POST)
@ResponseBody
public Object delete(@PathVariable Long id){
int count = flashPromotionService.delete(id);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("修改上下线状态")
@RequestMapping(value = "/update/status/{id}",method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id,Integer status){
int count = flashPromotionService.updateStatus(id,status);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("获取活动详情")
@RequestMapping(value = "/{id}",method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id){
SmsFlashPromotion flashPromotion = flashPromotionService.getItem(id);
return new CommonResult().success(flashPromotion);
}
@ApiOperation("根据活动名称分页查询")
@RequestMapping(value = "/list",method = RequestMethod.GET)
@ResponseBody
public Object getItem(@RequestParam(value = "keyword",required = false)String keyword,
@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize,
@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum){
List<SmsFlashPromotion> flashPromotionList = flashPromotionService.list(keyword,pageSize,pageNum);
return new CommonResult().pageSuccess(flashPromotionList);
}
}

View File

@ -0,0 +1,76 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.dto.SmsFlashPromotionProduct;
import com.macro.mall.model.SmsFlashPromotionProductRelation;
import com.macro.mall.service.SmsFlashPromotionProductRelationService;
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/16.
*/
@Controller
@Api(tags = "SmsFlashPromotionProductRelationController", description = "限时购和商品关系管理")
@RequestMapping("/flashProductRelation")
public class SmsFlashPromotionProductRelationController {
@Autowired
private SmsFlashPromotionProductRelationService relationService;
@ApiOperation("批量选择商品添加关联")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public Object create(@RequestBody List<SmsFlashPromotionProductRelation> relationList) {
int count = relationService.create(relationList);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("修改关联相关信息")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id, @RequestBody SmsFlashPromotionProductRelation relation) {
int count = relationService.update(id,relation);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("删除关联")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public Object delete(@PathVariable Long id) {
int count = relationService.delete(id);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("获取管理商品促销信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id) {
SmsFlashPromotionProductRelation relation = relationService.getItem(id);
return new CommonResult().success(relation);
}
@ApiOperation("分页查询不同场次关联及商品信息")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(@RequestParam(value = "flashPromotionId")Long flashPromotionId,
@RequestParam(value = "flashPromotionSessionId")Long flashPromotionSessionId,
@RequestParam(value = "pageSize",defaultValue = "5")Integer pageSize,
@RequestParam(value = "pageNum",defaultValue = "1")Integer pageNum) {
List<SmsFlashPromotionProduct> flashPromotionProductList = relationService.list(flashPromotionId,flashPromotionSessionId,pageSize,pageNum);
return new CommonResult().pageSuccess(flashPromotionProductList);
}
}

View File

@ -0,0 +1,83 @@
package com.macro.mall.controller;
import com.macro.mall.dto.CommonResult;
import com.macro.mall.model.SmsFlashPromotionSession;
import com.macro.mall.service.SmsFlashPromotionSessionService;
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/16.
*/
@Controller
@Api(tags = "SmsFlashPromotionSessionController", description = "限时购场次管理")
@RequestMapping("/flashSession")
public class SmsFlashPromotionSessionController {
@Autowired
private SmsFlashPromotionSessionService flashPromotionSessionService;
@ApiOperation("添加场次")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public Object create(@RequestBody SmsFlashPromotionSession promotionSession) {
int count = flashPromotionSessionService.create(promotionSession);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("修改场次")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id, @RequestBody SmsFlashPromotionSession promotionSession) {
int count = flashPromotionSessionService.update(id,promotionSession);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("修改启用状态")
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
@ResponseBody
public Object updateStatus(@PathVariable Long id, Integer status) {
int count = flashPromotionSessionService.updateStatus(id,status);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("删除场次")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public Object delete(@PathVariable Long id) {
int count = flashPromotionSessionService.delete(id);
if(count>0){
return new CommonResult().success(count);
}
return new CommonResult().failed();
}
@ApiOperation("获取场次详情")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id) {
SmsFlashPromotionSession promotionSession = flashPromotionSessionService.getItem(id);
return new CommonResult().success(promotionSession);
}
@ApiOperation("根据状态获取全部场次")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list(Integer status) {
List<SmsFlashPromotionSession> promotionSessionList = flashPromotionSessionService.list(status);
return new CommonResult().pageSuccess(promotionSessionList);
}
}

View File

@ -0,0 +1,17 @@
package com.macro.mall.dao;
import com.macro.mall.dto.SmsFlashPromotionProduct;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 限时购商品关联自定义Dao
* Created by macro on 2018/11/16.
*/
public interface SmsFlashPromotionProductRelationDao {
/**
* 获取限时购及相关商品信息
*/
List<SmsFlashPromotionProduct> getList(@Param("flashPromotionId") Long flashPromotionId, @Param("flashPromotionSessionId") Long flashPromotionSessionId);
}

View File

@ -0,0 +1,16 @@
package com.macro.mall.dto;
import com.macro.mall.model.PmsProduct;
import com.macro.mall.model.SmsFlashPromotionProductRelation;
import lombok.Getter;
import lombok.Setter;
/**
* 限时购及商品信息封装
* Created by macro on 2018/11/16.
*/
public class SmsFlashPromotionProduct extends SmsFlashPromotionProductRelation{
@Getter
@Setter
private PmsProduct product;
}

View File

@ -0,0 +1,42 @@
package com.macro.mall.service;
import com.macro.mall.dto.SmsFlashPromotionProduct;
import com.macro.mall.model.SmsFlashPromotionProductRelation;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* 限时购商品关联管理Service
* Created by macro on 2018/11/16.
*/
public interface SmsFlashPromotionProductRelationService {
/**
* 批量添加关联
*/
@Transactional
int create(List<SmsFlashPromotionProductRelation> relationList);
/**
* 修改关联相关信息
*/
int update(Long id, SmsFlashPromotionProductRelation relation);
/**
* 删除关联
*/
int delete(Long id);
/**
* 获取关联详情
*/
SmsFlashPromotionProductRelation getItem(Long id);
/**
* 分页查询相关商品及促销信息
*
* @param flashPromotionId 限时购id
* @param flashPromotionSessionId 限时购场次id
*/
List<SmsFlashPromotionProduct> list(Long flashPromotionId, Long flashPromotionSessionId, Integer pageSize, Integer pageNum);
}

View File

@ -0,0 +1,41 @@
package com.macro.mall.service;
import com.macro.mall.model.SmsFlashPromotion;
import java.util.List;
/**
* 限时购活动管理Service
* Created by macro on 2018/11/16.
*/
public interface SmsFlashPromotionService {
/**
* 添加活动
*/
int create(SmsFlashPromotion flashPromotion);
/**
* 修改指定活动
*/
int update(Long id, SmsFlashPromotion flashPromotion);
/**
* 删除单个活动
*/
int delete(Long id);
/**
* 修改上下线状态
*/
int updateStatus(Long id, Integer status);
/**
* 获取详细信息
*/
SmsFlashPromotion getItem(Long id);
/**
* 分页查询活动
*/
List<SmsFlashPromotion> list(String keyword, Integer pageSize, Integer pageNum);
}

View File

@ -0,0 +1,41 @@
package com.macro.mall.service;
import com.macro.mall.model.SmsFlashPromotionSession;
import java.util.List;
/**
* 限时购场次管理Service
* Created by macro on 2018/11/16.
*/
public interface SmsFlashPromotionSessionService {
/**
* 添加场次
*/
int create(SmsFlashPromotionSession promotionSession);
/**
* 修改场次
*/
int update(Long id, SmsFlashPromotionSession promotionSession);
/**
* 修改场次启用状态
*/
int updateStatus(Long id, Integer status);
/**
* 删除场次
*/
int delete(Long id);
/**
* 获取详情
*/
SmsFlashPromotionSession getItem(Long id);
/**
* 根据启用状态获取场次列表
*/
List<SmsFlashPromotionSession> list(Integer status);
}

View File

@ -0,0 +1,53 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.dao.SmsFlashPromotionProductRelationDao;
import com.macro.mall.dto.SmsFlashPromotionProduct;
import com.macro.mall.mapper.SmsFlashPromotionProductRelationMapper;
import com.macro.mall.model.SmsFlashPromotionProductRelation;
import com.macro.mall.service.SmsFlashPromotionProductRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 限时购商品关联管理Service实现类
* Created by macro on 2018/11/16.
*/
@Service
public class SmsFlashPromotionProductRelationServiceImpl implements SmsFlashPromotionProductRelationService {
@Autowired
private SmsFlashPromotionProductRelationMapper relationMapper;
@Autowired
private SmsFlashPromotionProductRelationDao relationDao;
@Override
public int create(List<SmsFlashPromotionProductRelation> relationList) {
for (SmsFlashPromotionProductRelation relation : relationList) {
relationMapper.insert(relation);
}
return relationList.size();
}
@Override
public int update(Long id, SmsFlashPromotionProductRelation relation) {
relation.setId(id);
return relationMapper.updateByPrimaryKey(relation);
}
@Override
public int delete(Long id) {
return relationMapper.deleteByPrimaryKey(id);
}
@Override
public SmsFlashPromotionProductRelation getItem(Long id) {
return relationMapper.selectByPrimaryKey(id);
}
@Override
public List<SmsFlashPromotionProduct> list(Long flashPromotionId, Long flashPromotionSessionId, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum,pageSize);
return relationDao.getList(flashPromotionId,flashPromotionSessionId);
}
}

View File

@ -0,0 +1,63 @@
package com.macro.mall.service.impl;
import com.github.pagehelper.PageHelper;
import com.macro.mall.mapper.SmsFlashPromotionMapper;
import com.macro.mall.model.SmsFlashPromotion;
import com.macro.mall.model.SmsFlashPromotionExample;
import com.macro.mall.service.SmsFlashPromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import java.util.Date;
import java.util.List;
/**
* 限时购活动管理Service实现类
* Created by macro on 2018/11/16.
*/
@Service
public class SmsFlashPromotionServiceImpl implements SmsFlashPromotionService {
@Autowired
private SmsFlashPromotionMapper flashPromotionMapper;
@Override
public int create(SmsFlashPromotion flashPromotion) {
flashPromotion.setCreateTime(new Date());
return flashPromotionMapper.insert(flashPromotion);
}
@Override
public int update(Long id, SmsFlashPromotion flashPromotion) {
flashPromotion.setId(id);
return flashPromotionMapper.updateByPrimaryKey(flashPromotion);
}
@Override
public int delete(Long id) {
return flashPromotionMapper.deleteByPrimaryKey(id);
}
@Override
public int updateStatus(Long id, Integer status) {
SmsFlashPromotion flashPromotion = new SmsFlashPromotion();
flashPromotion.setId(id);
flashPromotion.setStatus(status);
return flashPromotionMapper.updateByPrimaryKeySelective(flashPromotion);
}
@Override
public SmsFlashPromotion getItem(Long id) {
return flashPromotionMapper.selectByPrimaryKey(id);
}
@Override
public List<SmsFlashPromotion> list(String keyword, Integer pageSize, Integer pageNum) {
PageHelper.startPage(pageNum, pageSize);
SmsFlashPromotionExample example = new SmsFlashPromotionExample();
if (!StringUtils.isEmpty(keyword)) {
example.createCriteria().andTitleLike("%" + keyword + "%");
}
return flashPromotionMapper.selectByExample(example);
}
}

View File

@ -0,0 +1,60 @@
package com.macro.mall.service.impl;
import com.macro.mall.mapper.SmsFlashPromotionSessionMapper;
import com.macro.mall.model.SmsFlashPromotionSession;
import com.macro.mall.model.SmsFlashPromotionSessionExample;
import com.macro.mall.service.SmsFlashPromotionSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 限时购场次管理Service实现类
* Created by macro on 2018/11/16.
*/
@Service
public class SmsFlashPromotionSessionServiceImpl implements SmsFlashPromotionSessionService {
@Autowired
private SmsFlashPromotionSessionMapper promotionSessionMapper;
@Override
public int create(SmsFlashPromotionSession promotionSession) {
promotionSession.setCreateTime(new Date());
return promotionSessionMapper.insert(promotionSession);
}
@Override
public int update(Long id, SmsFlashPromotionSession promotionSession) {
promotionSession.setId(id);
return promotionSessionMapper.updateByPrimaryKey(promotionSession);
}
@Override
public int updateStatus(Long id, Integer status) {
SmsFlashPromotionSession promotionSession = new SmsFlashPromotionSession();
promotionSession.setId(id);
promotionSession.setStatus(status);
return promotionSessionMapper.updateByPrimaryKeySelective(promotionSession);
}
@Override
public int delete(Long id) {
return promotionSessionMapper.deleteByPrimaryKey(id);
}
@Override
public SmsFlashPromotionSession getItem(Long id) {
return promotionSessionMapper.selectByPrimaryKey(id);
}
@Override
public List<SmsFlashPromotionSession> list(Integer status) {
SmsFlashPromotionSessionExample example = new SmsFlashPromotionSessionExample();
if (status != null) {
example.createCriteria().andStatusEqualTo(status);
}
return promotionSessionMapper.selectByExample(example);
}
}

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.macro.mall.dao.SmsFlashPromotionProductRelationDao">
<resultMap id="flashProductMap" type="com.macro.mall.dto.SmsFlashPromotionProduct" extends="com.macro.mall.mapper.SmsFlashPromotionProductRelationMapper.BaseResultMap">
<association property="product" resultMap="com.macro.mall.mapper.PmsProductMapper.BaseResultMap" columnPrefix="p_"/>
</resultMap>
<select id="getList" resultMap="flashProductMap">
SELECT
r.id,
r.flash_promotion_price,
r.flash_promotion_count,
r.flash_promotion_limit,
r.sort,
p.id p_id,
p.`name` p_name,
p.product_sn p_product_sn,
p.price p_price,
p.stock p_stock
FROM
sms_flash_promotion_product_relation r
LEFT JOIN pms_product p ON r.product_id = p.id
WHERE
r.flash_promotion_id = #{flashPromotionId}
AND r.flash_promotion_session_id = #{flashPromotionSessionId}
</select>
</mapper>