Skip to content

Commit b2803f5

Browse files
authored
chore: Remove some unused code (#11105)
1 parent bbc14bb commit b2803f5

File tree

11 files changed

+2
-133
lines changed

11 files changed

+2
-133
lines changed

agent/app/api/v2/database_mysql.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -194,24 +194,6 @@ func (b *BaseApi) SearchMysql(c *gin.Context) {
194194
})
195195
}
196196

197-
// @Tags Database Mysql
198-
// @Summary List mysql database names
199-
// @Accept json
200-
// @Param request body dto.PageInfo true "request"
201-
// @Success 200 {array} dto.MysqlOption
202-
// @Security ApiKeyAuth
203-
// @Security Timestamp
204-
// @Router /databases/options [get]
205-
func (b *BaseApi) ListDBName(c *gin.Context) {
206-
list, err := mysqlService.ListDBOption()
207-
if err != nil {
208-
helper.InternalServer(c, err)
209-
return
210-
}
211-
212-
helper.SuccessWithData(c, list)
213-
}
214-
215197
// @Tags Database Mysql
216198
// @Summary List mysql database format collation options
217199
// @Accept json

agent/utils/cloud_storage/client/helper/webdav/auth.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
7272
return az
7373
}
7474

75-
func NewEmptyAuth() Authorizer {
76-
fmap := make([]authfactory, 0)
77-
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
78-
return az
79-
}
80-
81-
func NewPreemptiveAuth(auth Authenticator) Authorizer {
82-
return &preemptiveAuthorizer{auth: auth}
83-
}
84-
8575
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
8676
var retryBuf io.Reader = body
8777
if body != nil {
@@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
296286
func (n *nullAuth) String() string {
297287
return "NullAuth"
298288
}
299-
300-
func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
301-
return b.auth.Clone(), body
302-
}
303-
304-
func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
305-
panic("You're funny! A preemptive authorizer may only have a single authentication method")
306-
}

agent/utils/cloud_storage/client/helper/webdav/utils.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package webdav
22

33
import (
4-
"bytes"
54
"encoding/xml"
65
"io"
76
"net/url"
@@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
6362
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
6463
}
6564

66-
func String(r io.Reader) string {
67-
buf := new(bytes.Buffer)
68-
// TODO - make String return an error as well
69-
_, _ = buf.ReadFrom(r)
70-
return buf.String()
71-
}
72-
7365
func parseInt64(s *string) int64 {
7466
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
7567
return n

core/app/api/v2/auth.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,6 @@ func (b *BaseApi) Captcha(c *gin.Context) {
118118
helper.SuccessWithData(c, captcha)
119119
}
120120

121-
func (b *BaseApi) GetResponsePage(c *gin.Context) {
122-
pageCode, err := authService.GetResponsePage()
123-
if err != nil {
124-
helper.InternalServer(c, err)
125-
return
126-
}
127-
helper.SuccessWithData(c, pageCode)
128-
}
129-
130121
func (b *BaseApi) GetWelcomePage(c *gin.Context) {
131122
count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}})
132123
if count != 1 {

core/app/api/v2/upgrade.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -79,25 +79,3 @@ func (b *BaseApi) Upgrade(c *gin.Context) {
7979
}
8080
helper.Success(c)
8181
}
82-
83-
// @Tags System Setting
84-
// @Summary Upgrade
85-
// @Accept json
86-
// @Param request body dto.OperateByID true "request"
87-
// @Success 200
88-
// @Security ApiKeyAuth
89-
// @Security Timestamp
90-
// @Router /core/settings/rollback [post]
91-
// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"upgrade_logs","output_column":"old_version","output_value":"version"}],"formatZH":"回滚系统 => [version]","formatEN":"rollback system => [version]"}
92-
func (b *BaseApi) Rollback(c *gin.Context) {
93-
var req dto.OperateByID
94-
if err := helper.CheckBindAndValidate(&req, c); err != nil {
95-
return
96-
}
97-
98-
if err := upgradeService.Rollback(req); err != nil {
99-
helper.InternalServer(c, err)
100-
return
101-
}
102-
helper.Success(c)
103-
}

core/app/repo/common.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,6 @@ func WithByNode(node string) global.DBOption {
6060
return g.Where("node = ?", node)
6161
}
6262
}
63-
func WithByGroupBelong(group string) global.DBOption {
64-
return func(g *gorm.DB) *gorm.DB {
65-
return g.Where("group_belong = ?", group)
66-
}
67-
}
6863

6964
func WithOrderBy(orderStr string) global.DBOption {
7065
if orderStr == "createdAt" {

core/app/repo/host.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ type IHostRepo interface {
2020
WithByInfo(info string) global.DBOption
2121
WithByPort(port uint) global.DBOption
2222
WithByUser(user string) global.DBOption
23-
WithByAddr(addr string) global.DBOption
2423
}
2524

2625
func NewIHostRepo() IHostRepo {
@@ -79,11 +78,6 @@ func (h *HostRepo) WithByUser(user string) global.DBOption {
7978
return g.Where("user = ?", user)
8079
}
8180
}
82-
func (h *HostRepo) WithByAddr(addr string) global.DBOption {
83-
return func(g *gorm.DB) *gorm.DB {
84-
return g.Where("addr = ?", addr)
85-
}
86-
}
8781

8882
func (h *HostRepo) Create(host *model.Host) error {
8983
return global.DB.Create(host).Error

core/app/service/host.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func (u *HostService) TestByInfo(req dto.HostConnTest) bool {
5050
req.PrivateKey = string(privateKey)
5151
}
5252
if len(req.Password) == 0 && len(req.PrivateKey) == 0 {
53-
host, err := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
53+
host, err := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
5454
if err != nil {
5555
return false
5656
}
@@ -235,7 +235,7 @@ func (u *HostService) GetHostByID(id uint) (*dto.HostInfo, error) {
235235
}
236236

237237
func (u *HostService) Create(req dto.HostOperate) (*dto.HostInfo, error) {
238-
hostItem, _ := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
238+
hostItem, _ := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
239239
if hostItem.ID != 0 {
240240
return nil, buserr.New("ErrRecordExist")
241241
}

core/utils/cloud_storage/client/helper/webdav/auth.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
7272
return az
7373
}
7474

75-
func NewEmptyAuth() Authorizer {
76-
fmap := make([]authfactory, 0)
77-
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
78-
return az
79-
}
80-
81-
func NewPreemptiveAuth(auth Authenticator) Authorizer {
82-
return &preemptiveAuthorizer{auth: auth}
83-
}
84-
8575
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
8676
var retryBuf io.Reader = body
8777
if body != nil {
@@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
296286
func (n *nullAuth) String() string {
297287
return "NullAuth"
298288
}
299-
300-
func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
301-
return b.auth.Clone(), body
302-
}
303-
304-
func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
305-
panic("You're funny! A preemptive authorizer may only have a single authentication method")
306-
}

core/utils/cloud_storage/client/helper/webdav/utils.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package webdav
22

33
import (
4-
"bytes"
54
"encoding/xml"
65
"io"
76
"net/url"
@@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
6362
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
6463
}
6564

66-
func String(r io.Reader) string {
67-
buf := new(bytes.Buffer)
68-
// TODO - make String return an error as well
69-
_, _ = buf.ReadFrom(r)
70-
return buf.String()
71-
}
72-
7365
func parseInt64(s *string) int64 {
7466
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
7567
return n

0 commit comments

Comments
 (0)