i18n: Translate all Chinese to English across the codebase
Translate Chinese comments, log/error messages, validator labels and Swagger annotations to English throughout the source code, generated Swagger docs, config files and CI workflows. Make the English README primary: README.md now holds the English docs and README_EN.md holds the Chinese version, with cross-language links updated accordingly. Note: the generated docs/ swagger files were translated in place; run `go generate ./...` (swag init) to regenerate them from the now-English annotations when a Go toolchain is available. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+17
-17
@@ -53,29 +53,29 @@ func (s *AddressBookService) AddAddressBook(ab *model.AddressBook) error {
|
||||
|
||||
// UpdateAddressBook
|
||||
func (s *AddressBookService) UpdateAddressBook(abs []*model.AddressBook, userId uint) error {
|
||||
//比较peers和数据库中的数据,如果peers中的数据在数据库中不存在,则添加,如果存在则更新,如果数据库中的数据在peers中不存在,则删除
|
||||
// 开始事务
|
||||
// compare peers with the data in the database: if a peer does not exist in the database, add it; if it exists, update it; if data in the database does not exist in peers, delete it
|
||||
// begin transaction
|
||||
tx := DB.Begin()
|
||||
//1. 获取数据库中的数据
|
||||
// 1. get the data in the database
|
||||
var dbABs []*model.AddressBook
|
||||
tx.Where("user_id = ?", userId).Find(&dbABs)
|
||||
//2. 比较peers和数据库中的数据
|
||||
//2.1 获取peers中的id
|
||||
// 2. compare peers with the data in the database
|
||||
// 2.1 get the ids in peers
|
||||
aBIds := make(map[string]*model.AddressBook)
|
||||
for _, ab := range abs {
|
||||
aBIds[ab.Id] = ab
|
||||
}
|
||||
//2.2 获取数据库中的id
|
||||
// 2.2 get the ids from the database
|
||||
dbABIds := make(map[string]*model.AddressBook)
|
||||
for _, dbAb := range dbABs {
|
||||
dbABIds[dbAb.Id] = dbAb
|
||||
}
|
||||
//2.3 比较peers和数据库中的数据
|
||||
// 2.3 compare peers with the data in the database
|
||||
for id, ab := range aBIds {
|
||||
dbAB, ok := dbABIds[id]
|
||||
ab.UserId = userId
|
||||
if !ok {
|
||||
//添加
|
||||
//add
|
||||
if ab.Platform == "" || ab.Username == "" || ab.Hostname == "" {
|
||||
peer := AllService.PeerService.FindById(ab.Id)
|
||||
if peer.RowId != 0 {
|
||||
@@ -86,11 +86,11 @@ func (s *AddressBookService) UpdateAddressBook(abs []*model.AddressBook, userId
|
||||
}
|
||||
tx.Create(ab)
|
||||
} else {
|
||||
//更新
|
||||
//update
|
||||
tx.Model(&model.AddressBook{}).Where("row_id = ?", dbAB.RowId).Updates(ab)
|
||||
}
|
||||
}
|
||||
//2.4 删除
|
||||
// 2.4 delete
|
||||
for id, dbAB := range dbABIds {
|
||||
_, ok := aBIds[id]
|
||||
if !ok {
|
||||
@@ -126,7 +126,7 @@ func (s *AddressBookService) FromPeer(peer *model.Peer) (a *model.AddressBook) {
|
||||
return a
|
||||
}
|
||||
|
||||
// Create 创建
|
||||
// Create create
|
||||
func (s *AddressBookService) Create(u *model.AddressBook) error {
|
||||
res := DB.Create(u).Error
|
||||
return res
|
||||
@@ -135,22 +135,22 @@ func (s *AddressBookService) Delete(u *model.AddressBook) error {
|
||||
return DB.Delete(u).Error
|
||||
}
|
||||
|
||||
// Update 更新
|
||||
// Update update
|
||||
func (s *AddressBookService) Update(u *model.AddressBook) error {
|
||||
return DB.Model(u).Updates(u).Error
|
||||
}
|
||||
|
||||
// UpdateByMap 更新
|
||||
// UpdateByMap update
|
||||
func (s *AddressBookService) UpdateByMap(u *model.AddressBook, data map[string]interface{}) error {
|
||||
return DB.Model(u).Updates(data).Error
|
||||
}
|
||||
|
||||
// UpdateAll 更新
|
||||
// UpdateAll update
|
||||
func (s *AddressBookService) UpdateAll(u *model.AddressBook) error {
|
||||
return DB.Model(u).Select("*").Omit("created_at").Updates(u).Error
|
||||
}
|
||||
|
||||
// ShareByWebClient 分享
|
||||
// ShareByWebClient share
|
||||
func (s *AddressBookService) ShareByWebClient(m *model.ShareRecord) error {
|
||||
m.ShareToken = uuid.New().String()
|
||||
return DB.Create(m).Error
|
||||
@@ -279,7 +279,7 @@ func (s *AddressBookService) UpdateCollection(t *model.AddressBookCollection) er
|
||||
}
|
||||
|
||||
func (s *AddressBookService) DeleteCollection(t *model.AddressBookCollection) error {
|
||||
//删除集合下的所有规则、地址簿,再删除集合
|
||||
//delete all rules and address books under the collection, then delete the collection
|
||||
tx := DB.Begin()
|
||||
tx.Where("collection_id = ?", t.Id).Delete(&model.AddressBookCollectionRule{})
|
||||
tx.Where("collection_id = ?", t.Id).Delete(&model.AddressBook{})
|
||||
@@ -326,7 +326,7 @@ func (s *AddressBookService) DeleteRule(t *model.AddressBookCollectionRule) erro
|
||||
return DB.Delete(t).Error
|
||||
}
|
||||
|
||||
// CheckCollectionOwner 检查Collection的所有者
|
||||
// CheckCollectionOwner checkCollection's owner
|
||||
func (s *AddressBookService) CheckCollectionOwner(uid uint, cid uint) bool {
|
||||
p := s.CollectionInfoById(cid)
|
||||
return p.UserId == uid
|
||||
|
||||
Reference in New Issue
Block a user