You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

108 lines
3.0 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package main
  2. import (
  3. "git.ouxuan.net/hasaki-service/hasaki-sdk/hskdb"
  4. "git.ouxuan.net/hasaki-service/hasaki-sdk/hskgin"
  5. "xorm.io/xorm"
  6. )
  7. type Temp3A60 struct {
  8. Id int
  9. }
  10. // ----------------------------temp------------------------------------
  11. func (TempLowHead3A60 *Temp3A60) where() (q interface{}, args []interface{}) {
  12. //todo 根据需求修改
  13. return "`id`=?", []interface{}{
  14. TempLowHead3A60.Id,
  15. }
  16. }
  17. func (TempLowHead3A60 *Temp3A60) getXorm() *xorm.Engine {
  18. return hskdb.GetXormAuto()
  19. }
  20. func (TempLowHead3A60 *Temp3A60) Save(isAllCols ...bool) (err error) {
  21. tmp := Temp3A60{}
  22. whereQuery, whereArgs := TempLowHead3A60.where()
  23. TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&tmp)
  24. if tmp.Id == 0 {
  25. _, err = TempLowHead3A60.getXorm().Insert(TempLowHead3A60)
  26. } else {
  27. if len(isAllCols) > 0 && isAllCols[0] {
  28. _, err = TempLowHead3A60.getXorm().AllCols().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
  29. } else {
  30. _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
  31. }
  32. }
  33. return err
  34. }
  35. func (TempLowHead3A60 *Temp3A60) Load() (err error) {
  36. whereQuery, whereArgs := TempLowHead3A60.where()
  37. _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&TempLowHead3A60)
  38. return
  39. }
  40. func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) {
  41. TempLowHead3A60.getXorm().OrderBy("id desc").Find(&data)
  42. return
  43. }
  44. func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, count int64) {
  45. count, _ = TempLowHead3A60.getXorm().OrderBy("id desc").Limit(pageSize, page*pageSize).FindAndCount(&data)
  46. return
  47. }
  48. func (TempLowHead3A60 *Temp3A60) Delete() (err error) {
  49. whereQuery, whereArgs := TempLowHead3A60.where()
  50. _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Delete(&TempLowHead3A60)
  51. return
  52. }
  53. //该方法请不要放在db文件中
  54. func InitializationTemp3A60(router *hskgin.GinHelper) {
  55. var authority = func(ctx *hskgin.GinContextHelper) {
  56. //todo 权限控制
  57. }
  58. router.Any("/Prefix3A60/TempLowHead3A60/get", func(ctx *hskgin.GinContextHelper) {
  59. authority(ctx)
  60. req := Temp3A60{}
  61. ctx.Bind(&req)
  62. err := req.Load()
  63. ctx.CheckErrDisplayByError(err)
  64. ctx.DisplayByData(req)
  65. })
  66. router.Any("/Prefix3A60/TempLowHead3A60/save", func(ctx *hskgin.GinContextHelper) {
  67. authority(ctx)
  68. req := Temp3A60{}
  69. ctx.Bind(&req)
  70. err := req.Save()
  71. ctx.CheckErrDisplayByError(err)
  72. err = req.Load()
  73. ctx.CheckErrDisplayByError(err)
  74. ctx.DisplayByData(req)
  75. })
  76. router.Any("/Prefix3A60/TempLowHead3A60/data", func(ctx *hskgin.GinContextHelper) {
  77. authority(ctx)
  78. req := Temp3A60{}
  79. ctx.Bind(&req)
  80. data := req.Data()
  81. ctx.DisplayByData(data)
  82. })
  83. router.Any("/Prefix3A60/TempLowHead3A60/list", func(ctx *hskgin.GinContextHelper) {
  84. authority(ctx)
  85. req := Temp3A60{}
  86. ctx.Bind(&req)
  87. page := ctx.ParamRequired2Page(true)
  88. data, count := req.PageData(page, 10)
  89. ctx.DisplayByPage(data, count)
  90. })
  91. }
  92. // ----------------------------temp------------------------------------