|
@@ -22,7 +22,7 @@ import (
|
|
|
"bp.jydev.jianyu360.cn/BaseService/userCenter/rpc/pb"
|
|
|
)
|
|
|
|
|
|
-//获取用户合并以前,合并以后的openid
|
|
|
+// 获取用户合并以前,合并以后的openid
|
|
|
func GetOldOpenid(s_m_openid, a_m_openid, s_phone string, mergeorder interface{}) string {
|
|
|
a_mergeorder, _ := mergeorder.([]interface{})
|
|
|
openid := ""
|
|
@@ -55,19 +55,20 @@ var filterReg_1 = regexp.MustCompile("^([0-9]{1,3}|[零一二三四五六七八
|
|
|
var filterReg = regexp.MustCompile("^[的人号时元万公告项目地址电话邮编日期联系招标中结果成交项目项目采购采购项目政府采购公告更正公告]+$")
|
|
|
var PhoneReg = regexp.MustCompile("^[1][3-9][0-9]{9}$")
|
|
|
var EmailPattern = regexp.MustCompile("^([a-zA-Z0-9_\\-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([a-zA-Z0-9\\-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$")
|
|
|
+var filterReg_4 = regexp.MustCompile("([)>》】\\]\\}}〕,,;;::'\"“”。\\.\\??、/\\+=\\\\_—\\*&……\\^%$¥@!!`~·(\\(<《【\\[\\{{〔])")
|
|
|
|
|
|
-//P279删除通用过滤词,例如“公告”
|
|
|
+// P279删除通用过滤词,例如“公告”
|
|
|
func FilteKey(k string) string {
|
|
|
k = strings.TrimSpace(k)
|
|
|
// k = filterReg_3.ReplaceAllString(k, "")
|
|
|
- k = filterReg_2.ReplaceAllString(k, "")
|
|
|
+ k = filterReg_4.ReplaceAllString(k, "")
|
|
|
// k = filterReg_1.ReplaceAllString(k, "")
|
|
|
// k = filterReg.ReplaceAllString(k, "")
|
|
|
return k
|
|
|
}
|
|
|
|
|
|
// InterceptSearchKW 超过20个字,截断
|
|
|
-//返回截取后的字符串和截取掉中的前3个字
|
|
|
+// 返回截取后的字符串和截取掉中的前3个字
|
|
|
func InterceptSearchKW(word string, keywordsLimit int, isFilter bool) (b_word, a_word, s_word string) {
|
|
|
if word == "" {
|
|
|
return
|
|
@@ -97,7 +98,7 @@ func HttpEs(ques, analyzer, esAddress string) string {
|
|
|
return es.Analyze(ques, "bidding", analyzer)
|
|
|
}
|
|
|
|
|
|
-//发送邮箱验证码
|
|
|
+// 发送邮箱验证码
|
|
|
func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
|
|
|
html := fmt.Sprintf(`<div>
|
|
|
<div>
|
|
@@ -133,13 +134,12 @@ func SendMailIdentCode(to, code string, auth []*mail.GmailAuth) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func SendSMS(address, mobile string, params ...string) {
|
|
|
sms.SendSms(address, "01", mobile, params...)
|
|
|
}
|
|
|
|
|
|
-//发送验证码
|
|
|
-//增加sessionKey字段 更换手机号防止绕过身份校验
|
|
|
+// 发送验证码
|
|
|
+// 增加sessionKey字段 更换手机号防止绕过身份校验
|
|
|
func SendPhoneIdentCode(address, phone string, session *httpsession.Session, sessionKey ...string) bool {
|
|
|
sessionKeyFlag := defaultPhoneFlag
|
|
|
if len(sessionKey) > 0 && sessionKey[0] != "" {
|
|
@@ -164,7 +164,7 @@ func SendPhoneIdentCode(address, phone string, session *httpsession.Session, ses
|
|
|
|
|
|
const defaultPhoneFlag = "identCode"
|
|
|
|
|
|
-//短信验证码校验
|
|
|
+// 短信验证码校验
|
|
|
func CheckPhoneIdent(session *httpsession.Session, code string, sessionKey ...string) string {
|
|
|
sessionKeyFlag := defaultPhoneFlag
|
|
|
if len(sessionKey) > 0 && sessionKey[0] != "" {
|
|
@@ -179,7 +179,7 @@ func CheckPhoneIdent(session *httpsession.Session, code string, sessionKey ...st
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
-//删除短信验证码有关的session
|
|
|
+// 删除短信验证码有关的session
|
|
|
func ClearPhoneIdentSession(session *httpsession.Session, sessionKey ...string) {
|
|
|
sessionKeyFlag := defaultPhoneFlag
|
|
|
if len(sessionKey) > 0 && sessionKey[0] != "" {
|
|
@@ -190,17 +190,17 @@ func ClearPhoneIdentSession(session *httpsession.Session, sessionKey ...string)
|
|
|
session.Del(fmt.Sprintf("%sTime", sessionKeyFlag))
|
|
|
}
|
|
|
|
|
|
-//邮箱校验
|
|
|
+// 邮箱校验
|
|
|
func IsEmail(value string) bool {
|
|
|
return EmailPattern.MatchString(value)
|
|
|
}
|
|
|
|
|
|
-//手机号校验
|
|
|
+// 手机号校验
|
|
|
func IsPhone(phone string) bool {
|
|
|
return PhoneReg.MatchString(phone)
|
|
|
}
|
|
|
|
|
|
-//获取信息行业
|
|
|
+// 获取信息行业
|
|
|
func Getindustrys(industryname string, mongodb MongodbSim) (industry map[string][]string, sortArray []string) {
|
|
|
industry = map[string][]string{}
|
|
|
sortArray = []string{}
|
|
@@ -243,8 +243,7 @@ func Getindustrys(industryname string, mongodb MongodbSim) (industry map[string]
|
|
|
return industry, sortArray
|
|
|
}
|
|
|
|
|
|
-//对应月份
|
|
|
-//
|
|
|
+// 对应月份
|
|
|
func GetMonth(mon string) int {
|
|
|
month := map[string]int{
|
|
|
"January": 1,
|
|
@@ -263,12 +262,12 @@ func GetMonth(mon string) int {
|
|
|
return month[mon]
|
|
|
}
|
|
|
|
|
|
-//value unlimited 并发限制登陆用户
|
|
|
+// value unlimited 并发限制登陆用户
|
|
|
func LoginRedisKey(userid string) string {
|
|
|
return fmt.Sprintf("unlimited_%s", userid)
|
|
|
}
|
|
|
|
|
|
-//获取loginSess
|
|
|
+// 获取loginSess
|
|
|
func GetLoginSess(userid string) []string {
|
|
|
key := LoginRedisKey(userid)
|
|
|
if data, ok := redis.Get("other", key).([]interface{}); ok {
|
|
@@ -277,7 +276,7 @@ func GetLoginSess(userid string) []string {
|
|
|
return []string{}
|
|
|
}
|
|
|
|
|
|
-//判断是否在内
|
|
|
+// 判断是否在内
|
|
|
func IsInLoginSess(key string, arr []string) bool {
|
|
|
for _, v := range arr {
|
|
|
if key == v {
|
|
@@ -298,7 +297,7 @@ type AppLoginPush struct {
|
|
|
PhoneType string `json:"phoneType"`
|
|
|
}
|
|
|
|
|
|
-//更新存储用户sessionid的队列 【sessionid ttl小于三天的清除】 key:sessionid
|
|
|
+// 更新存储用户sessionid的队列 【sessionid ttl小于三天的清除】 key:sessionid
|
|
|
func PutLoginSess(mongodb MongodbSim, apppushRpc, key, userid string, limit, max int) bool {
|
|
|
value := GetLoginSess(userid)
|
|
|
if !IsInLoginSess(key, value) {
|
|
@@ -344,7 +343,7 @@ func PutLoginSess(mongodb MongodbSim, apppushRpc, key, userid string, limit, max
|
|
|
return redis.Put("other", LoginRedisKey(userid), value, -1)
|
|
|
}
|
|
|
|
|
|
-//清除数组中的s
|
|
|
+// 清除数组中的s
|
|
|
func removeArr(arr []string, s string) []string {
|
|
|
result := []string{}
|
|
|
for _, v := range arr {
|
|
@@ -356,7 +355,6 @@ func removeArr(arr []string, s string) []string {
|
|
|
return result
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func LoginOutPush(mongodb MongodbSim, userid, sessid, apppushRpc string) {
|
|
|
rediskey := fmt.Sprintf("app_%s", sessid)
|
|
|
r := redis.Get("other", rediskey)
|
|
@@ -393,7 +391,7 @@ func LoginOutPush(mongodb MongodbSim, userid, sessid, apppushRpc string) {
|
|
|
log.Println("ok:", ok)
|
|
|
}
|
|
|
|
|
|
-//session数组清除某个value[针对多账号同时在线的方法、退出登录时调用]
|
|
|
+// session数组清除某个value[针对多账号同时在线的方法、退出登录时调用]
|
|
|
func DelUnlimitSessionId(sessid, userid string) []string {
|
|
|
sessArr := GetLoginSess(userid)
|
|
|
newArr := []string{}
|
|
@@ -406,7 +404,7 @@ func DelUnlimitSessionId(sessid, userid string) []string {
|
|
|
return newArr
|
|
|
}
|
|
|
|
|
|
-//获取当天结束时间 单位秒
|
|
|
+// 获取当天结束时间 单位秒
|
|
|
func GetExpire() int {
|
|
|
t, _ := time.ParseInLocation(Date_Short_Layout, time.Now().AddDate(0, 0, 1).Format(Date_Short_Layout), time.Local)
|
|
|
t2, _ := time.ParseInLocation(Date_Full_Layout, time.Now().Format(Date_Full_Layout), time.Local)
|
|
@@ -420,7 +418,7 @@ func TimeProcessing(hour interface{}, duration int) time.Time {
|
|
|
return t
|
|
|
}
|
|
|
|
|
|
-//清除用户权益缓存、菜单缓存
|
|
|
+// 清除用户权益缓存、菜单缓存
|
|
|
func ClearUserCache(middleground *Middleground, positionId int64) {
|
|
|
middleground.UserCenter.WorkDesktopClearUserInfo(pb.WorkDesktopClearUserInfoReq{
|
|
|
PositionId: fmt.Sprint(positionId),
|