| | |
| | | package com.ks.daylucky.util.activity; |
| | | |
| | | public class ActivityUtil { |
| | | import com.google.gson.Gson; |
| | | import com.ks.daylucky.pojo.DTO.AssistJoinInfoDTO; |
| | | import com.ks.lucky.pojo.DO.LuckyActivity; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.encrypt.AESUtil; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class ActivityUtil { |
| | | private final static String TOKEN_KEY = "@2020_Ks@8#8!!@#"; |
| | | |
| | | /** |
| | | * 返回活动期号 |
| | |
| | | return String.format("NO.%s", id + ""); |
| | | } |
| | | |
| | | /** |
| | | * 获取可以显示出来的活动 |
| | | * |
| | | * @return |
| | | */ |
| | | public static List<Integer> getCanShowAcivityStateList() { |
| | | List<Integer> stateList = new ArrayList<>(); |
| | | |
| | | stateList.add(LuckyActivity.STATE_STARTED); |
| | | stateList.add(LuckyActivity.STATE_FINISH); |
| | | stateList.add(LuckyActivity.STATE_PRE_OPENED); |
| | | stateList.add(LuckyActivity.STATE_OPENED); |
| | | return stateList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取可以被助力的状态 |
| | | * |
| | | * @return |
| | | */ |
| | | public static List<Integer> getCanAssistStateList() { |
| | | List<Integer> stateList = new ArrayList<>(); |
| | | stateList.add(LuckyActivity.STATE_STARTED); |
| | | return stateList; |
| | | } |
| | | |
| | | |
| | | public static String getShareJoinInfo(Long uid, Long activityId) { |
| | | String str = JsonUtil.getSimpleGson().toJson(new AssistJoinInfoDTO(uid, activityId)); |
| | | String joinInfo = AESUtil.encrypt(str, TOKEN_KEY); |
| | | return joinInfo; |
| | | } |
| | | |
| | | public static AssistJoinInfoDTO parseShareJoinInfo(String str) { |
| | | try { |
| | | String decryptStr = AESUtil.decrypt(str, TOKEN_KEY); |
| | | return new Gson().fromJson(decryptStr, AssistJoinInfoDTO.class); |
| | | } catch (Exception e) { |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |