fix: 接口返回值参数驼峰

This commit is contained in:
骑着蜗牛追导弹 2024-11-09 21:27:39 +08:00
parent b39b699770
commit 3cad8d369e
2 changed files with 28 additions and 16 deletions

View File

@ -10,8 +10,8 @@ import (
) )
type ResolveVersion struct { type ResolveVersion struct {
Id int `xorm:"pk not null integer 'id' autoincr"` Id int `xorm:"pk not null integer 'id' autoincr" json:"id"`
CurrentVersion int `xorm:"not null integer 'curr_version'"` CurrentVersion int `xorm:"not null integer 'curr_version'" json:"currentVersion"`
} }
func (ResolveVersion) TableName() string { func (ResolveVersion) TableName() string {

View File

@ -13,25 +13,41 @@ import (
) )
type ResolveRecord struct { type ResolveRecord struct {
Id int `xorm:"pk not null integer 'id' autoincr"` Id int `xorm:"pk not null integer 'id' autoincr" json:"id"`
Name string `xorm:"not null text 'name'"` Name string `xorm:"not null text 'name'" json:"name"`
RecordType string `xorm:"not null text 'record_type'"` RecordType string `xorm:"not null text 'record_type'" json:"recordType"`
Ttl int `xorm:"not null integer 'ttl'"` Ttl int `xorm:"not null integer 'ttl'" json:"ttl"`
Value string `xorm:"not null text 'value'"` Value string `xorm:"not null text 'value'" json:"value"`
Version int `xorm:"not null integer 'version'"` Version int `xorm:"not null integer 'version'" json:"version"`
} }
func (ResolveRecord) TableName() string { func (ResolveRecord) TableName() string {
return "resolve_record" return "resolve_record"
} }
func FindResolveRecordById(id int) ResolveRecord { func FindResolveRecordById(id int) *ResolveRecord {
var record ResolveRecord var record ResolveRecord
_, err := Engine.Table("resolve_record").Where("`id` = ?", id).Get(&record) _, err := Engine.Table("resolve_record").Where("`id` = ?", id).Get(&record)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return nil
} }
return record return &record
}
func FindOneResolveRecord(wrapper *ResolveRecord, version int) *ResolveRecord {
var record ResolveRecord
_, err := Engine.Table("resolve_record").Where("`name` = ? and `record_type` = ? and `value` = ? and `version` = ?",
wrapper.Name,
wrapper.RecordType,
wrapper.Value,
version,
).Get(&record)
if err != nil {
fmt.Println(err)
return nil
}
return &record
} }
func FindResolveRecordByVersion(version int) []ResolveRecord { func FindResolveRecordByVersion(version int) []ResolveRecord {
@ -154,12 +170,8 @@ func IsResolveRecordExistById(id int) bool {
} }
func IsUpdResolveRecordExist(id int, wrapper *ResolveRecord) bool { func IsUpdResolveRecordExist(id int, wrapper *ResolveRecord) bool {
r := new(ResolveRecord) wrapper.Version = GetResolveVersion()
r.Name = wrapper.Name count, err := Engine.Table("resolve_record").Where("id != ?", id).Count(wrapper)
r.RecordType = wrapper.RecordType
r.Value = wrapper.Value
r.Version = GetResolveVersion()
count, err := Engine.Table("resolve_record").Where("id != ?", id).Count(r)
if err != nil { if err != nil {
fmt.Println(err) fmt.Println(err)
return false return false