cooperation_mode.go 5.9 KB
package domain

import "time"

// 共创模式实体
type CooperationMode struct {
	// 共创模式ID
	CooperationModeId int64 `json:"cooperationModeId,string"`
	// 共创模式编码,唯一确定
	CooperationModeNumber string `json:"cooperationModeNumber"`
	// 模式名称,唯一确定
	CooperationModeName string `json:"cooperationModeName"`
	// 共创模式状态,1启用,2禁用
	Status int32 `json:"status"`
	// 数据所属组织机构
	Org *Org `json:"org"`
	// 公司
	Company *Company `json:"company"`
	// 备注
	Remarks string `json:"remarks"`
	// 操作人
	Operator *User `json:"operator"`
	// 操作时间
	OperateTime time.Time `json:"operateTime"`
	// 更新时间
	UpdatedAt time.Time `json:"updatedAt"`
	// 删除时间
	DeletedAt time.Time `json:"deletedAt"`
	// 创建时间
	CreatedAt time.Time `json:"createdAt"`
}

type CooperationModeRepository interface {
	Save(cooperationMode *CooperationMode) (*CooperationMode, error)
	Remove(cooperationMode *CooperationMode) (*CooperationMode, error)
	FindOne(queryOptions map[string]interface{}) (*CooperationMode, error)
	Find(queryOptions map[string]interface{}) (int64, []*CooperationMode, error)
}

func (cooperationMode *CooperationMode) Identify() interface{} {
	if cooperationMode.CooperationModeId == 0 {
		return nil
	}
	return cooperationMode.CooperationModeId
}

func (cooperationMode *CooperationMode) Update(data map[string]interface{}) error {
	if cooperationModeId, ok := data["cooperationModeId"]; ok {
		cooperationMode.CooperationModeId = cooperationModeId.(int64)
	}
	if cooperationModeNumber, ok := data["cooperationModeNumber"]; ok {
		cooperationMode.CooperationModeNumber = cooperationModeNumber.(string)
	}
	if cooperationModeName, ok := data["cooperationModeName"]; ok {
		cooperationMode.CooperationModeName = cooperationModeName.(string)
	}
	if status, ok := data["status"]; ok {
		cooperationMode.Status = status.(int32)
	}
	if orgId, ok := data["orgId"]; ok {
		cooperationMode.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		cooperationMode.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationMode.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationMode.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationMode.Org.Company.CompanyName = companyName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationMode.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationMode.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationMode.Company.CompanyName = companyName.(string)
	}
	if remarks, ok := data["remarks"]; ok {
		cooperationMode.Remarks = remarks.(string)
	}
	if userId, ok := data["userId"]; ok {
		cooperationMode.Operator.UserId = userId.(int64)
	}
	if userBaseId, ok := data["userBaseId"]; ok {
		cooperationMode.Operator.UserBaseId = userBaseId.(int64)
	}
	if orgId, ok := data["orgId"]; ok {
		cooperationMode.Operator.Org.OrgId = orgId.(int64)
	}
	if orgName, ok := data["orgName"]; ok {
		cooperationMode.Operator.Org.OrgName = orgName.(string)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationMode.Operator.Org.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationMode.Operator.Org.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationMode.Operator.Org.Company.CompanyName = companyName.(string)
	}
	if orgs, ok := data["orgs"]; ok {
		cooperationMode.Operator.Orgs = orgs.([]*Org)
	}
	if departmentId, ok := data["departmentId"]; ok {
		cooperationMode.Operator.Department.DepartmentId = departmentId.(int64)
	}
	if departmentName, ok := data["departmentName"]; ok {
		cooperationMode.Operator.Department.DepartmentName = departmentName.(string)
	}
	if departmentNumber, ok := data["departmentNumber"]; ok {
		cooperationMode.Operator.Department.DepartmentNumber = departmentNumber.(string)
	}
	if isOrganization, ok := data["isOrganization"]; ok {
		cooperationMode.Operator.Department.IsOrganization = isOrganization.(bool)
	}
	if roleId, ok := data["roleId"]; ok {
		cooperationMode.Operator.Role.RoleId = roleId.(int64)
	}
	if roleName, ok := data["roleName"]; ok {
		cooperationMode.Operator.Role.RoleName = roleName.(string)
	}
	if userAvatar, ok := data["userAvatar"]; ok {
		cooperationMode.Operator.UserInfo.UserAvatar = userAvatar.(string)
	}
	if userEmail, ok := data["userEmail"]; ok {
		cooperationMode.Operator.UserInfo.UserEmail = userEmail.(string)
	}
	if userName, ok := data["userName"]; ok {
		cooperationMode.Operator.UserInfo.UserName = userName.(string)
	}
	if userPhone, ok := data["userPhone"]; ok {
		cooperationMode.Operator.UserInfo.UserPhone = userPhone.(string)
	}
	if userAccount, ok := data["userAccount"]; ok {
		cooperationMode.Operator.UserInfo.UserAccount = userAccount.(string)
	}
	if userType, ok := data["userType"]; ok {
		cooperationMode.Operator.UserType = userType.(int32)
	}
	if status, ok := data["status"]; ok {
		cooperationMode.Operator.Status = status.(int32)
	}
	if companyId, ok := data["companyId"]; ok {
		cooperationMode.Operator.Company.CompanyId = companyId.(int64)
	}
	if companyLogo, ok := data["companyLogo"]; ok {
		cooperationMode.Operator.Company.CompanyLogo = companyLogo.(string)
	}
	if companyName, ok := data["companyName"]; ok {
		cooperationMode.Operator.Company.CompanyName = companyName.(string)
	}
	if operateTime, ok := data["operateTime"]; ok {
		cooperationMode.OperateTime = operateTime.(time.Time)
	}
	if updatedAt, ok := data["updatedAt"]; ok {
		cooperationMode.UpdatedAt = updatedAt.(time.Time)
	}
	if deletedAt, ok := data["deletedAt"]; ok {
		cooperationMode.DeletedAt = deletedAt.(time.Time)
	}
	if createdAt, ok := data["createdAt"]; ok {
		cooperationMode.CreatedAt = createdAt.(time.Time)
	}
	return nil
}