-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from sunmi-OS/docs
feat: update
- Loading branch information
Showing
14 changed files
with
100 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,10 @@ | ||
<%: func FromConfBase(buffer *bytes.Buffer) %> | ||
<%: func FromConfBase(baseConf string,buffer *bytes.Buffer) %> | ||
package conf | ||
|
||
var BaseConfig = ` | ||
[network] | ||
ApiServiceHost = "<%== goCoreConfig.HttpApis.Host %>" | ||
ApiServicePort = "<%== goCoreConfig.HttpApis.Port %>" | ||
|
||
<%== baseConf %> | ||
` |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<%: func FromConfLocal(env,content string,buffer *bytes.Buffer) %> | ||
package conf | ||
|
||
var <%== env %> = `<%== content %>` | ||
var <%== env %> = `<%== content %> | ||
` | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,13 @@ | ||
<%: func FromModelTable(dbName, tableStruct, tableName, fields string, buffer *bytes.Buffer) %> | ||
package <%== dbName %> | ||
|
||
import ( | ||
gormx "gorm.io/gorm" | ||
) | ||
|
||
var <%== tableStruct %>Handler = &<%== tableStruct %>{} | ||
|
||
type <%== tableStruct %> struct { | ||
<%== fields %> | ||
} | ||
|
||
func (* <%== tableStruct %>) Insert(db *gormx.DB, data * <%== tableStruct %>) error { | ||
if db == nil { | ||
db = Orm() | ||
} | ||
return db.Create(data).Error | ||
} | ||
|
||
func (* <%== tableStruct %>) ButchInsert(db *gormx.DB, data []* <%== tableStruct %>) error { | ||
if db == nil { | ||
db = Orm() | ||
} | ||
return db.Create(&data).Error | ||
} | ||
|
||
func (* <%== tableStruct %>) GetOne(where string, args ...interface{}) (* <%== tableStruct %>, error) { | ||
var obj <%== tableStruct %> | ||
return &obj, Orm().Where(where, args...).Take(&obj).Error | ||
} | ||
|
||
func (* <%== tableStruct %>) GetList(where string, args ...interface{}) ([]* <%== tableStruct %>, error) { | ||
var list []*<%== tableStruct %> | ||
db := Orm() | ||
return list, db.Where(where, args...).Find(&list).Error | ||
} | ||
|
||
func (* <%== tableStruct %>) GetCount(where string, args ...interface{}) (int64, error) { | ||
var number int64 | ||
err := Orm().Model(&<%== tableStruct %>{}).Where(where, args...).Count(&number).Error | ||
return number, err | ||
} | ||
|
||
func (* <%== tableStruct %>) Delete(db *gormx.DB, where string, args ...interface{}) error { | ||
if db == nil { | ||
db = Orm() | ||
} | ||
return db.Where(where, args...).Delete(&<%== tableStruct %>{}).Error | ||
func (* <%== tableStruct %>) TableName() string { | ||
return "<%== tableName %>" | ||
} | ||
|
||
func (*<%== tableStruct %>) Update(db *gormx.DB, data map[string]interface{}, where string, args ...interface{}) (int64, error) { | ||
if db == nil { | ||
db = Orm() | ||
} | ||
db = db.Model(&<%== tableStruct %>{}).Where(where, args...).Updates(data) | ||
return db.RowsAffected, db.Error | ||
} |
Oops, something went wrong.