up_special.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. package model
  2. import (
  3. "fmt"
  4. "github.com/siddontang/go-mysql/mysql"
  5. "time"
  6. )
  7. //GetSpecialArg arg
  8. type GetSpecialArg struct {
  9. GroupID int `form:"group_id"`
  10. UID int `form:"uid"`
  11. FromTime string `form:"from_time"` // "2006-01-02 15:04:05"
  12. ToTime string `form:"to_time"` // "2006-01-02 15:04:05"
  13. Order string `form:"order" ` // 根据mtime排序,默认从升序, 取值,asc/desc
  14. Export string `form:"export"` // csv
  15. Charset string `form:"charset"` // 导出编码格式,默认gbk
  16. Pn uint `form:"pn"` // 页码,默认1
  17. Ps uint `form:"ps"` // 每页数量,默认20
  18. Mids string `form:"mids"` // 用户ids,以,分隔
  19. AdminName string `form:"admin_name"` // 管理员昵称
  20. }
  21. //UpSpecialWithName arg with name
  22. type UpSpecialWithName struct {
  23. UpSpecial
  24. UName string `json:"uname"`
  25. AdminName string `json:"admin_name"`
  26. }
  27. //GetSpecialByMidArg arg
  28. type GetSpecialByMidArg struct {
  29. Mid int `form:"mid" validate:"required"`
  30. }
  31. //Copy copy
  32. func (u *UpSpecialWithName) Copy(special *UpSpecial) {
  33. u.UpSpecial = *special
  34. }
  35. //GetTitleFields get title fields
  36. func (u *UpSpecialWithName) GetTitleFields() []string {
  37. return []string{
  38. "配置时间",
  39. "MID",
  40. "昵称",
  41. "所属用户组",
  42. "描述",
  43. "配置人",
  44. "用户组Id",
  45. }
  46. }
  47. //ToStringFields get to string fields
  48. func (u *UpSpecialWithName) ToStringFields() []string {
  49. var fields []string
  50. var mtime = time.Unix(int64(u.MTime), 0)
  51. fields = append(fields, fmt.Sprintf("%v", mtime.Format(mysql.TimeFormat)))
  52. fields = append(fields, fmt.Sprintf("%v", u.Mid))
  53. fields = append(fields, fmt.Sprintf("%v", u.UName))
  54. fields = append(fields, fmt.Sprintf("%v", u.GroupName))
  55. fields = append(fields, fmt.Sprintf("%v", u.Note))
  56. fields = append(fields, fmt.Sprintf("%v", u.AdminName))
  57. fields = append(fields, fmt.Sprintf("%v", u.GroupID))
  58. return fields
  59. }
  60. // UpsPage CategoryPager def.
  61. type UpsPage struct {
  62. Items []*UpSpecialWithName `json:"items"`
  63. Pager *Pager `json:"page"`
  64. }
  65. // Pager Common Pager def.
  66. type Pager struct {
  67. Num uint `json:"num"`
  68. Size uint `json:"size"`
  69. Total int `json:"total"`
  70. }