Compare commits
4 Commits
71dc85bae8
...
bd22a5aa41
| Author | SHA1 | Date | |
|---|---|---|---|
| bd22a5aa41 | |||
| fec81e9e74 | |||
| b8c2d5d103 | |||
| 179ce30a7c |
@ -6,12 +6,14 @@ import (
|
||||
"case-open-api/api/requests"
|
||||
"case-open-api/api/responses"
|
||||
"case-open-api/api/service"
|
||||
"case-open-api/config"
|
||||
"case-open-api/global"
|
||||
"case-open-api/utils"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"math"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -115,6 +117,20 @@ func (b *Res) GetResCaseList(c *gin.Context) {
|
||||
// 处理返回值
|
||||
g := dto.GetCaseResListDto(cases)
|
||||
|
||||
// 获取平台数据
|
||||
platformDao := dao.PlatformDao{}
|
||||
platform, err := platformDao.GetPlatformById(platformId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), 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)
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
@ -213,8 +229,8 @@ func (b *Res) GetResCaseRecordList(c *gin.Context) {
|
||||
Beizhu: "",
|
||||
OpenId: "",
|
||||
Title: v.Case.CaseName,
|
||||
NickName: v.User.UserName,
|
||||
RealName: v.User.UserName,
|
||||
NickName: utils.MaskNameStr(v.User.UserName, 2),
|
||||
RealName: utils.MaskNameStr(v.User.UserName, 2),
|
||||
Mobile: v.User.MobileEncryption,
|
||||
Hos2: v.User.DepartmentName, // 科室
|
||||
Job: utils.DoctorTitleToString(v.User.Title),
|
||||
@ -248,10 +264,6 @@ func (b *Res) GetResCaseRecordList(c *gin.Context) {
|
||||
}
|
||||
|
||||
if v3.Type == 3 {
|
||||
response.Credit3 = v3.Score
|
||||
}
|
||||
|
||||
if v3.Type == 4 {
|
||||
response.Credit4 = v3.Score
|
||||
}
|
||||
}
|
||||
@ -273,11 +285,39 @@ func (b *Res) GetResCaseRecordList(c *gin.Context) {
|
||||
|
||||
// 题目
|
||||
if len(caseUserAnswers) > 0 {
|
||||
caseItemQuestionOptionDao := dao.CaseItemQuestionOptionDao{}
|
||||
response.QuestionAnswer = make([]*dto.QuestionAnswerDto, len(caseUserAnswers))
|
||||
for i2, records := range caseUserAnswers {
|
||||
var answerValues []string
|
||||
|
||||
if records.CaseItemQuestion.QuestionType != 3 {
|
||||
// 获取对应题目选项
|
||||
maps = make(map[string]interface{})
|
||||
maps["question_id"] = records.QuestionId
|
||||
caseItemQuestionOptions, _ := caseItemQuestionOptionDao.GetCaseItemQuestionOptionList(maps)
|
||||
|
||||
answers := strings.Split(records.Answer, "")
|
||||
for _, answer := range answers {
|
||||
if records.CaseItemQuestion.QuestionType == 4 {
|
||||
if answer == "A" {
|
||||
answerValues = append(answerValues, "正确")
|
||||
}
|
||||
|
||||
if answer == "B" {
|
||||
answerValues = append(answerValues, "错误")
|
||||
}
|
||||
} else {
|
||||
answerNumber := int(answer[0] - 'A')
|
||||
if len(caseItemQuestionOptions) >= answerNumber {
|
||||
answerValues = append(answerValues, caseItemQuestionOptions[answerNumber].OptionValue)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
questionAnswerDto := &dto.QuestionAnswerDto{
|
||||
Question: records.CaseItemQuestion.QuestionName,
|
||||
Answer: records.Answer,
|
||||
Answer: strings.Join(answerValues, "|"),
|
||||
Correct: false,
|
||||
Order: i2 + 1,
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package dto
|
||||
|
||||
import (
|
||||
"case-open-api/api/model"
|
||||
"case-open-api/config"
|
||||
"case-open-api/utils"
|
||||
"fmt"
|
||||
)
|
||||
@ -138,9 +137,6 @@ func GetCaseResListDto(m []*model.Case) []*ResCaseDto {
|
||||
StarTime: v.CreatedAt,
|
||||
}
|
||||
|
||||
// 加载访问链接
|
||||
response.LoadLink(v)
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
@ -174,11 +170,8 @@ func (r *ResProjectDto) LoadIsRecentlyUpdate(m *model.Case) *ResProjectDto {
|
||||
}
|
||||
|
||||
// LoadLink 加载访问链接
|
||||
func (r *ResCaseDto) LoadLink(m *model.Case) *ResCaseDto {
|
||||
if m != nil {
|
||||
link := config.C.DomainName + "/caseIntro" + "?project_id=" + fmt.Sprintf("%d", m.ProjectId) + "&source=3" + "&platform_key=opf$di!3" + "&case_id=" + fmt.Sprintf("%d", m.CaseId)
|
||||
r.Url = link
|
||||
}
|
||||
func (r *ResCaseDto) LoadLink(link string) *ResCaseDto {
|
||||
r.Url = link
|
||||
|
||||
return r
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user