192 lines
7.2 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package dto
import (
"case-open-api/api/model"
"case-open-api/utils"
"fmt"
)
// ResProjectDto 项目
type ResProjectDto struct {
ProjectId string `json:"project_id"` // 主键id
ProjectName string `json:"project_name"` // 项目名称
ProjectStatus int `json:"project_status"` // 项目状态0:无效 1:正常)
ProjectImage string `json:"project_image"` // 项目背景图
IsLimitNum int `json:"is_limit_num"` // 是否限制参加数量0:否 1:是)
MaxJoinNum int `json:"max_join_num"` // 医生最多可参加数量
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
CaseCount int `json:"case_count"` // 关联病例数量
IsRecentlyUpdate int `json:"is_recently_update"` // 是否最近有更新(最近7天)
IsWelfare int `json:"is_welfare"` // 是否存在福利(区分平台)
}
// ResCaseDto 病历
type ResCaseDto struct {
SId string `json:"sid"` // 主键id
ProjectId string `json:"project_id"` // 项目标识
Titel string `json:"titel"` // 病例名称
Thumb string `json:"thumb"` // 封面图片
StarTime model.LocalTime `json:"startime"` // 创建时间
Url string `json:"url"` // 链接
IsWelfare bool `json:"Is_welfare"` // 是否存在福利
IsJoin bool `json:"is_join"` // 是否参与过
IssuedScore int `json:"issued_score"` // 已发放积分
}
// ResCaseRecordDto 病例领取记录
type ResCaseRecordDto struct {
CaseUserId string `json:"id"` // 主键id
Sid string `json:"sid"` // 病例id
Beizhu string `json:"beizhu"` // 备注
OpenId string `json:"openid"` // openid
Title string `json:"title"` // 问卷标题
NickName string `json:"nickname"` // 昵称
RealName string `json:"realname"` // 真实姓名
Mobile string `json:"mobile"` // 手机号
Hos2 string `json:"hos2"` // 科室
Job string `json:"job"` // 职称
HospitalName string `json:"hospital_name"` // 医院
ResideProvince string `json:"resideprovince"` // 省份
ResideCity string `json:"residecity"` // 城市
CreateDate string `json:"createdate"` // 日期
CreateTimes string `json:"createtimes"` // 时间
ResidenceTime string `json:"residencetime"` // 用时
QuestionAnswer []*QuestionAnswerDto `json:"question_answer"` // 问题和答案数组
TslUid string `json:"tsl_uid"` // 天士力系统uid
TslShareUserId string `json:"tsl_share_user_id"` // 天士力系统分享人uid
IsVip int `json:"is_vip"` // 是否把白名单 0:否 1:是
Credit1 int `json:"credit1"` // 阅读完成积分
Credit2 int `json:"credit2"` // 调研奖励(阅读质量) 阅读时长
Credit3 int `json:"credit3"` // 调研奖励(留言)—评论奖励
Credit4 int `json:"credit4"` // 调研奖励(社区贡献) 优质提问或者优质解答
CreditTotal int `json:"credit_total"` // 总获得积分
HasRemark int `json:"has_remark"` // 是否有评论 1是0否
Remark []*RemarkDto `json:"remark"` // 评论
}
// ResCaseBehaviorDto 病例用户操作行为
type ResCaseBehaviorDto struct {
TslUid string `json:"tsl_uid"` // 天士力系统uid
Sid string `json:"sid"` // 病例id
StartTime string `json:"starttime"` // 开始时间
EndTime string `json:"endtime"` // 结束时间
UseTime int `json:"usetime"` // 总用时单位秒
IsComplete int `json:"is_complete"` // 是否完成了问卷 1是0 否
Action []*ActionDto `json:"action"` // 步骤数组
}
// ActionDto 病例用户操作行为-步骤数组
type ActionDto struct {
Step string `json:"step"` //步骤名称
In string `json:"in"` //进入时间
Out string `json:"out"` //结束时间
UseTime int `json:"usetime"` //用时 单位秒
}
// QuestionAnswerDto 病例领取记录-问题
type QuestionAnswerDto struct {
Question string `json:"question"` // 问题标题
Answer string `json:"answer"` // 答案
Correct bool `json:"correct"` //
Order int `json:"order"` // 排序
}
// RemarkDto 病例领取记录-评论
type RemarkDto struct {
Remark string `json:"remark"` // 评论
CreateTime string `json:"createtime"` // 时间
}
// GetResProjectListDto 获取项目列表
func GetResProjectListDto(m []*model.Project) []*ResProjectDto {
// 处理返回值
responses := make([]*ResProjectDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := &ResProjectDto{
ProjectId: fmt.Sprintf("%d", v.ProjectId),
ProjectName: v.ProjectName,
ProjectStatus: v.ProjectStatus,
ProjectImage: utils.AddOssDomain(v.ProjectImage),
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 加载关联病例数量
response = response.LoadCaseCount(v.Case)
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
// GetCaseResListDto 获取病例列表
func GetCaseResListDto(m []*model.Case) []*ResCaseDto {
// 处理返回值
responses := make([]*ResCaseDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := &ResCaseDto{
SId: fmt.Sprintf("%d", v.CaseId),
ProjectId: fmt.Sprintf("%d", v.ProjectId),
Titel: v.CaseName,
Thumb: "",
StarTime: v.CreatedAt,
}
// 加载已发放积分
response.LoadIssuedScore(v.CasePlatform)
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
// LoadCaseCount 加载关联病例数量
func (r *ResProjectDto) LoadCaseCount(m []*model.Case) *ResProjectDto {
if len(m) > 0 {
r.CaseCount = len(m)
}
return r
}
// LoadIsWelfare 加载是否存在福利
func (r *ResProjectDto) LoadIsWelfare(m *model.ProjectPlatform) *ResProjectDto {
if m != nil {
r.IsWelfare = m.IsWelfare
}
return r
}
// LoadIsRecentlyUpdate 加载最近更新情况
func (r *ResProjectDto) LoadIsRecentlyUpdate(m *model.Case) *ResProjectDto {
if m != nil {
r.IsRecentlyUpdate = 1
}
return r
}
// LoadLink 加载访问链接
func (r *ResCaseDto) LoadLink(link string) *ResCaseDto {
r.Url = link
return r
}
// LoadIssuedScore 加载已发放积分
func (r *ResCaseDto) LoadIssuedScore(m *model.CasePlatform) *ResCaseDto {
if m != nil {
r.IssuedScore = m.IssuedScore
}
return r
}