comm: swagger doc
This commit is contained in:
@@ -11,15 +11,17 @@ func ListPublishedArticles() *[]models.ListArticle {
|
||||
return listArticles(1, 0)
|
||||
}
|
||||
|
||||
//ListPublishedArticlesByUser list the user's published articles
|
||||
func ListPublishedArticlesByUser(id int) *[]models.ListArticle {
|
||||
return listArticles(1, id)
|
||||
}
|
||||
|
||||
//ListNotPublishedArticlesByUser list all articles(without not published)
|
||||
//ListNotPublishedArticlesByUser list the user's not publish articles
|
||||
func ListNotPublishedArticlesByUser(id int) *[]models.ListArticle {
|
||||
return listArticles(0, id)
|
||||
}
|
||||
|
||||
//listArticles complex function need to directly use gorm
|
||||
func listArticles(isPublish int, createUser int) *[]models.ListArticle {
|
||||
queryStr := "back_article.is_delete = 0 AND is_publish = " + strconv.Itoa(isPublish)
|
||||
if createUser != 0 {
|
||||
|
||||
@@ -64,9 +64,11 @@ func ListRegister(claims models.TokenClaims) *[]map[string]interface{} {
|
||||
if claims.Region == "" {
|
||||
// do nothing
|
||||
} else if !strings.Contains(claims.Region, " ") {
|
||||
// Province Admin approve city admin
|
||||
tx.Where("approver = 0 AND is_delete = 0 AND region LIKE ? AND role = ?", claims.Region+" %", global.ROLE_ID_MAP["ADMIN"])
|
||||
registers = *models.ListByOrm(tx)
|
||||
} else {
|
||||
// City Admin approve workers and volunteers
|
||||
tx.Where("approver = 0 AND is_delete = 0 AND region = ? AND role in ?", claims.Region, []int{global.ROLE_ID_MAP["WORKER"], global.ROLE_ID_MAP["VOLUNTEER"]})
|
||||
registers = *models.ListByOrm(tx)
|
||||
}
|
||||
@@ -85,6 +87,10 @@ func ListApprovedRegister(claims models.TokenClaims) *[]map[string]interface{} {
|
||||
func ApproveRegister(claims models.TokenClaims, email string, pass bool) bool {
|
||||
queryMap := []map[string]interface{}{{"email": email}}
|
||||
var approver int
|
||||
// Approver field status:
|
||||
// = 0: not approved
|
||||
// > 0: approver id, and registe successful
|
||||
// < 0: approver id, and registe failed
|
||||
if pass {
|
||||
approver = claims.ID
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user