package com.ycl.service.platform.store.impl;
|
|
import cn.hutool.core.util.StrUtil;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.ycl.entity.platform.store.StoreScoreRule;
|
import com.ycl.exception.ApiException;
|
import com.ycl.mapper.platform.store.StoreScoreRuleMapper;
|
import com.ycl.service.platform.store.StoreScoreRuleService;
|
import com.ycl.vo.store.StoreScoreRuleVO;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
/**
|
* <p>
|
* 商铺积分规则管理 服务实现类
|
* </p>
|
*
|
* @author lyq
|
* @since 2022-09-14
|
*/
|
@Service
|
public class StoreScoreRuleServiceImpl extends ServiceImpl<StoreScoreRuleMapper, StoreScoreRule> implements StoreScoreRuleService {
|
|
@Override
|
public Page<StoreScoreRule> list(String keyword, Integer pageSize, Integer pageNum) {
|
Page<StoreScoreRule> page = new Page<>(pageSize, pageNum);
|
LambdaQueryWrapper<StoreScoreRule> wrapper = new LambdaQueryWrapper<>();
|
if (StrUtil.isNotEmpty(keyword)) {
|
wrapper.like(StoreScoreRule::getCategory, keyword);
|
}
|
wrapper.orderByDesc(StoreScoreRule::getCategory);
|
return page(page, wrapper);
|
}
|
|
@Override
|
@Transactional(rollbackFor = Exception.class)
|
public void add(StoreScoreRuleVO.AddScoreVO addScoreVO) {
|
StoreScoreRule build = StoreScoreRule.builder()
|
.category(addScoreVO.getCategory())
|
.deductionItem(addScoreVO.getDeductionItem())
|
.markScore(addScoreVO.getMarkScore()).build();
|
boolean save = save(build);
|
if (!save) {
|
throw new ApiException("添加失败");
|
}
|
}
|
}
|