doc_file.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. package model
  2. import (
  3. "time"
  4. "ulink-admin/pkg/base"
  5. )
  6. type DocFile struct {
  7. Id int64 `excel:"name= " xorm:"pk autoincr notnull comment('')" json:"id" binding:"required"` //
  8. CatgoryId int64 `excel:"name=分类id " xorm:"bigint(20) comment('分类id')" json:"catgoryId" ` //分类id
  9. UserId int64 `excel:"name=分类id " xorm:"bigint(20) comment('分类id')" json:"userId" ` //分类id
  10. Label string `excel:"name=标题 " xorm:"varchar(64) comment('标题')" json:"label" binding:"required"` //标题
  11. Keywords string `excel:"name=关键字 " xorm:"varchar(255) comment('关键字')" json:"keywords" ` //关键字
  12. Info string `excel:"name=简介 " xorm:"varchar(255) comment('简介')" json:"info" ` //简介
  13. Content string `excel:"name=内容 " xorm:"longtext comment('内容')" json:"content" binding:"required"` //内容
  14. File string `excel:"name=附件 " xorm:"text comment('附件')" json:"file" ` //附件
  15. State int `excel:"name=状态 ,format=1=禁用,2=启用" xorm:"int(1) notnull default(2) comment('状态')" json:"state" ` //状态(1禁用 2启用)
  16. Sort int64 `excel:"name=排序 " xorm:"bigint(20) default(0) comment('排序')" json:"sort" ` //排序
  17. CreateTime time.Time `excel:"name=创建时间 " xorm:"datetime comment('创建时间')" json:"createTime" ` //创建时间
  18. CreateBy string `excel:"name=创建人 " xorm:"varchar(255) comment('创建人')" json:"createBy" ` //创建人
  19. UpdateTime time.Time `excel:"name=更新时间 " xorm:"datetime comment('更新时间')" json:"updateTime" ` //更新时间
  20. UpdateBy string `excel:"name=更新人 " xorm:"varchar(255) comment('更新人')" json:"updateBy" ` //更新人
  21. CompanyId int64 `excel:"name=公司id " xorm:"bigint(20) comment('公司id')" json:"companyId" ` //公司id
  22. }
  23. func (this DocFile) TableName() string {
  24. return "doc_file"
  25. }
  26. func (this *DocFile) Key() int64 {
  27. return this.Id
  28. }
  29. func (this *DocFile) Model() interface{} {
  30. return this
  31. }
  32. func (this *DocFile) BeforeUpdate() {
  33. user := base.GetCurUser()
  34. if user != nil {
  35. this.UpdateBy = user.Name
  36. }
  37. if user.ComponyId > 0 {
  38. this.CompanyId = user.ComponyId
  39. }
  40. }
  41. func (this *DocFile) BeforeInsert() {
  42. user := base.GetCurUser()
  43. if user != nil {
  44. this.CreateBy = user.Name
  45. this.UpdateBy = user.Name
  46. }
  47. if user.ComponyId > 0 {
  48. this.CompanyId = user.ComponyId
  49. }
  50. }