新增了后台

This commit is contained in:
2024-09-03 16:05:14 +08:00
parent c233e5d9b4
commit 383817a543
40 changed files with 2485 additions and 129 deletions
-7
View File
@@ -16,7 +16,6 @@ type ArticleDto struct {
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
ArticleAuthor []*ArticleAuthorDto `json:"article_author"` // 作者
Rank *int `json:"rank"` // 排名
IsVote bool `json:"is_vote"` // 是否已投票(false:否 true:是)
}
// GetArticleListDto 列表-分页
@@ -76,9 +75,3 @@ func (r *ArticleDto) LoadRank(m int) *ArticleDto {
}
return r
}
// LoadVoteStatus 加载数据-投票状态
func (r *ArticleDto) LoadVoteStatus(m bool) *ArticleDto {
r.IsVote = m
return r
}
+10 -3
View File
@@ -1,11 +1,15 @@
package dto
import (
"fmt"
"vote-admin-api/api/model"
)
type ArticleAuthorDto struct {
AuthorId string `json:"author_id"` // 主键id
ArticleId string `json:"article_id"` // 文章id
AuthorName string `json:"author_name"` // 作者姓名
HospitalId string `json:"hospital_id"` // 作者所属id
HospitalName string `json:"hospital_name"` // 作者所属医院
}
@@ -17,12 +21,15 @@ func GetArticleAuthorListDto(m []*model.ArticleAuthor) []*ArticleAuthorDto {
if len(m) > 0 {
for i, v := range m {
response := &ArticleAuthorDto{
AuthorId: fmt.Sprintf("%d", v.AuthorId),
ArticleId: fmt.Sprintf("%d", v.ArticleId),
AuthorName: v.AuthorName,
HospitalId: fmt.Sprintf("%d", v.HospitalId),
}
// 加载数据-医院属性
if v.BaseHospital != nil {
response = response.LoadBaseHospitalAttr(v.BaseHospital)
response = response.LoadBaseHospital(v.BaseHospital)
}
// 将转换后的结构体添加到新切片中
@@ -33,8 +40,8 @@ func GetArticleAuthorListDto(m []*model.ArticleAuthor) []*ArticleAuthorDto {
return responses
}
// LoadBaseHospitalAttr 加载数据-医院属性
func (r *ArticleAuthorDto) LoadBaseHospitalAttr(m *model.BaseHospital) *ArticleAuthorDto {
// LoadBaseHospital 加载数据-医院
func (r *ArticleAuthorDto) LoadBaseHospital(m *model.BaseHospital) *ArticleAuthorDto {
if m != nil {
r.HospitalName = m.HospitalName
}
+26
View File
@@ -8,6 +8,7 @@ import (
// BaseAgreementDto 基础-协议
type BaseAgreementDto struct {
AgreementId string `json:"agreement_id"` // 主键id
AgreementTitle string `json:"agreement_title"` // 协议名称
AgreementType int `json:"agreement_type"` // 协议类型(1:大赛介绍 2:投票规则)
AgreementContent string `json:"agreement_content"` // 协议内容
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
@@ -18,9 +19,34 @@ type BaseAgreementDto struct {
func GetBaseAgreementDto(m *model.BaseAgreement) *BaseAgreementDto {
return &BaseAgreementDto{
AgreementId: fmt.Sprintf("%d", m.AgreementId),
AgreementTitle: m.AgreementTitle,
AgreementType: m.AgreementType,
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,
AgreementType: v.AgreementType,
AgreementContent: v.AgreementContent,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
+85
View File
@@ -0,0 +1,85 @@
package dto
import (
"fmt"
"vote-admin-api/api/model"
)
type BaseHospitalDto struct {
HospitalID string `json:"hospital_id"` // 主键id
HospitalName string `json:"hospital_name"` // 医院名称
HospitalStatus int `json:"hospital_status"` // 状态(0:禁用 1:正常 2:删除)
HospitalLevelName string `json:"hospital_level_name"` // 医院等级名称
PostCode string `json:"post_code"` // 邮政编码
Telephone string `json:"telephone"` // 电话
ProvinceID int `json:"province_id"` // 省份id
Province string `json:"province"` // 省份
CityID int `json:"city_id"` // 城市id
City string `json:"city"` // 城市
CountyID int `json:"county_id"` // 区县id
County string `json:"county"` // 区县
Address string `json:"address"` // 地址
Latitude string `json:"latitude"` // 纬度
Longitude string `json:"longitude"` // 经度
Description string `json:"description"` // 简介
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
func GetBaseHospitalDto(m *model.BaseHospital) *BaseHospitalDto {
return &BaseHospitalDto{
HospitalID: fmt.Sprintf("%d", m.HospitalId),
HospitalName: m.HospitalName,
HospitalStatus: m.HospitalStatus,
HospitalLevelName: m.HospitalLevelName,
PostCode: m.PostCode,
Telephone: m.HospitalName,
ProvinceID: m.ProvinceId,
Province: m.Province,
CityID: m.CityId,
City: m.City,
CountyID: m.CountyId,
County: m.County,
Address: m.Address,
Latitude: m.Lat,
Longitude: m.HospitalName,
Description: m.Desc,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
func GetBaseHospitalListDto(m []*model.BaseHospital) []BaseHospitalDto {
// 处理返回值
responses := make([]BaseHospitalDto, len(m))
if len(m) > 0 {
for i, v := range m {
response := BaseHospitalDto{
HospitalID: fmt.Sprintf("%d", v.HospitalId),
HospitalName: v.HospitalName,
HospitalStatus: v.HospitalStatus,
HospitalLevelName: v.HospitalLevelName,
PostCode: v.PostCode,
Telephone: v.HospitalName,
ProvinceID: v.ProvinceId,
Province: v.Province,
CityID: v.CityId,
City: v.City,
CountyID: v.CountyId,
County: v.County,
Address: v.Address,
Latitude: v.Lat,
Longitude: v.HospitalName,
Description: v.Desc,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
+2 -9
View File
@@ -16,15 +16,8 @@ type LoginDto struct {
// 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"` // 会员+单项购买总金额
ViewNum uint `json:"view_num"` // 浏览数量
VoteNum uint `json:"vote_num"` // 投票数量
}
// IndexDataDto 首页动态统计数据
+26
View File
@@ -0,0 +1,26 @@
package dto
import (
"fmt"
"vote-admin-api/api/model"
)
// SystemTimeDto 配置-时间
type SystemTimeDto struct {
SystemTimeId string `json:"system_time_id"` // 主键id
StartTime *model.LocalTime `json:"start_time"` // 开始投票时间
EndTime *model.LocalTime `json:"end_time"` // 结束投票时间
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 修改时间
}
// GetSystemTimeDto 详情
func GetSystemTimeDto(m *model.SystemTime) *SystemTimeDto {
return &SystemTimeDto{
SystemTimeId: fmt.Sprintf("%d", m.SystemTimeId),
StartTime: m.StartTime,
EndTime: m.EndTime,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
+50
View File
@@ -1,6 +1,7 @@
package dto
import (
"fmt"
"vote-admin-api/api/model"
)
@@ -9,8 +10,57 @@ type UserDto struct {
UserId string `json:"user_id"` // 用户id
UserStatus int `json:"user_status"` // 状态(1:正常 2:禁用)
OpenId string `json:"open_id"` // 用户微信标识
AppIden string `json:"app_iden"` // app唯一标识
LoginAt *model.LocalTime `json:"login_at"` // 登陆时间
LoginIp string `json:"login_ip"` // 登陆ip
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
}
// UserVoteDto 用户投票记录
type UserVoteDto struct {
Id string `json:"id"` // 图文/视频标识
AppIden string `json:"app_iden"` // app唯一标识
Title string `json:"title"` // 标题
VotedAt string `json:"voted_at"` // 投票时间
}
// 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),
UserStatus: v.UserStatus,
OpenId: v.OpenId,
AppIden: v.AppIden,
LoginAt: v.LoginAt,
LoginIp: v.LoginIp,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 将转换后的结构体添加到新切片中
responses[i] = response
}
}
return responses
}
// GetUserDto 详情-问题
func GetUserDto(m *model.User) *UserDto {
return &UserDto{
UserId: fmt.Sprintf("%d", m.UserId),
UserStatus: m.UserStatus,
OpenId: m.OpenId,
AppIden: m.AppIden,
LoginAt: m.LoginAt,
LoginIp: m.LoginIp,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
+26 -30
View File
@@ -7,16 +7,16 @@ import (
// VideoDto 视频表
type VideoDto struct {
VideoId string `json:"video_id"` // 主键id
VideoTitle string `json:"video_title"` // 视频标题
VideoStatus int `json:"article_status"` // 视频状态(1:正常 2:禁用)
VoteNum uint `json:"vote_num"` // 总票数
VideoUrl string `json:"video_url"` // 视频地址
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
VideoAuthor []*VideoAuthorDto `json:"video_author"` // 作者
Rank *int `json:"rank"` // 排名
IsVote bool `json:"is_vote"` // 是否已投票(false:否 true:是)
VideoId string `json:"video_id"` // 主键id
VideoTitle string `json:"video_title"` // 视频标题
VideoStatus int `json:"video_status"` // 视频状态(1:正常 2:禁用)
VideoNo string `json:"video_no"` // 视频编号
VoteNum uint `json:"vote_num"` // 总票数
VideoContent string `json:"video_content"` // 视频内容
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
VideoAuthor []*VideoAuthorDto `json:"video_author"` // 作者
Rank *int `json:"rank"` // 排名
}
// GetVideoListDto 列表-分页
@@ -27,13 +27,14 @@ func GetVideoListDto(m []*model.Video) []*VideoDto {
if len(m) > 0 {
for i, v := range m {
response := &VideoDto{
VideoId: fmt.Sprintf("%d", v.VideoId),
VideoTitle: v.VideoTitle,
VideoStatus: v.VideoStatus,
VoteNum: v.VoteNum,
VideoUrl: v.VideoUrl,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
VideoId: fmt.Sprintf("%d", v.VideoId),
VideoTitle: v.VideoTitle,
VideoStatus: v.VideoStatus,
VideoNo: v.VideoNo,
VoteNum: v.VoteNum,
VideoContent: v.VideoContent,
CreatedAt: v.CreatedAt,
UpdatedAt: v.UpdatedAt,
}
// 加载数据-作者
@@ -52,13 +53,14 @@ func GetVideoListDto(m []*model.Video) []*VideoDto {
// GetVideoDto 详情
func GetVideoDto(m *model.Video) *VideoDto {
return &VideoDto{
VideoId: fmt.Sprintf("%d", m.VideoId),
VideoTitle: m.VideoTitle,
VideoStatus: m.VideoStatus,
VoteNum: m.VoteNum,
VideoUrl: m.VideoUrl,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
VideoId: fmt.Sprintf("%d", m.VideoId),
VideoTitle: m.VideoTitle,
VideoStatus: m.VideoStatus,
VideoNo: m.VideoNo,
VoteNum: m.VoteNum,
VideoContent: m.VideoContent,
CreatedAt: m.CreatedAt,
UpdatedAt: m.UpdatedAt,
}
}
@@ -77,9 +79,3 @@ func (r *VideoDto) LoadRank(m int) *VideoDto {
}
return r
}
// LoadVoteStatus 加载数据-投票状态
func (r *VideoDto) LoadVoteStatus(m bool) *VideoDto {
r.IsVote = m
return r
}