department_translator.go 983 字节
package translator

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
	"time"
)

type DepartmentTranslator struct {
}

type DepartmentDetail struct {
	OrgId     int64     `json:"orgId"`
	CompanyId int64     `json:"companyId"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	DeletedAt time.Time `json:"deletedAt"`
	OrgCode   string    `json:"orgCode"`
	OrgName   string    `json:"orgName"`
	Ext       struct {
	} `json:"ext"`
	IsOrg     int `json:"isOrg"`
	OrgStatus int `json:"orgStatus"`
}

func (translator *DepartmentTranslator) ToDepartmentFromRepresentation(department *DepartmentDetail) (*domain.Department, error) {
	return &domain.Department{
		DepartmentId:     department.OrgId,
		DepartmentName:   department.OrgName,
		DepartmentNumber: department.OrgCode,
		IsOrganization:   false,
	}, nil
}

func NewDepartmentTranslator() (*DepartmentTranslator, error) {
	return &DepartmentTranslator{}, nil
}