Merge branch 'dev'
This commit is contained in:
commit
cb8bb58a34
@ -3,6 +3,7 @@ package controller
|
||||
import (
|
||||
"case-open-api/api/dao"
|
||||
"case-open-api/api/dto"
|
||||
"case-open-api/api/model"
|
||||
"case-open-api/api/requests"
|
||||
"case-open-api/api/responses"
|
||||
"case-open-api/api/service"
|
||||
@ -117,6 +118,37 @@ func (b *Res) GetResCaseList(c *gin.Context) {
|
||||
// 处理返回值
|
||||
g := dto.GetCaseResListDto(cases)
|
||||
|
||||
var users []*model.User
|
||||
|
||||
// 检测用户是否参与过
|
||||
if req.MobileEncryption != "" {
|
||||
// 获取全部相同手机号
|
||||
userDao := dao.UserDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["mobile_encryption"] = req.MobileEncryption
|
||||
users, err = userDao.GetUserList(maps)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
caseUserDao := dao.CaseUserDao{}
|
||||
|
||||
// 存在相同手机号用户
|
||||
for _, user := range users {
|
||||
for _, caseDto := range g {
|
||||
// 检测积分是否已在其他平台发放过
|
||||
maps = make(map[string]interface{})
|
||||
maps["case_id"] = caseDto.SId
|
||||
maps["user_id"] = user.UserId
|
||||
caseUser, _ := caseUserDao.GetCaseUser(maps)
|
||||
if caseUser != nil {
|
||||
caseDto.IsJoin = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 获取平台数据
|
||||
platformDao := dao.PlatformDao{}
|
||||
platform, err := platformDao.GetPlatformById(platformId)
|
||||
@ -125,10 +157,33 @@ func (b *Res) GetResCaseList(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 获取该平台全部关联项目
|
||||
projectPlatformDao := dao.ProjectPlatformDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["platform_id"] = platformId
|
||||
projectPlatforms, _ := projectPlatformDao.GetProjectPlatformList(maps)
|
||||
if len(projectPlatforms) <= 0 {
|
||||
responses.FailWithMessage("数据异常", c)
|
||||
return
|
||||
}
|
||||
|
||||
for _, caseDto := range g {
|
||||
// 加载访问链接
|
||||
link := config.C.DomainName + "/caseIntro" + "?project_id=" + caseDto.ProjectId + "&source=3" + "&platform_key=" + platform.PlatformKey + "&case_id=" + caseDto.SId
|
||||
caseDto.LoadLink(link)
|
||||
|
||||
for _, m := range projectPlatforms {
|
||||
projectId := fmt.Sprintf("%d", m.ProjectId)
|
||||
if projectId == caseDto.ProjectId {
|
||||
if m.IsWelfare == 1 {
|
||||
// 单个病例总积分-单个病例已发放积分
|
||||
diffScore := m.SingleCaseScore - caseDto.IssuedScore
|
||||
if diffScore > 0 {
|
||||
caseDto.IsWelfare = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
|
||||
@ -189,6 +189,9 @@ func (r *CaseDao) GetResCaseList(req requests.GetResCaseList) (m []*model.Case,
|
||||
// 构建查询条件
|
||||
query := global.Db.Model(&model.Case{})
|
||||
|
||||
// 获取病例平台表
|
||||
query = query.Preload("CasePlatform", "platform_id = ?", req.PlatformId)
|
||||
|
||||
projectPlatformSubQuery := global.Db.Model(&model.ProjectPlatform{}).
|
||||
Where("project_platform.project_id = case.project_id").
|
||||
Where("project_platform.platform_id = ?", req.PlatformId).
|
||||
|
||||
@ -23,12 +23,15 @@ type ResProjectDto struct {
|
||||
|
||||
// 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"` // 链接
|
||||
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 病例领取记录
|
||||
@ -137,6 +140,9 @@ func GetCaseResListDto(m []*model.Case) []*ResCaseDto {
|
||||
StarTime: v.CreatedAt,
|
||||
}
|
||||
|
||||
// 加载已发放积分
|
||||
response.LoadIssuedScore(v.CasePlatform)
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
@ -175,3 +181,11 @@ func (r *ResCaseDto) LoadLink(link string) *ResCaseDto {
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
// LoadIssuedScore 加载已发放积分
|
||||
func (r *ResCaseDto) LoadIssuedScore(m *model.CasePlatform) *ResCaseDto {
|
||||
if m != nil {
|
||||
r.IssuedScore = m.IssuedScore
|
||||
}
|
||||
return r
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ type Case struct {
|
||||
JoinWhiteNum int `gorm:"column:join_white_num;type:int(5);default:0;comment:多平台白名单参加总人数" json:"join_white_num"`
|
||||
MessageNum int `gorm:"column:message_num;type:int(5);default:0;comment:多平台留言人数" json:"message_num"`
|
||||
Model
|
||||
CasePlatform *CasePlatform `gorm:"foreignKey:CaseId;references:CaseId" json:"case_platform"`
|
||||
}
|
||||
|
||||
func (m *Case) TableName() string {
|
||||
|
||||
@ -14,8 +14,9 @@ type GetResProjectList struct {
|
||||
|
||||
// GetResCaseList 获取列表
|
||||
type GetResCaseList struct {
|
||||
PlatformId int64 `json:"platform_id" form:"platform_id" label:"平台id"`
|
||||
Keyword string `json:"keyword" form:"keyword" label:"关键词"`
|
||||
PlatformId int64 `json:"platform_id" form:"platform_id" label:"平台id"`
|
||||
Keyword string `json:"keyword" form:"keyword" label:"关键词"`
|
||||
MobileEncryption string `json:"mobile_encryption" form:"mobile_encryption" label:"用户手机号-加密"`
|
||||
}
|
||||
|
||||
// GetResCaseRecordList 病例领取记录
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user