|
|
@@ -0,0 +1,55 @@
|
|
|
+package io.renren.modules.qyh.service.impl;
|
|
|
+
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import io.renren.common.utils.PageUtils;
|
|
|
+import io.renren.common.utils.Query;
|
|
|
+import io.renren.modules.qyh.entity.PointsGiftConfigEntity;
|
|
|
+import io.renren.modules.qyh.mapper.PointsGiftConfigMapper;
|
|
|
+import io.renren.modules.qyh.service.PointsGiftConfigService;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service("pointsGiftConfigService")
|
|
|
+public class PointsGiftConfigServiceImpl extends ServiceImpl<PointsGiftConfigMapper, PointsGiftConfigEntity>
|
|
|
+ implements PointsGiftConfigService {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PageUtils queryPage(Map<String, Object> params) {
|
|
|
+ IPage<PointsGiftConfigEntity> page =
|
|
|
+ this.page(new Query<PointsGiftConfigEntity>().getPage(params), new QueryWrapper<PointsGiftConfigEntity>());
|
|
|
+
|
|
|
+ return new PageUtils(page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PointsGiftConfigEntity info() {
|
|
|
+ return baseMapper.selectOne(new LambdaQueryWrapper<PointsGiftConfigEntity>().last("limit 1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public PointsGiftConfigEntity getOne() {
|
|
|
+ return baseMapper.selectOne(new LambdaQueryWrapper<PointsGiftConfigEntity>()
|
|
|
+ .last("limit 1"));
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void addOrUpdate(PointsGiftConfigEntity entity) {
|
|
|
+ PointsGiftConfigEntity info = this.info();
|
|
|
+ entity.setCreateTime(LocalDateTime.now());
|
|
|
+ if (ObjectUtil.isNull(info)) {
|
|
|
+ baseMapper.insert(entity);
|
|
|
+ } else {
|
|
|
+ entity.setUpdateTime(LocalDateTime.now());
|
|
|
+ baseMapper.updateById(entity);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|