|
@@ -1,20 +1,54 @@
|
|
|
package com.izouma.nineth.service;
|
|
package com.izouma.nineth.service;
|
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
+import com.izouma.nineth.config.Constants;
|
|
|
import com.izouma.nineth.domain.DestroyRecord;
|
|
import com.izouma.nineth.domain.DestroyRecord;
|
|
|
|
|
+import com.izouma.nineth.domain.SysConfig;
|
|
|
|
|
+import com.izouma.nineth.dto.DestroyRecordRankDTO;
|
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
import com.izouma.nineth.dto.PageQuery;
|
|
|
|
|
+import com.izouma.nineth.exception.BusinessException;
|
|
|
import com.izouma.nineth.repo.DestroyRecordRepo;
|
|
import com.izouma.nineth.repo.DestroyRecordRepo;
|
|
|
|
|
+import com.izouma.nineth.repo.SysConfigRepo;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
|
|
+import jodd.util.StringUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.data.domain.Page;
|
|
import org.springframework.data.domain.Page;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
@Service
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
|
public class DestroyRecordService {
|
|
public class DestroyRecordService {
|
|
|
|
|
|
|
|
|
|
+ private final SysConfigRepo sysConfigRepo;
|
|
|
|
|
+
|
|
|
private DestroyRecordRepo destroyRecordRepo;
|
|
private DestroyRecordRepo destroyRecordRepo;
|
|
|
|
|
|
|
|
public Page<DestroyRecord> all(PageQuery pageQuery) {
|
|
public Page<DestroyRecord> all(PageQuery pageQuery) {
|
|
|
return destroyRecordRepo.findAll(JpaUtils.toSpecification(pageQuery, DestroyRecord.class), JpaUtils.toPageRequest(pageQuery));
|
|
return destroyRecordRepo.findAll(JpaUtils.toSpecification(pageQuery, DestroyRecord.class), JpaUtils.toPageRequest(pageQuery));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public List<DestroyRecordRankDTO> destroyRecordRank(String rare) {
|
|
|
|
|
+ String not = null;
|
|
|
|
|
+ if (Constants.Rarity.SSR.equals(rare)) {
|
|
|
|
|
+ not = "%" + Constants.Rarity.U + " #%";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Constants.Rarity.SR.equals(rare)) {
|
|
|
|
|
+ not = "%" + Constants.Rarity.SSR + " #%";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Constants.Rarity.U.equals(rare)) {
|
|
|
|
|
+ not = "%" + Constants.Rarity.SR + " #%";
|
|
|
|
|
+ }
|
|
|
|
|
+ SysConfig sysConfig = sysConfigRepo.findByName(Constants.Rarity.ACTIVITY_RANK_ID).orElseThrow(new BusinessException("请先配置盲盒id"));
|
|
|
|
|
+ if (StringUtil.isBlank(sysConfig.getValue())) {
|
|
|
|
|
+ throw new BusinessException("请先配置盲盒id");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long blindBoxId = Long.parseLong(sysConfig.getValue());
|
|
|
|
|
+ List<Map<String, String>> map = destroyRecordRepo.destroyRecordRank(blindBoxId, "%" + rare + " #%", not);
|
|
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
|
|
+ jsonArray.addAll(map);
|
|
|
|
|
+ return jsonArray.toJavaList(DestroyRecordRankDTO.class);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|