Browse Source

社区图谱

huangchundi 1 day ago
parent
commit
197406edb9
2 changed files with 8 additions and 8 deletions
  1. 3 3
      controllers/services/CommunityListService.go
  2. 5 5
      models/community_list.go

+ 3 - 3
controllers/services/CommunityListService.go

@@ -139,7 +139,7 @@ func (s *CommunityListService) GetAllCommunityLists(offset, limit int64) ([]Comm
 	for _, item := range ml {
 		if record, ok := item.(models.CommunityList); ok {
 			result = append(result, CommunityInfo{
-				Id:             record.Id,
+				Id:             record.CommunityId,
 				ParentId:       record.ParentId,
 				UserId:         record.UserId,
 				Username:       record.Username,
@@ -179,13 +179,13 @@ func (s *CommunityListService) DeleteCommunityList(id int) error {
 		return err
 	}
 
-	return models.DeleteCommunityList(record.Id)
+	return models.DeleteCommunityList(record.CommunityId)
 }
 
 // toCommunityInfo converts model to service info
 func (s *CommunityListService) toCommunityInfo(record *models.CommunityList) *CommunityInfo {
 	return &CommunityInfo{
-		Id:             record.Id,
+		Id:             record.CommunityId,
 		ParentId:       record.ParentId,
 		UserId:         record.UserId,
 		Username:       record.Username,

+ 5 - 5
models/community_list.go

@@ -10,7 +10,7 @@ import (
 )
 
 type CommunityList struct {
-	Id             int    `orm:"column(community_id);auto" description:"社区图谱"`
+	CommunityId    int    `orm:"column(community_id);auto" description:"社区图谱"`
 	ParentId       string `orm:"column(parent_id);size(225);null" description:"上级id"`
 	UserId         string `orm:"column(user_id);size(225);null"`
 	Username       string `orm:"column(username);size(255);null"`
@@ -44,7 +44,7 @@ func AddCommunityList(m *CommunityList) (id int64, err error) {
 // Id doesn't exist
 func GetCommunityListById(id int) (v *CommunityList, err error) {
 	o := orm.NewOrm()
-	v = &CommunityList{Id: id}
+	v = &CommunityList{CommunityId: id}
 	if err = o.Read(v); err == nil {
 		return v, nil
 	}
@@ -133,7 +133,7 @@ func GetAllCommunityList(query map[string]string, fields []string, sortby []stri
 // the record to be updated doesn't exist
 func UpdateCommunityListById(m *CommunityList) (err error) {
 	o := orm.NewOrm()
-	v := CommunityList{Id: m.Id}
+	v := CommunityList{CommunityId: m.CommunityId}
 	// ascertain id exists in the database
 	if err = o.Read(&v); err == nil {
 		var num int64
@@ -148,11 +148,11 @@ func UpdateCommunityListById(m *CommunityList) (err error) {
 // the record to be deleted doesn't exist
 func DeleteCommunityList(id int) (err error) {
 	o := orm.NewOrm()
-	v := CommunityList{Id: id}
+	v := CommunityList{CommunityId: id}
 	// ascertain id exists in the database
 	if err = o.Read(&v); err == nil {
 		var num int64
-		if num, err = o.Delete(&CommunityList{Id: id}); err == nil {
+		if num, err = o.Delete(&CommunityList{CommunityId: id}); err == nil {
 			fmt.Println("Number of records deleted in database:", num)
 		}
 	}