1
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"hepa-calc-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,51 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
)
|
||||
|
||||
type CouponDto struct {
|
||||
CouponId string `json:"coupon_id"` // 主键id
|
||||
CouponName string `json:"coupon_name"` // 优惠券名称
|
||||
CouponType string `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"` // 更新时间
|
||||
}
|
||||
|
||||
// GetCouponDto 优惠卷详情
|
||||
func GetCouponDto(m *model.Coupon) *CouponDto {
|
||||
return &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,
|
||||
WithAmount: m.WithAmount,
|
||||
ValidType: m.ValidType,
|
||||
ValidDays: m.ValidDays,
|
||||
ValidStartTime: m.ValidStartTime,
|
||||
ValidEndTime: m.ValidEndTime,
|
||||
CouponDesc: m.CouponDesc,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
)
|
||||
|
||||
// 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 model.LocalTime `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 model.LocalTime `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"` // 会员
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadSystemMember 加载会员数据
|
||||
func (r *OrderMemberDto) LoadSystemMember(m *model.SystemMember) *OrderMemberDto {
|
||||
if m != nil {
|
||||
r.SystemMember = GetSystemMemberDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
)
|
||||
|
||||
// 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 model.LocalTime `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 model.LocalTime `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"` // 问题
|
||||
}
|
||||
|
||||
// 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)
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
|
||||
// LoadQuestion 加载题目数据
|
||||
func (r *OrderSingleDto) LoadQuestion(m *model.Question) *OrderSingleDto {
|
||||
if m != nil {
|
||||
r.Question = GetQuestionDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package dto
|
||||
|
||||
import "hepa-calc-api/api/model"
|
||||
|
||||
// IndexDto 首页
|
||||
type IndexDto struct {
|
||||
BaseClass []*BaseClassDto `json:"base_class"` // 分类
|
||||
HotQuestion []*QuestionDto `json:"hot_question"` // 热榜
|
||||
RecommendQuestion []*QuestionDto `json:"recommend_question"` // 为你推荐
|
||||
GuessUserLikeQuestion []*QuestionDto `json:"guess_user_like_question"` // 猜你喜欢
|
||||
}
|
||||
|
||||
// LoadBaseClass 加载数据-分类
|
||||
func (r *IndexDto) LoadBaseClass(m []*model.BaseClass) *IndexDto {
|
||||
if len(m) > 0 {
|
||||
r.BaseClass = GetBaseClassListDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadHotQuestionList 加载数据-热榜
|
||||
func (r *IndexDto) LoadHotQuestionList(m []*model.Question) *IndexDto {
|
||||
if len(m) > 0 {
|
||||
r.HotQuestion = GetHotQuestionListDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadRecommendQuestionList 加载数据-为你推荐
|
||||
func (r *IndexDto) LoadRecommendQuestionList(m []*model.Question) *IndexDto {
|
||||
if len(m) > 0 {
|
||||
r.RecommendQuestion = GetRecommendQuestionListDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadGuessUserLikeList 加载数据-猜你喜欢
|
||||
func (r *IndexDto) LoadGuessUserLikeList(m []*model.Question) *IndexDto {
|
||||
if len(m) > 0 {
|
||||
r.GuessUserLikeQuestion = GetGuessUserLikeListDto(m)
|
||||
}
|
||||
return r
|
||||
}
|
||||
@@ -0,0 +1,210 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-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"` // 优惠价格
|
||||
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"` // 被购买数量
|
||||
}
|
||||
|
||||
// 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,
|
||||
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,
|
||||
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
|
||||
}
|
||||
|
||||
// GetQuestionPageListDto 列表-分页问题
|
||||
func GetQuestionPageListDto(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,
|
||||
Price: v.Price,
|
||||
DiscountPrice: v.DiscountPrice,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
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-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"` // 优惠价格
|
||||
FirstTimePrice float64 `json:"first_time_price"` // 首次购买价格
|
||||
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,
|
||||
FirstTimePrice: v.FirstTimePrice,
|
||||
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,
|
||||
FirstTimePrice: m.FirstTimePrice,
|
||||
CreatedAt: m.CreatedAt,
|
||||
UpdatedAt: m.UpdatedAt,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
"hepa-calc-api/utils"
|
||||
)
|
||||
|
||||
// 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 model.LocalTime `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"` // 更新时间
|
||||
}
|
||||
|
||||
// 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: 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,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-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-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