admin_user_dto.go 1.2 KB
package dto

import (
	"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
	"time"
)

type AdminUserDto struct {
	// 用户基础数据id
	UserId int `json:"userId,omitempty"`
	// 用工编号
	UserCode string `json:"userCode"`
	//姓名
	UserName string `json:"userName"`
	// 账号
	Phone string `json:"phone"`
	// 用户关联的组织
	DepartmentName string `json:"departmentName"`
	// 账号状态 1:正常 2.禁用 3:注销
	EnableStatus int `json:"enableStatus,omitempty"`
	// 推荐人
	Referer string `json:"referer"`
	// 创建时间
	RegistrationDate string `json:"registrationDate,omitempty"`
	// 最后登录时间
	LastLogIn string `json:"lastLogIn"`
}

func NewAdminUserDto(v allied_creation_user.UserDetail) AdminUserDto {
	item := AdminUserDto{
		UserCode:         v.UserCode,
		UserId:           v.UserId,
		Phone:            v.UserInfo.Phone,
		DepartmentName:   v.Department.DepartmentName,
		EnableStatus:     v.EnableStatus,
		UserName:         v.UserInfo.UserName,
		RegistrationDate: v.CreatedAt.Format("2006-01-02"),
		LastLogIn:        "",
	}
	if v.Favorite.LastLogInAt > 0 {
		item.LastLogIn = time.Unix(v.Favorite.LastLogInAt, 0).Format("2006-01-02 15:04:05")
	}
	return item
}