|
|
@@ -5,18 +5,42 @@ import com.izouma.nineth.dto.PageQuery;
|
|
|
import com.izouma.nineth.dto.PageWrapper;
|
|
|
import com.izouma.nineth.repo.BlindBoxItemRepo;
|
|
|
import com.izouma.nineth.utils.JpaUtils;
|
|
|
+import jodd.util.StringUtil;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
+
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class BlindBoxItemService {
|
|
|
|
|
|
private BlindBoxItemRepo blindBoxItemRepo;
|
|
|
|
|
|
+ private final String SSR = "SSR";
|
|
|
+ private final String SR = "SR";
|
|
|
+ private final String U = "U";
|
|
|
+
|
|
|
@Cacheable(value = "blindBoxList", key = "#pageQuery.hashCode()")
|
|
|
public PageWrapper<BlindBoxItem> all(PageQuery pageQuery) {
|
|
|
return PageWrapper.of(blindBoxItemRepo.findAll(JpaUtils.toSpecification(pageQuery, BlindBoxItem.class), JpaUtils.toPageRequest(pageQuery)));
|
|
|
}
|
|
|
+
|
|
|
+ public HashMap<String, String> getBlindBoxRare(Long blindBoxId) {
|
|
|
+ HashMap<String, String> rare = new HashMap<>();
|
|
|
+ String ssr = blindBoxItemRepo.getBlindBoxRare(blindBoxId, "%" + SSR + "%", "%" + U + "%");
|
|
|
+ if (StringUtil.isNotBlank(ssr)) {
|
|
|
+ rare.put(SSR, ssr);
|
|
|
+ }
|
|
|
+ String sr = blindBoxItemRepo.getBlindBoxRare(blindBoxId, "%" + SR + "%", "%" + SSR + "%");
|
|
|
+ if (StringUtil.isNotBlank(sr)) {
|
|
|
+ rare.put(SR, sr);
|
|
|
+ }
|
|
|
+ String u = blindBoxItemRepo.getBlindBoxRare(blindBoxId, "%" + U + "%", "%" + SR + "%");
|
|
|
+ if (StringUtil.isNotBlank(u)) {
|
|
|
+ rare.put(U, u);
|
|
|
+ }
|
|
|
+ return rare;
|
|
|
+ }
|
|
|
}
|