|
|
@@ -16,15 +16,24 @@
|
|
|
*/
|
|
|
package org.springblade.sing.active.service.impl;
|
|
|
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import io.jsonwebtoken.lang.Assert;
|
|
|
import org.springblade.sing.active.entity.ActiveHelpRecord;
|
|
|
+import org.springblade.sing.active.entity.ActiveProductRecord;
|
|
|
import org.springblade.sing.active.entity.ProductVote;
|
|
|
+import org.springblade.sing.active.service.IActiveProductRecordService;
|
|
|
import org.springblade.sing.active.vo.ActiveHelpRecordVO;
|
|
|
import org.springblade.sing.active.mapper.ActiveHelpRecordMapper;
|
|
|
import org.springblade.sing.active.service.IActiveHelpRecordService;
|
|
|
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 java.lang.reflect.Array;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
@@ -36,6 +45,9 @@ import java.util.List;
|
|
|
@Service
|
|
|
public class ActiveHelpRecordServiceImpl extends BaseServiceImpl<ActiveHelpRecordMapper, ActiveHelpRecord> implements IActiveHelpRecordService {
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IActiveProductRecordService activeProductRecordService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<ActiveHelpRecordVO> selectActiveHelpRecordPage(IPage<ActiveHelpRecordVO> page, ActiveHelpRecordVO activeHelpRecord) {
|
|
|
return page.setRecords(baseMapper.selectActiveHelpRecordPage(page, activeHelpRecord));
|
|
|
@@ -46,4 +58,74 @@ public class ActiveHelpRecordServiceImpl extends BaseServiceImpl<ActiveHelpRecor
|
|
|
return baseMapper.selectVote(productId);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public boolean recordHide(List<Long> recordIds) {
|
|
|
+ Assert.notNull(recordIds,"请选择助力记录");
|
|
|
+ List<ActiveHelpRecord> activeHelpRecords = super.listByIds(recordIds);
|
|
|
+ Assert.notNull(activeHelpRecords,"此助力记录已失效");
|
|
|
+
|
|
|
+ statusHide(activeHelpRecords);
|
|
|
+ return super.updateBatchById(activeHelpRecords);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean recordShow(List<Long> recordIds) {
|
|
|
+ Assert.notNull(recordIds,"请选择助力记录");
|
|
|
+ List<ActiveHelpRecord> activeHelpRecords = super.listByIds(recordIds);
|
|
|
+ Assert.notNull(activeHelpRecords,"此助力记录已失效");
|
|
|
+
|
|
|
+ statusShow(activeHelpRecords);
|
|
|
+ return super.updateBatchById(activeHelpRecords);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean recordHideByIp(List<String> ips) {
|
|
|
+ List<ActiveHelpRecord> activeHelpRecords = new ArrayList<>();
|
|
|
+ for (String ip : ips) {
|
|
|
+ List<ActiveHelpRecord> list = super.list(new LambdaQueryWrapper<ActiveHelpRecord>().eq(ActiveHelpRecord::getIp, ip));
|
|
|
+ statusHide(list);
|
|
|
+ activeHelpRecords.addAll(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ return super.updateBatchById(activeHelpRecords);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public boolean recordShowByIp(List<String> ips) {
|
|
|
+ List<ActiveHelpRecord> activeHelpRecords = new ArrayList<>();
|
|
|
+ for (String ip : ips) {
|
|
|
+ List<ActiveHelpRecord> list = super.list(new LambdaQueryWrapper<ActiveHelpRecord>().eq(ActiveHelpRecord::getIp, ip));
|
|
|
+ statusShow(list);
|
|
|
+ activeHelpRecords.addAll(list);
|
|
|
+ }
|
|
|
+ return super.updateBatchById(activeHelpRecords);
|
|
|
+ }
|
|
|
+
|
|
|
+ //恢复票数
|
|
|
+ private void statusShow(List<ActiveHelpRecord> list) {
|
|
|
+ for (ActiveHelpRecord activeHelpRecord : list) {
|
|
|
+ if (activeHelpRecord.getStatus() == 0){
|
|
|
+ activeHelpRecord.setStatus(1);
|
|
|
+ //更新作品票数
|
|
|
+ ActiveProductRecord productRecord = activeProductRecordService.getById(activeHelpRecord.getProductId());
|
|
|
+ productRecord.setVoteCount(productRecord.getVoteCount() + activeHelpRecord.getVoteCount());
|
|
|
+ activeProductRecordService.updateById(productRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //减去票数
|
|
|
+ private void statusHide(List<ActiveHelpRecord> list) {
|
|
|
+ for (ActiveHelpRecord activeHelpRecord : list) {
|
|
|
+ if (activeHelpRecord.getStatus() == 1){
|
|
|
+ activeHelpRecord.setStatus(0);
|
|
|
+ //更新作品票数
|
|
|
+ ActiveProductRecord productRecord = activeProductRecordService.getById(activeHelpRecord.getProductId());
|
|
|
+ productRecord.setVoteCount(productRecord.getVoteCount() - activeHelpRecord.getVoteCount());
|
|
|
+ activeProductRecordService.updateById(productRecord);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|