yshop1.6新增砍价后台管理
This commit is contained in:
@ -0,0 +1,156 @@
|
||||
package co.yixiang.modules.activity.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import javax.persistence.*;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
@Entity
|
||||
@Data
|
||||
@Table(name="yx_store_bargain")
|
||||
public class YxStoreBargain implements Serializable {
|
||||
|
||||
// 砍价产品ID
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id")
|
||||
private Integer id;
|
||||
|
||||
// 关联产品ID
|
||||
@Column(name = "product_id",nullable = false)
|
||||
private Integer productId;
|
||||
|
||||
// 砍价活动名称
|
||||
@Column(name = "title",nullable = false)
|
||||
private String title;
|
||||
|
||||
// 砍价活动图片
|
||||
@Column(name = "image",nullable = false)
|
||||
private String image;
|
||||
|
||||
// 单位名称
|
||||
@Column(name = "unit_name")
|
||||
private String unitName;
|
||||
|
||||
// 库存
|
||||
@Column(name = "stock")
|
||||
private Integer stock;
|
||||
|
||||
// 销量
|
||||
@Column(name = "sales")
|
||||
private Integer sales;
|
||||
|
||||
// 砍价产品轮播图
|
||||
@Column(name = "images",nullable = false)
|
||||
private String images;
|
||||
|
||||
// 砍价开启时间
|
||||
@Column(name = "start_time",nullable = false)
|
||||
private Integer startTime;
|
||||
|
||||
// 砍价结束时间
|
||||
@Column(name = "stop_time",nullable = false)
|
||||
private Integer stopTime;
|
||||
|
||||
@NotNull(message = "开始时间不能为空")
|
||||
private Date startTimeDate;
|
||||
|
||||
@NotNull(message = "结束时间不能为空")
|
||||
private Date endTimeDate;
|
||||
|
||||
// 砍价产品名称
|
||||
@Column(name = "store_name")
|
||||
private String storeName;
|
||||
|
||||
// 砍价金额
|
||||
@Column(name = "price")
|
||||
private BigDecimal price;
|
||||
|
||||
// 砍价商品最低价
|
||||
@Column(name = "min_price")
|
||||
private BigDecimal minPrice;
|
||||
|
||||
// 每次购买的砍价产品数量
|
||||
@Column(name = "num")
|
||||
private Integer num;
|
||||
|
||||
// 用户每次砍价的最大金额
|
||||
@Column(name = "bargain_max_price")
|
||||
private BigDecimal bargainMaxPrice;
|
||||
|
||||
// 用户每次砍价的最小金额
|
||||
@Column(name = "bargain_min_price")
|
||||
private BigDecimal bargainMinPrice;
|
||||
|
||||
// 用户每次砍价的次数
|
||||
@Column(name = "bargain_num",nullable = false)
|
||||
private Integer bargainNum;
|
||||
|
||||
// 砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)
|
||||
@Column(name = "status",nullable = false)
|
||||
private Integer status;
|
||||
|
||||
// 砍价详情
|
||||
@Column(name = "description")
|
||||
private String description;
|
||||
|
||||
// 反多少积分
|
||||
@Column(name = "give_integral",nullable = false)
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
// 砍价活动简介
|
||||
@Column(name = "info")
|
||||
private String info;
|
||||
|
||||
// 成本价
|
||||
@Column(name = "cost")
|
||||
private BigDecimal cost;
|
||||
|
||||
// 排序
|
||||
@Column(name = "sort",nullable = false)
|
||||
private Integer sort;
|
||||
|
||||
// 是否推荐0不推荐1推荐
|
||||
@Column(name = "is_hot",nullable = false)
|
||||
private Integer isHot;
|
||||
|
||||
// 是否删除 0未删除 1删除
|
||||
@Column(name = "is_del",nullable = false)
|
||||
private Integer isDel;
|
||||
|
||||
// 添加时间
|
||||
@Column(name = "add_time")
|
||||
private Integer addTime;
|
||||
|
||||
// 是否包邮 0不包邮 1包邮
|
||||
@Column(name = "is_postage",nullable = false)
|
||||
private Integer isPostage;
|
||||
|
||||
// 邮费
|
||||
@Column(name = "postage")
|
||||
private BigDecimal postage;
|
||||
|
||||
// 砍价规则
|
||||
@Column(name = "rule")
|
||||
private String rule;
|
||||
|
||||
// 砍价产品浏览量
|
||||
@Column(name = "look")
|
||||
private Integer look;
|
||||
|
||||
// 砍价产品分享量
|
||||
@Column(name = "share")
|
||||
private Integer share;
|
||||
|
||||
public void copy(YxStoreBargain source){
|
||||
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package co.yixiang.modules.activity.repository;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStoreBargain;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
public interface YxStoreBargainRepository extends JpaRepository<YxStoreBargain, Integer>, JpaSpecificationExecutor {
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package co.yixiang.modules.activity.rest;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import co.yixiang.aop.log.Log;
|
||||
import co.yixiang.modules.activity.domain.YxStoreBargain;
|
||||
import co.yixiang.modules.activity.service.YxStoreBargainService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria;
|
||||
import co.yixiang.utils.OrderUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.*;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
@Api(tags = "YxStoreBargain管理")
|
||||
@RestController
|
||||
@RequestMapping("api")
|
||||
public class YxStoreBargainController {
|
||||
|
||||
@Autowired
|
||||
private YxStoreBargainService yxStoreBargainService;
|
||||
|
||||
@Log("查询YxStoreBargain")
|
||||
@ApiOperation(value = "查询YxStoreBargain")
|
||||
@GetMapping(value = "/yxStoreBargain")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_SELECT')")
|
||||
public ResponseEntity getYxStoreBargains(YxStoreBargainQueryCriteria criteria, Pageable pageable){
|
||||
return new ResponseEntity(yxStoreBargainService.queryAll(criteria,pageable),HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Log("修改YxStoreBargain")
|
||||
@ApiOperation(value = "修改YxStoreBargain")
|
||||
@PutMapping(value = "/yxStoreBargain")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_EDIT')")
|
||||
public ResponseEntity update(@Validated @RequestBody YxStoreBargain resources){
|
||||
|
||||
if(ObjectUtil.isNotNull(resources.getStartTimeDate())){
|
||||
resources.setStartTime(OrderUtil.
|
||||
dateToTimestamp(resources.getStartTimeDate()));
|
||||
}
|
||||
if(ObjectUtil.isNotNull(resources.getEndTimeDate())){
|
||||
resources.setStopTime(OrderUtil.
|
||||
dateToTimestamp(resources.getEndTimeDate()));
|
||||
}
|
||||
if(ObjectUtil.isNull(resources.getId())){
|
||||
resources.setAddTime(OrderUtil.getSecondTimestampTwo());
|
||||
return new ResponseEntity(yxStoreBargainService.create(resources),HttpStatus.CREATED);
|
||||
}else{
|
||||
yxStoreBargainService.update(resources);
|
||||
return new ResponseEntity(HttpStatus.NO_CONTENT);
|
||||
}
|
||||
}
|
||||
|
||||
@Log("删除YxStoreBargain")
|
||||
@ApiOperation(value = "删除YxStoreBargain")
|
||||
@DeleteMapping(value = "/yxStoreBargain/{id}")
|
||||
@PreAuthorize("hasAnyRole('ADMIN','YXSTOREBARGAIN_ALL','YXSTOREBARGAIN_DELETE')")
|
||||
public ResponseEntity delete(@PathVariable Integer id){
|
||||
yxStoreBargainService.delete(id);
|
||||
return new ResponseEntity(HttpStatus.OK);
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package co.yixiang.modules.activity.service;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStoreBargain;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreBargainDTO;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria;
|
||||
import org.springframework.cache.annotation.CacheConfig;
|
||||
import org.springframework.cache.annotation.CacheEvict;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.Map;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
//@CacheConfig(cacheNames = "yxStoreBargain")
|
||||
public interface YxStoreBargainService {
|
||||
|
||||
/**
|
||||
* 查询数据分页
|
||||
* @param criteria
|
||||
* @param pageable
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable
|
||||
Map<String,Object> queryAll(YxStoreBargainQueryCriteria criteria, Pageable pageable);
|
||||
|
||||
/**
|
||||
* 查询所有数据不分页
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable
|
||||
List<YxStoreBargainDTO> queryAll(YxStoreBargainQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 根据ID查询
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@Cacheable(key = "#p0")
|
||||
YxStoreBargainDTO findById(Integer id);
|
||||
|
||||
/**
|
||||
* 创建
|
||||
* @param resources
|
||||
* @return
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
YxStoreBargainDTO create(YxStoreBargain resources);
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param resources
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void update(YxStoreBargain resources);
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id
|
||||
*/
|
||||
//@CacheEvict(allEntries = true)
|
||||
void delete(Integer id);
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package co.yixiang.modules.activity.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import java.io.Serializable;
|
||||
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
@Data
|
||||
public class YxStoreBargainDTO implements Serializable {
|
||||
|
||||
// 砍价产品ID
|
||||
private Integer id;
|
||||
|
||||
// 关联产品ID
|
||||
private Integer productId;
|
||||
|
||||
// 砍价活动名称
|
||||
private String title;
|
||||
|
||||
// 砍价活动图片
|
||||
private String image;
|
||||
|
||||
// 单位名称
|
||||
private String unitName;
|
||||
|
||||
// 库存
|
||||
private Integer stock;
|
||||
|
||||
// 销量
|
||||
private Integer sales;
|
||||
|
||||
// 砍价产品轮播图
|
||||
private String images;
|
||||
|
||||
// 砍价开启时间
|
||||
private Integer startTime;
|
||||
|
||||
// 砍价结束时间
|
||||
private Integer stopTime;
|
||||
|
||||
// 砍价产品名称
|
||||
private String storeName;
|
||||
|
||||
// 砍价金额
|
||||
private BigDecimal price;
|
||||
|
||||
// 砍价商品最低价
|
||||
private BigDecimal minPrice;
|
||||
|
||||
// 每次购买的砍价产品数量
|
||||
private Integer num;
|
||||
|
||||
// 用户每次砍价的最大金额
|
||||
private BigDecimal bargainMaxPrice;
|
||||
|
||||
// 用户每次砍价的最小金额
|
||||
private BigDecimal bargainMinPrice;
|
||||
|
||||
// 用户每次砍价的次数
|
||||
private Integer bargainNum;
|
||||
|
||||
// 砍价状态 0(到砍价时间不自动开启) 1(到砍价时间自动开启时间)
|
||||
private Integer status;
|
||||
|
||||
// 砍价详情
|
||||
private String description;
|
||||
|
||||
// 反多少积分
|
||||
private BigDecimal giveIntegral;
|
||||
|
||||
// 砍价活动简介
|
||||
private String info;
|
||||
|
||||
// 成本价
|
||||
private BigDecimal cost;
|
||||
|
||||
// 排序
|
||||
private Integer sort;
|
||||
|
||||
// 是否推荐0不推荐1推荐
|
||||
private Integer isHot;
|
||||
|
||||
// 是否删除 0未删除 1删除
|
||||
private Integer isDel;
|
||||
|
||||
// 添加时间
|
||||
private Integer addTime;
|
||||
|
||||
// 是否包邮 0不包邮 1包邮
|
||||
private Integer isPostage;
|
||||
|
||||
// 邮费
|
||||
private BigDecimal postage;
|
||||
|
||||
// 砍价规则
|
||||
private String rule;
|
||||
|
||||
// 砍价产品浏览量
|
||||
private Integer look;
|
||||
|
||||
// 砍价产品分享量
|
||||
private Integer share;
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
package co.yixiang.modules.activity.service.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
import co.yixiang.annotation.Query;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
@Data
|
||||
public class YxStoreBargainQueryCriteria{
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package co.yixiang.modules.activity.service.impl;
|
||||
|
||||
import co.yixiang.modules.activity.domain.YxStoreBargain;
|
||||
import co.yixiang.utils.ValidationUtil;
|
||||
import co.yixiang.modules.activity.repository.YxStoreBargainRepository;
|
||||
import co.yixiang.modules.activity.service.YxStoreBargainService;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreBargainDTO;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreBargainQueryCriteria;
|
||||
import co.yixiang.modules.activity.service.mapper.YxStoreBargainMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.Optional;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import co.yixiang.utils.PageUtil;
|
||||
import co.yixiang.utils.QueryHelp;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
@Service
|
||||
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
|
||||
public class YxStoreBargainServiceImpl implements YxStoreBargainService {
|
||||
|
||||
@Autowired
|
||||
private YxStoreBargainRepository yxStoreBargainRepository;
|
||||
|
||||
@Autowired
|
||||
private YxStoreBargainMapper yxStoreBargainMapper;
|
||||
|
||||
@Override
|
||||
public Map<String,Object> queryAll(YxStoreBargainQueryCriteria criteria, Pageable pageable){
|
||||
Page<YxStoreBargain> page = yxStoreBargainRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
|
||||
return PageUtil.toPage(page.map(yxStoreBargainMapper::toDto));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<YxStoreBargainDTO> queryAll(YxStoreBargainQueryCriteria criteria){
|
||||
return yxStoreBargainMapper.toDto(yxStoreBargainRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public YxStoreBargainDTO findById(Integer id) {
|
||||
Optional<YxStoreBargain> yxStoreBargain = yxStoreBargainRepository.findById(id);
|
||||
ValidationUtil.isNull(yxStoreBargain,"YxStoreBargain","id",id);
|
||||
return yxStoreBargainMapper.toDto(yxStoreBargain.get());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public YxStoreBargainDTO create(YxStoreBargain resources) {
|
||||
return yxStoreBargainMapper.toDto(yxStoreBargainRepository.save(resources));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void update(YxStoreBargain resources) {
|
||||
Optional<YxStoreBargain> optionalYxStoreBargain = yxStoreBargainRepository.findById(resources.getId());
|
||||
ValidationUtil.isNull( optionalYxStoreBargain,"YxStoreBargain","id",resources.getId());
|
||||
YxStoreBargain yxStoreBargain = optionalYxStoreBargain.get();
|
||||
yxStoreBargain.copy(resources);
|
||||
yxStoreBargainRepository.save(yxStoreBargain);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void delete(Integer id) {
|
||||
yxStoreBargainRepository.deleteById(id);
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
package co.yixiang.modules.activity.service.mapper;
|
||||
|
||||
import co.yixiang.mapper.EntityMapper;
|
||||
import co.yixiang.modules.activity.domain.YxStoreBargain;
|
||||
import co.yixiang.modules.activity.service.dto.YxStoreBargainDTO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.ReportingPolicy;
|
||||
|
||||
/**
|
||||
* @author xuwenbo
|
||||
* @date 2019-12-22
|
||||
*/
|
||||
@Mapper(componentModel = "spring",uses = {},unmappedTargetPolicy = ReportingPolicy.IGNORE)
|
||||
public interface YxStoreBargainMapper extends EntityMapper<YxStoreBargainDTO, YxStoreBargain> {
|
||||
|
||||
}
|
Reference in New Issue
Block a user