main #1
|
@ -40,7 +40,7 @@ type ApiListReq struct {
|
|||
}
|
||||
|
||||
type ApiListData struct {
|
||||
StreamerAuthApproval *dbstruct.StreamerAuthApproval `json:"streamer_auth_approval"`
|
||||
StreamerAuthApproval *StreamerAuthApprovalApiVO `json:"streamer_auth_approval"`
|
||||
}
|
||||
|
||||
type ApiListResp struct {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package proto
|
||||
|
||||
import "service/dbstruct"
|
||||
|
||||
type StreamerAuthApprovalApiVO struct {
|
||||
*dbstruct.StreamerAuthApproval
|
||||
UserId *int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
func (vo *StreamerAuthApprovalApiVO) CopyStreamerAuthApproval(streamerauthapproval *dbstruct.StreamerAuthApproval) *StreamerAuthApprovalApiVO {
|
||||
vo.StreamerAuthApproval = streamerauthapproval
|
||||
return vo
|
||||
}
|
||||
|
||||
func (vo *StreamerAuthApprovalApiVO) CopyAccount(account *dbstruct.Account) *StreamerAuthApprovalApiVO {
|
||||
vo.UserId = account.UserId
|
||||
return vo
|
||||
}
|
|
@ -56,9 +56,9 @@ type OpListReq struct {
|
|||
}
|
||||
|
||||
type OpListData struct {
|
||||
List []*dbstruct.StreamerAuthApproval `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
List []*StreamerAuthApprovalOpVO `json:"list"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type OpListResp struct {
|
||||
|
@ -75,9 +75,9 @@ type OpListByMidReq struct {
|
|||
}
|
||||
|
||||
type OpListByMidData struct {
|
||||
StreamerAuthApproval *dbstruct.StreamerAuthApproval `json:"streamer_auth_approval"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
StreamerAuthApproval *StreamerAuthApprovalOpVO `json:"streamer_auth_approval"`
|
||||
Offset int `json:"offset"`
|
||||
More int `json:"more"`
|
||||
}
|
||||
|
||||
type OpListByMidResp struct {
|
||||
|
|
|
@ -0,0 +1,18 @@
|
|||
package proto
|
||||
|
||||
import "service/dbstruct"
|
||||
|
||||
type StreamerAuthApprovalOpVO struct {
|
||||
*dbstruct.StreamerAuthApproval
|
||||
UserId *int64 `json:"user_id"`
|
||||
}
|
||||
|
||||
func (vo *StreamerAuthApprovalOpVO) CopyStreamerAuthApproval(streamerauthapproval *dbstruct.StreamerAuthApproval) *StreamerAuthApprovalOpVO {
|
||||
vo.StreamerAuthApproval = streamerauthapproval
|
||||
return vo
|
||||
}
|
||||
|
||||
func (vo *StreamerAuthApprovalOpVO) CopyAccount(account *dbstruct.Account) *StreamerAuthApprovalOpVO {
|
||||
vo.UserId = account.UserId
|
||||
return vo
|
||||
}
|
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"runtime"
|
||||
|
@ -21,6 +22,7 @@ import (
|
|||
"service/library/redis"
|
||||
"service/library/sms"
|
||||
"service/library/validator"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -95,7 +97,7 @@ func main() {
|
|||
validator.InitDefaultNotNullValidator()
|
||||
controller.Init(router)
|
||||
srv := &http.Server{
|
||||
Addr: fmt.Sprintf("%s:%d", cfg.App.Ip, cfg.App.Port),
|
||||
Addr: fmt.Sprintf("%s:%d", GetIp(), cfg.App.Port),
|
||||
Handler: router,
|
||||
}
|
||||
httpserver.StartHttpServer(srv, cfg.DefaultConfig)
|
||||
|
@ -107,3 +109,25 @@ func PrintAndExit(msg string) {
|
|||
time.Sleep(1) //wait logger flush
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
func GetIp() string {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
PrintAndExit("get ip fail")
|
||||
return "127.0.0.1"
|
||||
}
|
||||
retIp := ""
|
||||
for _, address := range addrs {
|
||||
// 检查ip地址判断是否回环地址
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
ip := ipnet.IP.String()
|
||||
if strings.HasPrefix(ip, "172.") {
|
||||
retIp = ip
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retIp
|
||||
}
|
||||
|
|
|
@ -145,15 +145,15 @@ func Init(r *gin.Engine) {
|
|||
apiContactCustomerServiceSessionGroup.POST("list_by_mid", middleware.JSONParamValidator(contact_customer_service_sessionproto.ApiListByMidReq{}), ApiGetContactCustomerServiceSessionListByMid)
|
||||
|
||||
// 主播标签
|
||||
apiStreamerTagGroup := r.Group("/api/streamer_tag", PrepareOp())
|
||||
apiStreamerTagGroup := r.Group("/api/streamer_tag", PrepareToC())
|
||||
apiStreamerTagGroup.POST("list", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetStreamerTagList)
|
||||
|
||||
// 平台icon
|
||||
apiPlatformGroup := r.Group("/api/platform", PrepareOp())
|
||||
apiPlatformGroup := r.Group("/api/platform", PrepareToC())
|
||||
apiPlatformGroup.POST("list", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetPlatformList)
|
||||
|
||||
// 运营微信
|
||||
apiSupportWxIdGroup := r.Group("/api/support_wx_id", PrepareOp())
|
||||
apiSupportWxIdGroup := r.Group("/api/support_wx_id", PrepareToC())
|
||||
apiSupportWxIdGroup.POST("list", middleware.JSONParamValidator(base.BaseRequest{}), middleware.JwtAuthenticator(), OpGetSupportWxIdList)
|
||||
|
||||
// 是否有新版本
|
||||
|
|
|
@ -834,7 +834,7 @@ func (s *Service) ApiDeleteStreamerAuthApproval(ctx *gin.Context, req *streamera
|
|||
return
|
||||
}
|
||||
|
||||
func (s *Service) ApiGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.ApiListReq) (streamerauthapproval *dbstruct.StreamerAuthApproval, ec errcode.ErrCode) {
|
||||
func (s *Service) ApiGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.ApiListReq) (vo *streamerauthapprovalproto.StreamerAuthApprovalApiVO, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
||||
|
||||
if ec = s.ApiGetStreamerAuthApprovalListBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerAuthApprovalSrvOk {
|
||||
|
@ -849,6 +849,20 @@ func (s *Service) ApiGetStreamerAuthApprovalList(ctx *gin.Context, req *streamer
|
|||
ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
account, err := _DefaultAccount.OpListByMid(ctx, &accountproto.OpListByMidReq{
|
||||
Mid: streamerauthapproval.Mid,
|
||||
})
|
||||
if err != nil {
|
||||
logger.Error("OpListByMid fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeAccountSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
vo = &streamerauthapprovalproto.StreamerAuthApprovalApiVO{}
|
||||
vo.CopyStreamerAuthApproval(streamerauthapproval)
|
||||
vo.CopyAccount(account)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -1232,52 +1232,7 @@ func (s *Service) OpGetAccountRelationBySentence(ctx *gin.Context, req *accountr
|
|||
return
|
||||
}
|
||||
|
||||
// StreamerAuthApproval
|
||||
// func (s *Service) OpCreateStreamerAuthApproval(ctx *gin.Context, req *streamerauthapprovalproto.OpCreateReq) (ec errcode.ErrCode) {
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
||||
// err := _DefaultStreamerAuthApproval.OpCreate(ctx, req)
|
||||
|
||||
// if mongo.IsDuplicateKeyError(err) {
|
||||
// logger.Error("OpCreate duplicate key found, req: %v, err: %v", util.ToJson(req), err)
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalDuplicateKey
|
||||
// return
|
||||
// }
|
||||
// if err != nil {
|
||||
// logger.Error("OpCreate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
|
||||
// return
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
// func (s *Service) OpUpdateStreamerAuthApproval(ctx *gin.Context, req *streamerauthapprovalproto.OpUpdateReq) (ec errcode.ErrCode) {
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
||||
// err := _DefaultStreamerAuthApproval.OpUpdate(ctx, req)
|
||||
// if err == qmgo.ErrNoSuchDocuments {
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalNotExist
|
||||
// err = nil
|
||||
// return
|
||||
// }
|
||||
// if err != nil {
|
||||
// logger.Error("OpUpdate fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
|
||||
// return
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
// func (s *Service) OpDeleteBatchStreamerAuthApproval(ctx *gin.Context, ids []int64) (ec errcode.ErrCode) {
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
||||
// err := _DefaultStreamerAuthApproval.OpDeleteBatch(ctx, ids)
|
||||
// if err != nil {
|
||||
// logger.Error("OpDeleteBatch fail, ids: %v, err: %v", ids, err)
|
||||
// ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
|
||||
// return
|
||||
// }
|
||||
// return
|
||||
// }
|
||||
|
||||
func (s *Service) OpGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.OpListReq) (list []*dbstruct.StreamerAuthApproval, ec errcode.ErrCode) {
|
||||
func (s *Service) OpGetStreamerAuthApprovalList(ctx *gin.Context, req *streamerauthapprovalproto.OpListReq) (volist []*streamerauthapprovalproto.StreamerAuthApprovalOpVO, ec errcode.ErrCode) {
|
||||
ec = errcode.ErrCodeStreamerAuthApprovalSrvOk
|
||||
|
||||
if ec = s.OpGetStreamerAuthApprovalListBusinessValidate(ctx, req); ec != errcode.ErrCodeStreamerAuthApprovalSrvOk {
|
||||
|
@ -1290,6 +1245,26 @@ func (s *Service) OpGetStreamerAuthApprovalList(ctx *gin.Context, req *streamera
|
|||
ec = errcode.ErrCodeStreamerAuthApprovalSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
//查询获得userId
|
||||
midList := make([]int64, len(list))
|
||||
for i, v := range list {
|
||||
midList[i] = util.DerefInt64(v.Mid)
|
||||
}
|
||||
_map, err := _DefaultAccount.GetAccountMapByMids(ctx, midList)
|
||||
if err != nil {
|
||||
logger.Error("GetAccountMapByMids fail, req: %v, err: %v", util.ToJson(req), err)
|
||||
ec = errcode.ErrCodeAccountSrvFail
|
||||
return
|
||||
}
|
||||
|
||||
volist = make([]*streamerauthapprovalproto.StreamerAuthApprovalOpVO, len(list))
|
||||
for i, streamerauthapproval := range list {
|
||||
volist[i] = &streamerauthapprovalproto.StreamerAuthApprovalOpVO{}
|
||||
volist[i].CopyStreamerAuthApproval(streamerauthapproval)
|
||||
volist[i].CopyAccount(_map[util.DerefInt64(volist[i].Mid)])
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,9 @@ app:
|
|||
port: 9999
|
||||
|
||||
mix_mongo:
|
||||
uri: "mongodb://dds-bp1628b447c242e41.mongodb.rds.aliyuncs.com:3717,dds-bp1628b447c242e42.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-74245203"
|
||||
username: "root"
|
||||
password: "Tbuy!vj@24vq"
|
||||
uri: "mongodb://root:Wishpal2024@dds-bp1628b447c242e41.mongodb.rds.aliyuncs.com:3717,dds-bp1628b447c242e42.mongodb.rds.aliyuncs.com:3717/admin?replicaSet=mgset-74245203"
|
||||
username: ""
|
||||
password: ""
|
||||
max_pool_size: 16
|
||||
connection_timeout_ms: 30000
|
||||
socket_timeout_ms: 5000
|
||||
|
@ -82,7 +82,7 @@ media:
|
|||
expire_time: 1800
|
||||
|
||||
redis:
|
||||
uri: "r-bp1slashewonusih6h.redis.rds.aliyuncs.com"
|
||||
uri: "r-bp1slashewonusih6h.redis.rds.aliyuncs.com:6379"
|
||||
password: "SWEbaxdt6aM@"
|
||||
max_active: 0
|
||||
max_idle: 0
|
||||
|
|
25
main.go
25
main.go
|
@ -4,10 +4,12 @@ import (
|
|||
"fmt"
|
||||
"github.com/aliyun/aliyun-oss-go-sdk/oss"
|
||||
"github.com/bwmarrin/snowflake"
|
||||
"net"
|
||||
"os"
|
||||
"service/library/configcenter"
|
||||
"service/library/redis"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
@ -18,8 +20,31 @@ func main() {
|
|||
|
||||
n, _ := snowflake.NewNode(6)
|
||||
fmt.Println(n.Generate().Time())
|
||||
|
||||
fmt.Println(GetIp())
|
||||
}
|
||||
|
||||
func GetIp() string {
|
||||
addrs, err := net.InterfaceAddrs()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return "127.0.0.1"
|
||||
}
|
||||
retIp := ""
|
||||
for _, address := range addrs {
|
||||
// 检查ip地址判断是否回环地址
|
||||
if ipnet, ok := address.(*net.IPNet); ok && !ipnet.IP.IsLoopback() {
|
||||
if ipnet.IP.To4() != nil {
|
||||
ip := ipnet.IP.String()
|
||||
if strings.HasPrefix(ip, "172.") {
|
||||
retIp = ip
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return retIp
|
||||
}
|
||||
func UploadImage() {
|
||||
// yourEndpoint填写Bucket对应的Endpoint,以华东1(杭州)为例,填写为https://oss-cn-hangzhou.aliyuncs.com。其它Region请按实际情况填写。
|
||||
// yourAccessKeyId以及yourAccessKeySecret分别填写从STS服务获取的临时访问密钥(AccessKey ID和AccessKey Secret)。
|
||||
|
|
Loading…
Reference in New Issue