Browse Source

Update service.go.tpl

回参与入参,我觉得可以去掉,基本调用的时候都知道是什么类型,就没必要写了
main
SliverHorn 3 years ago
committed by GitHub
parent
commit
f77d6b9209
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 38
      server/resource/template/server/service.go.tpl

38
server/resource/template/server/service.go.tpl

@ -7,66 +7,42 @@ import (
)
// Create{{.StructName}} 创建{{.StructName}}记录
// @author: [piexlmax](https://github.com/piexlmax)
// @function: Create{{.StructName}}
// @description: 创建{{.StructName}}记录
// @param: {{.Abbreviation}} model.{{.StructName}}
// @return: err error
// Author [piexlmax](https://github.com/piexlmax)
func Create{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
err = global.GVA_DB.Create(&{{.Abbreviation}}).Error
return err
}
// Delete{{.StructName}} 删除{{.StructName}}记录
// @author: [piexlmax](https://github.com/piexlmax)
// @function: Delete{{.StructName}}
// @description: 删除{{.StructName}}记录
// @param: {{.Abbreviation}} model.{{.StructName}}
// @return: err error
// Author [piexlmax](https://github.com/piexlmax)
func Delete{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
err = global.GVA_DB.Delete(&{{.Abbreviation}}).Error
return err
}
// Delete{{.StructName}}ByIds 批量删除{{.StructName}}记录
// @author: [piexlmax](https://github.com/piexlmax)
// @function: Delete{{.StructName}}ByIds
// @description: 批量删除{{.StructName}}记录
// @param: ids request.IdsReq
// @return: err error
// Author [piexlmax](https://github.com/piexlmax)
func Delete{{.StructName}}ByIds(ids request.IdsReq) (err error) {
err = global.GVA_DB.Delete(&[]model.{{.StructName}}{},"id in ?",ids.Ids).Error
return err
}
// Update{{.StructName}} 更新{{.StructName}}记录
// @author: [piexlmax](https://github.com/piexlmax)
// @function: Update{{.StructName}}
// @description: 更新{{.StructName}}记录
// @param: {{.Abbreviation}} *model.{{.StructName}}
// @return: err error
// Author [piexlmax](https://github.com/piexlmax)
func Update{{.StructName}}({{.Abbreviation}} model.{{.StructName}}) (err error) {
err = global.GVA_DB.Save(&{{.Abbreviation}}).Error
return err
}
// Get{{.StructName}} 根据id获取{{.StructName}}记录
// @author: [piexlmax](https://github.com/piexlmax)
// @function: Get{{.StructName}}
// @description: 根据id获取{{.StructName}}记录
// @param: id uint
// @return: err error, {{.Abbreviation}} model.{{.StructName}}
// Author [piexlmax](https://github.com/piexlmax)
func Get{{.StructName}}(id uint) (err error, {{.Abbreviation}} model.{{.StructName}}) {
err = global.GVA_DB.Where("id = ?", id).First(&{{.Abbreviation}}).Error
return
}
// Get{{.StructName}}InfoList 分页获取{{.StructName}}记录
// @author: [piexlmax](https://github.com/piexlmax)
// @function: Get{{.StructName}}InfoList
// @description: 分页获取{{.StructName}}记录
// @param: info request.{{.StructName}}Search
// @return: err error, list interface{}, total int64
// Author [piexlmax](https://github.com/piexlmax)
func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error, list interface{}, total int64) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
@ -102,4 +78,4 @@ func Get{{.StructName}}InfoList(info request.{{.StructName}}Search) (err error,
err = db.Count(&total).Error
err = db.Limit(limit).Offset(offset).Find(&{{.Abbreviation}}s).Error
return err, {{.Abbreviation}}s, total
}
}
Loading…
Cancel
Save