增加casdoor的接口

This commit is contained in:
ayflying
2025-09-18 11:04:27 +08:00
parent 70a5b3db89
commit 6f3555a14f
6 changed files with 101 additions and 1 deletions

4
go.mod
View File

@@ -5,6 +5,7 @@ go 1.24.0
require (
github.com/apolloconfig/agollo/v4 v4.4.0
github.com/ayflying/excel2json v1.1.9
github.com/casdoor/casdoor-go-sdk v1.20.0
github.com/elastic/go-elasticsearch/v8 v8.18.0
github.com/go-pay/crypto v0.0.1
github.com/go-pay/gopay v1.5.109
@@ -12,6 +13,7 @@ require (
github.com/goccy/go-json v0.10.5
github.com/gogf/gf/contrib/config/apollo/v2 v2.9.0
github.com/gogf/gf/v2 v2.9.0
github.com/google/uuid v1.6.0
github.com/lionsoul2014/ip2region/binding/golang v0.0.0-20241220152942-06eb5c6e8230
github.com/minio/minio-go/v7 v7.0.91
github.com/prometheus/client_golang v1.22.0
@@ -40,9 +42,9 @@ require (
github.com/go-pay/smap v0.0.2 // indirect
github.com/go-pay/xlog v0.0.3 // indirect
github.com/go-pay/xtime v0.0.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
github.com/gorilla/websocket v1.5.3 // indirect
github.com/grokify/html-strip-tags-go v0.1.0 // indirect

4
go.sum
View File

@@ -56,6 +56,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM=
github.com/casdoor/casdoor-go-sdk v1.20.0 h1:Xr8vzs25a0QzsLfs99x9kLoHkYznCa1Lf5nEvks9GLI=
github.com/casdoor/casdoor-go-sdk v1.20.0/go.mod h1:cMnkCQJgMYpgAlgEx8reSt1AVaDIQLcJ1zk5pzBaz+4=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs=
github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
@@ -129,6 +131,8 @@ github.com/gogf/gf/contrib/config/apollo/v2 v2.9.0/go.mod h1:uNjaJcnMvMl7bkcoL0a
github.com/gogf/gf/v2 v2.9.0 h1:semN5Q5qGjDQEv4620VzxcJzJlSD07gmyJ9Sy9zfbHk=
github.com/gogf/gf/v2 v2.9.0/go.mod h1:sWGQw+pLILtuHmbOxoe0D+0DdaXxbleT57axOLH2vKI=
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
github.com/golang-jwt/jwt/v4 v4.5.0 h1:7cYmW1XlMY7h7ii7UhUyChSgS5wUJEnm9uZVTGqOWzg=
github.com/golang-jwt/jwt/v4 v4.5.0/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=

View File

@@ -0,0 +1,60 @@
package casdoor
import (
"github.com/ayflying/utility_go/service"
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
)
type sCasdoor struct {
client *casdoorsdk.Client
config *casdoorsdk.AuthConfig
}
func init() {
var casdoor = &sCasdoor{}
service.RegisterCasdoor(New(casdoor))
}
func New(s *sCasdoor) *sCasdoor {
return s
}
func (s *sCasdoor) Load(endpoint string, clientId string, clientSecret string, certificate string, organizationName string, applicationName string) {
s.config = &casdoorsdk.AuthConfig{
Endpoint: endpoint,
ClientId: clientId,
ClientSecret: clientSecret,
Certificate: certificate,
OrganizationName: organizationName,
ApplicationName: applicationName,
}
}
func (s *sCasdoor) New() *casdoorsdk.Client {
if s.config == nil {
g.Log().Errorf(gctx.New(), "未读取到配置请先加载Load方法")
return nil
}
s.client = casdoorsdk.NewClient(
s.config.Endpoint,
s.config.ClientId,
s.config.ClientSecret,
s.config.Certificate,
s.config.OrganizationName,
s.config.ApplicationName,
)
return s.client
}
//func (s *sCasdoor) EditPassword(name, oldPassword, newPassword string) (res bool, err error) {
// res, err = s.client.SetPassword(s.config.OrganizationName, name, oldPassword, newPassword)
// return
//}
//
//func (s *sCasdoor) Edit() {
// s.client.GetGroups()
//
//}

View File

@@ -5,6 +5,7 @@
package logic
import (
_ "github.com/ayflying/utility_go/internal/logic/casdoor"
_ "github.com/ayflying/utility_go/internal/logic/gameAct"
_ "github.com/ayflying/utility_go/internal/logic/gameKv"
_ "github.com/ayflying/utility_go/internal/logic/ip2region"

32
service/casdoor.go Normal file
View File

@@ -0,0 +1,32 @@
// ================================================================================
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
// You can delete these comments if you wish manually maintain this interface file.
// ================================================================================
package service
import (
"github.com/casdoor/casdoor-go-sdk/casdoorsdk"
)
type (
ICasdoor interface {
Load(endpoint string, clientId string, clientSecret string, certificate string, organizationName string, applicationName string)
New() *casdoorsdk.Client
}
)
var (
localCasdoor ICasdoor
)
func Casdoor() ICasdoor {
if localCasdoor == nil {
panic("implement not found for interface ICasdoor, forgot register?")
}
return localCasdoor
}
func RegisterCasdoor(i ICasdoor) {
localCasdoor = i
}

View File

@@ -53,6 +53,7 @@ type (
// @Description: 保存游戏活动数据
// @receiver s *sGameAct: 游戏活动服务结构体指针
// @return err error: 返回错误信息
// SavesV2 保存游戏活动数据
SavesV2() (err error)
// SaveV2 保存游戏活动数据
//