Skip to content

Commit c10f65a

Browse files
correction in channel entry responses in model wise
1 parent 1c8165a commit c10f65a

File tree

5 files changed

+71
-78
lines changed

5 files changed

+71
-78
lines changed

.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ DB_NAME='' #your database names
1212
#
1313
JWT_SECRET = 'Secret123'
1414

15-
1615
#
1716
#url,port
1817
#

controller/category.go

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,15 @@ package controller
33
import (
44
"context"
55
"gqlserver/graph/model"
6-
"log"
76
"strconv"
87

9-
// "log"
108
"os"
119
"strings"
12-
1310
// "github.com/gin-gonic/gin"
1411
"gorm.io/gorm"
1512
)
1613

17-
func CategoriesList(db *gorm.DB,ctx context.Context,limit, offset int)(model.CategoriesList,error){
14+
func CategoriesList(db *gorm.DB, ctx context.Context, limit, offset int) (model.CategoriesList, error) {
1815

1916
// c,_ := ctx.Value(ContextKey).(*gin.Context)
2017

@@ -40,38 +37,36 @@ func CategoriesList(db *gorm.DB,ctx context.Context,limit, offset int)(model.Cat
4037
res := `WITH RECURSIVE cat_tree AS (
4138
SELECT id, category_name, category_slug,image_path, parent_id,created_on,modified_on,is_deleted
4239
FROM tbl_categories
43-
WHERE id = 8
40+
WHERE id = 1
4441
UNION ALL
4542
SELECT cat.id, cat.category_name, cat.category_slug, cat.image_path ,cat.parent_id,cat.created_on,cat.modified_on,
4643
cat.is_deleted
4744
FROM tbl_categories AS cat
4845
JOIN cat_tree ON cat.parent_id = cat_tree.id )`
4946

50-
if err := db.Debug().Raw(` `+res+` SELECT cat_tree.* FROM cat_tree where is_deleted = 0 and id not in (8) and parent_id =8 order by id desc`).Limit(limit).Offset(offset).Find(&categories).Error;err!=nil{
47+
if err := db.Debug().Raw(` ` + res + ` SELECT cat_tree.* FROM cat_tree where is_deleted = 0 and id not in (1) and parent_id =1 order by id desc limit ` + strconv.Itoa(limit) + ` offset ` + strconv.Itoa(offset)).Find(&categories).Error; err != nil {
5148

52-
return model.CategoriesList{},err
49+
return model.CategoriesList{}, err
5350
}
54-
55-
if err:= db.Debug().Raw(` `+res+` SELECT count(*) FROM cat_tree where is_deleted = 0 and id not in (8) and parent_id =8 group by id order by id desc`).Count(&count).Error;err!=nil{
5651

57-
return model.CategoriesList{},err
58-
}
52+
if err := db.Debug().Raw(` ` + res + ` SELECT count(*) FROM cat_tree where is_deleted = 0 and id not in (1) and parent_id =1 group by id order by id desc`).Count(&count).Error; err != nil {
5953

60-
log.Println("chkkk",categories)
54+
return model.CategoriesList{}, err
55+
}
6156

6257
var final_categoriesList []model.TblCategory
6358

64-
for _,parentCat := range categories{
59+
for _, parentCat := range categories {
6560

66-
modified_path := pathUrl + strings.TrimPrefix(parentCat.ImagePath,"/")
61+
modified_path := pathUrl + strings.TrimPrefix(parentCat.ImagePath, "/")
6762

6863
parentCat.ImagePath = modified_path
6964

7065
var childCategories []model.TblCategory
7166

72-
err := db.Debug().Raw(` `+res+` SELECT cat_tree.* FROM cat_tree where is_deleted = 0 and id not in (`+strconv.Itoa(parentCat.ID)+`) and parent_id =`+strconv.Itoa(parentCat.ID)+` order by id desc`).Limit(limit).Offset(offset).Find(&childCategories).Error
67+
err := db.Debug().Raw(` ` + res + ` SELECT cat_tree.* FROM cat_tree where is_deleted = 0 and id not in (` + strconv.Itoa(parentCat.ID) + `) and parent_id =` + strconv.Itoa(parentCat.ID) + ` order by id desc`).Find(&childCategories).Error
7368

74-
if err==nil{
69+
if err == nil {
7570

7671
parentCat.ChildCategories = childCategories
7772
}
@@ -80,7 +75,6 @@ func CategoriesList(db *gorm.DB,ctx context.Context,limit, offset int)(model.Cat
8075

8176
}
8277

83-
return model.CategoriesList{Categories: final_categoriesList,Count: int(count)},nil
78+
return model.CategoriesList{Categories: final_categoriesList, Count: int(count)}, nil
8479
}
8580

86-

graph/generated.go

Lines changed: 54 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graph/model/models_gen.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graph/schema.graphqls

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,6 @@ type AdditionalFields{
207207
fieldId: Int!
208208
fieldName: String!
209209
fieldTypeId: Int!
210-
fieldTypeName: String!
211210
mandatoryField: Int!
212211
optionExist: Int!
213212
createdOn: Time!
@@ -219,14 +218,15 @@ type AdditionalFields{
219218
deletedOn: Time
220219
fieldDesc: String!
221220
orderIndex: Int!
222-
initialValue: Int
221+
initialValue: String
223222
placeholder: String
224223
imagePath: String!
225224
datetimeFormat: String
226225
timeFormat: String
227226
url: String
228227
sectionParentId: Int
229228
characterAllowed: Int
229+
fieldTypeName: String!
230230
fieldValue: FieldValue
231231
fieldOptions: [FieldOptions!]
232232
}

0 commit comments

Comments
 (0)