Skip to content

Commit

Permalink
feat community query
Browse files Browse the repository at this point in the history
  • Loading branch information
krisine committed May 10, 2022
1 parent 9841f22 commit da13365
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
18 changes: 18 additions & 0 deletions dao/mysql/community.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package mysql

import (
"Goi/models"
"database/sql"
"go.uber.org/zap"
)

func GetCommunityList() (communityList []*models.Community, err error) {
sqlStr := "select community_id, community_name from community"
if err := db.Select(&communityList, sqlStr); err != nil {
if err == sql.ErrNoRows {
zap.L().Warn("there is no community in db")
err = nil
}
}
return
}
11 changes: 11 additions & 0 deletions logic/community.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package logic

import (
"Goi/dao/mysql"
"Goi/models"
)

func GetCommunityList() ([]*models.Community, error) {
// 查数据库 查找到所有的community 并返回
return mysql.GetCommunityList()
}

0 comments on commit da13365

Please sign in to comment.