小程序登录
This commit is contained in:
@@ -57,6 +57,10 @@ public enum ErrorCodeEnum {
|
||||
ZONE_NOT_EXIST(500004, "战区不存在!", null),
|
||||
|
||||
INTERVIEW_ENTER_FAIL(1021101, "进入面试间失败", null),
|
||||
|
||||
SIGN_FAIL(600000, "验签失败", null),
|
||||
GET_ACCESSTOKEN_ERROR(600001, "获取小程序TOKEN错误!", null),
|
||||
NEW_MOBILE_HAS_EXIST(600002,"加盟商用户信息已存在",null),
|
||||
;
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.cool.store.enums;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author wxp
|
||||
* @FileName: UserPlatformTypeEnum
|
||||
* @Description: 用户平台类型
|
||||
* @date 2023-06-13 17:12
|
||||
*/
|
||||
public enum UserPlatformTypeEnum {
|
||||
|
||||
WECHAT("wechat", "微信"),
|
||||
DOUYIN("douyin", "抖音"),
|
||||
WEIBO("weibo", "微博");
|
||||
|
||||
private String code;
|
||||
|
||||
private String msg;
|
||||
|
||||
protected static final Map<String, UserPlatformTypeEnum> map = Arrays.stream(values()).collect(
|
||||
Collectors.toMap(UserPlatformTypeEnum::getCode, Function.identity()));
|
||||
|
||||
UserPlatformTypeEnum(String code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
public static UserPlatformTypeEnum getByCode(String code) {
|
||||
return map.get(code);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.cool.store.utils;
|
||||
|
||||
import com.cool.store.exception.ServiceException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
/**
|
||||
* The type Md5 utils.
|
||||
*/
|
||||
public class Md5Utils {
|
||||
/**
|
||||
* logger.
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Md5Utils.class);
|
||||
|
||||
/**
|
||||
* Md 5 string.
|
||||
*
|
||||
* @param src the src
|
||||
* @param charset the charset
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
private static String md5(final String src, final String charset) {
|
||||
MessageDigest md5;
|
||||
StringBuilder hexValue = new StringBuilder(32);
|
||||
try {
|
||||
md5 = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new ServiceException(e.getMessage());
|
||||
}
|
||||
byte[] byteArray = new byte[0];
|
||||
try {
|
||||
byteArray = src.getBytes(charset);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
LOG.error(e.getMessage(), e);
|
||||
}
|
||||
byte[] md5Bytes = md5.digest(byteArray);
|
||||
for (byte md5Byte : md5Bytes) {
|
||||
int val = ((int) md5Byte) & 0xff;
|
||||
if (val < 16) {
|
||||
hexValue.append("0");
|
||||
}
|
||||
hexValue.append(Integer.toHexString(val));
|
||||
}
|
||||
return hexValue.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Md 5 string.
|
||||
*
|
||||
* @param src the src
|
||||
* @return the string
|
||||
*/
|
||||
public static String md5(final String src) {
|
||||
return md5(src, StandardCharsets.UTF_8.name());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.cool.store.utils;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
|
||||
public class Sha1Utils {
|
||||
|
||||
public static String getSha1(byte[] input) {
|
||||
try {
|
||||
MessageDigest mDigest = MessageDigest.getInstance("SHA1");
|
||||
byte[] result = mDigest.digest(input);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (byte b : result) {
|
||||
sb.append(Integer.toString((b & 0xff) + 0x100, 16).substring(1));
|
||||
}
|
||||
return sb.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user