Skip to content

Commit

Permalink
perf: some minor detail fixes during development
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhangSetSail committed Jan 11, 2024
1 parent c5f041d commit 48e9899
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
1 change: 1 addition & 0 deletions api/api/api_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ type AppInterface interface {
UploadID(w http.ResponseWriter, r *http.Request)
}

// LongVersionInterface long version interface
type LongVersionInterface interface {
UploadLongVersion(w http.ResponseWriter, r *http.Request)
OptionLongVersion(w http.ResponseWriter, r *http.Request)
Expand Down
7 changes: 0 additions & 7 deletions api/controller/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -473,13 +473,6 @@ func (c *ClusterController) GetLangVersion(w http.ResponseWriter, r *http.Reques
httputil.ReturnBcodeError(r, w, fmt.Errorf("update lang version failure: %v", err))
return
}
//if versions != nil && len(versions) == 0 {
// versions, err = db.GetManager().LongVersionDao().InitLanguageVersion(language)
// if err != nil {
// httputil.ReturnBcodeError(r, w, fmt.Errorf("failed to get language pack version"))
// return
// }
//}
httputil.ReturnSuccess(r, w, versions)
}

Expand Down
5 changes: 5 additions & 0 deletions api/controller/lg_pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import (
// LongVersionStruct -
type LongVersionStruct struct{}

// BaseUploadPath lang version base dir
const BaseUploadPath = "/grdata/lang"

// UploadLongVersion -
func (t *LongVersionStruct) UploadLongVersion(w http.ResponseWriter, r *http.Request) {
//从表单中读取文件
file, fileHeader, err := r.FormFile("file")
Expand Down Expand Up @@ -69,6 +71,7 @@ func (t *LongVersionStruct) UploadLongVersion(w http.ResponseWriter, r *http.Req
sendResponse(w, http.StatusOK, "successful", long)
}

// DownloadLongVersion -
func (t *LongVersionStruct) DownloadLongVersion(w http.ResponseWriter, r *http.Request) {
language := strings.TrimSpace(chi.URLParam(r, "language"))
version := strings.TrimSpace(chi.URLParam(r, "version"))
Expand All @@ -80,6 +83,7 @@ func (t *LongVersionStruct) DownloadLongVersion(w http.ResponseWriter, r *http.R
http.ServeFile(w, r, path.Join(BaseUploadPath, ver.EventID, ver.FileName))
}

// OptionLongVersion -
func (t *LongVersionStruct) OptionLongVersion(w http.ResponseWriter, r *http.Request) {
origin := r.Header.Get("Origin")
w.Header().Add("Access-Control-Allow-Origin", origin)
Expand All @@ -102,6 +106,7 @@ func generateRandomString(n int) (string, error) {
return string(bytes), nil
}

// APIResponse =
type APIResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Expand Down
1 change: 1 addition & 0 deletions api/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -2243,6 +2243,7 @@ type UploadChartValueYaml struct {
Readme string `json:"readme"`
}

// UpdateLangVersion -
type UpdateLangVersion struct {
Lang string `json:"lang"`
Version string `json:"version"`
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@ func ShowVersion(module string) {

// GetVersion GetVersion
func GetVersion() string {
return "tstt"
return version
}
4 changes: 4 additions & 0 deletions db/mysql/dao/lg_pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ func (t *LongVersionDaoImpl) ListVersionByLanguage(language string) ([]*model.En
return versions, nil
}

// GetVersionByLanguageAndVersion -
func (t *LongVersionDaoImpl) GetVersionByLanguageAndVersion(language, version string) (*model.EnterpriseLanguageVersion, error) {
ver := new(model.EnterpriseLanguageVersion)
if err := t.DB.Where("lang = ? and version = ?", language, version).Find(ver).Error; err != nil {
Expand All @@ -46,6 +47,7 @@ func (t *LongVersionDaoImpl) GetVersionByLanguageAndVersion(language, version st
return ver, nil
}

// DefaultLangVersion -
func (t *LongVersionDaoImpl) DefaultLangVersion(lang string, version string) error {
defaultVersion := new(model.EnterpriseLanguageVersion)
if err := t.DB.Debug().Where("lang = ? AND first_choice = ?", lang, true).Find(defaultVersion).Error; err != nil {
Expand Down Expand Up @@ -73,6 +75,7 @@ func (t *LongVersionDaoImpl) DefaultLangVersion(lang string, version string) err
return nil
}

// CreateLangVersion -
func (t *LongVersionDaoImpl) CreateLangVersion(lang, version, eventID, fileName string) error {
ver := new(model.EnterpriseLanguageVersion)
err := t.DB.Where("lang = ? and version = ?", lang, version).Find(ver).Error
Expand All @@ -92,6 +95,7 @@ func (t *LongVersionDaoImpl) CreateLangVersion(lang, version, eventID, fileName
return err
}

// DeleteLangVersion -
func (t *LongVersionDaoImpl) DeleteLangVersion(lang, version string) (string, error) {
ver := new(model.EnterpriseLanguageVersion)
if err := t.DB.Where("lang = ? and version = ?", lang, version).Find(ver).Error; err != nil {
Expand Down
19 changes: 19 additions & 0 deletions db/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ func (m *Manager) initLanguageVersion() {
}
}

// GolangInitVersion -
var GolangInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "golang",
Expand Down Expand Up @@ -354,6 +355,8 @@ var GolangInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "go1.12.17.tar.gz",
},
}

// OpenJDKInitVersion -
var OpenJDKInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "openJDK",
Expand Down Expand Up @@ -418,6 +421,8 @@ var OpenJDKInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "OpenJDK1.8.tar.gz",
},
}

// PythonInitVersion -
var PythonInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "python",
Expand Down Expand Up @@ -457,6 +462,8 @@ var PythonInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "Python2.7.18.tar.gz",
},
}

// MavenInitVersion -
var MavenInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "maven",
Expand Down Expand Up @@ -502,6 +509,8 @@ var MavenInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "Maven3.1.1.tar.gz",
},
}

// PHPInitVersion -
var PHPInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "php",
Expand All @@ -517,6 +526,8 @@ var PHPInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "php8.1.18.tar.gz",
},
}

// NodeInitVersion -
var NodeInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "node",
Expand Down Expand Up @@ -586,6 +597,8 @@ var NodeInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "Node11.15.0.tar.gz",
},
}

// WebCompilerInitVersion -
var WebCompilerInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "web_compiler",
Expand Down Expand Up @@ -625,6 +638,8 @@ var WebCompilerInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "jetty9.tar.gz",
},
}

// WebRuntimeInitVersion -
var WebRuntimeInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "web_runtime",
Expand All @@ -640,6 +655,8 @@ var WebRuntimeInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "apache-2.2.19.tar.gz",
},
}

// NetCompilerInitVersion -
var NetCompilerInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "net_compiler",
Expand All @@ -655,6 +672,8 @@ var NetCompilerInitVersion = []*model.EnterpriseLanguageVersion{
FileName: "mcr.microsoft.com/dotnet/sdk:2.1-sdk-alpine",
},
}

// NetRuntimeInitVersion -
var NetRuntimeInitVersion = []*model.EnterpriseLanguageVersion{
{
Lang: "net_runtime",
Expand Down

0 comments on commit 48e9899

Please sign in to comment.