Commit 631597ae authored by hujiebin's avatar hujiebin

feat:先处理国家势力的

parent d6a0473c
......@@ -132,3 +132,5 @@ const (
SWITCH_ON = 1
SWITH_OFF = 0
)
var GROUP_ROLE_VIEW_LIMIT = 10
This diff is collapsed.
package country_m
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/_const/enum/country_e"
"hilo-group/myerr"
)
type CountryMgrUser struct {
mysql.Entity
Country string
UserId mysql.ID
Role country_e.CountryMgrRole
}
// 获取国家管理人员
func GetCountryMgr(model *domain.Model, userId mysql.ID) (*CountryMgrUser, error) {
cmu := new(CountryMgrUser)
if err := model.Db.WithContext(model.MyContext.Context).Where("user_id = ?", userId).First(&cmu).Error; err != nil {
if err == gorm.ErrRecordNotFound {
return nil, nil
} else {
return nil, myerr.WrapErr(err)
}
}
return cmu, nil
}
// 更新国家管理人员
func (cmu *CountryMgrUser) UpdateCountryMgr(userId mysql.ID, role country_e.CountryMgrRole, country string) *CountryMgrUser {
cmu.UserId, cmu.Role, cmu.Country = userId, role, country
return cmu
}
// 删除国家管理人员
func (cmu *CountryMgrUser) DeleteCountryMgr() {
cmu.SetDel()
}
package user_m
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"gorm.io/gorm"
"hilo-group/myerr"
)
type UserOauth struct {
UserId uint64 `json:"user_id"`
ThirdPartyId string `json:"third_party_id"`
ThirdPartyType int8 `json:"third_party_type"`
}
func (p *UserOauth) TableName() string {
return "user_oauth"
}
func GetUserOauthByUserId(model *domain.Model, userId uint64, thirdType uint8) ([]*UserOauth, error) {
res := make([]*UserOauth, 0)
db := mysql.Db.Where(&UserOauth{UserId: userId})
if thirdType > 0 {
db = db.Where(&UserOauth{ThirdPartyType: int8(thirdType)})
}
err := db.Find(&res).Error
if err != nil {
if err == gorm.ErrRecordNotFound {
return nil, nil
} else {
return nil, myerr.WrapErr(err)
}
}
return res, nil
}
package user_m
import (
"git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/resource/mysql"
"time"
)
type UserBindInfo struct {
UserId uint64 `json:"user_id"`
Phone string `json:"phone"`
PhoneCountry string `json:"phone_country"`
Pwd string `json:"pwd"`
AreaCode string `json:"area_code"`
Icon string `json:"icon"`
CreateAt time.Time `json:"create_at"`
UpdateAt time.Time `json:"update_at"`
}
func (p *UserBindInfo) TableName() string {
return "user_bind_info"
}
type UserPhoneInfo struct {
Phone string `json:"phone"`
PhoneCountry string `json:"phoneCountry"`
AreaCode string `json:"areaCode"`
Icon string `json:"icon"`
}
func GetUserBindInfoByUserId(model *domain.Model, userId uint64) (*UserBindInfo, error) {
res := new(UserBindInfo)
err := mysql.Db.Where(&UserBindInfo{UserId: userId}).First(&res).Error
if err != nil {
return nil, err
}
return res, nil
}
package group_s
import (
"git.hilo.cn/hilo-common/domain"
"hilo-group/_const/enum/msg_e"
"hilo-group/domain/model/group_m"
"hilo-group/domain/model/res_m"
)
func (s *GroupService) GetWelcomeText(groupInfo *group_m.GroupInfo) (string, uint64, bool, error) {
model := domain.CreateModelContext(s.svc.MyContext)
g := group_m.GroupWelcomeText{GroupId: groupInfo.ImGroupId}
gwt, err := g.Get(model.Db)
if err != nil {
return "", 0, false, err
}
if gwt == nil {
// 通过国家推断语言
lang, err := res_m.GetLangeByCountry(model.Db, groupInfo.Country)
if err != nil {
return "", 0, false, err
}
resMul, err := res_m.GetResMultiTextBy(model.Db, msg_e.MSG_ID_GROUP_WELCOME, lang)
if err != nil {
return "", 0, false, err
}
return resMul.Content, groupInfo.Owner, true, nil
} else {
return gwt.Text, gwt.UserId, false, nil
}
}
......@@ -391,7 +391,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
}
model.Log.Infof("GetGroupDetail, after GetGroupTop3Consume: +%v", result)
result.WelcomeText, _, _, err = myService.GetWelcomeText(groupInfo)
result.WelcomeText, _, _, err = group_s.NewGroupService(myContext).GetWelcomeText(groupInfo)
if err != nil {
return myContext, err
}
......@@ -488,7 +488,7 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, err
}
*/
superManagerMap, err := cv.GetSuperManagerMap(userIds)
superManagerMap, err := user_m.GetSuperManagerMap(userIds)
if err != nil {
return myContext, err
}
......@@ -497,8 +497,8 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
for u, _ := range users {
m := users[u]
result.RoleMembers = append(result.RoleMembers, cv.RoleMemberInfo{
CvUserBase: cv.CvUserBase{
result.RoleMembers = append(result.RoleMembers, group_cv.RoleMemberInfo{
CvUserBase: user_cv.CvUserBase{
Avatar: &m.Avatar,
ExternalId: &m.ExternalId,
Nick: &m.Nick,
......@@ -530,20 +530,20 @@ func GetGroupDetail(c *gin.Context) (*mycontext.MyContext, error) {
})
// 截取前N个
endPos := common.GROUP_ROLE_VIEW_LIMIT
endPos := group_e.GROUP_ROLE_VIEW_LIMIT
if endPos > len(result.RoleMembers) {
endPos = len(result.RoleMembers)
}
result.RoleMembers = result.RoleMembers[0:endPos]
// todo: 直接用全量接口,只为方便
supportLevels, err := myService.GetWeekMaxSupportLevelMap()
supportLevels, err := group_s.NewGroupService(myContext).GetWeekMaxSupportLevelMap()
if err != nil {
return myContext, err
}
result.SupportLevel = supportLevels[groupId]
ResponseOk(c, result)
resp.ResponseOk(c, result)
return myContext, nil
}
......@@ -25,7 +25,7 @@ func InitRouter() *gin.Engine {
imGroup.POST("/group", wrapper(group_r.CreateGroup))
imGroup.DELETE("/group/:groupId", wrapper(group_r.DestroyGroup))
imGroup.GET("/group/:code", wrapper(group_r.GetGroupInfo))
imGroup.GET("/detail/:groupId", wrapper(GetGroupDetail))
imGroup.GET("/detail/:groupId", wrapper(group_r.GetGroupDetail))
//imGroup.PUT("/group/:groupId", wrapper(ModifyGroupInfo))
//imGroup.GET("/search/:code", wrapper(SearchGroup))
//imGroup.DELETE("/member/:groupId", wrapper(LeaveGroup))
......
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