Commit 823b8882 authored by chenweijian's avatar chenweijian

merge master

parents 536911b7 2c323d3c
......@@ -16,6 +16,7 @@ type UserBag struct {
Count mysql.Num `json:"count"` // 拥有数量
RemainDays int `json:"remainDays"` // 有效天数
TextStyleList []*TextStyle `json:"textStyleList"` // 文本样式
HasGiftText bool `json:"hasGiftText"` // 是否有礼物文字
}
type TextStyle struct {
......
......@@ -151,11 +151,15 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
//rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db)
_, myArea, err := user_m.GetUserCountryArea(domain.CreateModelNil(), myUserId)
if err != nil {
return nil, err
propertiesArea := make(map[int]map[uint64]property_cv.CvProperty)
for _, v := range []int{1, 2} {
properties, err := GetPropertyAll(mysql.Db, v)
if err != nil {
return nil, err
}
propertiesArea[v] = properties
}
properties, err := GetPropertyAll(mysql.Db, myArea)
areaMap, err := user_m.GetUserAreaMap(domain.CreateModelNil(), userIds)
if err != nil {
return nil, err
}
......@@ -173,6 +177,7 @@ func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error)
cvUserBases := []*CvUserBase{}
for i := 0; i < len(users); i++ {
user := users[i]
properties := propertiesArea[areaMap[user.ID]]
invisible := IfLogout(user.LogoutTime)
invisibleAvatar := ""
invisibleNick := user.Code
......
......@@ -22,6 +22,7 @@ type ResGift struct {
Together bool
Status mysql.UserYesNo
GiftType mysql.Type
HasGiftText bool
}
// 获取所有的礼物
......
......@@ -157,3 +157,21 @@ func GetUserCountryArea(model *domain.Model, userId mysql.ID) (string, int, erro
}
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
//rp := res_m.ResProperty{}
//properties, err := rp.GetAll(mysql.Db)
_, myArea, err := user_m.GetUserCountryArea(model, myUserId)
_, area, err := user_m.GetUserCountryArea(model, userId)
if err != nil {
return nil, err
}
properties, err := property_cv.GetPropertyAll(mysql.Db, myArea)
properties, err := property_cv.GetPropertyAll(mysql.Db, area)
if err != nil {
return nil, err
}
......
......@@ -3,6 +3,7 @@ package resp
import (
"encoding/json"
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin"
"hilo-user/myerr"
"hilo-user/req"
......@@ -15,6 +16,7 @@ type Response struct {
MessageData interface{} `json:"messageData"` // 消息详情
OperationMessage interface{} `json:"operationMessage"` // 操作消息
Data interface{} `json:"data"` // 数据
Edata interface{} `json:"edata"` // 加密数据
}
type GameResponse struct {
......@@ -36,7 +38,12 @@ func ResponseOk(c *gin.Context, data interface{}) {
Code: myerr.GetSuccessCode(),
Message: 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)
......@@ -50,15 +57,21 @@ func ResponsePageBaseOk(c *gin.Context, data interface{}, nextPageIndex int, has
if data == nil {
data = make([]interface{}, 0)
}
pageData := req.PageRespBase{
NextPageIndex: nextPageIndex,
HasNextPage: hasNextPage,
Data: data,
}
response := Response{
Code: myerr.GetSuccessCode(),
Message: myerr.GetSuccessMsg(),
OperationMessage: myerr.GetSuccessMsg(),
Data: req.PageRespBase{
NextPageIndex: nextPageIndex,
HasNextPage: hasNextPage,
Data: data,
},
}
if _, ok := c.Get(mycontext.InnerEncrypt); ok {
//response.Edata = utils.EncryptionData(data, []byte("484194d4d0f968a7"))
response.Edata = utils.EncryptionData(pageData, []byte("hilo!@#$%^&*()_+"))
} else {
response.Data = pageData
}
c.JSON(http.StatusOK, response)
}
......
......@@ -7,6 +7,7 @@ import (
"git.hilo.cn/hilo-common/mycontext"
"git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/config"
"git.hilo.cn/hilo-common/utils"
"github.com/gin-gonic/gin"
"hilo-user/myerr/bizerr"
"hilo-user/req"
......@@ -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)
}
// 加密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)
func HttpWebSecretHandle(c *gin.Context) {
traceId, _ := c.Keys[mycontext.TRACEID]
......
......@@ -29,8 +29,8 @@ func InitRouter() *gin.Engine {
{
user.GET("/nameplate", wrapper(user_r.UserNameplate))
user.GET("/bag/:resType", wrapper(user_r.UserBag))
user.GET("/detail", wrapper(user_r.UserDetail))
user.GET("/detail/:userExternalId", wrapper(user_r.UserDetailByExternalId))
user.GET("/detail", EncryptHandle, wrapper(user_r.UserDetail))
user.GET("/detail/:userExternalId", EncryptHandle, wrapper(user_r.UserDetailByExternalId))
}
cp := v2.Group("/cp")
{
......
......@@ -46,22 +46,24 @@ func UserBag(c *gin.Context) (*mycontext.MyContext, error) {
for _, bagGift := range userBagGifts {
if gift, ok := allGifts[bagGift.ResId]; ok {
info := user_cv.UserBag{
BagId: bagGift.ID,
ResType: res_e.ResUserBagGift,
ResId: gift.ID,
GiftId: gift.ID,
Name: gift.Name,
DiamondNum: gift.DiamondNum,
IconUrl: gift.IconUrl,
SvgaUrl: gift.SvagUrl,
Count: bagGift.Count,
RemainDays: int(bagGift.EndTime.Sub(time.Now()).Hours() / 24),
BagId: bagGift.ID,
ResType: res_e.ResUserBagGift,
ResId: gift.ID,
GiftId: gift.ID,
Name: gift.Name,
DiamondNum: gift.DiamondNum,
IconUrl: gift.IconUrl,
SvgaUrl: gift.SvagUrl,
Count: bagGift.Count,
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 = append(info.TextStyleList,
&user_cv.TextStyle{TextColor: "#ce0083", TextSize: 20, TextKey: "sender_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