Commit 823b8882 authored by chenweijian's avatar chenweijian

merge master

parents 536911b7 2c323d3c
...@@ -16,6 +16,7 @@ type UserBag struct { ...@@ -16,6 +16,7 @@ type UserBag struct {
Count mysql.Num `json:"count"` // 拥有数量 Count mysql.Num `json:"count"` // 拥有数量
RemainDays int `json:"remainDays"` // 有效天数 RemainDays int `json:"remainDays"` // 有效天数
TextStyleList []*TextStyle `json:"textStyleList"` // 文本样式 TextStyleList []*TextStyle `json:"textStyleList"` // 文本样式
HasGiftText bool `json:"hasGiftText"` // 是否有礼物文字
} }
type TextStyle struct { type TextStyle struct {
......
...@@ -151,11 +151,15 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) ...@@ -151,11 +151,15 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
//rp := res_m.ResProperty{} //rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db) //properties, err := rp.GetAll(mysql.Db)
_, myArea, err := user_m.GetUserCountryArea(domain.CreateModelNil(), myUserId) propertiesArea := make(map[int]map[uint64]property_cv.CvProperty)
for _, v := range []int{1, 2} {
properties, err := GetPropertyAll(mysql.Db, v)
if err != nil { if err != nil {
return nil, err return nil, err
} }
properties, err := GetPropertyAll(mysql.Db, myArea) propertiesArea[v] = properties
}
areaMap, err := user_m.GetUserAreaMap(domain.CreateModelNil(), userIds)
if err != nil { if err != nil {
return nil, err return nil, err
} }
...@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) ...@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
cvUserBases := []*CvUserBase{} cvUserBases := []*CvUserBase{}
for i := 0; i < len(users); i++ { for i := 0; i < len(users); i++ {
user := users[i] user := users[i]
properties := propertiesArea[areaMap[user.ID]]
invisible := IfLogout(user.LogoutTime) invisible := IfLogout(user.LogoutTime)
invisibleAvatar := "" invisibleAvatar := ""
invisibleNick := user.Code invisibleNick := user.Code
......
...@@ -22,6 +22,7 @@ type ResGift struct { ...@@ -22,6 +22,7 @@ type ResGift struct {
Together bool Together bool
Status mysql.UserYesNo Status mysql.UserYesNo
GiftType mysql.Type GiftType mysql.Type
HasGiftText bool
} }
// 获取所有的礼物 // 获取所有的礼物
......
...@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro ...@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro
} }
return res.Name, res.Area, nil return res.Name, res.Area, nil
} }
//获取用户的国家所属的区域(是否阿语区)
func GetUserAreaMap(model *domain.Model, userIds []mysql.ID) (map[mysql.ID]int, error) {
type info struct {
Id mysql.ID
Area int
}
rows := make([]*info, 0)
sql := "select user.id, rc.area from user left join res_country rc on user.country = rc.name where user.id in (?);"
if err := model.DB().Raw(sql, userIds).Scan(&rows).Error; err != nil {
return nil, myerr.WrapErr(err)
}
res := make(map[mysql.ID]int)
for _, v := range rows {
res[v.Id] = v.Area
}
return res, nil
}
...@@ -172,11 +172,11 @@ func (s *UserService) GetUserDetail(userId mysql.ID, myUserId mysql.ID, lang str ...@@ -172,11 +172,11 @@ func (s *UserService) GetUserDetail(userId mysql.ID, myUserId mysql.ID, lang str
//rp := res_m.ResProperty{} //rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db) //properties, err := rp.GetAll(mysql.Db)
_, myArea, err := user_m.GetUserCountryArea(model, myUserId) _, area, err := user_m.GetUserCountryArea(model, userId)
if err != nil { if err != nil {
return nil, err return nil, err
} }
properties, err := property_cv.GetPropertyAll(mysql.Db, myArea) properties, err := property_cv.GetPropertyAll(mysql.Db, area)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -3,6 +3,7 @@ package resp ...@@ -3,6 +3,7 @@ package resp
import ( import (
"encoding/json" "encoding/json"
"git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"hilo-user/myerr" "hilo-user/myerr"
"hilo-user/req" "hilo-user/req"
...@@ -15,6 +16,7 @@ type Response struct { ...@@ -15,6 +16,7 @@ type Response struct {
MessageData interface{} `json:"messageData"` // 消息详情 MessageData interface{} `json:"messageData"` // 消息详情
OperationMessage interface{} `json:"operationMessage"` // 操作消息 OperationMessage interface{} `json:"operationMessage"` // 操作消息
Data interface{} `json:"data"` // 数据 Data interface{} `json:"data"` // 数据
Edata interface{} `json:"edata"` // 加密数据
} }
type GameResponse struct { type GameResponse struct {
...@@ -36,7 +38,12 @@ func ResponseOk(c *gin.Context, data interface{}) { ...@@ -36,7 +38,12 @@ func ResponseOk(c *gin.Context, data interface{}) {
Code: myerr.GetSuccessCode(), Code: myerr.GetSuccessCode(),
Message: myerr.GetSuccessMsg(), Message: myerr.GetSuccessMsg(),
OperationMessage: myerr.GetSuccessMsg(), OperationMessage: myerr.GetSuccessMsg(),
Data: data, }
if _, ok := c.Get(mycontext.InnerEncrypt); ok {
//response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7"))
response.Edata = utils.EncryptionData(data, []byte("hilo!@#$%^&*()_+"))
} else {
response.Data = data
} }
printResponseBody(c, &response) printResponseBody(c, &response)
...@@ -50,15 +57,21 @@ func ResponsePageBaseOk(c *gin.Context, data interface{}, nextPageIndex int, has ...@@ -50,15 +57,21 @@ func ResponsePageBaseOk(c *gin.Context, data interface{}, nextPageIndex int, has
if data == nil { if data == nil {
data = make([]interface{}, 0) data = make([]interface{}, 0)
} }
pageData := req.PageRespBase{
NextPageIndex: nextPageIndex,
HasNextPage: hasNextPage,
Data: data,
}
response := Response{ response := Response{
Code: myerr.GetSuccessCode(), Code: myerr.GetSuccessCode(),
Message: myerr.GetSuccessMsg(), Message: myerr.GetSuccessMsg(),
OperationMessage: myerr.GetSuccessMsg(), OperationMessage: myerr.GetSuccessMsg(),
Data: req.PageRespBase{ }
NextPageIndex: nextPageIndex, if _, ok := c.Get(mycontext.InnerEncrypt); ok {
HasNextPage: hasNextPage, //response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7"))
Data: data, response.Edata = utils.EncryptionData(pageData, []byte("hilo!@#$%^&*()_+"))
}, } else {
response.Data = pageData
} }
c.JSON(http.StatusOK, response) c.JSON(http.StatusOK, response)
} }
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"git.hilo.cn/hilo-common/mycontext" "git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/config" "git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"hilo-user/myerr/bizerr" "hilo-user/myerr/bizerr"
"hilo-user/req" "hilo-user/req"
...@@ -137,6 +138,18 @@ func LoggerHandle(c *gin.Context) { ...@@ -137,6 +138,18 @@ func LoggerHandle(c *gin.Context) {
mycontext.CreateMyContext(c.Keys).Log.Infof("request end fullPath:%v,url:%v, method: %v, traceId:%v, latency:%v userId:%v", c.FullPath(), reqUri, method, traceId, latency, userId) mycontext.CreateMyContext(c.Keys).Log.Infof("request end fullPath:%v,url:%v, method: %v, traceId:%v, latency:%v userId:%v", c.FullPath(), reqUri, method, traceId, latency, userId)
} }
// 加密Handle
func EncryptHandle(c *gin.Context) {
header := c.Request.Header
appVersion := header.Get("Appversion")
if len(appVersion) > 0 {
if high, _ := utils.CompareVersion(appVersion, "> 3.9.0"); high {
c.Set(mycontext.InnerEncrypt, true)
}
}
c.Next()
}
//http信息解密(web) //http信息解密(web)
func HttpWebSecretHandle(c *gin.Context) { func HttpWebSecretHandle(c *gin.Context) {
traceId, _ := c.Keys[mycontext.TRACEID] traceId, _ := c.Keys[mycontext.TRACEID]
......
...@@ -29,8 +29,8 @@ func InitRouter() *gin.Engine { ...@@ -29,8 +29,8 @@ func InitRouter() *gin.Engine {
{ {
user.GET("/nameplate", wrapper(user_r.UserNameplate)) user.GET("/nameplate", wrapper(user_r.UserNameplate))
user.GET("/bag/:resType", wrapper(user_r.UserBag)) user.GET("/bag/:resType", wrapper(user_r.UserBag))
user.GET("/detail", wrapper(user_r.UserDetail)) user.GET("/detail", EncryptHandle, wrapper(user_r.UserDetail))
user.GET("/detail/:userExternalId", wrapper(user_r.UserDetailByExternalId)) user.GET("/detail/:userExternalId", EncryptHandle, wrapper(user_r.UserDetailByExternalId))
} }
cp := v2.Group("/cp") cp := v2.Group("/cp")
{ {
......
...@@ -56,12 +56,14 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -56,12 +56,14 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) {
SvgaUrl: gift.SvagUrl, SvgaUrl: gift.SvagUrl,
Count: bagGift.Count, Count: bagGift.Count,
RemainDays: int(bagGift.EndTime.Sub(time.Now()).Hours() / 24), RemainDays: int(bagGift.EndTime.Sub(time.Now()).Hours() / 24),
HasGiftText: gift.HasGiftText,
} }
if gift.ID == cp_e.CpConfessionGiftId { // 如果是cp告白礼物 if gift.ID == cp_e.CpConfessionGiftId || gift.HasGiftText { // 如果是cp告白礼物
info.TextStyleList = make([]*user_cv.TextStyle, 0, 2) info.TextStyleList = make([]*user_cv.TextStyle, 0, 2)
info.TextStyleList = append(info.TextStyleList, info.TextStyleList = append(info.TextStyleList,
&user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "sender_name"}, &user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "sender_name"},
&user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "receiver_name"}, &user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "receiver_name"},
&user_cv.TextStyle{TextColor: "#FFFFFF", TextSize: 40, TextKey: "gift_text"},
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment