|
|
@@ -16,13 +16,24 @@
|
|
|
*/
|
|
|
package org.springblade.sing.active.service.impl;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import org.checkerframework.checker.units.qual.A;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.sing.active.entity.ActiveProductRecord;
|
|
|
+import org.springblade.sing.active.mapper.ActiveHelpMapper;
|
|
|
+import org.springblade.sing.active.mapper.ActiveHelpRecordMapper;
|
|
|
+import org.springblade.sing.active.service.IActiveHelpRecordService;
|
|
|
import org.springblade.sing.active.vo.ActiveProductRecordVO;
|
|
|
import org.springblade.sing.active.mapper.ActiveProductRecordMapper;
|
|
|
import org.springblade.sing.active.service.IActiveProductRecordService;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 活动作品 服务实现类
|
|
|
@@ -33,6 +44,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
@Service
|
|
|
public class ActiveProductRecordServiceImpl extends BaseServiceImpl<ActiveProductRecordMapper, ActiveProductRecord> implements IActiveProductRecordService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ActiveHelpRecordMapper activeHelpRecordMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ActiveProductRecordVO> selectActiveProductRecordPage(IPage<ActiveProductRecordVO> page, ActiveProductRecordVO activeProductRecord) {
|
|
|
return page.setRecords(baseMapper.selectActiveProductRecordPage(page, activeProductRecord));
|
|
|
@@ -43,4 +57,35 @@ public class ActiveProductRecordServiceImpl extends BaseServiceImpl<ActiveProduc
|
|
|
return baseMapper.selectProductByActiveId(activeId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public boolean editCountById(Long id) {
|
|
|
+
|
|
|
+ ActiveProductRecord activeProductRecord = baseMapper.selectById(id);
|
|
|
+
|
|
|
+ //查询真实票数
|
|
|
+ Long count = activeHelpRecordMapper.selectVoteCountByProductId(id);
|
|
|
+ activeProductRecord.setVoteCount(count);
|
|
|
+ baseMapper.updateById(activeProductRecord);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean editVoteCountByActiveId(Long activeId) {
|
|
|
+
|
|
|
+ List<ActiveProductRecord> activeProductRecords = baseMapper.selectList(new LambdaQueryWrapper<ActiveProductRecord>()
|
|
|
+ .eq(activeId != null, ActiveProductRecord::getActiveId, activeId));
|
|
|
+
|
|
|
+ List<Map<String, Object>> list = activeHelpRecordMapper.selectVoteCountByActiveId(activeId);
|
|
|
+ for (ActiveProductRecord activeProductRecord : activeProductRecords) {
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ if (map.get("productId") == activeProductRecord.getId()){
|
|
|
+ activeProductRecord.setVoteCount((Long)map.get("voteCount"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ super.updateBatchById(activeProductRecords);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
}
|