package com.mzl.flower.service.point.impl;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.mzl.flower.config.exception.ValidationException;
|
import com.mzl.flower.config.security.SecurityUtils;
|
import com.mzl.flower.dto.request.point.CustomerPointDetailDTO;
|
import com.mzl.flower.dto.request.point.CustomerPointDetailQueryDTO;
|
import com.mzl.flower.dto.response.point.CustomerPointDetailVO;
|
import com.mzl.flower.entity.point.CustomerPointDetail;
|
import com.mzl.flower.mapper.point.CustomerPointDetailMapper;
|
import com.mzl.flower.service.point.CustomerPointDetailService;
|
import lombok.RequiredArgsConstructor;
|
import org.springframework.beans.BeanUtils;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import java.util.List;
|
|
/**
|
* @author fanghaowei
|
* @version version2.0
|
* @className MemberServiceImpl
|
* @date 2024/8/26
|
* @description 积分记录
|
*/
|
@Service
|
@Transactional
|
@RequiredArgsConstructor
|
public class CustomerPointDetailServiceImpl extends ServiceImpl<CustomerPointDetailMapper, CustomerPointDetail> implements CustomerPointDetailService {
|
|
private final CustomerPointDetailMapper customerPointDetailMapper;
|
|
@Override
|
public void save(CustomerPointDetailDTO customerPointDetailDTO) {
|
if (customerPointDetailDTO.getId() != null) {
|
throw new ValidationException("id必须为空");
|
}
|
CustomerPointDetail customerPointDetail = new CustomerPointDetail();
|
BeanUtils.copyProperties(customerPointDetailDTO, customerPointDetail);
|
customerPointDetail.create(SecurityUtils.getUserId());
|
customerPointDetailMapper.insert(customerPointDetail);
|
}
|
|
@Override
|
public void update(CustomerPointDetailDTO customerPointDetailDTO) {
|
if (customerPointDetailDTO.getId() == null || customerPointDetailDTO.getId() == 0) {
|
throw new ValidationException("id不能为空");
|
}
|
CustomerPointDetail customerPointDetail = customerPointDetailMapper.selectById(customerPointDetailDTO.getId());
|
if (customerPointDetail == null) {
|
throw new ValidationException("找不到id为" + customerPointDetail.getId() + "的积分记录");
|
}
|
BeanUtils.copyProperties(customerPointDetailDTO, customerPointDetail, "id", "createTime", "createBy", "deleted", "status");
|
customerPointDetail.update(SecurityUtils.getUserId());
|
customerPointDetailMapper.updateById(customerPointDetail);
|
}
|
|
|
@Override
|
public void delete(Long id) {
|
CustomerPointDetail customerPointDetail = customerPointDetailMapper.selectById(id);
|
if (customerPointDetail == null) {
|
throw new ValidationException("找不到id为" + id + "的积分记录");
|
}
|
customerPointDetailMapper.deleteById(id);
|
|
}
|
|
@Override
|
public Page<CustomerPointDetailVO> queryPage(CustomerPointDetailQueryDTO customerPointDetailQueryDTO, Page page) {
|
List<CustomerPointDetailVO> list = customerPointDetailMapper.queryPage(customerPointDetailQueryDTO, page);
|
page.setRecords(list);
|
return page;
|
}
|
}
|