mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-12-18 13:29:03 +08:00
chore: Remove some unused code (#11105)
This commit is contained in:
parent
bbc14bb723
commit
b2803f574b
11 changed files with 2 additions and 133 deletions
|
|
@ -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
|
// @Tags Database Mysql
|
||||||
// @Summary List mysql database format collation options
|
// @Summary List mysql database format collation options
|
||||||
// @Accept json
|
// @Accept json
|
||||||
|
|
|
||||||
|
|
@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
|
||||||
return az
|
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) {
|
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
|
||||||
var retryBuf io.Reader = body
|
var retryBuf io.Reader = body
|
||||||
if body != nil {
|
if body != nil {
|
||||||
|
|
@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
|
||||||
func (n *nullAuth) String() string {
|
func (n *nullAuth) String() string {
|
||||||
return "NullAuth"
|
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")
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package webdav
|
package webdav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
|
||||||
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
|
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 {
|
func parseInt64(s *string) int64 {
|
||||||
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
|
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
|
||||||
return n
|
return n
|
||||||
|
|
|
||||||
|
|
@ -118,15 +118,6 @@ func (b *BaseApi) Captcha(c *gin.Context) {
|
||||||
helper.SuccessWithData(c, captcha)
|
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) {
|
func (b *BaseApi) GetWelcomePage(c *gin.Context) {
|
||||||
count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}})
|
count, _, _ := logService.PageLoginLog(c, dto.SearchLgLogWithPage{PageInfo: dto.PageInfo{Page: 1, PageSize: 10}})
|
||||||
if count != 1 {
|
if count != 1 {
|
||||||
|
|
|
||||||
|
|
@ -79,25 +79,3 @@ func (b *BaseApi) Upgrade(c *gin.Context) {
|
||||||
}
|
}
|
||||||
helper.Success(c)
|
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)
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -60,11 +60,6 @@ func WithByNode(node string) global.DBOption {
|
||||||
return g.Where("node = ?", node)
|
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 {
|
func WithOrderBy(orderStr string) global.DBOption {
|
||||||
if orderStr == "createdAt" {
|
if orderStr == "createdAt" {
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@ type IHostRepo interface {
|
||||||
WithByInfo(info string) global.DBOption
|
WithByInfo(info string) global.DBOption
|
||||||
WithByPort(port uint) global.DBOption
|
WithByPort(port uint) global.DBOption
|
||||||
WithByUser(user string) global.DBOption
|
WithByUser(user string) global.DBOption
|
||||||
WithByAddr(addr string) global.DBOption
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewIHostRepo() IHostRepo {
|
func NewIHostRepo() IHostRepo {
|
||||||
|
|
@ -79,11 +78,6 @@ func (h *HostRepo) WithByUser(user string) global.DBOption {
|
||||||
return g.Where("user = ?", user)
|
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 {
|
func (h *HostRepo) Create(host *model.Host) error {
|
||||||
return global.DB.Create(host).Error
|
return global.DB.Create(host).Error
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ func (u *HostService) TestByInfo(req dto.HostConnTest) bool {
|
||||||
req.PrivateKey = string(privateKey)
|
req.PrivateKey = string(privateKey)
|
||||||
}
|
}
|
||||||
if len(req.Password) == 0 && len(req.PrivateKey) == 0 {
|
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 {
|
if err != nil {
|
||||||
return false
|
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) {
|
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 {
|
if hostItem.ID != 0 {
|
||||||
return nil, buserr.New("ErrRecordExist")
|
return nil, buserr.New("ErrRecordExist")
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -72,16 +72,6 @@ func NewAutoAuth(login string, secret string) Authorizer {
|
||||||
return az
|
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) {
|
func (a *authorizer) NewAuthenticator(body io.Reader) (Authenticator, io.Reader) {
|
||||||
var retryBuf io.Reader = body
|
var retryBuf io.Reader = body
|
||||||
if body != nil {
|
if body != nil {
|
||||||
|
|
@ -296,11 +286,3 @@ func (n *nullAuth) Clone() Authenticator {
|
||||||
func (n *nullAuth) String() string {
|
func (n *nullAuth) String() string {
|
||||||
return "NullAuth"
|
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")
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package webdav
|
package webdav
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
|
||||||
"encoding/xml"
|
"encoding/xml"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
@ -63,13 +62,6 @@ func Join(path0 string, path1 string) string {
|
||||||
return strings.TrimSuffix(path0, "/") + "/" + strings.TrimPrefix(path1, "/")
|
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 {
|
func parseInt64(s *string) int64 {
|
||||||
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
|
if n, e := strconv.ParseInt(*s, 10, 64); e == nil {
|
||||||
return n
|
return n
|
||||||
|
|
|
||||||
|
|
@ -31,25 +31,6 @@ func LoadDBConnByPath(fullPath, dbName string) *gorm.DB {
|
||||||
return 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) {
|
func CloseDB(db *gorm.DB) {
|
||||||
sqlDB, err := db.DB()
|
sqlDB, err := db.DB()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue