|
@@ -0,0 +1,74 @@
|
|
|
+package com.citu.module.menduner.reward.service;
|
|
|
+
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
+import com.citu.module.menduner.reward.controller.admin.pointruleconfig.vo.*;
|
|
|
+import com.citu.module.menduner.reward.dal.dataobject.pointruleconfig.PointRuleConfigDO;
|
|
|
+import com.citu.framework.common.pojo.PageResult;
|
|
|
+import com.citu.framework.common.pojo.PageParam;
|
|
|
+import com.citu.framework.common.util.object.BeanUtils;
|
|
|
+
|
|
|
+import com.citu.module.menduner.reward.dal.mysql.pointruleconfig.PointRuleConfigMapper;
|
|
|
+
|
|
|
+import static com.citu.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
|
+import static com.citu.module.menduner.reward.enums.ErrorCodeConstants.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 积分规则配置 Service 实现类
|
|
|
+ *
|
|
|
+ * @author Rayson
|
|
|
+ */
|
|
|
+@Service
|
|
|
+@Validated
|
|
|
+public class PointRuleConfigServiceImpl implements PointRuleConfigService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private PointRuleConfigMapper pointRuleConfigMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Long createPointRuleConfig(PointRuleConfigSaveReqVO createReqVO) {
|
|
|
+ // 插入
|
|
|
+ PointRuleConfigDO pointRuleConfig = BeanUtils.toBean(createReqVO, PointRuleConfigDO.class);
|
|
|
+ pointRuleConfigMapper.insert(pointRuleConfig);
|
|
|
+ // 返回
|
|
|
+ return pointRuleConfig.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updatePointRuleConfig(PointRuleConfigSaveReqVO updateReqVO) {
|
|
|
+ // 校验存在
|
|
|
+ validatePointRuleConfigExists(updateReqVO.getId());
|
|
|
+ // 更新
|
|
|
+ PointRuleConfigDO updateObj = BeanUtils.toBean(updateReqVO, PointRuleConfigDO.class);
|
|
|
+ pointRuleConfigMapper.updateById(updateObj);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void deletePointRuleConfig(Long id) {
|
|
|
+ // 校验存在
|
|
|
+ validatePointRuleConfigExists(id);
|
|
|
+ // 删除
|
|
|
+ pointRuleConfigMapper.deleteById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void validatePointRuleConfigExists(Long id) {
|
|
|
+ if (pointRuleConfigMapper.selectById(id) == null) {
|
|
|
+ throw exception(POINT_RULE_CONFIG_NOT_EXISTS);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PointRuleConfigDO getPointRuleConfig(Long id) {
|
|
|
+ return pointRuleConfigMapper.selectById(id);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageResult<PointRuleConfigDO> getPointRuleConfigPage(PointRuleConfigPageReqVO pageReqVO) {
|
|
|
+ return pointRuleConfigMapper.selectPage(pageReqVO);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|