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.

112 lines
3.1 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
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. //wherePrimaryKey
  12. func (TempLowHead3A60 *Temp3A60) wherePrimaryKey() (q interface{}, args []interface{}) {
  13. //todo 根据需求修改
  14. return "`id`=?", []interface{}{
  15. TempLowHead3A60.Id,
  16. }
  17. }
  18. func (TempLowHead3A60 *Temp3A60) getXorm() *xorm.Engine {
  19. return hskdb.GetXormAuto()
  20. }
  21. // ----------------------------temp------------------------------------
  22. func (TempLowHead3A60 *Temp3A60) Save(isAllCols ...bool) (err error) {
  23. tmp := Temp3A60{}
  24. whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
  25. TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(&tmp)
  26. if tmp.Id == 0 {
  27. _, err = TempLowHead3A60.getXorm().Insert(TempLowHead3A60)
  28. } else {
  29. if len(isAllCols) > 0 && isAllCols[0] {
  30. _, err = TempLowHead3A60.getXorm().AllCols().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
  31. } else {
  32. _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Update(TempLowHead3A60)
  33. }
  34. }
  35. return err
  36. }
  37. func (TempLowHead3A60 *Temp3A60) Load() (err error) {
  38. whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
  39. _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Get(TempLowHead3A60)
  40. return
  41. }
  42. func (TempLowHead3A60 *Temp3A60) Data() (data []Temp3A60) {
  43. TempLowHead3A60.getXorm().OrderBy("id desc").Find(&data)
  44. return
  45. }
  46. func (TempLowHead3A60 *Temp3A60) PageData(page, pageSize int) (data []Temp3A60, count int64) {
  47. count, _ = TempLowHead3A60.getXorm().OrderBy("id desc").Limit(pageSize, page*pageSize).FindAndCount(&data)
  48. return
  49. }
  50. func (TempLowHead3A60 *Temp3A60) Delete() (err error) {
  51. whereQuery, whereArgs := TempLowHead3A60.wherePrimaryKey()
  52. _, err = TempLowHead3A60.getXorm().Where(whereQuery, whereArgs...).Delete(TempLowHead3A60)
  53. return
  54. }
  55. // ----------------------------temp------------------------------------
  56. func InitializationPrefixHigHead3A60Temp3A60(router *hskgin.GinHelper) {
  57. var authority = func(ctx *hskgin.GinContextHelper) {
  58. //todo 权限控制
  59. }
  60. router.Any("/Prefix3A60/TempLowHead3A60/get", func(ctx *hskgin.GinContextHelper) {
  61. authority(ctx)
  62. req := Temp3A60{}
  63. ctx.Bind(&req)
  64. err := req.Load()
  65. ctx.CheckErrDisplayByError(err)
  66. ctx.DisplayByData(req)
  67. })
  68. router.Any("/Prefix3A60/TempLowHead3A60/save", func(ctx *hskgin.GinContextHelper) {
  69. authority(ctx)
  70. req := Temp3A60{}
  71. ctx.Bind(&req)
  72. err := req.Save()
  73. ctx.CheckErrDisplayByError(err)
  74. err = req.Load()
  75. ctx.CheckErrDisplayByError(err)
  76. ctx.DisplayByData(req)
  77. })
  78. router.Any("/Prefix3A60/TempLowHead3A60/data", func(ctx *hskgin.GinContextHelper) {
  79. authority(ctx)
  80. req := Temp3A60{}
  81. ctx.Bind(&req)
  82. data := req.Data()
  83. ctx.DisplayByData(data)
  84. })
  85. router.Any("/Prefix3A60/TempLowHead3A60/list", func(ctx *hskgin.GinContextHelper) {
  86. authority(ctx)
  87. req := Temp3A60{}
  88. ctx.Bind(&req)
  89. page := ctx.ParamRequired2Page(true)
  90. data, count := req.PageData(page, 10)
  91. ctx.DisplayByPage(data, count)
  92. })
  93. }
  94. // ----------------------------temp------------------------------------