chore: Remove some unused code (#11105)

This commit is contained in:
ssongliu 2025-11-27 17:59:48 +08:00 committed by GitHub
parent bbc14bb723
commit b2803f574b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 2 additions and 133 deletions

View file

@ -194,24 +194,6 @@ func (b *BaseApi) SearchMysql(c *gin.Context) {
})
}
// @Tags Database Mysql
// @Summary List mysql database names
// @Accept json
// @Param request body dto.PageInfo true "request"
// @Success 200 {array} dto.MysqlOption
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /databases/options [get]
func (b *BaseApi) ListDBName(c *gin.Context) {
list, err := mysqlService.ListDBOption()
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, list)
}
// @Tags Database Mysql
// @Summary List mysql database format collation options
// @Accept json

View file

@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
return az
}
func NewEmptyAuth() Authorizer {
fmap := make([]authfactory, 0)
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
return az
}
func NewPreemptiveAuth(auth Authenticator) Authorizer {
return &preemptiveAuthorizer{auth: auth}
}
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
var retryBuf io.Reader = body
if body != nil {
@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
func (n *nullAuth) String() string {
return "NullAuth"
}
func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
return b.auth.Clone(), body
}
func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
panic("You're funny! A preemptive authorizer may only have a single authentication method")
}

View file

@ -1,7 +1,6 @@
package webdav
import (
"bytes"
"encoding/xml"
"io"
"net/url"
@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
}
func String(r io.Reader) string {
buf := new(bytes.Buffer)
// TODO - make String return an error as well
_, _ = buf.ReadFrom(r)
return buf.String()
}
func parseInt64(s *string) int64 {
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
return n

View file

@ -118,15 +118,6 @@ func (b *BaseApi) Captcha(c *gin.Context) {
helper.SuccessWithData(c, captcha)
}
func (b *BaseApi) GetResponsePage(c *gin.Context) {
pageCode, err := authService.GetResponsePage()
if err != nil {
helper.InternalServer(c, err)
return
}
helper.SuccessWithData(c, pageCode)
}
func (b *BaseApi) GetWelcomePage(c *gin.Context) {
count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}})
if count != 1 {

View file

@ -79,25 +79,3 @@ func (b *BaseApi) Upgrade(c *gin.Context) {
}
helper.Success(c)
}
// @Tags System Setting
// @Summary Upgrade
// @Accept json
// @Param request body dto.OperateByID true "request"
// @Success 200
// @Security ApiKeyAuth
// @Security Timestamp
// @Router /core/settings/rollback [post]
// @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]"}
func (b *BaseApi) Rollback(c *gin.Context) {
var req dto.OperateByID
if err := helper.CheckBindAndValidate(&req, c); err != nil {
return
}
if err := upgradeService.Rollback(req); err != nil {
helper.InternalServer(c, err)
return
}
helper.Success(c)
}

View file

@ -60,11 +60,6 @@ func WithByNode(node string) global.DBOption {
return g.Where("node = ?", node)
}
}
func WithByGroupBelong(group string) global.DBOption {
return func(g *gorm.DB) *gorm.DB {
return g.Where("group_belong = ?", group)
}
}
func WithOrderBy(orderStr string) global.DBOption {
if orderStr == "createdAt" {

View file

@ -20,7 +20,6 @@ type IHostRepo interface {
WithByInfo(info string) global.DBOption
WithByPort(port uint) global.DBOption
WithByUser(user string) global.DBOption
WithByAddr(addr string) global.DBOption
}
func NewIHostRepo() IHostRepo {
@ -79,11 +78,6 @@ func (h *HostRepo) WithByUser(user string) global.DBOption {
return g.Where("user = ?", user)
}
}
func (h *HostRepo) WithByAddr(addr string) global.DBOption {
return func(g *gorm.DB) *gorm.DB {
return g.Where("addr = ?", addr)
}
}
func (h *HostRepo) Create(host *model.Host) error {
return global.DB.Create(host).Error

View file

@ -50,7 +50,7 @@ func (u *HostService) TestByInfo(req dto.HostConnTest) bool {
req.PrivateKey = string(privateKey)
}
if len(req.Password) == 0 && len(req.PrivateKey) == 0 {
host, err := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
host, err := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByPort(req.Port))
if err != nil {
return false
}
@ -235,7 +235,7 @@ func (u *HostService) GetHostByID(id uint) (*dto.HostInfo, error) {
}
func (u *HostService) Create(req dto.HostOperate) (*dto.HostInfo, error) {
hostItem, _ := hostRepo.Get(hostRepo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
hostItem, _ := hostRepo.Get(repo.WithByAddr(req.Addr), hostRepo.WithByUser(req.User), hostRepo.WithByPort(req.Port))
if hostItem.ID != 0 {
return nil, buserr.New("ErrRecordExist")
}

View file

@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
return az
}
func NewEmptyAuth() Authorizer {
fmap := make([]authfactory, 0)
az := &authorizer{factories: fmap, defAuthMux: sync.Mutex{}, defAuth: &nullAuth{}}
return az
}
func NewPreemptiveAuth(auth Authenticator) Authorizer {
return &preemptiveAuthorizer{auth: auth}
}
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
var retryBuf io.Reader = body
if body != nil {
@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
func (n *nullAuth) String() string {
return "NullAuth"
}
func (b *preemptiveAuthorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
return b.auth.Clone(), body
}
func (b *preemptiveAuthorizer) AddAuthenticator(key string, fn AuthFactory) {
panic("You're funny! A preemptive authorizer may only have a single authentication method")
}

View file

@ -1,7 +1,6 @@
package webdav
import (
"bytes"
"encoding/xml"
"io"
"net/url"
@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
}
func String(r io.Reader) string {
buf := new(bytes.Buffer)
// TODO - make String return an error as well
_, _ = buf.ReadFrom(r)
return buf.String()
}
func parseInt64(s *string) int64 {
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
return n

View file

@ -31,25 +31,6 @@ func LoadDBConnByPath(fullPath, dbName string) *gorm.DB {
return db
}
func LoadDBConnByPathWithErr(fullPath, dbName string) (*gorm.DB, error) {
if _, err := CreateDirWhenNotExist(true, path.Dir(fullPath)); err != nil {
return nil, fmt.Errorf("init db dir failed, err: %v", err)
}
if _, err := os.Stat(fullPath); err != nil {
f, err := os.Create(fullPath)
if err != nil {
return nil, fmt.Errorf("init %s db file failed, err: %v", dbName, err)
}
_ = f.Close()
}
db, err := GetDBWithPath(fullPath)
if err != nil {
return nil, fmt.Errorf("init %s db failed, err: %v", dbName, err)
}
return db, nil
}
func CloseDB(db *gorm.DB) {
sqlDB, err := db.DB()
if err != nil {