Skip to content

Commit e08b237

Browse files
committed
docs: update api document
1 parent 25d80d2 commit e08b237

32 files changed

+189
-174
lines changed

docs/apis.swagger.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"paths": {
2424
"/api/v1/userExample": {
2525
"post": {
26-
"summary": "create a new userExample",
26+
"summary": "Create a new userExample",
2727
"description": "Creates a new userExample entity using the provided data in the request body.",
2828
"operationId": "userExample_Create",
2929
"responses": {
@@ -91,7 +91,7 @@
9191
},
9292
"/api/v1/userExample/{id}": {
9393
"get": {
94-
"summary": "get userExample details by id",
94+
"summary": "Get a userExample by id",
9595
"description": "Gets detailed information of a userExample specified by the given id in the path.",
9696
"operationId": "userExample_GetByID",
9797
"responses": {
@@ -122,7 +122,7 @@
122122
]
123123
},
124124
"delete": {
125-
"summary": "delete a userExample by id",
125+
"summary": "Delete a userExample by id",
126126
"description": "Deletes a existing userExample identified by the given id in the path.",
127127
"operationId": "userExample_DeleteByID",
128128
"responses": {
@@ -153,7 +153,7 @@
153153
]
154154
},
155155
"put": {
156-
"summary": "update a userExample by id",
156+
"summary": "Update a userExample by id",
157157
"description": "Updates the specified userExample with new data provided in the request body. The target is identified by id in the path.",
158158
"operationId": "userExample_UpdateByID",
159159
"responses": {

docs/swagger.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"tags": [
3030
"userExample"
3131
],
32-
"summary": "create a new userExample",
32+
"summary": "Create a new userExample",
3333
"parameters": [
3434
{
3535
"description": "userExample information",
@@ -68,7 +68,7 @@
6868
"tags": [
6969
"userExample"
7070
],
71-
"summary": "get a list of userExample by custom conditions",
71+
"summary": "Get a paginated list of userExamples by custom conditions",
7272
"parameters": [
7373
{
7474
"description": "query parameters",
@@ -107,7 +107,7 @@
107107
"tags": [
108108
"userExample"
109109
],
110-
"summary": "get userExample details by id",
110+
"summary": "Get a userExample by id",
111111
"parameters": [
112112
{
113113
"type": "string",
@@ -142,7 +142,7 @@
142142
"tags": [
143143
"userExample"
144144
],
145-
"summary": "update a userExample by id",
145+
"summary": "Update a userExample by id",
146146
"parameters": [
147147
{
148148
"type": "string",
@@ -186,7 +186,7 @@
186186
"tags": [
187187
"userExample"
188188
],
189-
"summary": "delete a userExample by id",
189+
"summary": "Delete a userExample by id",
190190
"parameters": [
191191
{
192192
"type": "string",

docs/swagger.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ paths:
237237
$ref: '#/definitions/types.CreateUserExampleReply'
238238
security:
239239
- BearerAuth: []
240-
summary: create a new userExample
240+
summary: Create a new userExample
241241
tags:
242242
- userExample
243243
/api/v1/userExample/{id}:
@@ -261,7 +261,7 @@ paths:
261261
$ref: '#/definitions/types.DeleteUserExampleByIDReply'
262262
security:
263263
- BearerAuth: []
264-
summary: delete a userExample by id
264+
summary: Delete a userExample by id
265265
tags:
266266
- userExample
267267
get:
@@ -284,7 +284,7 @@ paths:
284284
$ref: '#/definitions/types.GetUserExampleByIDReply'
285285
security:
286286
- BearerAuth: []
287-
summary: get userExample details by id
287+
summary: Get a userExample by id
288288
tags:
289289
- userExample
290290
put:
@@ -313,7 +313,7 @@ paths:
313313
$ref: '#/definitions/types.UpdateUserExampleByIDReply'
314314
security:
315315
- BearerAuth: []
316-
summary: update a userExample by id
316+
summary: Update a userExample by id
317317
tags:
318318
- userExample
319319
/api/v1/userExample/list:
@@ -338,7 +338,7 @@ paths:
338338
$ref: '#/definitions/types.ListUserExamplesReply'
339339
security:
340340
- BearerAuth: []
341-
summary: get a list of userExample by custom conditions
341+
summary: Get a paginated list of userExamples by custom conditions
342342
tags:
343343
- userExample
344344
/codes:

internal/dao/userExample.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func (d *userExampleDao) updateDataByID(ctx context.Context, db *gorm.DB, table
121121
return db.WithContext(ctx).Model(table).Updates(update).Error
122122
}
123123

124-
// GetByID get userExample details by id
124+
// GetByID get a userExample by id
125125
func (d *userExampleDao) GetByID(ctx context.Context, id uint64) (*model.UserExample, error) {
126126
// no cache
127127
if d.cache == nil {
@@ -175,7 +175,7 @@ func (d *userExampleDao) GetByID(ctx context.Context, id uint64) (*model.UserExa
175175
return nil, err
176176
}
177177

178-
// GetByColumns get a list of userExample by custom conditions.
178+
// GetByColumns get a paginated list of userExamples by custom conditions.
179179
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
180180
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
181181
queryStr, args, err := params.ConvertToGormConditions(query.WithWhitelistNames(model.UserExampleColumnNames))

internal/dao/userExample.go.exp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func (d *userExampleDao) updateDataByID(ctx context.Context, db *gorm.DB, table
127127
return db.WithContext(ctx).Model(table).Updates(update).Error
128128
}
129129

130-
// GetByID get userExample details by id
130+
// GetByID get a userExample by id
131131
func (d *userExampleDao) GetByID(ctx context.Context, id uint64) (*model.UserExample, error) {
132132
// no cache
133133
if d.cache == nil {
@@ -181,7 +181,7 @@ func (d *userExampleDao) GetByID(ctx context.Context, id uint64) (*model.UserExa
181181
return nil, err
182182
}
183183

184-
// GetByColumns get a list of userExample by custom conditions.
184+
// GetByColumns get a paginated list of userExamples by custom conditions.
185185
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
186186
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
187187
queryStr, args, err := params.ConvertToGormConditions(query.WithWhitelistNames(model.UserExampleColumnNames))
@@ -210,7 +210,7 @@ func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params)
210210
return records, total, err
211211
}
212212

213-
// DeleteByIDs delete userExample by batch id
213+
// DeleteByIDs batch delete userExample by ids
214214
func (d *userExampleDao) DeleteByIDs(ctx context.Context, ids []uint64) error {
215215
err := d.db.WithContext(ctx).Where("id IN (?)", ids).Delete(&model.UserExample{}).Error
216216
if err != nil {
@@ -225,7 +225,7 @@ func (d *userExampleDao) DeleteByIDs(ctx context.Context, ids []uint64) error {
225225
return nil
226226
}
227227

228-
// GetByCondition get userExample details by custom condition
228+
// GetByCondition get a userExample by custom condition
229229
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html#_2-condition-parameters-optional
230230
func (d *userExampleDao) GetByCondition(ctx context.Context, c *query.Conditions) (*model.UserExample, error) {
231231
queryStr, args, err := c.ConvertToGorm(query.WithWhitelistNames(model.UserExampleColumnNames))
@@ -242,7 +242,7 @@ func (d *userExampleDao) GetByCondition(ctx context.Context, c *query.Conditions
242242
return table, nil
243243
}
244244

245-
// GetByIDs get a list of userExample by batch id
245+
// GetByIDs Batch get userExample by ids
246246
func (d *userExampleDao) GetByIDs(ctx context.Context, ids []uint64) (map[uint64]*model.UserExample, error) {
247247
// no cache
248248
if d.cache == nil {
@@ -316,7 +316,7 @@ func (d *userExampleDao) GetByIDs(ctx context.Context, ids []uint64) (map[uint64
316316
return itemMap, nil
317317
}
318318

319-
// GetByLastID get a list of userExample by last id
319+
// GetByLastID Get a paginated list of userExamples by last id
320320
func (d *userExampleDao) GetByLastID(ctx context.Context, lastID uint64, limit int, sort string) ([]*model.UserExample, error) {
321321
page := query.NewPage(0, limit, sort)
322322

internal/dao/userExample.go.exp.tpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ func (d *{{.TableNameCamelFCL}}Dao) updateDataBy{{.ColumnNameCamel}}(ctx context
131131
return db.WithContext(ctx).Model(table).Updates(update).Error
132132
}
133133

134-
// GetBy{{.ColumnNameCamel}} get {{.TableNameCamelFCL}} details by {{.ColumnNameCamelFCL}}
134+
// GetBy{{.ColumnNameCamel}} get a {{.TableNameCamelFCL}} by {{.ColumnNameCamelFCL}}
135135
func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNameCamel}}(ctx context.Context, {{.ColumnNameCamelFCL}} {{.GoType}}) (*model.{{.TableNameCamel}}, error) {
136136
// no cache
137137
if d.cache == nil {
@@ -187,7 +187,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNameCamel}}(ctx context.Contex
187187
return nil, err
188188
}
189189

190-
// GetByColumns get a list of {{.TableNameCamelFCL}} by custom conditions.
190+
// GetByColumns get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions.
191191
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
192192
func (d *{{.TableNameCamelFCL}}Dao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.{{.TableNameCamel}}, int64, error) {
193193
if params.Sort == "" {
@@ -219,7 +219,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetByColumns(ctx context.Context, params *qu
219219
return records, total, err
220220
}
221221

222-
// DeleteBy{{.ColumnNamePluralCamel}} delete {{.TableNameCamelFCL}} by batch {{.ColumnNameCamelFCL}}
222+
// DeleteBy{{.ColumnNamePluralCamel}} batch delete {{.TableNamePluralCamelFCL}} by {{.ColumnNamePluralCamelFCL}}
223223
func (d *{{.TableNameCamelFCL}}Dao) DeleteBy{{.ColumnNamePluralCamel}}(ctx context.Context, {{.ColumnNamePluralCamelFCL}} []{{.GoType}}) error {
224224
err := d.db.WithContext(ctx).Where("{{.ColumnName}} IN (?)", {{.ColumnNamePluralCamelFCL}}).Delete(&model.{{.TableNameCamel}}{}).Error
225225
if err != nil {
@@ -234,7 +234,7 @@ func (d *{{.TableNameCamelFCL}}Dao) DeleteBy{{.ColumnNamePluralCamel}}(ctx conte
234234
return nil
235235
}
236236

237-
// GetByCondition get {{.TableNameCamelFCL}} details by custom condition
237+
// GetByCondition get a {{.TableNameCamelFCL}} by custom condition
238238
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html#_2-condition-parameters-optional
239239
func (d *{{.TableNameCamelFCL}}Dao) GetByCondition(ctx context.Context, c *query.Conditions) (*model.{{.TableNameCamel}}, error) {
240240
queryStr, args, err := c.ConvertToGorm(query.WithWhitelistNames(model.{{.TableNameCamel}}ColumnNames))
@@ -251,7 +251,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetByCondition(ctx context.Context, c *query
251251
return table, nil
252252
}
253253

254-
// GetBy{{.ColumnNamePluralCamel}} get a list of {{.TableNameCamelFCL}} by batch {{.ColumnNameCamelFCL}}
254+
// GetBy{{.ColumnNamePluralCamel}} batch get {{.TableNamePluralCamelFCL}} by {{.ColumnNamePluralCamelFCL}}
255255
func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNamePluralCamel}}(ctx context.Context, {{.ColumnNamePluralCamelFCL}} []{{.GoType}}) (map[{{.GoType}}]*model.{{.TableNameCamel}}, error) {
256256
// no cache
257257
if d.cache == nil {
@@ -326,7 +326,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNamePluralCamel}}(ctx context.
326326
return itemMap, nil
327327
}
328328

329-
// GetByLast{{.ColumnNameCamel}} get a list of {{.TableNameCamelFCL}} by last {{.ColumnNameCamelFCL}}
329+
// GetByLast{{.ColumnNameCamel}} get a paginated list of {{.TableNamePluralCamelFCL}} by last {{.ColumnNameCamelFCL}}
330330
func (d *{{.TableNameCamelFCL}}Dao) GetByLast{{.ColumnNameCamel}}(ctx context.Context, last{{.ColumnNameCamel}} {{.GoType}}, limit int, sort string) ([]*model.{{.TableNameCamel}}, error) {
331331
if sort == "" {
332332
sort = "-{{.ColumnName}}"

internal/dao/userExample.go.mgo

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (d *userExampleDao) updateDataByID(ctx context.Context, collection *mongo.C
134134
return err
135135
}
136136

137-
// GetByID get userExample details by id
137+
// GetByID get a userExample by id
138138
func (d *userExampleDao) GetByID(ctx context.Context, id string) (*model.UserExample, error) {
139139
oid := database.ToObjectID(id)
140140
if oid.IsZero() {
@@ -193,15 +193,17 @@ func (d *userExampleDao) GetByID(ctx context.Context, id string) (*model.UserExa
193193
return nil, err
194194
}
195195

196-
// GetByColumns get a list of userExample by custom conditions.
196+
// GetByColumns get a paginated list of userExamples by custom conditions.
197197
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
198198
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
199199
filter, err := params.ConvertToMongoFilter(query.WithWhitelistNames(model.UserExampleColumnNames))
200200
if err != nil {
201201
return nil, 0, errors.New("query params error: " + err.Error())
202202
}
203+
filter = mgo.ExcludeDeleted(filter)
204+
logger.Info("query filter", logger.Any("filter", filter))
203205

204-
total, err := d.collection.CountDocuments(ctx, mgo.ExcludeDeleted(filter))
206+
total, err := d.collection.CountDocuments(ctx, filter)
205207
if err != nil {
206208
return nil, 0, err
207209
}
@@ -215,7 +217,7 @@ func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params)
215217
findOpts.SetLimit(int64(limit)).SetSkip(int64(skip))
216218
findOpts.Sort = sort
217219

218-
cursor, err := d.collection.Find(ctx, mgo.ExcludeDeleted(filter), findOpts)
220+
cursor, err := d.collection.Find(ctx, filter, findOpts)
219221
if err != nil {
220222
return nil, 0, err
221223
}

internal/dao/userExample.go.mgo.exp

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (d *userExampleDao) updateDataByID(ctx context.Context, collection *mongo.C
139139
return err
140140
}
141141

142-
// GetByID get userExample details by id
142+
// GetByID get a userExample by id
143143
func (d *userExampleDao) GetByID(ctx context.Context, id string) (*model.UserExample, error) {
144144
oid := database.ToObjectID(id)
145145
if oid.IsZero() {
@@ -198,15 +198,17 @@ func (d *userExampleDao) GetByID(ctx context.Context, id string) (*model.UserExa
198198
return nil, err
199199
}
200200

201-
// GetByColumns get a list of userExample by custom conditions.
201+
// GetByColumns get a paginated list of userExamples by custom conditions.
202202
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
203203
func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.UserExample, int64, error) {
204204
filter, err := params.ConvertToMongoFilter(query.WithWhitelistNames(model.UserExampleColumnNames))
205205
if err != nil {
206206
return nil, 0, errors.New("query params error: " + err.Error())
207207
}
208+
filter = mgo.ExcludeDeleted(filter)
209+
logger.Info("query filter", logger.Any("filter", filter))
208210

209-
total, err := d.collection.CountDocuments(ctx, mgo.ExcludeDeleted(filter))
211+
total, err := d.collection.CountDocuments(ctx, filter)
210212
if err != nil {
211213
return nil, 0, err
212214
}
@@ -220,7 +222,7 @@ func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params)
220222
findOpts.SetLimit(int64(limit)).SetSkip(int64(skip))
221223
findOpts.Sort = sort
222224

223-
cursor, err := d.collection.Find(ctx, mgo.ExcludeDeleted(filter), findOpts)
225+
cursor, err := d.collection.Find(ctx, filter, findOpts)
224226
if err != nil {
225227
return nil, 0, err
226228
}
@@ -232,7 +234,7 @@ func (d *userExampleDao) GetByColumns(ctx context.Context, params *query.Params)
232234
return records, total, err
233235
}
234236

235-
// DeleteByIDs delete userExample by batch id
237+
// DeleteByIDs batch delete userExample by ids
236238
func (d *userExampleDao) DeleteByIDs(ctx context.Context, ids []string) error {
237239
oids := mgo.ConvertToObjectIDs(ids)
238240
filter := bson.M{"_id": bson.M{"$in": oids}}
@@ -249,24 +251,26 @@ func (d *userExampleDao) DeleteByIDs(ctx context.Context, ids []string) error {
249251
return nil
250252
}
251253

252-
// GetByCondition get userExample details by custom condition.
254+
// GetByCondition get a userExample by custom condition.
253255
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html#_2-condition-parameters-optional
254256
func (d *userExampleDao) GetByCondition(ctx context.Context, c *query.Conditions) (*model.UserExample, error) {
255257
filter, err := c.ConvertToMongo(query.WithWhitelistNames(model.UserExampleColumnNames))
256258
if err != nil {
257259
return nil, err
258260
}
261+
filter = mgo.ExcludeDeleted(filter)
262+
logger.Info("query filter", logger.Any("filter", filter))
259263

260264
record := &model.UserExample{}
261-
err = d.collection.FindOne(ctx, mgo.ExcludeDeleted(filter)).Decode(record)
265+
err = d.collection.FindOne(ctx, filter).Decode(record)
262266
if err != nil {
263267
return nil, err
264268
}
265269

266270
return record, nil
267271
}
268272

269-
// GetByIDs get a list of userExample by batch id
273+
// GetByIDs Batch get userExample by ids
270274
func (d *userExampleDao) GetByIDs(ctx context.Context, ids []string) (map[string]*model.UserExample, error) {
271275
// no cache
272276
if d.cache == nil {
@@ -352,7 +356,7 @@ func (d *userExampleDao) GetByIDs(ctx context.Context, ids []string) (map[string
352356
return itemMap, nil
353357
}
354358

355-
// GetByLastID get a list of userExample by last id
359+
// GetByLastID Get a paginated list of userExamples by last id
356360
func (d *userExampleDao) GetByLastID(ctx context.Context, lastID string, limit int, sort string) ([]*model.UserExample, error) {
357361
page := query.NewPage(0, limit, sort)
358362

internal/dao/userExample.go.tpl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func (d *{{.TableNameCamelFCL}}Dao) updateDataBy{{.ColumnNameCamel}}(ctx context
125125
return db.WithContext(ctx).Model(table).Updates(update).Error
126126
}
127127

128-
// GetBy{{.ColumnNameCamel}} get {{.TableNameCamelFCL}} details by {{.ColumnNameCamelFCL}}
128+
// GetBy{{.ColumnNameCamel}} get a {{.TableNameCamelFCL}} by {{.ColumnNameCamelFCL}}
129129
func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNameCamel}}(ctx context.Context, {{.ColumnNameCamelFCL}} {{.GoType}}) (*model.{{.TableNameCamel}}, error) {
130130
// no cache
131131
if d.cache == nil {
@@ -181,7 +181,7 @@ func (d *{{.TableNameCamelFCL}}Dao) GetBy{{.ColumnNameCamel}}(ctx context.Contex
181181
return nil, err
182182
}
183183

184-
// GetByColumns get a list of {{.TableNameCamelFCL}} by custom conditions.
184+
// GetByColumns get a paginated list of {{.TableNamePluralCamelFCL}} by custom conditions.
185185
// For more details, please refer to https://go-sponge.com/component/custom-page-query.html
186186
func (d *{{.TableNameCamelFCL}}Dao) GetByColumns(ctx context.Context, params *query.Params) ([]*model.{{.TableNameCamel}}, int64, error) {
187187
if params.Sort == "" {

0 commit comments

Comments
 (0)