Commit 3c564750 3c564750736caf05cef92d844340463f0c8a097c by xianghan@topdraw.cn

1.接口优化,删除不必要的接口

1 parent 7c7d4f22
Showing 100 changed files with 1087 additions and 1530 deletions
......@@ -25,94 +25,94 @@ import java.time.LocalDateTime;
@Table(name="m_coupon")
public class Coupon implements Serializable {
// id
/** id */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 标识
/** 标识 */
@Column(name = "code", nullable = false)
private String code;
// 名称
/** 名称 */
@Column(name = "title", nullable = false)
private String title;
// 图片
/** 图片 */
@Column(name = "images")
private String images;
// 发行量,-1代表不限量
/** 发行量,-1代表不限量 */
@Column(name = "stock")
private Integer stock;
// 剩余量,-1代表不限量
/** 剩余量,-1代表不限量 */
@Column(name = "remain_stock")
private Integer remainStock;
// 优惠形式:1:现金;2:折扣
/** 优惠形式:1:现金;2:折扣 */
@Column(name = "use_type")
private Integer useType;
// 面额
/** 面额 */
@Column(name = "denomination")
private BigDecimal denomination;
// 折扣
/** 折扣 */
@Column(name = "discount")
private BigDecimal discount;
// 适用用户范围:1:新用户;2:全体用户
/** 适用用户范围:1:新用户;2:全体用户 */
@Column(name = "user_range")
private Integer userRange;
// 限领次数 -1:无限次; >0:具体次数
/** 限领次数 -1:无限次; >0:具体次数 */
@Column(name = "collect_limit")
private Integer collectLimit;
// 适用门槛:1:无门槛;2:满减形式
/** 适用门槛:1:无门槛;2:满减形式 */
@Column(name = "threshold_type")
private Integer thresholdType;
// 满减门槛
/** 满减门槛 */
@Column(name = "amount_threshold")
private BigDecimal amountThreshold;
// 产品范围:1:全部商品;2:指定商品
/** 产品范围:1:全部商品;2:指定商品 */
@Column(name = "item_range")
private Integer itemRange;
// 生效形式:1:固定日期;2:相对日期
/** 生效形式:1:固定日期;2:相对日期 */
@Column(name = "effect_type")
private Integer effectType;
// 生效时间
/** 生效时间 */
@Column(name = "start_time")
private Timestamp startTime;
// 过期时间
/** 过期时间 */
@Column(name = "expire_time")
private LocalDateTime expireTime;
// 自领取当日,几天内有效
/** 自领取当日,几天内有效 */
@Column(name = "valid_days")
private Integer validDays;
// 使用说明
/** 使用说明 */
@Column(name = "description")
private String description;
// 状态0:未开始,1:启用;2:停用
/** 状态0:未开始,1:启用;2:停用 */
@Column(name = "status")
private Integer status;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
......
package com.topdraw.business.module.coupon.domain;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.util.IdWorker;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* 优惠券
*/
public class CouponBuilder {
public static Coupon build(CouponDTO couponDTO){
Coupon coupon = new Coupon();
BeanUtils.copyProperties(couponDTO,coupon);
return build(coupon.getId(),
coupon.getCode(),
coupon.getTitle(),coupon.getImages(),coupon.getStock(),coupon.getRemainStock(),coupon.getUseType(),
coupon.getDenomination(),coupon.getDiscount(),coupon.getUserRange(),coupon.getCollectLimit(),
coupon.getThresholdType(),coupon.getAmountThreshold(),coupon.getItemRange(),coupon.getEffectType(),
coupon.getStartTime(),coupon.getExpireTime(),coupon.getValidDays(),coupon.getDescription(),coupon.getStatus());
}
public static Coupon build(Coupon coupon){
return build(coupon.getId(),
coupon.getCode(),
coupon.getTitle(),coupon.getImages(),coupon.getStock(),coupon.getRemainStock(),coupon.getUseType(),
coupon.getDenomination(),coupon.getDiscount(),coupon.getUserRange(),coupon.getCollectLimit(),
coupon.getThresholdType(),coupon.getAmountThreshold(),coupon.getItemRange(),coupon.getEffectType(),
coupon.getStartTime(),coupon.getExpireTime(),coupon.getValidDays(),coupon.getDescription(),coupon.getStatus());
}
public static Coupon build(Long id , String code , String title,
String images,
Integer stock,
Integer remainStock,
Integer useType,
BigDecimal denomination,
BigDecimal discount,
Integer userRange,
Integer collectLimit,
Integer thresholdType,
BigDecimal amountThreshold,
Integer itemRange,
Integer effectType,
Timestamp startTime,
LocalDateTime expireTime,
Integer validDays,String description , Integer status){
Coupon coupon = new Coupon();
coupon.setId(id);
coupon.setCode(StringUtils.isBlank(code)? IdWorker.generatorCode("coupon"):code);
coupon.setTitle(StringUtils.isBlank(title)?null:title);
coupon.setImages(StringUtils.isBlank(images)?null:images);
coupon.setStock(Objects.isNull(stock)?null:stock);
coupon.setRemainStock(Objects.isNull(remainStock)?null:remainStock);
coupon.setUseType(Objects.isNull(useType)?null:useType);
coupon.setDenomination(Objects.isNull(denomination)?null:denomination);
coupon.setDiscount(Objects.isNull(discount)?null:discount);
coupon.setUserRange(Objects.isNull(userRange)?null:userRange);
coupon.setCollectLimit(collectLimit);
coupon.setThresholdType(Objects.isNull(thresholdType)?null:thresholdType);
coupon.setAmountThreshold(Objects.isNull(amountThreshold)?null:amountThreshold);
coupon.setItemRange(Objects.isNull(itemRange)?null:itemRange);
coupon.setEffectType(Objects.isNull(effectType)?null:effectType);
coupon.setStartTime(Objects.isNull(startTime)?null: startTime);
coupon.setExpireTime(Objects.isNull(expireTime)?null:expireTime);
coupon.setValidDays(validDays);
coupon.setDescription(StringUtils.isBlank(description)?"":description);
coupon.setStatus(Objects.nonNull(status)?status:0);
return coupon;
}
}
......@@ -24,54 +24,54 @@ import java.time.LocalDateTime;
@Table(name="m_coupon_history")
public class CouponHistory implements Serializable {
// 主键
/** 主键 */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 优惠券id
/** 优惠券id */
@Column(name = "coupon_id")
private Long couponId;
// 领券用户id(对应账号)
/** 领券用户id(对应账号) */
@Column(name = "user_id")
private Long userId;
// 优惠券code
/** 优惠券code */
@Column(name = "coupon_code")
private String couponCode;
// 领取人昵称
/** 领取人昵称 */
@Column(name = "user_nickname")
private String userNickname;
// 领取时间
/** 领取时间 */
@Column(name = "receive_time")
private LocalDateTime receiveTime;
// 失效时间
/** 失效时间 */
@Column(name = "expire_time")
private LocalDateTime expireTime;
// 使用状态 0:未使用;1:已使用;-1:已过期
/** 使用状态 0:未使用;1:已使用;-1:已过期 */
@Column(name = "use_status")
private Integer useStatus;
// 使用时间
/** 使用时间 */
@Column(name = "use_time")
private LocalDateTime useTime;
// 订单详情id
/** 订单详情id */
@Column(name = "order_detail_id")
private Long orderDetailId;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private LocalDateTime createTime;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private LocalDateTime updateTime;
......
package com.topdraw.business.module.coupon.history.domain;
import com.topdraw.business.module.coupon.domain.Coupon;
import org.apache.commons.lang3.StringUtils;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* 优惠券
*/
public class CouponHistoryBuilder {
public static CouponHistory build(CouponHistory couponHistory){
return build(couponHistory.getId(),
couponHistory.getCouponId(),
couponHistory.getUserId(),
couponHistory.getCouponCode(),
couponHistory.getUserNickname(),
couponHistory.getReceiveTime(),
couponHistory.getExpireTime(),
couponHistory.getUseStatus(),
couponHistory.getUseTime(),
couponHistory.getOrderDetailId());
}
public static CouponHistory build(Coupon coupon,Long userId,String userNickname){
return build(coupon,userId,userNickname,null);
}
public static CouponHistory build(Coupon coupon,Long userId,String userNickname,Long orderDetailId){
return build(null,
coupon.getId(),userId,coupon.getCode(),userNickname,LocalDateTime.now(),
coupon.getExpireTime(),coupon.getStatus(),null,orderDetailId);
}
public static CouponHistory build(Long id , Long couponId , Long userId,String couponCode,String userNickname,LocalDateTime receiveTime,
LocalDateTime expireTime,Integer useStatus,LocalDateTime useTime,
Long orderDetailId) {
CouponHistory couponHistory = new CouponHistory();
couponHistory.setId(id);
couponHistory.setCouponId(Objects.isNull(couponId)?null:couponId);
couponHistory.setUserId(Objects.isNull(userId)?null:userId);
couponHistory.setCouponCode(StringUtils.isBlank(couponCode)?null:couponCode);
couponHistory.setUserNickname(StringUtils.isBlank(userNickname)?null:userNickname);
couponHistory.setReceiveTime(Objects.isNull(receiveTime)?null:receiveTime);
couponHistory.setExpireTime(Objects.isNull(expireTime)?null:expireTime);
couponHistory.setUseStatus(Objects.isNull(useStatus)?0:useStatus);
couponHistory.setUseTime(Objects.isNull(useTime)?null:useTime);
couponHistory.setOrderDetailId(Objects.isNull(orderDetailId)?null:orderDetailId);
return couponHistory;
}
}
package com.topdraw.business.module.coupon.history.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-23
*/
@Api(tags = "CouponHistory管理")
@RestController
@RequestMapping("/api/CouponHistory")
public class CouponHistoryController {
@Autowired
private CouponHistoryService CouponHistoryService;
@GetMapping
@ApiOperation("查询CouponHistory")
public ResultInfo getCouponHistorys(CouponHistoryQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(CouponHistoryService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有CouponHistory")
public ResultInfo getCouponHistorys(CouponHistoryQueryCriteria criteria) {
return ResultInfo.success(CouponHistoryService.queryAll(criteria));
}
@PostMapping(value = "/create")
@ApiOperation("新增CouponHistory")
public ResultInfo create(@Validated @RequestBody CouponHistory resources) {
CouponHistoryService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改CouponHistory")
public ResultInfo update(@Validated @RequestBody CouponHistory resources) {
CouponHistoryService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除CouponHistory")
public ResultInfo delete(@PathVariable Long id) {
CouponHistoryService.delete(id);
return ResultInfo.success();
}
}
......@@ -2,12 +2,9 @@ package com.topdraw.business.module.coupon.history.service;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import org.springframework.data.domain.Pageable;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Map;
import java.util.List;
/**
......@@ -16,20 +13,6 @@ import java.util.List;
*/
public interface CouponHistoryService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(CouponHistoryQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<CouponHistoryDTO>
*/
List<CouponHistoryDTO> queryAll(CouponHistoryQueryCriteria criteria);
/**
* 根据ID查询
......@@ -38,15 +21,45 @@ public interface CouponHistoryService {
*/
CouponHistoryDTO findById(Long id);
/**
*
* @param resources
*/
void create(CouponHistory resources);
/**
*
* @param resources
*/
void update(CouponHistory resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param userId
* @return
*/
Long countByUserId(Long userId);
/**
*
* @param userId
* @param now
* @return
*/
Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now);
/**
*
* @param userId
* @param now
* @param expireTime
* @return
*/
Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime);
}
......
......@@ -12,39 +12,39 @@ import java.time.LocalDateTime;
@Data
public class CouponHistoryDTO implements Serializable {
// 主键
/** 主键 */
private Long id;
// 优惠券id
/** 优惠券id */
private Long couponId;
// 领券用户id(对应账号)
/** 领券用户id(对应账号) */
private Long userId;
// 优惠券code
/** 优惠券code */
private String couponCode;
// 领取人昵称
/** 领取人昵称 */
private String userNickname;
// 领取时间
/** 领取时间 */
private LocalDateTime receiveTime;
// 失效时间
/** 失效时间 */
private LocalDateTime expireTime;
// 使用状态 0:未使用;1:已使用;-1:已过期
/** 使用状态 0:未使用;1:已使用;-1:已过期 */
private Integer useStatus;
// 使用时间
/** 使用时间 */
private LocalDateTime useTime;
// 订单详情id
/** 订单详情id */
private Long orderDetailId;
// 创建时间
/** 创建时间 */
private LocalDateTime createTime;
// 更新时间
/** 更新时间 */
private LocalDateTime updateTime;
}
......
package com.topdraw.business.module.coupon.history.service.dto;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-10-23
*/
@Data
public class CouponHistoryQueryCriteria{
}
package com.topdraw.business.module.coupon.history.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.domain.CouponHistoryBuilder;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.coupon.history.repository.CouponHistoryRepository;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryDTO;
import com.topdraw.business.module.coupon.history.service.dto.CouponHistoryQueryCriteria;
import com.topdraw.business.module.coupon.history.service.mapper.CouponHistoryMapper;
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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
......@@ -33,67 +25,56 @@ import java.util.Map;
public class CouponHistoryServiceImpl implements CouponHistoryService {
@Autowired
private CouponHistoryRepository CouponHistoryRepository;
private CouponHistoryMapper couponHistoryMapper;
@Autowired
private CouponHistoryMapper CouponHistoryMapper;
private CouponHistoryRepository couponHistoryRepository;
@Override
public Map<String, Object> queryAll(CouponHistoryQueryCriteria criteria, Pageable pageable) {
Page<CouponHistory> page = CouponHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(CouponHistoryMapper::toDto));
}
@Override
public List<CouponHistoryDTO> queryAll(CouponHistoryQueryCriteria criteria) {
return CouponHistoryMapper.toDto(CouponHistoryRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public CouponHistoryDTO findById(Long id) {
CouponHistory CouponHistory = CouponHistoryRepository.findById(id).orElseGet(CouponHistory::new);
ValidationUtil.isNull(CouponHistory.getId(),"CouponHistory","id",id);
return CouponHistoryMapper.toDto(CouponHistory);
CouponHistory couponHistory = this.couponHistoryRepository.findById(id).orElseGet(CouponHistory::new);
ValidationUtil.isNull(couponHistory.getId(),"CouponHistory","id",id);
return this.couponHistoryMapper.toDto(couponHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(CouponHistory resources) {
CouponHistoryRepository.save(resources);
CouponHistory couponHistory = CouponHistoryBuilder.build(resources);
this.couponHistoryRepository.save(couponHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(CouponHistory resources) {
CouponHistory CouponHistory = CouponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new);
ValidationUtil.isNull( CouponHistory.getId(),"CouponHistory","id",resources.getId());
CouponHistory.copy(resources);
CouponHistoryRepository.save(CouponHistory);
CouponHistory couponHistory = this.couponHistoryRepository.findById(resources.getId()).orElseGet(CouponHistory::new);
ValidationUtil.isNull(couponHistory.getId(),"CouponHistory","id",resources.getId());
couponHistory.copy(resources);
this.couponHistoryRepository.save(couponHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
CouponHistory CouponHistory = CouponHistoryRepository.findById(id).orElseThrow(
CouponHistory couponHistory = this.couponHistoryRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", CouponHistory.class, id), 1));
CouponHistoryRepository.delete(CouponHistory);
this.couponHistoryRepository.delete(couponHistory);
}
@Override
public Long countByUserId(Long userId) {
return this.CouponHistoryRepository.countByUserId(userId);
return this.couponHistoryRepository.countByUserId(userId);
}
@Override
public Long countByUserIdAndExpireTimeBefore(Long userId, LocalDateTime now) {
return this.CouponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now);
return this.couponHistoryRepository.countByUserIdAndExpireTimeBefore(userId,now);
}
@Override
public Long countByUserIdAndExpireTimeBetween(Long userId, LocalDateTime now, LocalDateTime expireTime) {
return this.CouponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime);
return this.couponHistoryRepository.countByUserIdAndExpireTimeBetween(userId,now,expireTime);
}
}
......
package com.topdraw.business.module.coupon.repository;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
import java.util.Optional;
/**
......@@ -13,4 +15,7 @@ import java.util.Optional;
public interface CouponRepository extends JpaRepository<Coupon, Long>, JpaSpecificationExecutor<Coupon> {
Optional<Coupon> findFirstByCode(String code);
List<CouponDTO> findByUserId(Long userId);
}
......
package com.topdraw.business.module.coupon.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.CouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Coupon管理")
@RestController
@RequestMapping("/api/Coupon")
public class CouponController {
@Autowired
private CouponService CouponService;
@PostMapping(value = "/create")
@ApiOperation("新增Coupon")
public ResultInfo create(@Validated @RequestBody Coupon resources) {
CouponService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改Coupon")
public ResultInfo update(@Validated @RequestBody Coupon resources) {
CouponService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除Coupon")
public ResultInfo delete(@PathVariable Long id) {
CouponService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(CouponService.getByCode(code));
}
}
......@@ -2,9 +2,7 @@ package com.topdraw.business.module.coupon.service;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.service.dto.CouponQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
......@@ -12,6 +10,14 @@ import java.util.List;
* @date 2021-10-22
*/
public interface CouponService {
/**
* 根据ID查询
* @param userId ID
* @return CouponDTO
*/
List<CouponDTO> findByUserId(Long userId);
/**
* 根据ID查询
* @param id ID
......@@ -19,16 +25,12 @@ public interface CouponService {
*/
CouponDTO findById(Long id);
void create(Coupon resources);
void update(Coupon resources);
void delete(Long id);
/**
* Code校验
* @param code
* @return CouponDTO
*/
CouponDTO getByCode(String code);
}
......
......@@ -14,69 +14,69 @@ import java.time.LocalDateTime;
@Data
public class CouponDTO implements Serializable {
// id
/** id */
private Long id;
// 标识
/** 标识 */
private String code;
// 名称
/** 名称 */
private String title;
// 图片
/** 图片 */
private String images;
// 发行量,-1代表不限量
/** 发行量,-1代表不限量 */
private Integer stock;
// 剩余量,-1代表不限量
/** 剩余量,-1代表不限量 */
private Integer remainStock;
// 优惠形式:1:现金;2:折扣
/** 优惠形式:1:现金;2:折扣 */
private Integer useType;
// 面额
/** 面额 */
private BigDecimal denomination;
// 折扣
/** 折扣 */
private BigDecimal discount;
// 适用用户范围:1:新用户;2:全体用户
/** 适用用户范围:1:新用户;2:全体用户 */
private Integer userRange;
// 限领次数 -1:无限次; >0:具体次数
/** 限领次数 -1:无限次; >0:具体次数 */
private Integer collectLimit;
// 适用门槛:1:无门槛;2:满减形式
/** 适用门槛:1:无门槛;2:满减形式 */
private Integer thresholdType;
// 满减门槛
/** 满减门槛 */
private BigDecimal amountThreshold;
// 产品范围:1:全部商品;2:指定商品
/** 产品范围:1:全部商品;2:指定商品 */
private Integer itemRange;
// 生效形式:1:固定日期;2:相对日期
/** 生效形式:1:固定日期;2:相对日期 */
private Integer effectType;
// 生效时间
/** 生效时间 */
private Timestamp startTime;
// 过期时间
/** 过期时间 */
private LocalDateTime expireTime;
// 自领取当日,几天内有效
/** 自领取当日,几天内有效 */
private Integer validDays;
// 使用说明
/** 使用说明 */
private String description;
// 状态0:未开始,1:启用;2:停用
/** 状态0:未开始,1:启用;2:停用 */
private Integer status;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
}
......
package com.topdraw.business.module.coupon.service.dto;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Data
public class CouponQueryCriteria{
}
package com.topdraw.business.module.coupon.service.impl;
import com.topdraw.business.module.coupon.domain.Coupon;
import com.topdraw.util.RedissonUtil;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.coupon.repository.CouponRepository;
import com.topdraw.business.module.coupon.service.CouponService;
import com.topdraw.business.module.coupon.service.dto.CouponDTO;
import com.topdraw.business.module.coupon.service.mapper.CouponMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import com.topdraw.utils.StringUtils;
import java.util.List;
/**
* @author XiangHan
......@@ -26,58 +26,29 @@ import com.topdraw.utils.StringUtils;
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class CouponServiceImpl implements CouponService {
@Autowired
private CouponRepository CouponRepository;
@Autowired
private CouponMapper CouponMapper;
private CouponMapper couponMapper;
@Autowired
private RedissonClient redissonClient;
private CouponRepository couponRepository;
@Override
public CouponDTO findById(Long id) {
Coupon Coupon = CouponRepository.findById(id).orElseGet(Coupon::new);
ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id);
return CouponMapper.toDto(Coupon);
public List<CouponDTO> findByUserId(Long userId) {
List<CouponDTO> couponDTOList = this.couponRepository.findByUserId(userId);
return couponDTOList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(Coupon resources) {
CouponRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(Coupon resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
RedissonUtil.lock(rLock);
Coupon Coupon = CouponRepository.findById(resources.getId()).orElseGet(Coupon::new);
ValidationUtil.isNull( Coupon.getId(),"Coupon","id",resources.getId());
Coupon.copy(resources);
CouponRepository.save(Coupon);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
Coupon Coupon = CouponRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Coupon.class, id), 1));
CouponRepository.delete(Coupon);
public CouponDTO findById(Long id) {
Assert.notNull(id, GlobeExceptionMsg.COUPON_ID_IS_NULL);
Coupon Coupon = this.couponRepository.findById(id).orElseGet(Coupon::new);
ValidationUtil.isNull(Coupon.getId(),"Coupon","id",id);
return this.couponMapper.toDto(Coupon);
}
@Override
public CouponDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? CouponMapper.toDto(CouponRepository.findFirstByCode(code).orElseGet(Coupon::new))
return StringUtils.isNotEmpty(code) ? this.couponMapper.toDto(this.couponRepository.findFirstByCode(code).orElseGet(Coupon::new))
: new CouponDTO();
}
}
......
......@@ -23,70 +23,70 @@ import java.io.Serializable;
@Table(name="uc_exp_detail")
public class ExpDetail implements Serializable {
// 主键
/** 主键 */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 标识
/** 标识 */
@Column(name = "code", nullable = false)
private String code;
// 应用code
/** 应用code */
@Column(name = "app_code")
private String appCode;
// 会员id
/** 会员id */
@Column(name = "member_id", nullable = false)
private Long memberId;
// 账号id
/** 账号id */
@Column(name = "account_id")
private Long accountId;
// 原始成长值
/** 原始成长值 */
@Column(name = "original_exp", nullable = false)
private Long originalExp;
// 结果成长值
/** 结果成长值 */
@Column(name = "result_exp", nullable = false)
private Long resultExp;
// 成长值变化,一般为正数
/** 成长值变化,一般为正数 */
@Column(name = "exp", nullable = false)
private Long exp;
// 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
/** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */
@Column(name = "device_type", nullable = false)
private Integer deviceType;
// 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他
/** 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 */
@Column(name = "evt_type", nullable = false)
private Integer evtType;
// 订单id(针对订购操作)
/** 订单id(针对订购操作) */
@Column(name = "order_id")
private Long orderId;
// 节目id(针对观影操作)
/** 节目id(针对观影操作) */
@Column(name = "media_id")
private Long mediaId;
// 活动id(针对参与活动)
/** 活动id(针对参与活动) */
@Column(name = "activity_id")
private Long activityId;
// 成长值变化描述,用于管理侧显示
/** 成长值变化描述,用于管理侧显示 */
@Column(name = "description", nullable = false)
private String description;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
......
package com.topdraw.business.module.exp.detail.domain;
import com.topdraw.exception.GlobeExceptionMsg;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import java.util.Objects;
public class ExpDetailBuilder {
public static ExpDetail build(Long memberId, Long originalExp, Long resultExp,
Integer deviceType, Integer evtType){
ExpDetail expDetail = new ExpDetail();
expDetail.setMemberId(memberId);
expDetail.setOriginalExp(originalExp);
expDetail.setResultExp(resultExp);
expDetail.setDeviceType(deviceType);
expDetail.setEvtType(evtType);
return build(expDetail);
}
public static ExpDetail build(ExpDetail expDetail){
return build(expDetail.getId(),
expDetail.getCode(),
expDetail.getAppCode(),
expDetail.getMemberId(),
expDetail.getAccountId(),
expDetail.getOriginalExp(),expDetail.getResultExp(),
expDetail.getExp(),expDetail.getDeviceType(),
expDetail.getEvtType(), expDetail.getOrderId(), expDetail.getMediaId(),
expDetail.getActivityId(),expDetail.getDescription());
}
public static ExpDetail build(Long id, String code,
String appCode, Long memberId, Long accountId,
Long originalExp, Long resultExp, Long exp,
Integer deviceType, Integer evtType, Long orderId,
Long mediaId, Long activityId, String description){
Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL);
ExpDetail expDetail = new ExpDetail();
expDetail.setId(Objects.isNull(id)?null:id);
expDetail.setCode(StringUtils.isBlank(code)?null:code);
expDetail.setAppCode(StringUtils.isBlank(appCode)?null:appCode);
expDetail.setMemberId(Objects.isNull(memberId)?null:memberId);
expDetail.setAccountId(Objects.isNull(accountId)?null:accountId);
expDetail.setOriginalExp(Objects.isNull(originalExp)?0:originalExp);
expDetail.setResultExp(Objects.isNull(resultExp)?0:resultExp);
expDetail.setExp(Objects.isNull(exp)?0:exp);
expDetail.setDeviceType(Objects.isNull(deviceType)?null:deviceType);
expDetail.setEvtType(Objects.isNull(evtType)?null:evtType);
expDetail.setOrderId(Objects.isNull(orderId)?null:orderId);
expDetail.setMediaId(Objects.isNull(mediaId)?null:mediaId);
expDetail.setActivityId(Objects.isNull(activityId)?null:activityId);
expDetail.setDescription(StringUtils.isBlank(description)?null:description);
return expDetail;
}
}
package com.topdraw.business.module.exp.detail.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "ExpDetail管理")
@RestController
@RequestMapping("/api/ExpDetail")
public class ExpDetailController {
@Autowired
private ExpDetailService ExpDetailService;
@GetMapping
@ApiOperation("查询ExpDetail")
public ResultInfo getExpDetails(ExpDetailQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(ExpDetailService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有ExpDetail")
public ResultInfo getExpDetails(ExpDetailQueryCriteria criteria) {
return ResultInfo.success(ExpDetailService.queryAll(criteria));
}
@PostMapping(value = "/create")
@ApiOperation("新增ExpDetail")
public ResultInfo create(@Validated @RequestBody ExpDetail resources) {
ExpDetailService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改ExpDetail")
public ResultInfo update(@Validated @RequestBody ExpDetail resources) {
ExpDetailService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除ExpDetail")
public ResultInfo delete(@PathVariable Long id) {
ExpDetailService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(ExpDetailService.getByCode(code));
}
}
......@@ -2,10 +2,6 @@ package com.topdraw.business.module.exp.detail.service;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
* @author XiangHan
......@@ -14,31 +10,28 @@ import java.util.List;
public interface ExpDetailService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<ExpDetailDTO>
*/
List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return ExpDetailDTO
*/
ExpDetailDTO findById(Long id);
/**
*
* @param resources
*/
void create(ExpDetail resources);
/**
*
* @param resources
*/
void update(ExpDetail resources);
/**
*
* @param id
*/
void delete(Long id);
/**
......
......@@ -12,51 +12,51 @@ import java.io.Serializable;
@Data
public class ExpDetailDTO implements Serializable {
// 主键
/** 主键 */
private Long id;
// 标识
/** 标识 */
private String code;
// 应用code
/** 应用code */
private String appCode;
// 会员id
/** 会员id */
private Long memberId;
// 账号id
/** 账号id */
private Long accountId;
// 原始成长值
/** 原始成长值 */
private Long originalExp;
// 结果成长值
/** 结果成长值 */
private Long resultExp;
// 成长值变化,一般为正数
/** 成长值变化,一般为正数 */
private Long exp;
// 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
/** 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) */
private Integer deviceType;
// 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他
/** 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;98:系统操作;99:其他 */
private Integer evtType;
// 订单id(针对订购操作)
/** 订单id(针对订购操作) */
private Long orderId;
// 节目id(针对观影操作)
/** 节目id(针对观影操作) */
private Long mediaId;
// 活动id(针对参与活动)
/** 活动id(针对参与活动) */
private Long activityId;
// 成长值变化描述,用于管理侧显示
/** 成长值变化描述,用于管理侧显示 */
private String description;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
}
......
package com.topdraw.business.module.exp.detail.service.dto;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Data
public class ExpDetailQueryCriteria{
}
package com.topdraw.business.module.exp.detail.service.impl;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.domain.ExpDetailBuilder;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.exp.detail.repository.ExpDetailRepository;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailDTO;
import com.topdraw.business.module.exp.detail.service.dto.ExpDetailQueryCriteria;
import com.topdraw.business.module.exp.detail.service.mapper.ExpDetailMapper;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
......@@ -14,15 +14,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
......@@ -33,36 +27,25 @@ import java.util.Map;
public class ExpDetailServiceImpl implements ExpDetailService {
@Autowired
private ExpDetailRepository ExpDetailRepository;
private ExpDetailRepository expDetailRepository;
@Autowired
private ExpDetailMapper ExpDetailMapper;
private ExpDetailMapper expDetailMapper;
@Autowired
private RedissonClient redissonClient;
@Override
public Map<String, Object> queryAll(ExpDetailQueryCriteria criteria, Pageable pageable) {
Page<ExpDetail> page = ExpDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(ExpDetailMapper::toDto));
}
@Override
public List<ExpDetailDTO> queryAll(ExpDetailQueryCriteria criteria) {
return ExpDetailMapper.toDto(ExpDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public ExpDetailDTO findById(Long id) {
ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseGet(ExpDetail::new);
ExpDetail ExpDetail = this.expDetailRepository.findById(id).orElseGet(ExpDetail::new);
ValidationUtil.isNull(ExpDetail.getId(),"ExpDetail","id",id);
return ExpDetailMapper.toDto(ExpDetail);
return this.expDetailMapper.toDto(ExpDetail);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(ExpDetail resources) {
ExpDetailRepository.save(resources);
ExpDetail expDetail = ExpDetailBuilder.build(resources);
this.expDetailRepository.save(expDetail);
}
@Override
......@@ -70,10 +53,10 @@ public class ExpDetailServiceImpl implements ExpDetailService {
public void update(ExpDetail resources) {
RLock rLock = this.redissonClient.getLock(resources.getId().toString());
try {
ExpDetail ExpDetail = ExpDetailRepository.findById(resources.getId()).orElseGet(ExpDetail::new);
ExpDetail ExpDetail = this.expDetailRepository.findById(resources.getId()).orElseGet(ExpDetail::new);
ValidationUtil.isNull( ExpDetail.getId(),"ExpDetail","id",resources.getId());
ExpDetail.copy(resources);
ExpDetailRepository.save(ExpDetail);
this.expDetailRepository.save(ExpDetail);
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -86,14 +69,14 @@ public class ExpDetailServiceImpl implements ExpDetailService {
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
ExpDetail ExpDetail = ExpDetailRepository.findById(id).orElseThrow(
ExpDetail ExpDetail = this.expDetailRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ExpDetail.class, id), 1));
ExpDetailRepository.delete(ExpDetail);
this.expDetailRepository.delete(ExpDetail);
}
@Override
public ExpDetailDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? ExpDetailMapper.toDto(ExpDetailRepository.findFirstByCode(code).orElseGet(ExpDetail::new))
return StringUtils.isNotEmpty(code) ? this.expDetailMapper.toDto(this.expDetailRepository.findFirstByCode(code).orElseGet(ExpDetail::new))
: new ExpDetailDTO();
}
}
......
package com.topdraw.business.module.exp.history.domain;
import com.topdraw.exception.GlobeExceptionMsg;
import com.topdraw.util.IdWorker;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import java.util.Objects;
public class ExpHistoryBuilder {
public ExpHistory build(Long memberId, Long originalExp, Long resultExp, Long exp,Integer deviceType , Integer evtType) {
ExpHistory expHistory = new ExpHistory();
expHistory.setMemberId(memberId);
expHistory.setOriginalExp(originalExp);
expHistory.setResultExp(resultExp);
expHistory.setDeviceType(deviceType);
expHistory.setEvtType(evtType);
expHistory.setExp(exp);
return build(expHistory);
}
public ExpHistory build(ExpHistory expHistory) {
return build(expHistory.getId(),expHistory.getCode(),
expHistory.getMemberId(),expHistory.getAccountId(),
expHistory.getOriginalExp(),expHistory.getResultExp(),expHistory.getExp(),
expHistory.getDeviceType(),expHistory.getEvtType(),expHistory.getOrderId(),
expHistory.getMediaId(),expHistory.getActivityId(),expHistory.getDescription());
}
public ExpHistory build(Long id,String code,Long memberId,Long accountId,
Long originalExp,Long resultExp,Long exp,
Integer deviceType,Integer evtType,Long orderId,
Long mediaId,Long activityId,String description) {
Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL);
ExpHistory expHistory = new ExpHistory();
expHistory.setId(Objects.isNull(id)?null:id);
expHistory.setCode(StringUtils.isBlank(code)? IdWorker.generatorCode("exp") :code);
expHistory.setMemberId(memberId);
expHistory.setAccountId(Objects.isNull(accountId)?null:accountId);
expHistory.setOriginalExp(Objects.isNull(originalExp)?0L:originalExp);
expHistory.setResultExp(Objects.isNull(resultExp)?0L:resultExp);
expHistory.setExp(Objects.isNull(exp)?0L:exp);
expHistory.setDeviceType(Objects.isNull(deviceType)?4:deviceType);
expHistory.setEvtType(Objects.isNull(evtType)?98:evtType);
expHistory.setOrderId(Objects.isNull(orderId)?null:orderId);
expHistory.setMediaId(Objects.isNull(mediaId)?null:mediaId);
expHistory.setActivityId(Objects.isNull(activityId)?null:activityId);
expHistory.setDescription(StringUtils.isBlank(description)?null:description);
return expHistory;
}
}
......@@ -19,12 +19,12 @@ public interface ExpHistoryService {
*/
ExpHistoryDTO findById(Long id);
/**
*
* @param resources
*/
void create(ExpHistory resources);
void update(ExpHistory resources);
void delete(Long id);
/**
* Code校验
* @param code
......
......@@ -10,8 +10,6 @@ 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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import com.topdraw.utils.StringUtils;
......@@ -24,45 +22,28 @@ import com.topdraw.utils.StringUtils;
public class ExpHistoryServiceImpl implements ExpHistoryService {
@Autowired
private ExpHistoryRepository ExpHistoryRepository;
private ExpHistoryMapper expHistoryMapper;
@Autowired
private ExpHistoryMapper ExpHistoryMapper;
private ExpHistoryRepository expHistoryRepository;
@Override
public ExpHistoryDTO findById(Long id) {
ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseGet(ExpHistory::new);
ExpHistory ExpHistory = this.expHistoryRepository.findById(id).orElseGet(ExpHistory::new);
ValidationUtil.isNull(ExpHistory.getId(),"ExpHistory","id",id);
return ExpHistoryMapper.toDto(ExpHistory);
return this.expHistoryMapper.toDto(ExpHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(ExpHistory resources) {
ExpHistoryRepository.save(resources);
this.expHistoryRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(ExpHistory resources) {
ExpHistory ExpHistory = ExpHistoryRepository.findById(resources.getId()).orElseGet(ExpHistory::new);
ValidationUtil.isNull( ExpHistory.getId(),"ExpHistory","id",resources.getId());
ExpHistory.copy(resources);
ExpHistoryRepository.save(ExpHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
ExpHistory ExpHistory = ExpHistoryRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", ExpHistory.class, id), 1));
ExpHistoryRepository.delete(ExpHistory);
}
@Override
public ExpHistoryDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? ExpHistoryMapper.toDto(ExpHistoryRepository.findFirstByCode(code).orElseGet(ExpHistory::new))
return StringUtils.isNotEmpty(code) ? this.expHistoryMapper.toDto(this.expHistoryRepository.findFirstByCode(code).orElseGet(ExpHistory::new))
: new ExpHistoryDTO();
}
}
......
package com.topdraw.business.module.member.address.domain;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.exception.GlobeExceptionMsg;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import java.util.Objects;
......@@ -83,6 +85,7 @@ public class MemberAddressBuilder {
String contactor,String cellphone,
String country,String province,String city,
String district,String address,String zipCode){
Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL);
MemberAddress memberAddress = new MemberAddress();
memberAddress.setId(Objects.nonNull(id)?null:id);
......@@ -108,12 +111,8 @@ public class MemberAddressBuilder {
}
private static String stringIsNull(String s){
return StringUtils.isBlank(s)?"":s;
}
private static Object objectIsNull(Object s){
return Objects.nonNull(s)?null:s;
}
}
......
package com.topdraw.business.module.member.address.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.domain.MemberAddressBuilder;
import com.topdraw.business.module.member.service.MemberService;
......
......@@ -10,8 +10,6 @@ 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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import java.util.List;
......
package com.topdraw.business.module.member.profile.domain;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.exception.GlobeExceptionMsg;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import java.util.Objects;
......@@ -36,8 +38,7 @@ public class MemberProfileBuilder {
String email, String description, String phone, String constellation,
String birthday) {
if (memberId == null)
throw new NullPointerException("memberId is null");
Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL);
MemberProfile memberProfile = new MemberProfile();
memberProfile.setMemberId(memberId);
......
package com.topdraw.business.module.member.profile.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.domain.MemberProfileBuilder;
......
package com.topdraw.business.module.member.relatedinfo.domain;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.exception.GlobeExceptionMsg;
import org.apache.commons.lang3.StringUtils;
import org.springframework.util.Assert;
import java.time.LocalDate;
import java.util.Objects;
......@@ -32,6 +34,9 @@ public class MemberRelatedInfoBuilder {
public static MemberRelatedInfo build(Long memberId , String memberCode , Long id , String name , Integer sex ,
String cellphone , String idCard, LocalDate birthday , String avatarUrl , Integer type){
Assert.notNull(memberId, GlobeExceptionMsg.MEMBER_ID_IS_NULL);
MemberRelatedInfo memberRelatedInfo = new MemberRelatedInfo();
memberRelatedInfo.setMemberId(memberId);
memberRelatedInfo.setMemberCode(memberCode);
......
......@@ -35,12 +35,13 @@ public class MemberServiceImpl implements MemberService {
@Autowired
private MemberMapper memberMapper;
@Autowired
private RedissonClient redissonClient;
@Autowired
private MemberRepository memberRepository;
@Autowired
private MemberProfileService memberProfileService;
@Autowired
private RedissonClient redissonClient;
@Override
public MemberDTO findById(Long id) {
......
package com.topdraw.business.module.member.viphistory.domain;
import com.topdraw.business.module.member.domain.Member;
import java.time.LocalDateTime;
import java.util.Objects;
public class MemberVipHistoryBuilder {
public static MemberVipHistory build(Member member , Integer beforeVip) {
Long id = member.getId();
Integer vip = member.getVip();
LocalDateTime vipExpireTime = member.getVipExpireTime();
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setMemberId(Objects.isNull(id)? null:id);
memberVipHistory.setVip(Objects.isNull(vip)? null:vip);
memberVipHistory.setBeforeVip(Objects.isNull(beforeVip)? null:beforeVip);
memberVipHistory.setVipExpireTime(Objects.isNull(vipExpireTime)? null:vipExpireTime);
return build(memberVipHistory);
}
public static MemberVipHistory build(Long memberId, Integer vip, Integer beforeVip, LocalDateTime vipExpireTime ) {
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setMemberId(Objects.isNull(memberId)? null:memberId);
memberVipHistory.setVip(Objects.isNull(vip)? null:vip);
memberVipHistory.setBeforeVip(Objects.isNull(beforeVip)? null:beforeVip);
memberVipHistory.setVipExpireTime(Objects.isNull(vipExpireTime)? null:vipExpireTime);
return build(memberVipHistory);
}
public static MemberVipHistory build(MemberVipHistory memberVipHistory) {
return build(memberVipHistory.getId(),
memberVipHistory.getMemberId(),
memberVipHistory.getVip(),
memberVipHistory.getBeforeVip(),
memberVipHistory.getVipExpireTime(),
memberVipHistory.getStatus());
}
public static MemberVipHistory build(Long id, Long memberId , Integer vip , Integer beforeVip , LocalDateTime vipExpireTime, Integer status){
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setId(Objects.isNull(id)? null:id);
memberVipHistory.setMemberId(Objects.isNull(memberId)? null:memberId) ;
memberVipHistory.setVip(Objects.isNull(vip)? null:vip);
memberVipHistory.setBeforeVip(Objects.isNull(beforeVip)? null:beforeVip);
memberVipHistory.setVipExpireTime(Objects.isNull(vipExpireTime)? null:vipExpireTime);
memberVipHistory.setStatus(Objects.isNull(status)? 1:status);
return memberVipHistory;
}
}
......@@ -2,12 +2,10 @@ package com.topdraw.business.module.member.viphistory.rest;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryQueryCriteria;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -15,9 +13,9 @@ import org.springframework.web.bind.annotation.*;
* @author luerlong
* @date 2021-12-10
*/
@Api(tags = "MemberVipHistory管理")
@Api(tags = "会员vip历史管理")
@RestController
@RequestMapping("/api/memberVipHistory")
@RequestMapping("/ucEngine/api/memberVipHistory")
public class MemberVipHistoryController {
@Autowired
......@@ -30,18 +28,4 @@ public class MemberVipHistoryController {
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改MemberVipHistory")
public ResultInfo update(@Validated @RequestBody MemberVipHistory resources) {
memberVipHistoryService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除MemberVipHistory")
public ResultInfo delete(@PathVariable Long id) {
memberVipHistoryService.delete(id);
return ResultInfo.success();
}
}
......
package com.topdraw.business.module.member.viphistory.service;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
......@@ -26,6 +27,12 @@ public interface MemberVipHistoryService {
/**
*
* @param member
*/
void create(Member member, Integer beforeVip);
/**
*
* @param resources
*/
void update(MemberVipHistory resources);
......
package com.topdraw.business.module.member.viphistory.service.impl;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistoryBuilder;
import com.topdraw.business.module.member.viphistory.repository.MemberVipHistoryRepository;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.member.viphistory.service.dto.MemberVipHistoryDTO;
......@@ -39,10 +41,10 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
@Override
public MemberVipHistoryDTO findById(Long id) {
log.info("MemberVipHistoryServiceImpl ==>> findById ==>> param ==>> [{}]",id);
MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseGet(MemberVipHistory::new);
MemberVipHistory memberVipHistory = this.memberVipHistoryRepository.findById(id).orElseGet(MemberVipHistory::new);
ValidationUtil.isNull(memberVipHistory.getId(),"MemberVipHistory","id",id);
log.info("MemberVipHistoryServiceImpl ==>> findById ==>> result ==>> [{}]",memberVipHistory);
return memberVipHistoryMapper.toDto(memberVipHistory);
return this.memberVipHistoryMapper.toDto(memberVipHistory);
}
@Override
......@@ -50,25 +52,34 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
public void create(MemberVipHistory resources) {
log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources);
this.checkMember(resources);
memberVipHistoryRepository.save(resources);
MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources);
this.memberVipHistoryRepository.save(memberVipHistory);
}
@Override
public void create(Member member, Integer beforeVip) {
this.checkMember(member);
MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(member, beforeVip);
this.memberVipHistoryRepository.save(memberVipHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(MemberVipHistory resources) {
MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(resources.getId()).orElseGet(MemberVipHistory::new);
MemberVipHistory memberVipHistory = this.memberVipHistoryRepository.findById(resources.getId()).orElseGet(MemberVipHistory::new);
ValidationUtil.isNull( memberVipHistory.getId(),"MemberVipHistory","id",resources.getId());
memberVipHistory.copy(resources);
memberVipHistoryRepository.save(memberVipHistory);
this.memberVipHistoryRepository.save(memberVipHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
MemberVipHistory memberVipHistory = memberVipHistoryRepository.findById(id).orElseThrow(
MemberVipHistory memberVipHistory = this.memberVipHistoryRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", MemberVipHistory.class, id), 1));
memberVipHistoryRepository.delete(memberVipHistory);
this.memberVipHistoryRepository.delete(memberVipHistory);
}
@Override
......@@ -83,4 +94,10 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
return this.memberService.checkMember(memberId, code);
}
private MemberDTO checkMember(Member resources){
Long memberId = resources.getId();
String code = resources.getCode();
return this.memberService.checkMember(memberId, code);
}
}
......
package com.topdraw.business.module.points.available.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.topdraw.business.module.common.domain.AsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
......@@ -54,7 +55,7 @@ public class PointsAvailable extends AsyncMqModule implements Serializable {
private Long points;
// 过期时间
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
// @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",locale = "")
@Column(name = "expire_time")
private LocalDateTime expireTime;
......
package com.topdraw.business.module.points.available.rest;
/**
* @author XiangHan
* @date 2021-10-23
*/
//@Api(tags = "PointsAvailable管理")
//@RestController
//@RequestMapping("/api/PointsAvailable")
public class PointsAvailableController {
/*@Autowired
private PointsAvailableService PointsAvailableService;
@GetMapping
@ApiOperation("查询PointsAvailable")
public ResultInfo getPointsAvailables(PointsAvailableQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(PointsAvailableService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有PointsAvailable")
public ResultInfo getPointsAvailables(PointsAvailableQueryCriteria criteria) {
return ResultInfo.success(PointsAvailableService.queryAll(criteria));
}
@Log
@PostMapping
@ApiOperation("新增PointsAvailable")
public ResultInfo create(@Validated @RequestBody PointsAvailable resources) {
PointsAvailableService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改PointsAvailable")
public ResultInfo update(@Validated @RequestBody PointsAvailable resources) {
PointsAvailableService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除PointsAvailable")
public ResultInfo delete(@PathVariable Long id) {
PointsAvailableService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(PointsAvailableService.getByCode(code));
}*/
}
......@@ -16,21 +16,6 @@ import java.util.List;
public interface PointsAvailableService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(PointsAvailableQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<PointsAvailableDTO>
*/
List<PointsAvailableDTO> queryAll(PointsAvailableQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return PointsAvailableDTO
......
......@@ -44,23 +44,11 @@ public class PointsAvailableServiceImpl implements PointsAvailableService {
private RedissonClient redissonClient;
@Override
public Map<String, Object> queryAll(PointsAvailableQueryCriteria criteria, Pageable pageable) {
Page<PointsAvailable> page = PointsAvailableRepository.findAll((root, criteriaQuery, criteriaBuilder) ->
QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(PointsAvailableMapper::toDto));
}
@Override
public List<PointsAvailableDTO> findByMemberIdOrderByExpireTime(Long memberId) {
return PointsAvailableMapper.toDto(PointsAvailableRepository.findByMemberIdOrderByExpireTime(memberId));
}
@Override
public List<PointsAvailableDTO> queryAll(PointsAvailableQueryCriteria criteria) {
return PointsAvailableMapper.toDto(PointsAvailableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public PointsAvailableDTO findById(Long id) {
PointsAvailable PointsAvailable = PointsAvailableRepository.findById(id).orElseGet(PointsAvailable::new);
ValidationUtil.isNull(PointsAvailable.getId(),"PointsAvailable","id",id);
......
package com.topdraw.business.module.points.rest;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Points管理")
//@RestController
//@RequestMapping("/api/Points")
public class PointsController {
/*@Autowired
private PointsService PointsService;
@GetMapping
@ApiOperation("查询Points")
public ResultInfo getPointss(PointsQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(PointsService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有Points")
public ResultInfo getPointss(PointsQueryCriteria criteria) {
return ResultInfo.success(PointsService.queryAll(criteria));
}*/
/*@Log
@PostMapping
@ApiOperation("新增Points")
public ResultInfo create(@Validated @RequestBody Points resources) {
PointsService.create(resources);
return ResultInfo.success();
}
@Log
@PutMapping
@ApiOperation("修改Points")
public ResultInfo update(@Validated @RequestBody Points resources) {
PointsService.update(resources);
return ResultInfo.success();
}
@Log
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Points")
public ResultInfo delete(@PathVariable Long id) {
PointsService.delete(id);
return ResultInfo.success();
}*/
}
package com.topdraw.business.module.rights.history.repository;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.business.module.rights.history.service.dto.RightsHistoryDTO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import java.util.List;
/**
* @author XiangHan
* @date 2021-10-22
*/
public interface RightsHistoryRepository extends JpaRepository<RightsHistory, Long>, JpaSpecificationExecutor<RightsHistory> {
List<RightsHistoryDTO> findByMemberId(Long memberId);
}
......
......@@ -14,6 +14,14 @@ import java.util.List;
public interface RightsHistoryService {
/**
*
* @param memberId
* @param memberCode
* @return
*/
List<RightsHistoryDTO> findByMemberIdOrMemberCode(Long memberId , String memberCode);
/**
* 根据ID查询
* @param id ID
* @return RightsHistoryDTO
......
package com.topdraw.business.module.rights.history.service.impl;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.rights.history.domain.RightsHistory;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.rights.history.repository.RightsHistoryRepository;
......@@ -14,6 +16,8 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.util.Assert;
import java.util.List;
/**
* @author XiangHan
* @date 2021-10-22
......@@ -23,40 +27,49 @@ import org.springframework.util.Assert;
public class RightsHistoryServiceImpl implements RightsHistoryService {
@Autowired
private RightsHistoryRepository RightsHistoryRepository;
private MemberService memberService;
@Autowired
private RightsHistoryMapper RightsHistoryMapper;
private RightsHistoryMapper rightsHistoryMapper;
@Autowired
private RightsHistoryRepository rightsHistoryRepository;
@Override
public List<RightsHistoryDTO> findByMemberIdOrMemberCode(Long memberId, String memberCode) {
MemberDTO memberDTO = this.memberService.checkMember(memberId, memberCode);
List<RightsHistoryDTO> rightsHistoryDTOList = this.rightsHistoryRepository.findByMemberId(memberDTO.getId());
return rightsHistoryDTOList;
}
@Override
public RightsHistoryDTO findById(Long id) {
RightsHistory RightsHistory = RightsHistoryRepository.findById(id).orElseGet(RightsHistory::new);
RightsHistory RightsHistory = this.rightsHistoryRepository.findById(id).orElseGet(RightsHistory::new);
ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",id);
return RightsHistoryMapper.toDto(RightsHistory);
return this.rightsHistoryMapper.toDto(RightsHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(RightsHistory resources) {
RightsHistoryRepository.save(resources);
this.rightsHistoryRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(RightsHistory resources) {
RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new);
RightsHistory RightsHistory = this.rightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new);
ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId());
RightsHistory.copy(resources);
RightsHistoryRepository.save(RightsHistory);
this.rightsHistoryRepository.save(RightsHistory);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
RightsHistory RightsHistory = RightsHistoryRepository.findById(id).orElseThrow(
RightsHistory RightsHistory = this.rightsHistoryRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", RightsHistory.class, id), 1));
RightsHistoryRepository.delete(RightsHistory);
this.rightsHistoryRepository.delete(RightsHistory);
}
......
......@@ -24,58 +24,58 @@ import java.io.Serializable;
@Table(name="uc_permanent_rights")
public class PermanentRights implements Serializable {
// ID
/** ID */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 标识
/** 标识 */
@Column(name = "code", nullable = false)
private String code;
// 名称
/** 名称 */
@Column(name = "name", nullable = false)
private String name;
// 永久权益类型 0:vip;1:会员等级
/** 永久权益类型 0:vip;1:会员等级 */
@Column(name = "type")
private Integer type;
// 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index)
/** 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index) */
@Column(name = "level")
private Integer level;
// 商品折扣,10代表10% off,范围为0-100
/** 商品折扣,10代表10% off,范围为0-100 */
@Column(name = "item_discount", nullable = false)
private BigDecimal itemDiscount;
// 额外积分比率,范围为0-1000
/** 额外积分比率,范围为0-1000 */
@Column(name = "extra_points", nullable = false)
private BigDecimal extraPoints;
// 免广告
/** 免广告 */
@Column(name = "ad_disabled", nullable = false)
private Integer adDisabled;
// 额外活动参与机会
/** 额外活动参与机会 */
@Column(name = "extra_activity_ticket", nullable = false)
private Integer extraActivityTicket;
// 免费试看
/** 免费试看 */
@Column(name = "free_trial", nullable = false)
private Integer freeTrial;
// 上电视专区权益
/** 上电视专区权益 */
@Column(name = "zone_sds", nullable = false)
private Integer zoneSds;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
......
package com.topdraw.business.module.rights.permanentrights.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "PermanentRights管理")
@RestController
@RequestMapping("/api/PermanentRights")
public class PermanentRightsController {
@Autowired
private PermanentRightsService PermanentRightsService;
@GetMapping
@ApiOperation("查询PermanentRights")
public ResultInfo pagePermanentRights(PermanentRightsQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(PermanentRightsService.queryAll(criteria,pageable));
}
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询PermanentRights")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(PermanentRightsService.findById(id));
}
@PostMapping(value = "/create")
@ApiOperation("新增PermanentRights")
public ResultInfo create(@Validated @RequestBody PermanentRights resources) {
PermanentRightsService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改PermanentRights")
public ResultInfo update(@Validated @RequestBody PermanentRights resources) {
PermanentRightsService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除PermanentRights")
public ResultInfo delete(@PathVariable Long id) {
PermanentRightsService.delete(id);
return ResultInfo.success();
}
@GetMapping(value = "/getByCode/{code}")
@ApiOperation(value = "根据标识查询")
public ResultInfo getByCode(@PathVariable String code) {
return ResultInfo.success(PermanentRightsService.getByCode(code));
}
}
package com.topdraw.business.module.rights.permanentrights.service;
import com.topdraw.business.module.rights.permanentrights.domain.PermanentRights;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
* @author XiangHan
......@@ -14,33 +9,12 @@ import java.util.List;
public interface PermanentRightsService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(PermanentRightsQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<PermanentRightsDTO>
*/
List<PermanentRightsDTO> queryAll(PermanentRightsQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return PermanentRightsDTO
*/
PermanentRightsDTO findById(Long id);
void create(PermanentRights resources);
void update(PermanentRights resources);
void delete(Long id);
/**
* Code校验
* @param code
......
......@@ -13,42 +13,42 @@ import java.io.Serializable;
@Data
public class PermanentRightsDTO implements Serializable {
// ID
/** ID */
private Long id;
// 标识
/** 标识 */
private String code;
// 名称
/** 名称 */
private String name;
// 永久权益类型 0:vip;1:会员等级
/** 永久权益类型 0:vip;1:会员等级 */
private Integer type;
// 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index)
/** 等级(当权益类型为vip时,对应vip值,当权益类型为会员等级时,对应等级index) */
private Integer level;
// 商品折扣,10代表10% off,范围为0-100
/** 商品折扣,10代表10% off,范围为0-100 */
private BigDecimal itemDiscount;
// 额外积分比率,范围为0-1000
/** 额外积分比率,范围为0-1000 */
private BigDecimal extraPoints;
// 免广告
/** 免广告 */
private Integer adDisabled;
// 额外活动参与机会
/** 额外活动参与机会 */
private Integer extraActivityTicket;
// 免费试看
/** 免费试看 */
private Integer freeTrial;
// 上电视专区权益
/** 上电视专区权益 */
private Integer zoneSds;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
}
......
package com.topdraw.business.module.rights.permanentrights.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Data
public class PermanentRightsQueryCriteria{
@Query(type = Query.Type.EQUAL)
private Integer level;
}
......@@ -5,23 +5,13 @@ import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.rights.permanentrights.repository.PermanentRightsRepository;
import com.topdraw.business.module.rights.permanentrights.service.PermanentRightsService;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsDTO;
import com.topdraw.business.module.rights.permanentrights.service.dto.PermanentRightsQueryCriteria;
import com.topdraw.business.module.rights.permanentrights.service.mapper.PermanentRightsMapper;
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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.StringUtils;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
* @date 2021-10-22
......@@ -31,63 +21,27 @@ import java.util.Map;
public class PermanentRightsServiceImpl implements PermanentRightsService {
@Autowired
private PermanentRightsRepository PermanentRightsRepository;
private PermanentRightsRepository permanentRightsRepository;
@Autowired
private PermanentRightsMapper PermanentRightsMapper;
@Override
public Map<String, Object> queryAll(PermanentRightsQueryCriteria criteria, Pageable pageable) {
Page<PermanentRights> page = PermanentRightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(PermanentRightsMapper::toDto));
}
@Override
public List<PermanentRightsDTO> queryAll(PermanentRightsQueryCriteria criteria) {
return PermanentRightsMapper.toDto(PermanentRightsRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
private PermanentRightsMapper permanentRightsMapper;
@Override
public PermanentRightsDTO findById(Long id) {
PermanentRights PermanentRights = PermanentRightsRepository.findById(id).orElseGet(PermanentRights::new);
PermanentRights PermanentRights = this.permanentRightsRepository.findById(id).orElseGet(PermanentRights::new);
ValidationUtil.isNull(PermanentRights.getId(),"PermanentRights","id",id);
return PermanentRightsMapper.toDto(PermanentRights);
return this.permanentRightsMapper.toDto(PermanentRights);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(PermanentRights resources) {
PermanentRightsRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(PermanentRights resources) {
PermanentRights PermanentRights = PermanentRightsRepository.findById(resources.getId()).orElseGet(PermanentRights::new);
ValidationUtil.isNull( PermanentRights.getId(),"PermanentRights","id",resources.getId());
PermanentRights.copy(resources);
PermanentRightsRepository.save(PermanentRights);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
PermanentRights PermanentRights = PermanentRightsRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", PermanentRights.class, id), 1));
PermanentRightsRepository.delete(PermanentRights);
}
@Override
public PermanentRightsDTO getByCode(String code) {
return StringUtils.isNotEmpty(code) ? PermanentRightsMapper.toDto(PermanentRightsRepository.findFirstByCode(code).orElseGet(PermanentRights::new))
return StringUtils.isNotEmpty(code) ? this.permanentRightsMapper.toDto(this.permanentRightsRepository.findFirstByCode(code).orElseGet(PermanentRights::new))
: new PermanentRightsDTO();
}
@Override
public PermanentRightsDTO findByLevel(Integer level) {
PermanentRights PermanentRights = PermanentRightsRepository.findByLevel(level);
return PermanentRightsMapper.toDto(PermanentRights);
PermanentRights PermanentRights = this.permanentRightsRepository.findByLevel(level);
return this.permanentRightsMapper.toDto(PermanentRights);
}
}
......
package com.topdraw.business.module.rights.rest;
import com.topdraw.business.module.rights.service.RightsService;
import com.topdraw.common.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Rights管理")
@RestController
@RequestMapping("/api/Rights")
public class RightsController {
@Autowired
private RightsService rightsService;
@GetMapping(value = "/findById/{id}")
@ApiOperation("查询Rights")
public ResultInfo findById(@PathVariable("id") Long id) {
return ResultInfo.success(rightsService.findById(id));
}
}
......@@ -5,8 +5,6 @@ import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.io.Serializable;
......@@ -27,11 +25,11 @@ public class TaskAttr implements Serializable {
@Column(name = "id")
private Long id;
// 任务id(关联task主键)
/** 任务id(关联task主键) */
@Column(name = "task_id")
private Long taskId;
// 任务属性字符串
/** 任务属性字符串 */
@Column(name = "attr_str")
private String attrStr;
......
......@@ -15,11 +15,28 @@ public interface TaskAttrService {
*/
TaskAttrDTO findById(Long id);
/**
*
* @param resources
*/
void create(TaskAttr resources);
/**
*
* @param resources
*/
void update(TaskAttr resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param taskId
* @return
*/
TaskAttrDTO findByTaskId(Long taskId);
}
......
......@@ -3,7 +3,6 @@ package com.topdraw.business.module.task.attribute.service.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author XiangHan
* @date 2022-01-13
......@@ -13,9 +12,9 @@ public class TaskAttrDTO implements Serializable {
private Long id;
// 任务id(关联task主键)
/** 任务id(关联task主键) */
private Long taskId;
// 任务属性字符串
/** 任务属性字符串 */
private String attrStr;
}
......
package com.topdraw.business.module.task.attribute.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
/**
* @author XiangHan
* @date 2022-01-13
*/
@Data
public class TaskAttrQueryCriteria{
}
......@@ -22,46 +22,46 @@ import org.springframework.util.Assert;
public class TaskAttrServiceImpl implements TaskAttrService {
@Autowired
private TaskAttrRepository TaskAttrRepository;
private TaskAttrMapper taskAttrMapper;
@Autowired
private TaskAttrMapper TaskAttrMapper;
private TaskAttrRepository taskAttrRepository;
@Override
public TaskAttrDTO findById(Long id) {
TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseGet(TaskAttr::new);
TaskAttr TaskAttr = this.taskAttrRepository.findById(id).orElseGet(TaskAttr::new);
ValidationUtil.isNull(TaskAttr.getId(),"TaskAttr","id",id);
return TaskAttrMapper.toDto(TaskAttr);
return this.taskAttrMapper.toDto(TaskAttr);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(TaskAttr resources) {
TaskAttrRepository.save(resources);
this.taskAttrRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TaskAttr resources) {
TaskAttr TaskAttr = TaskAttrRepository.findById(resources.getId()).orElseGet(TaskAttr::new);
TaskAttr TaskAttr = this.taskAttrRepository.findById(resources.getId()).orElseGet(TaskAttr::new);
ValidationUtil.isNull( TaskAttr.getId(),"TaskAttr","id",resources.getId());
TaskAttr.copy(resources);
TaskAttrRepository.save(TaskAttr);
this.taskAttrRepository.save(TaskAttr);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
TaskAttr TaskAttr = TaskAttrRepository.findById(id).orElseThrow(
TaskAttr TaskAttr = this.taskAttrRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TaskAttr.class, id), 1));
TaskAttrRepository.delete(TaskAttr);
this.taskAttrRepository.delete(TaskAttr);
}
@Override
public TaskAttrDTO findByTaskId(Long taskId) {
TaskAttr TaskAttr = TaskAttrRepository.findByTaskId(taskId).orElseGet(TaskAttr::new);
return TaskAttrMapper.toDto(TaskAttr);
TaskAttr TaskAttr = this.taskAttrRepository.findByTaskId(taskId).orElseGet(TaskAttr::new);
return this.taskAttrMapper.toDto(TaskAttr);
}
......
......@@ -29,104 +29,104 @@ public class Task implements Serializable {
@Column(name = "id")
private Long id;
// 任务模板id
/** 任务模板id */
@Column(name = "task_template_id", nullable = false)
private Long taskTemplateId;
// 任务重复类型,-1:不限次;1:单次;>1:多次
/** 任务重复类型,-1:不限次;1:单次;>1:多次 */
@Column(name = "task_repeat_type", nullable = false)
private Integer taskRepeatType;
// 任务每日重置 0:不重置;1:重置
/** 任务每日重置 0:不重置;1:重置 */
@Column(name = "task_daily_reset", nullable = false)
private Integer taskDailyReset;
// 行为量(完成此任务需要多少次相同行为的触发)
/** 行为量(完成此任务需要多少次相同行为的触发) */
@Column(name = "action_amount", nullable = false)
private Integer actionAmount;
// 任务生效时间
/** 任务生效时间 */
@Column(name = "valid_time")
private Timestamp validTime;
// 任务失效时间
/** 任务失效时间 */
@Column(name = "expire_time")
private LocalDateTime expireTime;
// 显示顺序
/** 显示顺序 */
@Column(name = "sequence")
private Integer sequence;
// 获得成长值
/** 获得成长值 */
@Column(name = "reward_exp", nullable = false)
private Long rewardExp;
// 获得积分
/** 获得积分 */
@Column(name = "reward_points", nullable = false)
private Long rewardPoints;
// 积分过期时间(空为不过期)
/** 积分过期时间(空为不过期) */
@Column(name = "reward_points_expire_time")
private Long rewardPointsExpireTime;
// 积分获取类型 0:定值;1:随机
/** 积分获取类型 0:定值;1:随机 */
@Column(name = "points_type")
private Integer pointsType;
// 随机积分最大值
/** 随机积分最大值 */
@Column(name = "reward_max_points")
private Integer rewardMaxPoints;
// 能够获取该任务的用户分组,为空则都能获取
/** 能够获取该任务的用户分组,为空则都能获取 */
@Column(name = "groups")
private String groups;
// 权益发放策略 0:立即发放;1:次日发放;2:次月发放
/** 权益发放策略 0:立即发放;1:次日发放;2:次月发放 */
@Column(name = "rights_send_strategy", nullable = false)
private Integer rightsSendStrategy;
// 会员等级门槛(0表示无门槛)
/** 会员等级门槛(0表示无门槛) */
@Column(name = "member_level", nullable = false)
private Integer memberLevel;
// 会员vip门槛(0表示没有门槛)
/** 会员vip门槛(0表示没有门槛) */
@Column(name = "member_vip")
private Integer memberVip;
// 权益id
/** 权益id */
@Column(name = "rights_id")
private Long rightsId;
// 权益数量(活动机会次数、优惠券数量、奖品数量)
/** 权益数量(活动机会次数、优惠券数量、奖品数量) */
@Column(name = "rights_amount")
private Integer rightsAmount;
// 权益2id
/** 权益2id */
@Column(name = "rights2_id")
private Long rights2Id;
// 权益2数量
/** 权益2数量 */
@Column(name = "rights2_amount")
private Integer rights2Amount;
// 权益3id
/** 权益3id */
@Column(name = "rights3_id")
private Long rights3Id;
// 权益3数量
/** 权益3数量 */
@Column(name = "rights3_amount")
private Integer rights3Amount;
// 状态 0:失效;1:生效
/** 状态 0:失效;1:生效 */
@Column(name = "status", nullable = false)
private Integer status;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
......
......@@ -32,27 +32,27 @@ public class TrTaskProgress implements Serializable {
@Column(name = "id")
private Long id;
// 用户id
/** 用户id */
@Column(name = "member_id", nullable = false)
private Long memberId;
// 任务id
/** 任务id */
@Column(name = "task_id")
private Long taskId;
// 已完成的行为量
/** 已完成的行为量 */
@Column(name = "current_action_amount")
private Integer currentActionAmount;
// 目标行为量
/** 目标行为量 */
@Column(name = "target_action_amount")
private Integer targetActionAmount;
// 状态 0:未完成;1:已完成
/** 状态 0:未完成;1:已完成 */
@Column(name = "status")
private Integer status;
// 完成时间
/** 完成时间 */
@Column(name = "completion_time")
private Timestamp completionTime;
......
......@@ -3,9 +3,7 @@ package com.topdraw.business.module.task.progress.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
......@@ -20,38 +18,26 @@ import io.swagger.annotations.*;
public class TrTaskProgressController {
@Autowired
private TrTaskProgressService TrTaskProgressService;
@GetMapping
@ApiOperation("查询TrTaskProgress")
public ResultInfo getTrTaskProgresss(TrTaskProgressQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(TrTaskProgressService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有TrTaskProgress")
public ResultInfo getTrTaskProgresss(TrTaskProgressQueryCriteria criteria) {
return ResultInfo.success(TrTaskProgressService.queryAll(criteria));
}
private TrTaskProgressService trTaskProgressService;
@PostMapping
@ApiOperation("新增TrTaskProgress")
public ResultInfo create(@Validated @RequestBody TrTaskProgress resources) {
TrTaskProgressService.create(resources);
this.trTaskProgressService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改TrTaskProgress")
public ResultInfo update(@Validated @RequestBody TrTaskProgress resources) {
TrTaskProgressService.update(resources);
this.trTaskProgressService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除TrTaskProgress")
public ResultInfo delete(@PathVariable Long id) {
TrTaskProgressService.delete(id);
this.trTaskProgressService.delete(id);
return ResultInfo.success();
}
......
......@@ -2,9 +2,6 @@ package com.topdraw.business.module.task.progress.service;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
......@@ -14,32 +11,36 @@ import java.util.List;
public interface TrTaskProgressService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TrTaskProgressQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TrTaskProgressDTO>
*/
List<TrTaskProgressDTO> queryAll(TrTaskProgressQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TrTaskProgressDTO
*/
TrTaskProgressDTO findById(Long id);
/**
*
* @param resources
*/
void create(TrTaskProgress resources);
/**
*
* @param resources
*/
void update(TrTaskProgress resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param memberId
* @param taskId
* @param time1
* @return
*/
List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1);
}
......
......@@ -14,22 +14,22 @@ public class TrTaskProgressDTO implements Serializable {
private Long id;
// 用户id
/** 用户id */
private Long memberId;
// 任务id
/** 任务id */
private Long taskId;
// 已完成的行为量
/** 已完成的行为量 */
private Integer currentActionAmount;
// 目标行为量
/** 目标行为量 */
private Integer targetActionAmount;
// 状态 0:未完成;1:已完成
/** 状态 0:未完成;1:已完成 */
private Integer status;
// 完成时间
/** 完成时间 */
private Timestamp completionTime;
private Timestamp createTime;
......
package com.topdraw.business.module.task.progress.service.dto;
import lombok.Data;
import com.topdraw.annotation.Query;
/**
* @author XiangHan
* @date 2021-11-02
*/
@Data
public class TrTaskProgressQueryCriteria{
@Query(type = Query.Type.EQUAL)
private Long taskId;
@Query(type = Query.Type.EQUAL)
private Long memberId;
@Query(type = Query.Type.BETWEEN)
private String completionTime;
}
......@@ -5,21 +5,15 @@ import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper;
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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.util.List;
import java.util.Map;
/**
* @author XiangHan
......@@ -30,56 +24,45 @@ import java.util.Map;
public class TrTaskProgressServiceImpl implements TrTaskProgressService {
@Autowired
private TrTaskProgressRepository TrTaskProgressRepository;
private TrTaskProgressRepository trTaskProgressRepository;
@Autowired
private TrTaskProgressMapper TrTaskProgressMapper;
@Override
public Map<String, Object> queryAll(TrTaskProgressQueryCriteria criteria, Pageable pageable) {
Page<TrTaskProgress> page = TrTaskProgressRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(TrTaskProgressMapper::toDto));
}
@Override
public List<TrTaskProgressDTO> queryAll(TrTaskProgressQueryCriteria criteria) {
return TrTaskProgressMapper.toDto(TrTaskProgressRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
private TrTaskProgressMapper trTaskProgressMapper;
@Override
public TrTaskProgressDTO findById(Long id) {
TrTaskProgress TrTaskProgress = TrTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new);
TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseGet(TrTaskProgress::new);
ValidationUtil.isNull(TrTaskProgress.getId(),"TrTaskProgress","id",id);
return TrTaskProgressMapper.toDto(TrTaskProgress);
return this.trTaskProgressMapper.toDto(TrTaskProgress);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(TrTaskProgress resources) {
TrTaskProgressRepository.save(resources);
this.trTaskProgressRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(TrTaskProgress resources) {
TrTaskProgress TrTaskProgress = TrTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new);
TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(resources.getId()).orElseGet(TrTaskProgress::new);
ValidationUtil.isNull( TrTaskProgress.getId(),"TrTaskProgress","id",resources.getId());
TrTaskProgress.copy(resources);
TrTaskProgressRepository.save(TrTaskProgress);
this.trTaskProgressRepository.save(TrTaskProgress);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
TrTaskProgress TrTaskProgress = TrTaskProgressRepository.findById(id).orElseThrow(
TrTaskProgress TrTaskProgress = this.trTaskProgressRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", TrTaskProgress.class, id), 1));
TrTaskProgressRepository.delete(TrTaskProgress);
this.trTaskProgressRepository.delete(TrTaskProgress);
}
@Override
public List<TrTaskProgressDTO> findByMemberIdAndTaskIdAndCompletionTime(Long memberId, Long taskId, String time1) {
return TrTaskProgressMapper.toDto(this.TrTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1));
return this.trTaskProgressMapper.toDto(this.trTaskProgressRepository.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1));
}
......
......@@ -14,5 +14,4 @@ public interface TaskRepository extends JpaRepository<Task, Long>, JpaSpecificat
List<Task> findByTaskTemplateId(Long taskTemplateId);
// List<Task> findByTemplateId(Long taskTemplateId);
}
......
package com.topdraw.business.module.task.rest;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Api(tags = "Task管理")
@RestController
@RequestMapping("/api/Task")
public class TaskController {
@Autowired
private TaskService TaskService;
@GetMapping
@ApiOperation("查询Task")
public ResultInfo getTasks(TaskQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(TaskService.queryAll(criteria,pageable));
}
@GetMapping(value = "/all")
@ApiOperation("查询所有Task")
public ResultInfo getTasks(TaskQueryCriteria criteria) {
return ResultInfo.success(TaskService.queryAll(criteria));
}
@PostMapping
@ApiOperation("新增Task")
public ResultInfo create(@Validated @RequestBody Task resources) {
TaskService.create(resources);
return ResultInfo.success();
}
@PutMapping
@ApiOperation("修改Task")
public ResultInfo update(@Validated @RequestBody Task resources) {
TaskService.update(resources);
return ResultInfo.success();
}
@DeleteMapping(value = "/{id}")
@ApiOperation("删除Task")
public ResultInfo delete(@PathVariable Long id) {
TaskService.delete(id);
return ResultInfo.success();
}
}
......@@ -2,9 +2,6 @@ package com.topdraw.business.module.task.service;
import com.topdraw.business.module.task.domain.Task;
import com.topdraw.business.module.task.service.dto.TaskDTO;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.Map;
import java.util.List;
/**
......@@ -14,32 +11,16 @@ import java.util.List;
public interface TaskService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(TaskQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<TaskDTO>
*/
List<TaskDTO> queryAll(TaskQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return TaskDTO
*/
TaskDTO findById(Long id);
void create(Task resources);
void update(Task resources);
void delete(Long id);
/**
*
* @param taskTemplateId
* @return
*/
List<Task> findByTemplateId(Long taskTemplateId);
}
......
......@@ -16,69 +16,69 @@ public class TaskDTO implements Serializable {
private Long id;
// 任务模板id
/** 任务模板id */
private Long taskTemplateId;
// 任务重复类型,-1:不限次;1:单次;>1:多次
/** 任务重复类型,-1:不限次;1:单次;>1:多次 */
private Integer taskRepeatType;
// 任务每日重置 0:不重置;1:重置
/** 任务每日重置 0:不重置;1:重置 */
private Integer taskDailyReset;
// 行为量(完成此任务需要多少次相同行为的触发)
/** 行为量(完成此任务需要多少次相同行为的触发) */
private Integer actionAmount;
// 任务生效时间
/** 任务生效时间 */
private Timestamp validTime;
// 任务失效时间
/** 任务失效时间 */
private LocalDateTime expireTime;
// 显示顺序
/** 显示顺序 */
private Integer sequence;
// 获得成长值
/** 获得成长值 */
private Long rewardExp;
// 获得积分
/** 获得积分 */
private Long rewardPoints;
// 积分过期时间(空为不过期)
/** 积分过期时间(空为不过期) */
private Long rewardPointsExpireTime;
// 能够获取该任务的用户分组,为空则都能获取
/** 能够获取该任务的用户分组,为空则都能获取 */
private String groups;
// 会员等级门槛(0表示无门槛)
/** 会员等级门槛(0表示无门槛) */
private Integer memberLevel;
// 会员vip门槛(0表示没有门槛)
/** 会员vip门槛(0表示没有门槛) */
private Integer memberVip;
// 权益id
/** 权益id */
private Long rightsId;
// 权益数量(活动机会次数、优惠券数量、奖品数量)
/** 权益数量(活动机会次数、优惠券数量、奖品数量) */
private Integer rightsAmount;
// 权益2id
/** 权益2id */
private Long rights2Id;
// 权益2数量
/** 权益2数量 */
private Integer rights2Amount;
// 权益3id
/** 权益3id */
private Long rights3Id;
// 权益3数量
/** 权益3数量 */
private Integer rights3Amount;
// 状态 0:失效;1:生效
/** 状态 0:失效;1:生效 */
private Integer status;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
}
......
package com.topdraw.business.module.task.service.dto;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-10-22
*/
@Data
public class TaskQueryCriteria{
}
......@@ -5,21 +5,15 @@ import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.task.repository.TaskRepository;
import com.topdraw.business.module.task.service.TaskService;
import com.topdraw.business.module.task.service.dto.TaskDTO;
import com.topdraw.business.module.task.service.dto.TaskQueryCriteria;
import com.topdraw.business.module.task.service.mapper.TaskMapper;
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 org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import java.util.List;
import java.util.Map;
import java.util.Objects;
/**
......@@ -31,57 +25,21 @@ import java.util.Objects;
public class TaskServiceImpl implements TaskService {
@Autowired
private TaskRepository TaskRepository;
private TaskMapper taskMapper;
@Autowired
private TaskMapper TaskMapper;
@Override
public Map<String, Object> queryAll(TaskQueryCriteria criteria, Pageable pageable) {
Page<Task> page = TaskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(TaskMapper::toDto));
}
private TaskRepository taskRepository;
@Override
public List<TaskDTO> queryAll(TaskQueryCriteria criteria) {
return TaskMapper.toDto(TaskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public TaskDTO findById(Long id) {
Task Task = TaskRepository.findById(id).orElseGet(Task::new);
Task Task = this.taskRepository.findById(id).orElseGet(Task::new);
ValidationUtil.isNull(Task.getId(),"Task","id",id);
return TaskMapper.toDto(Task);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void create(Task resources) {
TaskRepository.save(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(Task resources) {
Task Task = TaskRepository.findById(resources.getId()).orElseGet(Task::new);
ValidationUtil.isNull( Task.getId(),"Task","id",resources.getId());
Task.copy(resources);
TaskRepository.save(Task);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
Task Task = TaskRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", Task.class, id), 1));
TaskRepository.delete(Task);
return this.taskMapper.toDto(Task);
}
// @Cacheable(cacheNames = "uc-admin_taskList" , key = "#taskTemplateId")
@Override
public List<Task> findByTemplateId(Long taskTemplateId) {
return Objects.nonNull(taskTemplateId) ? this.TaskRepository.findByTaskTemplateId(taskTemplateId) : null;
return Objects.nonNull(taskTemplateId) ? this.taskRepository.findByTaskTemplateId(taskTemplateId) : null;
}
......
......@@ -30,96 +30,97 @@ public class UserTv extends AsyncMqModule implements Serializable {
/** 绑定的小屏账户会员编码 */
@Column(name = "priority_member_code")
private String priorityMemberCode;
// ID
/** ID */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 人ID
/** 人ID */
@Column(name = "person_id")
private Long personId;
// 运营商平台
/** 运营商平台 */
@Column(name = "platform")
private String platform;
// 运营商平台账号
/** 运营商平台账号 */
@Column(name = "platform_account")
@NotNull(message = "platformAccount can't be null !",groups = {CreateGroup.class})
private String platformAccount;
// 手机号
/** 手机号 */
@Column(name = "cellphone")
private String cellphone;
// 用户名
/** 用户名 */
@Column(name = "username")
private String username;
// 密码 MD5
/** 密码 MD5 */
@Column(name = "password")
private String password;
// 昵称 Base64
/** 昵称 Base64 */
@Column(name = "nickname")
private String nickname;
// 头像
/** 头像 */
@Column(name = "image")
private String image;
// 登录天数(总天数)
/** 登录天数(总天数) */
@Column(name = "login_days")
private Integer loginDays;
// 连续登录天数
/** 连续登录天数 */
@Column(name = "continue_days")
private Integer continueDays;
// 活跃时间
/** 活跃时间 */
@Column(name = "active_time")
private Timestamp activeTime;
// 分组 分组ID用逗号分隔
/** 分组 分组ID用逗号分隔 */
@Column(name = "groups")
private String groups;
// 标签 标签用逗号分隔
/** 标签 标签用逗号分隔 */
@Column(name = "tags")
private String tags;
// 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录
/** 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 */
@Column(name = "login_type")
private Integer loginType;
// 状态 0-下线 1-上线
/** 状态 0-下线 1-上线 */
@Column(name = "status")
private Integer status;
// 描述
/** 描述 */
@Column(name = "description")
private String description;
// 创建者
/** 创建者 */
@Column(name = "create_by")
private String createBy;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新者
/** 更新者 */
@Column(name = "update_by")
private String updateBy;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
// 会员id
/** 会员id */
@Column(name = "member_id")
private Long memberId;
......
......@@ -71,5 +71,10 @@ public interface UserTvService {
*/
boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId,String memberCode);
/**
*
* @param platformAccount
* @return
*/
MemberDTO findMemberByPlatformAccount(String platformAccount);
}
......
......@@ -17,70 +17,70 @@ public class UserTvDTO implements Serializable {
/** 绑定的小屏账户会员编码 */
private String priorityMemberCode;
// ID
/** ID */
private Long id;
// 人ID
/** 人ID */
private Long personId;
// 运营商平台
/** 运营商平台 */
private String platform;
// 运营商平台账号
/** 运营商平台账号 */
private String platformAccount;
// 手机号
/** 手机号 */
private String cellphone;
// 用户名
/** 用户名 */
private String username;
// 密码 MD5
/** 密码 MD5 */
private String password;
// 昵称 Base64
/** 昵称 Base64 */
private String nickname;
// 头像
/** 头像 */
private String image;
// 登录天数(总天数)
/** 登录天数(总天数) */
private Integer loginDays;
// 连续登录天数
/** 连续登录天数 */
private Integer continueDays;
// 活跃时间
/** 活跃时间 */
private Timestamp activeTime;
// 分组 分组ID用逗号分隔
/** 分组 分组ID用逗号分隔 */
private String groups;
// 标签 标签用逗号分隔
/** 标签 标签用逗号分隔 */
private String tags;
// 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录
/** 登录类型 1-运营商隐式登录 2-手机验证登录 3-微信登录 4-QQ登录 5-微博登录 6-苹果登录 */
private Integer loginType;
// 状态 0-下线 1-上线
/** 状态 0-下线 1-上线 */
private Integer status;
// 描述
/** 描述 */
private String description;
// 创建者
/** 创建者 */
private String createBy;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新者
/** 更新者 */
private String updateBy;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
// 会员id
/** 会员id */
private Long memberId;
}
......
package com.topdraw.business.module.user.iptv.service.dto;
import lombok.Data;
/**
* @author XiangHan
* @date 2021-12-16
*/
@Data
public class UserTvQueryCriteria{
}
......@@ -153,7 +153,7 @@ public class UserTvServiceImpl implements UserTvService {
public boolean checkPriorityMemberByMemberIdOrMemberCode(Long memberId, String memberCode) {
// 检查会员是否存在
this.checkMember(memberId, memberCode);
//
UserTvDTO userTvDTO = this.findByPriorityMemberCode(memberCode);
if (Objects.nonNull(userTvDTO)) {
return true;
......@@ -165,5 +165,4 @@ public class UserTvServiceImpl implements UserTvService {
this.memberService.checkMember(memberId, memberCode);
}
}
......
......@@ -23,38 +23,38 @@ import java.sql.Timestamp;
@Table(name="uc_user_collection")
public class UserCollection implements Serializable {
// ID
/** ID */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 应用ID
/** 应用ID */
@Column(name = "app_id")
private Long appId;
// 用户ID
/** 用户ID */
@Column(name = "user_id")
private Long userId;
// 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
/** 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅 */
@Column(name = "type")
private Integer type;
// 收藏夹名称
/** 收藏夹名称 */
@Column(name = "name")
private String name;
// 数量
/** 数量 */
@Column(name = "count")
private Integer count;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
......
......@@ -25,89 +25,89 @@ public class UserCollectionDetail implements Serializable {
@JoinColumn(name = "user_collection_id", insertable = false, updatable = false)
private UserCollection userCollection;
// ID
/** ID */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 收藏夹ID
/** 收藏夹ID */
@Column(name = "user_collection_id")
private Long userCollectionId;
// 自定义收藏内容的类型CODE,默认:DEFAULT
/** 自定义收藏内容的类型CODE,默认:DEFAULT */
@Column(name = "detail_folder_code")
private String detailFolderCode;
// 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
/** 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL */
@Column(name = "detail_type")
private String detailType;
// 收藏内容的ID
/** 收藏内容的ID */
@Column(name = "detail_id")
private Long detailId;
// 收藏内容的CODE
/** 收藏内容的CODE */
@Column(name = "detail_code")
private String detailCode;
// 收藏内容的剧集ID
/** 收藏内容的剧集ID */
@Column(name = "detail_episode_id")
private Long detailEpisodeId;
// 收藏内容的剧集CODE
/** 收藏内容的剧集CODE */
@Column(name = "detail_episode_code")
private String detailEpisodeCode;
// 收藏内容的名称
/** 收藏内容的名称 */
@Column(name = "detail_name")
private String detailName;
// 收藏内容的标记
/** 收藏内容的标记 */
@Column(name = "detail_mark")
private Integer detailMark;
// 收藏内容的图片
/** 收藏内容的图片 */
@Column(name = "detail_img")
private String detailImg;
// 收藏内容的剧集序号
/** 收藏内容的剧集序号 */
@Column(name = "detail_index")
private Integer detailIndex;
// 收藏内容的剧集总数
/** 收藏内容的剧集总数 */
@Column(name = "detail_total_index")
private Integer detailTotalIndex;
// 收藏内容的播放时间
/** 收藏内容的播放时间 */
@Column(name = "detail_play_time")
private Integer detailPlayTime;
// 收藏内容的总时间
/** 收藏内容的总时间 */
@Column(name = "detail_total_time")
private Integer detailTotalTime;
// 收藏内容在同一folder中的顺序
/** 收藏内容在同一folder中的顺序 */
@Column(name = "detail_sequence")
private Integer detailSequence;
// 收藏内容的评分
/** 收藏内容的评分 */
@Column(name = "detail_score")
private Float detailScore;
// 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
/** 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅 */
@Column(name = "detail_like")
private Integer detailLike;
// 收藏内容的扩展数据
/** 收藏内容的扩展数据 */
@Column(name = "detail_ext_data")
private String detailExtData;
// 创建时间
/** 创建时间 */
@Column(name = "create_time")
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@Column(name = "update_time")
private Timestamp updateTime;
......
......@@ -14,8 +14,6 @@ import java.util.Optional;
*/
public interface UserCollectionRepository extends JpaRepository<UserCollection, Long>, JpaSpecificationExecutor<UserCollection> {
Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long userId, Integer type, String name);
List<UserCollection> findByUserIdAndType(Long userId, Integer type);
}
......
......@@ -2,11 +2,8 @@ package com.topdraw.business.module.user.weixin.collection.service;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionDetail;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria;
import org.springframework.data.domain.Pageable;
import java.util.List;
import java.util.Map;
/**
* @author pengmengqing
......@@ -15,27 +12,40 @@ import java.util.Map;
public interface UserCollectionDetailService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable);
/**
* 根据ID查询
* @param id ID
* @return UserCollectionDetailDTO
*/
UserCollectionDetailDTO findById(Long id);
/**
*
* @param resources
* @return
*/
UserCollectionDetailDTO create(UserCollectionDetail resources);
/**
*
* @param resources
*/
void update(UserCollectionDetail resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param id
*/
void deleteAllByUserCollectionId(Long id);
/**
*
* @param userCollectionDetailOptional
*/
void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional);
}
......
......@@ -2,13 +2,10 @@ package com.topdraw.business.module.user.weixin.collection.service;
import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria;
import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
/**
......@@ -18,38 +15,60 @@ import java.util.Optional;
public interface UserCollectionService {
/**
* 查询数据分页
* @param criteria 条件参数
* @param pageable 分页参数
* @return Map<String,Object>
*/
Map<String,Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable);
/**
* 查询所有数据不分页
* @param criteria 条件参数
* @return List<UserCollectionDTO>
*/
List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria);
/**
* 根据ID查询
* @param id ID
* @return UserCollectionDTO
*/
UserCollectionDTO findById(Long id);
/**
*
* @param resources
* @return
*/
UserCollectionDTO create(UserCollection resources);
/**
*
* @param resources
*/
void update(UserCollection resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param all
* @param response
* @throws IOException
*/
void download(List<UserCollectionDTO> all, HttpServletResponse response) throws IOException;
/**
*
* @param id
* @param type
* @return
*/
List<UserCollection> findByUserIdAndType(Long id, Integer type);
/**
*
* @param id
* @param type
* @param name
* @return
*/
Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name);
/**
*
* @param userCollection
* @return
*/
UserCollection save(UserCollection userCollection);
}
......
......@@ -13,27 +13,27 @@ import java.sql.Timestamp;
@Data
public class UserCollectionDTO implements Serializable {
// ID
/** ID */
private Long id;
// 应用ID
/** 应用ID */
private Long appId;
// 用户ID
/** 用户ID */
private Long userId;
// 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅
/** 收藏夹类型:1-收藏 2-播放记录 3-播放列表 4-评分 5-点赞/关注/订阅 */
private Integer type;
// 收藏夹名称
/** 收藏夹名称 */
private String name;
// 数量
/** 数量 */
private Integer count;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
}
......
......@@ -14,71 +14,71 @@ import java.sql.Timestamp;
@Data
public class UserCollectionDetailDTO implements Serializable {
// ID
/** ID */
private Long id;
// 收藏夹ID
/** 收藏夹ID */
private Long userCollectionId;
// 自定义收藏内容的类型CODE,默认:DEFAULT
/** 自定义收藏内容的类型CODE,默认:DEFAULT */
private String detailFolderCode;
// 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL
/** 收藏内容的类型:MEDIA|EPISODE|CATEGORY|SUBJECT|ARTICLE|ARTIST|SCHOOL */
private String detailType;
// 收藏内容的ID
/** 收藏内容的ID */
private Long detailId;
// 收藏内容的CODE
/** 收藏内容的CODE */
private String detailCode;
// 收藏内容的剧集ID
/** 收藏内容的剧集ID */
private Long detailEpisodeId;
// 收藏内容的剧集CODE
/** 收藏内容的剧集CODE */
private String detailEpisodeCode;
// 收藏内容的名称
/** 收藏内容的名称 */
private String detailName;
// 收藏内容的标记
/** 收藏内容的标记 */
private Integer detailMark;
// 收藏内容的图片
/** 收藏内容的图片 */
private String detailImg;
// 收藏内容的剧集序号
/** 收藏内容的剧集序号 */
private Integer detailIndex;
// 收藏内容的剧集总数
/** 收藏内容的剧集总数 */
private Integer detailTotalIndex;
// 收藏内容的播放时间
/** 收藏内容的播放时间 */
private Integer detailPlayTime;
// 收藏内容的总时间
/** 收藏内容的总时间 */
private Integer detailTotalTime;
// 收藏内容在同一folder中的顺序
/** 收藏内容在同一folder中的顺序 */
private Integer detailSequence;
// 收藏内容的评分
/** 收藏内容的评分 */
private Float detailScore;
// 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅
/** 收藏内容(根据文件夹和类型的不同)的点赞/关注/订阅 */
private Integer detailLike;
// 收藏内容的扩展数据
/** 收藏内容的扩展数据 */
private String detailExtData;
// 创建时间
/** 创建时间 */
@JsonFormat(
pattern = "MM月dd日 HH:mm",
timezone = "GMT+8"
)
private Timestamp createTime;
// 更新时间
/** 更新时间 */
@JsonFormat(
pattern = "MM月dd日 HH:mm",
timezone = "GMT+8"
......
package com.topdraw.business.module.user.weixin.collection.service.dto;
import com.topdraw.annotation.Query;
import lombok.Data;
import javax.persistence.criteria.JoinType;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Data
public class UserCollectionDetailQueryCriteria{
private Long userWeixinId;
@Query(joinType = JoinType.INNER, joinName = "userCollection")
private Long userId;
@Query(joinType = JoinType.INNER, joinName = "userCollection")
private Integer type;
private String detailType;
private String detailFolderCode = "DEFAULT";
private Long detailId;
}
package com.topdraw.business.module.user.weixin.collection.service.dto;
import lombok.Data;
/**
* @author pengmengqing
* @date 2021-04-02
*/
@Data
public class UserCollectionQueryCriteria{
}
......@@ -4,13 +4,10 @@ import com.topdraw.business.module.user.weixin.collection.domain.UserCollectionD
import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionDetailRepository;
import com.topdraw.business.module.user.weixin.collection.service.UserCollectionDetailService;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDetailQueryCriteria;
import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionDetailMapper;
import com.topdraw.utils.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -28,15 +25,9 @@ public class UserCollectionDetailServiceImpl implements UserCollectionDetailServ
@Autowired
private UserCollectionDetailRepository userCollectionDetailRepository;
@Autowired
private UserCollectionDetailMapper userCollectionDetailMapper;
@Override
public Map<String, Object> queryAll(UserCollectionDetailQueryCriteria criteria, Pageable pageable) {
Page<UserCollectionDetail> page = userCollectionDetailRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(userCollectionDetailMapper::toDto));
}
@Override
public UserCollectionDetailDTO findById(Long id) {
......
......@@ -4,16 +4,11 @@ import com.topdraw.business.module.user.weixin.collection.domain.UserCollection;
import com.topdraw.business.module.user.weixin.collection.repository.UserCollectionRepository;
import com.topdraw.business.module.user.weixin.collection.service.UserCollectionService;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionDTO;
import com.topdraw.business.module.user.weixin.collection.service.dto.UserCollectionQueryCriteria;
import com.topdraw.business.module.user.weixin.collection.service.mapper.UserCollectionMapper;
import com.topdraw.utils.FileUtil;
import com.topdraw.utils.PageUtil;
import com.topdraw.utils.QueryHelp;
import com.topdraw.utils.ValidationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.EmptyResultDataAccessException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -37,19 +32,6 @@ public class UserCollectionServiceImpl implements UserCollectionService {
@Autowired
private UserCollectionMapper userCollectionMapper;
@Override
public Map<String, Object> queryAll(UserCollectionQueryCriteria criteria, Pageable pageable) {
Page<UserCollection> page = userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
return PageUtil.toPage(page.map(userCollectionMapper::toDto));
}
@Override
public List<UserCollectionDTO> queryAll(UserCollectionQueryCriteria criteria) {
return userCollectionMapper.toDto(userCollectionRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
}
@Override
public UserCollectionDTO findById(Long id) {
UserCollection userCollection = userCollectionRepository.findById(id).orElseGet(UserCollection::new);
......
......@@ -27,114 +27,114 @@ import java.io.Serializable;
@Table(name="uc_user_weixin")
public class UserWeixin extends AsyncMqModule implements Serializable {
// ID
/** ID */
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
// 用户ID
/** 用户ID */
@Column(name = "member_id")
private Long memberId;
// 微信unionid,针对开发者
/** 微信unionid,针对开发者 */
@Column(name = "unionid")
@NotNull(message = "unionid can't be null",groups = {CreateGroup.class})
private String unionid;
// 微信appid
/** 微信appid */
@Column(name = "appid")
@NotNull(message = "appid can't be null",groups = {CreateGroup.class})
private String appid;
// 微信openid,针对微信app
/** 微信openid,针对微信app */
@Column(name = "openid")
@NotNull(message = "openid can't be null",groups = {CreateGroup.class})
private String openid;
// 关注状态 0 -未关注 1 - 已关注
/** 关注状态 0 -未关注 1 - 已关注 */
@Column(name = "status")
private Integer status;
// 关注同步状态 0-未同步,1-已同步
/** 关注同步状态 0-未同步,1-已同步 */
@Column(name = "sync_status")
private Integer syncStatus;
// 昵称
/** 昵称 */
@Column(name = "nickname")
private String nickname;
// 头像地址
/** 头像地址 */
@Column(name = "headimgurl")
private String headimgurl;
// 特权信息
/** 特权信息 */
@Column(name = "privilege")
private String privilege;
// 刷新凭据
/** 刷新凭据 */
@Column(name = "refresh_token")
private String refreshToken;
// 凭据
/** 凭据 */
@Column(name = "access_token")
private String accessToken;
// 超时(秒)
/** 超时(秒) */
@Column(name = "expires_in")
private Integer expiresIn;
// 超时时间
/** 超时时间 */
@Column(name = "expires_time")
private Timestamp expiresTime;
// 描述
/** 描述 */
@Column(name = "description")
private String description;
// 创建者
/** 创建者 */
@Column(name = "create_by")
private String createBy;
// 创建时间
/** 创建时间 */
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
// 更新者
/** 更新者 */
@Column(name = "update_by")
private String updateBy;
// 更新时间
/** 更新时间 */
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
// 来源类型
/** 来源类型 */
@Column(name = "source_type")
private String sourceType;
// 来源id
/** 来源id */
@Column(name = "source_id")
private String sourceId;
// 来源id
/** 来源id */
@Column(name = "source_desc")
private String sourceDesc;
// 人id
/** 人id */
@Column(name = "person_id")
private Long personId;
// 来源用户id
/** 来源用户id */
@Column(name = "source_user")
private Long sourceUser;
// 来源实体:活动-activity/商品-item
/** 来源实体:活动-activity/商品-item */
@Column(name = "source_entity")
private String sourceEntity;
// 授权时间
/** 授权时间 */
@Column(name = "auth_time")
private Timestamp authTime;
......
......@@ -28,6 +28,6 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J
@Modifying
@Transactional
@Query(value = "update uc_user_weixin set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true)
@Query(value = "update `uc_user_weixin` set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true)
void updateTime(@Param("resources") UserWeixin resources);
}
......
......@@ -5,7 +5,6 @@ import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
......
......@@ -16,21 +16,68 @@ public interface UserWeixinService {
*/
UserWeixinDTO findById(Long id);
/**
*
* @param resources
* @return
*/
UserWeixin create(UserWeixin resources);
/**
*
* @param resources
*/
void update(UserWeixin resources);
/**
*
* @param resources
*/
void updateTime(UserWeixin resources);
/**
*
* @param id
*/
void delete(Long id);
/**
*
* @param memberId
* @param appid
* @return
*/
UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid);
/**
*
* @param unionId
* @param appId
* @param openId
* @return
*/
UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId);
/**
*
* @param appId
* @param openId
* @return
*/
UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId);
/**
*
* @param unionid
* @return
*/
UserWeixinDTO findFirstByUnionId(String unionid);
/**
*
* @param unionid
* @param appId
* @return
*/
UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId);
}
......
......@@ -16,82 +16,82 @@ import java.io.Serializable;
@Data
public class UserWeixinDTO implements Serializable {
// ID
/** ID */
private Long id;
// 用户ID
/** 用户ID */
private Long memberId;
// 微信unionid,针对开发者
/** 微信unionid,针对开发者 */
private String unionid;
// 微信appid
/** 微信appid */
private String appid;
// 微信openid,针对微信app
/** 微信openid,针对微信app */
private String openid;
// 关注状态 0 -未关注 1 - 已关注
/** 关注状态 0 -未关注 1 - 已关注 */
private Integer status;
// 关注同步状态 0-未同步,1-已同步
/** 关注同步状态 0-未同步,1-已同步 */
private Integer syncStatus;
// 昵称
/** 昵称 */
private String nickname;
// 头像地址
/** 头像地址 */
private String headimgurl;
// 特权信息
/** 特权信息 */
private String privilege;
// 刷新凭据
/** 刷新凭据 */
private String refreshToken;
// 凭据
/** 凭据 */
private String accessToken;
// 超时(秒)
/** 超时(秒) */
private Integer expiresIn;
// 超时时间
/** 超时时间 */
private Timestamp expiresTime;
// 描述
/** 描述 */
private String description;
// 创建者
/** 创建者 */
private String createBy;
// 创建时间
/** 创建时间 */
private Timestamp createTime;
// 更新者
/** 更新者 */
private String updateBy;
// 更新时间
/** 更新时间 */
private Timestamp updateTime;
// 来源类型
/** 来源类型 */
private String sourceType;
// 来源id
/** 来源id */
private String sourceId;
// 来源id
/** 来源id */
private String sourceDesc;
// 人id
/** 人id */
private Long personId;
// 来源用户id
/** 来源用户id */
private Long sourceUser;
// 来源实体:活动-activity/商品-item
/** 来源实体:活动-activity/商品-item */
private String sourceEntity;
// 授权时间
/** 授权时间 */
private Timestamp authTime;
private Integer gender;
......
package com.topdraw.business.module.user.weixin.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.domain.UserWeixinBuilder;
import com.topdraw.utils.ValidationUtil;
......@@ -24,78 +23,78 @@ import org.springframework.util.Assert;
public class UserWeixinServiceImpl implements UserWeixinService {
@Autowired
private UserWeixinRepository UserWeixinRepository;
private UserWeixinRepository userWeixinRepository;
@Autowired
private UserWeixinMapper UserWeixinMapper;
private UserWeixinMapper userWeixinMapper;
@Override
public UserWeixinDTO findById(Long id) {
UserWeixin UserWeixin = UserWeixinRepository.findById(id).orElseGet(UserWeixin::new);
UserWeixin UserWeixin = this.userWeixinRepository.findById(id).orElseGet(UserWeixin::new);
ValidationUtil.isNull(UserWeixin.getId(),"UserWeixin","id",id);
return UserWeixinMapper.toDto(UserWeixin);
return this.userWeixinMapper.toDto(UserWeixin);
}
@Override
@Transactional(rollbackFor = Exception.class)
public UserWeixin create(UserWeixin resources) {
UserWeixin build = UserWeixinBuilder.build(resources);
UserWeixinRepository.save(build);
this.userWeixinRepository.save(build);
return resources;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void update(UserWeixin resources) {
UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new);
UserWeixin UserWeixin = this.userWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new);
ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId());
UserWeixin.copy(resources);
UserWeixinRepository.save(UserWeixin);
this.userWeixinRepository.save(UserWeixin);
}
@Override
public void updateTime(UserWeixin resources) {
UserWeixinRepository.updateTime(resources);
this.userWeixinRepository.updateTime(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserWeixin UserWeixin = UserWeixinRepository.findById(id).orElseThrow(
UserWeixin UserWeixin = this.userWeixinRepository.findById(id).orElseThrow(
() -> new EmptyResultDataAccessException(String.format("No %s entity " + "with id %s " + "exists!", UserWeixin.class, id), 1));
UserWeixinRepository.delete(UserWeixin);
this.userWeixinRepository.delete(UserWeixin);
}
@Override
public UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByMemberIdAndAppid(memberId, appid).orElseGet(UserWeixin::new);
UserWeixin userWeixin = this.userWeixinRepository.findFirstByMemberIdAndAppid(memberId, appid).orElseGet(UserWeixin::new);
ValidationUtil.isNull(userWeixin.getId(),"UserWeixin","id",memberId);
return UserWeixinMapper.toDto(userWeixin);
return this.userWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByUnionIdAndAppIdAndOpenId(String unionId, String appId, String openId) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionidAndAppidAndOpenid(unionId, appId,openId).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
UserWeixin userWeixin = this.userWeixinRepository.findFirstByUnionidAndAppidAndOpenid(unionId, appId,openId).orElseGet(UserWeixin::new);
return this.userWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByAppIdAndOpenId(String appId, String openId) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByAppidAndOpenid(appId,openId).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
UserWeixin userWeixin = this.userWeixinRepository.findFirstByAppidAndOpenid(appId,openId).orElseGet(UserWeixin::new);
return this.userWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByUnionId(String unionid) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionid(unionid).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
UserWeixin userWeixin = this.userWeixinRepository.findFirstByUnionid(unionid).orElseGet(UserWeixin::new);
return this.userWeixinMapper.toDto(userWeixin);
}
@Override
public UserWeixinDTO findFirstByUnionidAndAppid(String unionid, String appId) {
UserWeixin userWeixin = this.UserWeixinRepository.findFirstByUnionidAndAppid(unionid,appId).orElseGet(UserWeixin::new);
return UserWeixinMapper.toDto(userWeixin);
UserWeixin userWeixin = this.userWeixinRepository.findFirstByUnionidAndAppid(unionid,appId).orElseGet(UserWeixin::new);
return this.userWeixinMapper.toDto(userWeixin);
}
}
......
......@@ -16,7 +16,7 @@ import java.util.List;
*/
@Api(tags = "CouponOperation管理")
@RestController
@RequestMapping("/api/CouponOperation")
@RequestMapping("/ucEngine/api/couponOperation")
public class CouponOperationController {
@Autowired
......
......@@ -23,7 +23,7 @@ import java.util.List;
*/
@Api(tags = "ExpOperation管理")
@RestController
@RequestMapping("/api/ExpOperation")
@RequestMapping("/ucEngine/api/expOperation")
public class ExpOperationController {
@Autowired
......
......@@ -3,9 +3,6 @@ package com.topdraw.business.process.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryCriteria;
import com.topdraw.business.module.points.available.service.dto.PointsAvailableQueryType;
import com.topdraw.business.module.points.detail.service.PointsDetailService;
import com.topdraw.business.module.points.detail.service.dto.PointsDetailQueryCriteria;
import com.topdraw.business.module.user.iptv.service.UserTvService;
......@@ -18,11 +15,8 @@ import com.topdraw.business.process.service.dto.CustomPointsResult;
import com.topdraw.business.process.service.PointsOperationService;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.LocalConstants;
import com.topdraw.util.TimestampUtil;
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.data.domain.Pageable;
import org.springframework.util.Assert;
......@@ -41,20 +35,16 @@ import java.util.Objects;
@RequestMapping("/ucEngine/api/pointsOperation")
public class PointsOperationController {
private static final Logger LOG = LoggerFactory.getLogger(PointsOperationController.class);
@Autowired
PointsOperationService pointsOperationService;
@Autowired
PointsDetailService pointsDetailService;
private UserTvService userTvService;
@Autowired
PointsAvailableService pointsAvailableService;
private MemberService memberService;
@Autowired
UserTvService userTvService;
private UserWeixinService userWeixinService;
@Autowired
UserWeixinService userWeixinService;
private PointsDetailService pointsDetailService;
@Autowired
MemberService memberService;
private PointsOperationService pointsOperationService;
@GetMapping(value = "/pagePointsDetails")
......@@ -64,18 +54,6 @@ public class PointsOperationController {
return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable));
}
@GetMapping(value = "/pageAvailablePoints")
@ApiOperation("查询PointsAvailable")
@AnonymousAccess
public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) {
PointsAvailableQueryType queryType = criteria.getQueryType();
// 可用
if (queryType == PointsAvailableQueryType.AVAILABLE_ONLY) {
criteria.setExpireTime(TimestampUtil.now());
}
return ResultInfo.successPage(pointsAvailableService.queryAll(criteria,pageable));
}
@GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}")
@ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用")
@AnonymousAccess
......@@ -119,7 +97,6 @@ public class PointsOperationController {
Long orderId = tempIptvUser.getOrderId();
Integer deviceType = tempIptvUser.getDeviceType();
TempPoints tempPoints = new TempPoints();
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
if (Objects.nonNull(userTvDTO)) {
......
......@@ -23,7 +23,7 @@ import java.util.List;
*/
@Api(tags = "Rights管理")
@RestController
@RequestMapping("/api/RightsOperation")
@RequestMapping("/ucEngine/api/rightsOperation")
public class RightsOperationController {
@Autowired
......
......@@ -27,6 +27,10 @@ public interface ExpOperationService {
*/
void grantExpByManual(Long memberId,Long userId ,List<TempExp> tempExpList);
/**
*
* @param tempExpList
*/
void grantExpByManual(List<TempExp> tempExpList);
}
......
......@@ -16,6 +16,11 @@ public interface TaskOperationService {
*/
ResultInfo dealTask(String content);
/**
*
* @param platformAccount
* @param points
* @return
*/
boolean createPoint2ChongQing(String platformAccount, Long points);
}
......
......@@ -15,7 +15,6 @@ import com.topdraw.business.module.task.attribute.service.dto.TaskAttrDTO;
import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressQueryCriteria;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
......@@ -671,14 +670,10 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @return boolean false:失败 true:成功
*/
private boolean checkAndRefreshTaskCompletion(Long memberId , List<Task> taskStream) {
TrTaskProgressQueryCriteria trTaskProgressQueryCriteria = new TrTaskProgressQueryCriteria();
trTaskProgressQueryCriteria.setMemberId(memberId);
String time1 = LocalDateTimeUtil.todayStart();
for (Task task : taskStream) {
Long taskId = task.getId();
trTaskProgressQueryCriteria.setTaskId(taskId);
// 任务完成记录
List<TrTaskProgressDTO> trTaskProgressDTOS =
this.trTaskProgressService.findByMemberIdAndTaskIdAndCompletionTime(memberId,taskId,time1);
......@@ -772,6 +767,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
// 更新任务完成情况
this.doRefreshTrTaskProcess(trTaskProgress);
// 行为量达标
if (currentActionAmount.compareTo(actionAmount) == 0) {
return true;
......
......@@ -16,6 +16,13 @@ public interface GlobeExceptionMsg {
String OPERATION_FORBID = "operation forbid";
String ENTITY_ALREADY_EXISTS = "entity already exists";
/**************************************************************/
/** 优惠券 */
String COUPON_ID_IS_NULL = "coupon id is null";
String COUPON_CODE_IS_NULL = "coupon code is null";
/**************************************************************/
/** 会员管理 */
......
package com.topdraw.util;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -149,6 +150,14 @@ public class IdWorker {
return idWorker.nextId();
}
public static String generatorCode(String prefix){
IdWorker idWorker = new IdWorker();
if (StringUtils.isNotBlank(prefix)) {
return prefix+"_"+String.valueOf(idWorker.nextId());
}
return String.valueOf(idWorker.nextId());
}
public static void main(String[] args) {
IdWorker idWorker = new IdWorker();
System.out.println(idWorker.nextId());
......