患者列表-导出
This commit is contained in:
@@ -172,6 +172,17 @@ type OrderInquiryForAccount struct {
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// UserPatientData 患者列表
|
||||
type UserPatientData struct {
|
||||
UserName string // 用户名称
|
||||
Status string // 状态(0:禁用 1:正常 2:删除)
|
||||
Mobile string // 手机号
|
||||
Avatar string // 头像
|
||||
DisableReason string // 禁用理由
|
||||
PatientFamilyCount string // 家庭成员数量
|
||||
CreatedAt time.Time // 创建时间
|
||||
}
|
||||
|
||||
// DoctorWithdrawal 提现记录
|
||||
func (r *ExportService) DoctorWithdrawal(doctorWithdrawals []*model.DoctorWithdrawal) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
@@ -1026,3 +1037,60 @@ func (r *ExportService) OrderInquiryForAccount(d []*model.OrderInquiry) (string,
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
// UserPatient 患者列表
|
||||
func (r *ExportService) UserPatient(d []*model.UserPatient) (string, error) {
|
||||
header := []utils.HeaderCellData{
|
||||
{Value: "用户名称", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "状态", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "手机号", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "头像", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "禁用理由", CellType: "string", NumberFmt: "", ColWidth: 30},
|
||||
{Value: "家庭成员数量", CellType: "string", NumberFmt: "", ColWidth: 18},
|
||||
{Value: "创建时间", CellType: "date", NumberFmt: "yyyy-mm-dd hh:mm:ss", ColWidth: 30},
|
||||
}
|
||||
|
||||
var dataSlice []interface{}
|
||||
for _, v := range d {
|
||||
data := UserPatientData{
|
||||
UserName: v.UserName,
|
||||
Status: utils.UserPatientStatusToString(v.Status),
|
||||
Avatar: utils.AddOssDomain(v.Avatar),
|
||||
DisableReason: v.DisableReason,
|
||||
}
|
||||
|
||||
if v.User != nil {
|
||||
data.Mobile = v.User.Mobile
|
||||
}
|
||||
|
||||
if v.CreatedAt != (model.LocalTime{}) {
|
||||
t := time.Time(v.CreatedAt)
|
||||
data.CreatedAt = t
|
||||
}
|
||||
|
||||
if len(v.PatientFamily) > 0 {
|
||||
data.PatientFamilyCount = fmt.Sprintf("%d", len(v.PatientFamily))
|
||||
}
|
||||
dataSlice = append(dataSlice, data)
|
||||
}
|
||||
|
||||
file, err := utils.Export(header, dataSlice)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 设置文件名字
|
||||
now := time.Now()
|
||||
dateTimeString := now.Format("20060102150405") // 当前时间字符串
|
||||
rand.Seed(time.Now().UnixNano()) // 设置随机数
|
||||
ossPath := "admin/export/output" + dateTimeString + fmt.Sprintf("%d", rand.Intn(9000)+1000) + ".xlsx"
|
||||
|
||||
// 上传oss
|
||||
_, err = aliyun.PutObjectByte(ossPath, file.Bytes())
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ossPath = utils.AddOssDomain("/" + ossPath)
|
||||
return ossPath, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user