package dto import ( "IotAdmin/app/system/models" common "IotAdmin/common/models" ) // SysOrgGetPageReq 列表或者搜索使用结构体 type SysOrgGetPageReq struct { OrgId int `form:"orgId" search:"-" comment:"id"` //id ParentId int `form:"parentId" search:"type:exact;column:parent_id;table:sys_org" comment:"上级组织机构"` //上级组织机构 OrgPath string `form:"orgPath" search:"type:exact;column:org_path;table:sys_org" comment:""` //路径 OrgName string `form:"orgName" search:"type:exact;column:org_name;table:sys_org" comment:"组织机构名称"` //组织机构名称 Sort int `form:"sort" search:"type:exact;column:sort;table:sys_org" comment:"排序"` //排序 Leader string `form:"leader" search:"type:exact;column:leader;table:sys_org" comment:"负责人"` //负责人 Phone string `form:"phone" search:"type:exact;column:phone;table:sys_org" comment:"手机"` //手机 Email string `form:"email" search:"type:exact;column:email;table:sys_org" comment:"邮箱"` //邮箱 Status string `form:"status" search:"type:exact;column:status;table:sys_org" comment:"状态"` //状态 } func (m *SysOrgGetPageReq) GetNeedSearch() interface{} { return *m } type SysOrgInsertReq struct { OrgId int `uri:"id" comment:"编码"` // 编码 ParentId int `json:"parentId" comment:"上级组织机构" vd:"?"` //上级组织机构 OrgPath string `json:"orgPath" comment:""` //路径 OrgName string `json:"orgName" comment:"组织机构名称" vd:"len($)>0"` //组织机构名称 Sort int `json:"sort" comment:"排序" vd:"?"` //排序 //Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人 Leader string `json:"leader" comment:"负责人" vd:"?"` //负责人 Phone string `json:"phone" comment:"手机" vd:"?"` //手机 Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱 Status int `json:"status" comment:"状态" vd:"$>0"` //状态 common.ControlBy } func (s *SysOrgInsertReq) Generate(model *models.SysOrg) { if s.OrgId != 0 { model.OrgId = s.OrgId } model.OrgName = s.OrgName model.ParentId = s.ParentId model.OrgPath = s.OrgPath model.Sort = s.Sort model.Leader = s.Leader model.Phone = s.Phone model.Email = s.Email model.Status = s.Status model.CreateBy = s.CreateBy } // GetId 获取数据对应的ID func (s *SysOrgInsertReq) GetId() interface{} { return s.OrgId } type SysOrgUpdateReq struct { OrgId int `uri:"id" comment:"编码"` // 编码 ParentId int `json:"parentId" comment:"上级组织机构" vd:"?"` //上级组织机构 OrgPath string `json:"orgPath" comment:""` //路径 OrgName string `json:"orgName" comment:"组织机构名称" vd:"len($)>0"` //组织机构名称 Sort int `json:"sort" comment:"排序" vd:"?"` //排序 //Leader string `json:"leader" comment:"负责人" vd:"@:len($)>0; msg:'leader不能为空'"` //负责人 Leader string `json:"leader" comment:"负责人" vd:"?"` //负责人 Phone string `json:"phone" comment:"手机" vd:"?"` //手机 Email string `json:"email" comment:"邮箱" vd:"?"` //邮箱 Status int `json:"status" comment:"状态" vd:"$>0"` //状态 common.ControlBy } // Generate 结构体数据转化 从 SysOrgControl 至 Org 对应的模型 func (s *SysOrgUpdateReq) Generate(model *models.SysOrg) { if s.OrgId != 0 { model.OrgId = s.OrgId } model.OrgName = s.OrgName model.ParentId = s.ParentId model.OrgPath = s.OrgPath model.Sort = s.Sort model.Leader = s.Leader model.Phone = s.Phone model.Email = s.Email model.Status = s.Status model.UpdateBy = s.UpdateBy } // GetId 获取数据对应的ID func (s *SysOrgUpdateReq) GetId() interface{} { return s.OrgId } type SysOrgGetReq struct { Id int `uri:"id"` } func (s *SysOrgGetReq) GetId() interface{} { return s.Id } type SysOrgDeleteReq struct { Ids []int `json:"ids"` } func (s *SysOrgDeleteReq) GetId() interface{} { return s.Ids } type OrgLabel struct { Id int `gorm:"-" json:"id"` Label string `gorm:"-" json:"label"` Children []OrgLabel `gorm:"-" json:"children"` }