肝病算一算后台api初始化
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
// BaseAgreementDto 基础数据-协议
|
||||
type BaseAgreementDto struct {
|
||||
AgreementId string `json:"agreement_id"` // 主键id
|
||||
AgreementTitle string `json:"agreement_title"` // 协议标题
|
||||
AgreementContent string `json:"agreement_content"` // 协议内容
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetBaseAgreementDto 详情-协议-分类表
|
||||
func GetBaseAgreementDto(m *model.BaseAgreement) *BaseAgreementDto {
|
||||
return &BaseAgreementDto{
|
||||
AgreementId: fmt.Sprintf("%d", m.AgreementId),
|
||||
AgreementTitle: m.AgreementTitle,
|
||||
AgreementContent: m.AgreementContent,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetBaseAgreementListDto 列表-基础数据-协议
|
||||
func GetBaseAgreementListDto(m []*model.BaseAgreement) []*BaseAgreementDto {
|
||||
// 处理返回值
|
||||
responses := make([]*BaseAgreementDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &BaseAgreementDto{
|
||||
AgreementId: fmt.Sprintf("%d", v.AgreementId),
|
||||
AgreementTitle: v.AgreementTitle,
|
||||
AgreementContent: v.AgreementContent,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
)
|
||||
|
||||
// BaseClassDto 基础数据-分类表
|
||||
type BaseClassDto struct {
|
||||
ClassId string `json:"class_id"` // 主键id
|
||||
ClassName string `json:"class_name"` // 分类名称
|
||||
ClassStatus int `json:"class_status"` // 分类状态(1:正常 2:隐藏)
|
||||
ClassIcon string `json:"class_icon"` // 图标地址
|
||||
ClassBrief string `json:"class_brief"` // 分类简介
|
||||
Sort uint `json:"sort"` // 排序值(越大排名越靠前)
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetBaseClassDto 详情-基础数据-分类表
|
||||
func GetBaseClassDto(m *model.BaseClass) *BaseClassDto {
|
||||
return &BaseClassDto{
|
||||
ClassId: fmt.Sprintf("%d", m.ClassId),
|
||||
ClassName: m.ClassName,
|
||||
ClassStatus: m.ClassStatus,
|
||||
ClassIcon: utils.AddOssDomain(m.ClassIcon),
|
||||
ClassBrief: m.ClassBrief,
|
||||
Sort: m.Sort,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetBaseClassListDto 列表-基础数据-分类表
|
||||
func GetBaseClassListDto(m []*model.BaseClass) []*BaseClassDto {
|
||||
// 处理返回值
|
||||
responses := make([]*BaseClassDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &BaseClassDto{
|
||||
ClassId: fmt.Sprintf("%d", v.ClassId),
|
||||
ClassName: v.ClassName,
|
||||
ClassStatus: v.ClassStatus,
|
||||
ClassIcon: utils.AddOssDomain(v.ClassIcon),
|
||||
ClassBrief: v.ClassBrief,
|
||||
Sort: v.Sort,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
type CouponDto struct {
|
||||
CouponId string `json:"coupon_id"` // 主键id
|
||||
CouponName string `json:"coupon_name"` // 优惠券名称
|
||||
CouponType int `json:"coupon_type"` // 优惠券类型(1:无门槛 2:满减)
|
||||
CouponStatus int `json:"coupon_status"` // 状态(1:正常 2:强制失效 3:结束 4:删除)
|
||||
ApplicationScope int `json:"application_scope"` // 适用范围(1:全场通用)
|
||||
IsMutex int `json:"is_mutex"` // 是否互斥(0:否 1:是)
|
||||
CouponCount int `json:"coupon_count"` // 发放数量
|
||||
CouponTakeCount int `json:"coupon_take_count"` // 已领取数量
|
||||
CouponUsedCount int `json:"coupon_used_count"` // 已使用数量
|
||||
CouponPrice float64 `json:"coupon_price"` // 优惠券金额
|
||||
WithAmount float64 `json:"with_amount"` // 符合满减标准金额(优惠券类型为满减时使用)
|
||||
ValidType int `json:"valid_type"` // 有效类型(1:绝对时效,xxx-xxx时间段有效 2:相对时效 n天内有效)
|
||||
ValidDays int `json:"valid_days"` // 自领取之日起有效天数
|
||||
ValidStartTime *model.LocalTime `json:"valid_start_time"` // 开始使用时间
|
||||
ValidEndTime *model.LocalTime `json:"valid_end_time"` // 结束使用时间
|
||||
CouponDesc string `json:"coupon_desc"` // 优惠券描述
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetCouponListDto 列表
|
||||
func GetCouponListDto(m []*model.Coupon) []*CouponDto {
|
||||
// 处理返回值
|
||||
responses := make([]*CouponDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &CouponDto{
|
||||
CouponId: fmt.Sprintf("%d", v.CouponId),
|
||||
CouponName: v.CouponName,
|
||||
CouponType: v.CouponType,
|
||||
CouponStatus: v.CouponStatus,
|
||||
ApplicationScope: v.ApplicationScope,
|
||||
IsMutex: v.IsMutex,
|
||||
CouponCount: v.CouponCount,
|
||||
CouponTakeCount: v.CouponTakeCount,
|
||||
CouponUsedCount: v.CouponUsedCount,
|
||||
CouponPrice: v.CouponPrice,
|
||||
ValidType: v.ValidType,
|
||||
ValidStartTime: v.ValidStartTime,
|
||||
ValidEndTime: v.ValidEndTime,
|
||||
CouponDesc: v.CouponDesc,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
if v.WithAmount != nil {
|
||||
response.WithAmount = *v.WithAmount
|
||||
}
|
||||
|
||||
if v.ValidDays != nil {
|
||||
response.ValidDays = *v.ValidDays
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetCouponDto 优惠卷详情
|
||||
func GetCouponDto(m *model.Coupon) *CouponDto {
|
||||
response := &CouponDto{
|
||||
CouponId: fmt.Sprintf("%d", m.CouponId),
|
||||
CouponName: m.CouponName,
|
||||
CouponType: m.CouponType,
|
||||
CouponStatus: m.CouponStatus,
|
||||
ApplicationScope: m.ApplicationScope,
|
||||
IsMutex: m.IsMutex,
|
||||
CouponCount: m.CouponCount,
|
||||
CouponTakeCount: m.CouponTakeCount,
|
||||
CouponUsedCount: m.CouponUsedCount,
|
||||
CouponPrice: m.CouponPrice,
|
||||
ValidType: m.ValidType,
|
||||
ValidStartTime: m.ValidStartTime,
|
||||
ValidEndTime: m.ValidEndTime,
|
||||
CouponDesc: m.CouponDesc,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
|
||||
if m.WithAmount != nil {
|
||||
response.WithAmount = *m.WithAmount
|
||||
}
|
||||
|
||||
if m.ValidDays != nil {
|
||||
response.ValidDays = *m.ValidDays
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
type WxDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
type MobileDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
// LoginWxDto 微信登陆
|
||||
func LoginWxDto(m *model.User) *WxDto {
|
||||
return &WxDto{
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
UserName: m.UserName,
|
||||
Mobile: m.Mobile,
|
||||
OpenId: m.OpenId,
|
||||
Avatar: utils.AddOssDomain(m.Avatar),
|
||||
IsMember: m.IsMember,
|
||||
MemberExpireDate: m.MemberExpireDate,
|
||||
}
|
||||
}
|
||||
|
||||
// LoginMobileDto 手机号登陆
|
||||
func LoginMobileDto(m *model.User) *MobileDto {
|
||||
return &MobileDto{
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
UserName: m.UserName,
|
||||
Mobile: m.Mobile,
|
||||
OpenId: m.OpenId,
|
||||
Avatar: utils.AddOssDomain(m.Avatar),
|
||||
IsMember: m.IsMember,
|
||||
MemberExpireDate: m.MemberExpireDate,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadToken 加载token
|
||||
func (r *WxDto) LoadToken(token string) *WxDto {
|
||||
r.Token = token
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadToken 加载token
|
||||
func (r *MobileDto) LoadToken(token string) *MobileDto {
|
||||
r.Token = token
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderMemberDto 订单-会员
|
||||
type OrderMemberDto struct {
|
||||
OrderId string `json:"order_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
SystemMemberId string `json:"system_member_id"` // 会员id
|
||||
OrderStatus int `json:"order_status"` // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
IsDelete int `json:"is_delete"` // 用户删除状态(0:否 1:是)
|
||||
PayChannel int `json:"pay_channel"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PayTime *time.Time `json:"pay_time"` // 支付时间
|
||||
RefundStatus int `json:"refund_status"` // 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
OrderNo string `json:"order_no"` // 系统订单编号
|
||||
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
CancelStatus int `json:"cancel_status"` // 取消状态(0:否 1:是)
|
||||
CancelTime *time.Time `json:"cancel_time"` // 订单取消时间
|
||||
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注
|
||||
OrderRemarks string `json:"order_remarks"` // 订单备注
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
SystemMember *SystemMemberDto `json:"system_member"` // 会员
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Avatar string `json:"avatar"` // 用户头像
|
||||
}
|
||||
|
||||
// GetOrderMemberListDto 列表
|
||||
func GetOrderMemberListDto(m []*model.OrderMember) []*OrderMemberDto {
|
||||
// 处理返回值
|
||||
responses := make([]*OrderMemberDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &OrderMemberDto{
|
||||
OrderId: fmt.Sprintf("%d", v.OrderId),
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
SystemMemberId: fmt.Sprintf("%d", v.SystemMemberId),
|
||||
OrderStatus: v.OrderStatus,
|
||||
IsDelete: v.IsDelete,
|
||||
PayChannel: v.PayChannel,
|
||||
PayStatus: v.PayStatus,
|
||||
PayTime: v.PayTime,
|
||||
RefundStatus: v.RefundStatus,
|
||||
OrderNo: v.OrderNo,
|
||||
EscrowTradeNo: v.EscrowTradeNo,
|
||||
AmountTotal: v.AmountTotal,
|
||||
CouponAmountTotal: v.CouponAmountTotal,
|
||||
PaymentAmountTotal: v.PaymentAmountTotal,
|
||||
CancelStatus: v.CancelStatus,
|
||||
CancelTime: v.CancelTime,
|
||||
CancelRemarks: v.CancelRemarks,
|
||||
OrderRemarks: v.OrderRemarks,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载会员数据
|
||||
if v.SystemMember != nil {
|
||||
response = response.LoadSystemMember(v.SystemMember)
|
||||
}
|
||||
|
||||
// 加载用户数据
|
||||
if v.User != nil {
|
||||
response = response.LoadUserAttr(v.User)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetOrderMemberDto 详情
|
||||
func GetOrderMemberDto(m *model.OrderMember) *OrderMemberDto {
|
||||
return &OrderMemberDto{
|
||||
OrderId: fmt.Sprintf("%d", m.OrderId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
SystemMemberId: fmt.Sprintf("%d", m.SystemMemberId),
|
||||
OrderStatus: m.OrderStatus,
|
||||
IsDelete: m.IsDelete,
|
||||
PayChannel: m.PayChannel,
|
||||
PayStatus: m.PayStatus,
|
||||
PayTime: m.PayTime,
|
||||
RefundStatus: m.RefundStatus,
|
||||
OrderNo: m.OrderNo,
|
||||
EscrowTradeNo: m.EscrowTradeNo,
|
||||
AmountTotal: m.AmountTotal,
|
||||
CouponAmountTotal: m.CouponAmountTotal,
|
||||
PaymentAmountTotal: m.PaymentAmountTotal,
|
||||
CancelStatus: m.CancelStatus,
|
||||
CancelTime: m.CancelTime,
|
||||
CancelRemarks: m.CancelRemarks,
|
||||
OrderRemarks: m.OrderRemarks,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadSystemMember 加载会员数据
|
||||
func (r *OrderMemberDto) LoadSystemMember(m *model.SystemMember) *OrderMemberDto {
|
||||
if m != nil {
|
||||
r.SystemMember = GetSystemMemberDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserAttr 加载用户数据
|
||||
func (r *OrderMemberDto) LoadUserAttr(m *model.User) *OrderMemberDto {
|
||||
if m != nil {
|
||||
r.UserName = m.UserName
|
||||
r.Avatar = utils.AddOssDomain(m.Avatar)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OrderSingleDto 订单-单项
|
||||
type OrderSingleDto struct {
|
||||
OrderId string `json:"order_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
QuestionId string `json:"question_id"` // 问题id
|
||||
OrderStatus int `json:"order_status"` // 订单状态(1:待支付 2:已完成 3:已取消)
|
||||
IsDelete int `json:"is_delete"` // 用户删除状态(0:否 1:是)
|
||||
PayChannel int `json:"pay_channel"` // 支付渠道(1:h5支付 2:app支付 3:会员支付)
|
||||
PayStatus int `json:"pay_status"` // 支付状态(1:未支付 2:已支付 3:支付中 4:支付失败 5:支付超时 6:支付关闭 7:已撤销 8:转入退款)
|
||||
PayTime *time.Time `json:"pay_time"` // 支付时间
|
||||
RefundStatus int `json:"refund_status"` // 订单退款状态(0:无退款 1:申请退款 2:退款中 3:退款成功 4:拒绝退款 5:退款关闭 6:退款异常 7:部分退款)
|
||||
OrderNo string `json:"order_no"` // 系统订单编号
|
||||
EscrowTradeNo string `json:"escrow_trade_no"` // 第三方支付流水号
|
||||
AmountTotal float64 `json:"amount_total"` // 订单金额
|
||||
CouponAmountTotal float64 `json:"coupon_amount_total"` // 优惠卷总金额
|
||||
PaymentAmountTotal float64 `json:"payment_amount_total"` // 实际付款金额
|
||||
CancelStatus int `json:"cancel_status"` // 取消状态(0:否 1:是)
|
||||
CancelTime *time.Time `json:"cancel_time"` // 订单取消时间
|
||||
CancelRemarks string `json:"cancel_remarks"` // 取消订单备注
|
||||
OrderRemarks string `json:"order_remarks"` // 订单备注
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Question *QuestionDto `json:"question"` // 问题
|
||||
ValidDate model.LocalTime `json:"valid_date"` // 到期时间
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Avatar string `json:"avatar"` // 用户头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 用户会员到期时间(非会员时为null)
|
||||
}
|
||||
|
||||
// GetOrderSingleListDto 列表
|
||||
func GetOrderSingleListDto(m []*model.OrderSingle) []*OrderSingleDto {
|
||||
// 处理返回值
|
||||
responses := make([]*OrderSingleDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &OrderSingleDto{
|
||||
OrderId: fmt.Sprintf("%d", v.OrderId),
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
||||
OrderStatus: v.OrderStatus,
|
||||
IsDelete: v.IsDelete,
|
||||
PayChannel: v.PayChannel,
|
||||
PayStatus: v.PayStatus,
|
||||
PayTime: v.PayTime,
|
||||
RefundStatus: v.RefundStatus,
|
||||
OrderNo: v.OrderNo,
|
||||
EscrowTradeNo: v.EscrowTradeNo,
|
||||
AmountTotal: v.AmountTotal,
|
||||
CouponAmountTotal: v.CouponAmountTotal,
|
||||
PaymentAmountTotal: v.PaymentAmountTotal,
|
||||
CancelStatus: v.CancelStatus,
|
||||
CancelTime: v.CancelTime,
|
||||
CancelRemarks: v.CancelRemarks,
|
||||
OrderRemarks: v.OrderRemarks,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载问题数据
|
||||
if v.Question != nil {
|
||||
response = response.LoadQuestion(v.Question)
|
||||
}
|
||||
|
||||
// 加载用户数据
|
||||
if v.User != nil {
|
||||
response = response.LoadUserAttr(v.User)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetOrderSingleDto 详情
|
||||
func GetOrderSingleDto(m *model.OrderSingle) *OrderSingleDto {
|
||||
return &OrderSingleDto{
|
||||
OrderId: fmt.Sprintf("%d", m.OrderId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
QuestionId: fmt.Sprintf("%d", m.QuestionId),
|
||||
OrderStatus: m.OrderStatus,
|
||||
IsDelete: m.IsDelete,
|
||||
PayChannel: m.PayChannel,
|
||||
PayStatus: m.PayStatus,
|
||||
PayTime: m.PayTime,
|
||||
RefundStatus: m.RefundStatus,
|
||||
OrderNo: m.OrderNo,
|
||||
EscrowTradeNo: m.EscrowTradeNo,
|
||||
AmountTotal: m.AmountTotal,
|
||||
CouponAmountTotal: m.CouponAmountTotal,
|
||||
PaymentAmountTotal: m.PaymentAmountTotal,
|
||||
CancelStatus: m.CancelStatus,
|
||||
CancelTime: m.CancelTime,
|
||||
CancelRemarks: m.CancelRemarks,
|
||||
OrderRemarks: m.OrderRemarks,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadQuestion 加载题目数据
|
||||
func (r *OrderSingleDto) LoadQuestion(m *model.Question) *OrderSingleDto {
|
||||
if m != nil {
|
||||
r.Question = GetQuestionDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadValidDate 加载到期时间
|
||||
func (r *OrderSingleDto) LoadValidDate(m *time.Time) *OrderSingleDto {
|
||||
if m != nil {
|
||||
r.ValidDate = model.LocalTime(*m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadUserAttr 加载用户数据
|
||||
func (r *OrderSingleDto) LoadUserAttr(m *model.User) *OrderSingleDto {
|
||||
if m != nil {
|
||||
r.UserName = m.UserName
|
||||
r.Avatar = utils.AddOssDomain(m.Avatar)
|
||||
r.IsMember = m.IsMember
|
||||
r.MemberExpireDate = m.MemberExpireDate
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
)
|
||||
|
||||
// LoginDto 登陆
|
||||
type LoginDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
NickName string `json:"nick_name"` // 用户名称
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
Token string `json:"token"` // token
|
||||
}
|
||||
|
||||
// IndexDto 首页
|
||||
type IndexDto struct {
|
||||
QuestionCount int64 `json:"question_count"` // 问题数量
|
||||
UserCount int64 `json:"user_count"` // 用户数量
|
||||
ValidMemberCount int64 `json:"valid_member_count"` // 有效会员数
|
||||
QuestionSubmitCount int64 `json:"question_submit_count"` // 问题总提交次数
|
||||
QuestionPayCount int64 `json:"question_pay_count"` // 问题总支付次数
|
||||
MemberBuyCount int64 `json:"member_buy_count"` // 会员购买次数
|
||||
MemberAmountTotal float64 `json:"member_amount_total"` // 会员购买总金额
|
||||
SingleAmountTotal float64 `json:"single_amount_total"` // 单项购买总金额
|
||||
AmountTotal float64 `json:"amount_total"` // 会员+单项购买总金额
|
||||
}
|
||||
|
||||
// IndexDataDto 首页动态统计数据
|
||||
type IndexDataDto struct {
|
||||
Date string `json:"date"` // 日期
|
||||
Count int64 `json:"count"` // 数量
|
||||
}
|
||||
|
||||
// AdminLoginDto 微信登陆
|
||||
func AdminLoginDto(m *model.AdminUser) *LoginDto {
|
||||
return &LoginDto{
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
NickName: m.NickName,
|
||||
Avatar: utils.AddOssDomain(m.Avatar),
|
||||
}
|
||||
}
|
||||
|
||||
// LoadToken 加载token
|
||||
func (r *LoginDto) LoadToken(token string) *LoginDto {
|
||||
r.Token = token
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,187 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
// QuestionDto 问题表
|
||||
type QuestionDto struct {
|
||||
QuestionId string `json:"question_id"` // 主键id
|
||||
QuestionTitle string `json:"question_title"` // 标题
|
||||
QuestionSubtitle string `json:"question_subtitle"` // 副标题
|
||||
QuestionIden string `json:"question_iden"` // 唯一标识
|
||||
QuestionStatus int `json:"question_status"` // 问题状态(1:正常 2:待发布)
|
||||
IsHide int `json:"is_hide"` // 是否隐藏(0:否 1:是)
|
||||
IsRecommend int `json:"is_recommend"` // 是否推荐(0:否 1:是)
|
||||
ClickCount int `json:"click_count"` // 点击次数(点击进入详情页的人次)
|
||||
SubmitCount int `json:"submit_count"` // 提交次数(提交个人信息进行了算算的人次)
|
||||
PayCount int `json:"pay_count"` // 支付次数(查看报告的人次)
|
||||
Price float64 `json:"price"` // 价格(原价)
|
||||
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
|
||||
DiscountEndTime *model.LocalTime `json:"discount_end_time"` // 优惠截止时间
|
||||
QuestionBrief string `json:"question_brief"` // 问题介绍
|
||||
QuestionExplain string `json:"question_explain"` // 问题解释/科普
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
IsCollection bool `json:"is_collection"` // 用户是否收藏
|
||||
FirstTimePrice *float64 `json:"first_time_price"` // 首次购买价格
|
||||
BuyCount int `json:"buy_count"` // 被购买数量
|
||||
BaseClass []*BaseClassDto `json:"base_class"` // 关联分类
|
||||
}
|
||||
|
||||
// GetQuestionDto 详情-问题
|
||||
func GetQuestionDto(m *model.Question) *QuestionDto {
|
||||
return &QuestionDto{
|
||||
QuestionId: fmt.Sprintf("%d", m.QuestionId),
|
||||
QuestionTitle: m.QuestionTitle,
|
||||
QuestionSubtitle: m.QuestionSubtitle,
|
||||
QuestionIden: m.QuestionIden,
|
||||
QuestionStatus: m.QuestionStatus,
|
||||
IsHide: m.IsHide,
|
||||
IsRecommend: m.IsRecommend,
|
||||
ClickCount: m.ClickCount,
|
||||
SubmitCount: m.SubmitCount,
|
||||
PayCount: m.PayCount,
|
||||
Price: m.Price,
|
||||
DiscountPrice: m.DiscountPrice,
|
||||
DiscountEndTime: (*model.LocalTime)(m.DiscountEndTime),
|
||||
QuestionBrief: m.QuestionBrief,
|
||||
QuestionExplain: m.QuestionExplain,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetQuestionListDto 列表-问题
|
||||
func GetQuestionListDto(m []*model.Question) []*QuestionDto {
|
||||
// 处理返回值
|
||||
responses := make([]*QuestionDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &QuestionDto{
|
||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
||||
QuestionTitle: v.QuestionTitle,
|
||||
QuestionSubtitle: v.QuestionSubtitle,
|
||||
QuestionIden: v.QuestionIden,
|
||||
QuestionStatus: v.QuestionStatus,
|
||||
IsHide: v.IsHide,
|
||||
IsRecommend: v.IsRecommend,
|
||||
ClickCount: v.ClickCount,
|
||||
SubmitCount: v.SubmitCount,
|
||||
PayCount: v.PayCount,
|
||||
Price: v.Price,
|
||||
DiscountPrice: v.DiscountPrice,
|
||||
DiscountEndTime: (*model.LocalTime)(v.DiscountEndTime),
|
||||
QuestionBrief: v.QuestionBrief,
|
||||
QuestionExplain: v.QuestionExplain,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetHotQuestionListDto 列表-热榜问题
|
||||
func GetHotQuestionListDto(m []*model.Question) []*QuestionDto {
|
||||
// 处理返回值
|
||||
responses := make([]*QuestionDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &QuestionDto{
|
||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
||||
QuestionTitle: v.QuestionTitle,
|
||||
QuestionSubtitle: v.QuestionSubtitle,
|
||||
QuestionIden: v.QuestionIden,
|
||||
ClickCount: v.ClickCount,
|
||||
SubmitCount: v.SubmitCount,
|
||||
PayCount: v.PayCount,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetRecommendQuestionListDto 列表-为你推荐
|
||||
func GetRecommendQuestionListDto(m []*model.Question) []*QuestionDto {
|
||||
// 处理返回值
|
||||
responses := make([]*QuestionDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &QuestionDto{
|
||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
||||
QuestionTitle: v.QuestionTitle,
|
||||
QuestionSubtitle: v.QuestionSubtitle,
|
||||
QuestionIden: v.QuestionIden,
|
||||
ClickCount: v.ClickCount,
|
||||
SubmitCount: v.SubmitCount,
|
||||
PayCount: v.PayCount,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetGuessUserLikeListDto 列表-猜你喜欢
|
||||
func GetGuessUserLikeListDto(m []*model.Question) []*QuestionDto {
|
||||
// 处理返回值
|
||||
responses := make([]*QuestionDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &QuestionDto{
|
||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
||||
QuestionTitle: v.QuestionTitle,
|
||||
QuestionSubtitle: v.QuestionSubtitle,
|
||||
QuestionIden: v.QuestionIden,
|
||||
ClickCount: v.ClickCount,
|
||||
SubmitCount: v.SubmitCount,
|
||||
PayCount: v.PayCount,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadIsCollection 加载数据-是否收藏
|
||||
func (r *QuestionDto) LoadIsCollection(isCollection bool) *QuestionDto {
|
||||
r.IsCollection = isCollection
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadFirstTimePrice 加载数据-首次购买价格
|
||||
func (r *QuestionDto) LoadFirstTimePrice(firstTimePrice *float64) *QuestionDto {
|
||||
if firstTimePrice != nil {
|
||||
r.FirstTimePrice = firstTimePrice
|
||||
}
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadBuyCount 加载数据-问题被购买数量
|
||||
func (r *QuestionDto) LoadBuyCount(buyCount int) *QuestionDto {
|
||||
r.BuyCount = buyCount
|
||||
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
// SystemMemberDto 配置-会员配置
|
||||
type SystemMemberDto struct {
|
||||
SystemMemberId string `json:"system_member_id"` // 主键id
|
||||
MemberDays uint `json:"member_days"` // 会员天数
|
||||
Price float64 `json:"price"` // 价格(原价)
|
||||
DiscountPrice *float64 `json:"discount_price"` // 优惠价格
|
||||
DiscountEndTime *model.LocalTime `json:"discount_end_time"` // 优惠截止时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetSystemMemberListDto 列表
|
||||
func GetSystemMemberListDto(m []*model.SystemMember) []*SystemMemberDto {
|
||||
// 处理返回值
|
||||
responses := make([]*SystemMemberDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &SystemMemberDto{
|
||||
SystemMemberId: fmt.Sprintf("%d", v.SystemMemberId),
|
||||
MemberDays: v.MemberDays,
|
||||
Price: v.Price,
|
||||
DiscountPrice: v.DiscountPrice,
|
||||
DiscountEndTime: (*model.LocalTime)(v.DiscountEndTime),
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetSystemMemberDto 详情
|
||||
func GetSystemMemberDto(m *model.SystemMember) *SystemMemberDto {
|
||||
return &SystemMemberDto{
|
||||
SystemMemberId: fmt.Sprintf("%d", m.SystemMemberId),
|
||||
MemberDays: m.MemberDays,
|
||||
Price: m.Price,
|
||||
DiscountPrice: m.DiscountPrice,
|
||||
DiscountEndTime: (*model.LocalTime)(m.DiscountEndTime),
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
// SystemSingleDto 配置-会员配置
|
||||
type SystemSingleDto struct {
|
||||
SystemSingleId string `json:"system_member_id"` // 主键id
|
||||
FirstTimePrice float64 `json:"first_time_price"` // 首次购买价格
|
||||
ValidDays int `json:"valid_days"` // 购买后有效天数
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetSystemSingleListDto 列表
|
||||
func GetSystemSingleListDto(m []*model.SystemSingle) []*SystemSingleDto {
|
||||
// 处理返回值
|
||||
responses := make([]*SystemSingleDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &SystemSingleDto{
|
||||
SystemSingleId: fmt.Sprintf("%d", v.SystemSingleId),
|
||||
FirstTimePrice: v.FirstTimePrice,
|
||||
ValidDays: v.ValidDays,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetSystemSingleDto 详情
|
||||
func GetSystemSingleDto(m *model.SystemSingle) *SystemSingleDto {
|
||||
return &SystemSingleDto{
|
||||
SystemSingleId: fmt.Sprintf("%d", m.SystemSingleId),
|
||||
FirstTimePrice: m.FirstTimePrice,
|
||||
ValidDays: m.ValidDays,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
"hepa-calc-admin-api/utils"
|
||||
"time"
|
||||
)
|
||||
|
||||
// UserDto 用户表
|
||||
type UserDto struct {
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
UserName string `json:"user_name"` // 用户名称
|
||||
Mobile string `json:"mobile"` // 手机号
|
||||
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
|
||||
RegisterSource int `json:"register_source"` // 注册来源(1:app注册 2:公众号注册)
|
||||
OpenId string `json:"open_id"` // 用户微信标识
|
||||
UnionId string `json:"union_id"` // 微信开放平台标识
|
||||
Age *uint `json:"age"` // 年龄
|
||||
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||
Avatar string `json:"avatar"` // 头像
|
||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||
MemberExpireDate *time.Time `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||
LoginAt model.LocalTime `json:"login_at"` // 登陆时间
|
||||
LoginIp string `json:"login_ip"` // 登陆ip
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
IsInfoComplete int `json:"is_info_complete"` // 信息完善状态 0:否 1:是
|
||||
}
|
||||
|
||||
// GetUserListDto 列表
|
||||
func GetUserListDto(m []*model.User) []*UserDto {
|
||||
// 处理返回值
|
||||
responses := make([]*UserDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &UserDto{
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
UserName: v.UserName,
|
||||
Mobile: v.Mobile,
|
||||
UserStatus: v.UserStatus,
|
||||
RegisterSource: v.RegisterSource,
|
||||
Age: v.Age,
|
||||
Sex: uint(v.Sex),
|
||||
Avatar: utils.AddOssDomain(v.Avatar),
|
||||
IsMember: v.IsMember,
|
||||
MemberExpireDate: v.MemberExpireDate,
|
||||
LoginAt: v.LoginAt,
|
||||
LoginIp: v.LoginIp,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载信息完善状态
|
||||
if v.UserInfo != nil {
|
||||
response = response.LoadIsInfoComplete(v.UserInfo)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// GetUserDto 详情-问题
|
||||
func GetUserDto(m *model.User) *UserDto {
|
||||
return &UserDto{
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
UserName: m.UserName,
|
||||
Mobile: m.Mobile,
|
||||
UserStatus: m.UserStatus,
|
||||
RegisterSource: m.RegisterSource,
|
||||
Age: m.Age,
|
||||
Sex: uint(m.Sex),
|
||||
Avatar: utils.AddOssDomain(m.Avatar),
|
||||
IsMember: m.IsMember,
|
||||
MemberExpireDate: m.MemberExpireDate,
|
||||
LoginAt: m.LoginAt,
|
||||
LoginIp: m.LoginIp,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// LoadIsInfoComplete 加载信息完善状态
|
||||
func (r *UserDto) LoadIsInfoComplete(m *model.UserInfo) *UserDto {
|
||||
if m != nil {
|
||||
if m.DiseaseClassId != 0 && m.FamilyHistoryId != 0 {
|
||||
r.IsInfoComplete = 1
|
||||
}
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
type UserCollectionDto struct {
|
||||
CollectionId string `json:"collection_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
QuestionId string `json:"question_id"` // 问题id
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Question *QuestionDto `json:"question"` // 问题
|
||||
}
|
||||
|
||||
// GetUserCollectionDto 用户收藏详情
|
||||
func GetUserCollectionDto(m *model.UserCollection) *UserCollectionDto {
|
||||
return &UserCollectionDto{
|
||||
CollectionId: fmt.Sprintf("%d", m.CollectionId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
QuestionId: fmt.Sprintf("%d", m.QuestionId),
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserCollectionListDto 列表
|
||||
func GetUserCollectionListDto(m []*model.UserCollection) []*UserCollectionDto {
|
||||
// 处理返回值
|
||||
responses := make([]*UserCollectionDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &UserCollectionDto{
|
||||
CollectionId: fmt.Sprintf("%d", v.CollectionId),
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
QuestionId: fmt.Sprintf("%d", v.QuestionId),
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载问题数据
|
||||
if v.Question != nil {
|
||||
response = response.LoadQuestion(v.Question)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadQuestion 加载题目数据
|
||||
func (r *UserCollectionDto) LoadQuestion(m *model.Question) *UserCollectionDto {
|
||||
if m != nil {
|
||||
r.Question = GetQuestionDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-admin-api/api/model"
|
||||
)
|
||||
|
||||
type UserCouponDto struct {
|
||||
UserCouponId string `json:"user_coupon_id"` // 主键id
|
||||
UserId string `json:"user_id"` // 用户id
|
||||
CouponId string `json:"coupon_id"` // 优惠券id
|
||||
UserCouponStatus int `json:"user_coupon_status"` // 状态(0:未使用 1:已使用 3:已过期)
|
||||
IsWindows int `json:"is_windows"` // 是否已弹窗(0:否 1:是)
|
||||
CouponUseDate model.LocalTime `json:"coupon_use_date"` // 使用时间
|
||||
ValidStartTime model.LocalTime `json:"valid_start_time"` // 有效开始时间
|
||||
ValidEndTime model.LocalTime `json:"valid_end_time"` // 过期时间
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
Coupon *CouponDto `json:"coupon"` // 优惠卷
|
||||
}
|
||||
|
||||
// GetUserCouponDto 用户优惠卷详情
|
||||
func GetUserCouponDto(m *model.UserCoupon) *UserCouponDto {
|
||||
return &UserCouponDto{
|
||||
UserCouponId: fmt.Sprintf("%d", m.UserCouponId),
|
||||
UserId: fmt.Sprintf("%d", m.UserId),
|
||||
CouponId: fmt.Sprintf("%d", m.CouponId),
|
||||
UserCouponStatus: m.UserCouponStatus,
|
||||
IsWindows: m.IsWindows,
|
||||
CouponUseDate: m.CouponUseDate,
|
||||
ValidStartTime: m.ValidStartTime,
|
||||
ValidEndTime: m.ValidEndTime,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
|
||||
// GetUserCouponListDto 列表
|
||||
func GetUserCouponListDto(m []*model.UserCoupon) []*UserCouponDto {
|
||||
// 处理返回值
|
||||
responses := make([]*UserCouponDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &UserCouponDto{
|
||||
UserCouponId: fmt.Sprintf("%d", v.UserCouponId),
|
||||
UserId: fmt.Sprintf("%d", v.UserId),
|
||||
CouponId: fmt.Sprintf("%d", v.CouponId),
|
||||
UserCouponStatus: v.UserCouponStatus,
|
||||
IsWindows: v.IsWindows,
|
||||
CouponUseDate: v.CouponUseDate,
|
||||
ValidStartTime: v.ValidStartTime,
|
||||
ValidEndTime: v.ValidEndTime,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 加载优惠卷数据
|
||||
if v.Coupon != nil {
|
||||
response = response.LoadCoupon(v.Coupon)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadCoupon 加载优惠卷数据
|
||||
func (r *UserCouponDto) LoadCoupon(m *model.Coupon) *UserCouponDto {
|
||||
if m != nil {
|
||||
d := GetCouponDto(m)
|
||||
|
||||
r.Coupon = d
|
||||
}
|
||||
return r
|
||||
}
|
||||
Reference in New Issue
Block a user