Merge branch 'dev'
This commit is contained in:
commit
bd22a5aa41
@ -6,12 +6,14 @@ import (
|
|||||||
"case-open-api/api/requests"
|
"case-open-api/api/requests"
|
||||||
"case-open-api/api/responses"
|
"case-open-api/api/responses"
|
||||||
"case-open-api/api/service"
|
"case-open-api/api/service"
|
||||||
|
"case-open-api/config"
|
||||||
"case-open-api/global"
|
"case-open-api/global"
|
||||||
"case-open-api/utils"
|
"case-open-api/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"math"
|
"math"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -115,6 +117,20 @@ func (b *Res) GetResCaseList(c *gin.Context) {
|
|||||||
// 处理返回值
|
// 处理返回值
|
||||||
g := dto.GetCaseResListDto(cases)
|
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)
|
responses.OkWithData(g, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,8 +229,8 @@ func (b *Res) GetResCaseRecordList(c *gin.Context) {
|
|||||||
Beizhu: "",
|
Beizhu: "",
|
||||||
OpenId: "",
|
OpenId: "",
|
||||||
Title: v.Case.CaseName,
|
Title: v.Case.CaseName,
|
||||||
NickName: v.User.UserName,
|
NickName: utils.MaskNameStr(v.User.UserName, 2),
|
||||||
RealName: v.User.UserName,
|
RealName: utils.MaskNameStr(v.User.UserName, 2),
|
||||||
Mobile: v.User.MobileEncryption,
|
Mobile: v.User.MobileEncryption,
|
||||||
Hos2: v.User.DepartmentName, // 科室
|
Hos2: v.User.DepartmentName, // 科室
|
||||||
Job: utils.DoctorTitleToString(v.User.Title),
|
Job: utils.DoctorTitleToString(v.User.Title),
|
||||||
@ -248,10 +264,6 @@ func (b *Res) GetResCaseRecordList(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v3.Type == 3 {
|
if v3.Type == 3 {
|
||||||
response.Credit3 = v3.Score
|
|
||||||
}
|
|
||||||
|
|
||||||
if v3.Type == 4 {
|
|
||||||
response.Credit4 = v3.Score
|
response.Credit4 = v3.Score
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -273,11 +285,39 @@ func (b *Res) GetResCaseRecordList(c *gin.Context) {
|
|||||||
|
|
||||||
// 题目
|
// 题目
|
||||||
if len(caseUserAnswers) > 0 {
|
if len(caseUserAnswers) > 0 {
|
||||||
|
caseItemQuestionOptionDao := dao.CaseItemQuestionOptionDao{}
|
||||||
response.QuestionAnswer = make([]*dto.QuestionAnswerDto, len(caseUserAnswers))
|
response.QuestionAnswer = make([]*dto.QuestionAnswerDto, len(caseUserAnswers))
|
||||||
for i2, records := range 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{
|
questionAnswerDto := &dto.QuestionAnswerDto{
|
||||||
Question: records.CaseItemQuestion.QuestionName,
|
Question: records.CaseItemQuestion.QuestionName,
|
||||||
Answer: records.Answer,
|
Answer: strings.Join(answerValues, "|"),
|
||||||
Correct: false,
|
Correct: false,
|
||||||
Order: i2 + 1,
|
Order: i2 + 1,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package dto
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"case-open-api/api/model"
|
"case-open-api/api/model"
|
||||||
"case-open-api/config"
|
|
||||||
"case-open-api/utils"
|
"case-open-api/utils"
|
||||||
"fmt"
|
"fmt"
|
||||||
)
|
)
|
||||||
@ -138,9 +137,6 @@ func GetCaseResListDto(m []*model.Case) []*ResCaseDto {
|
|||||||
StarTime: v.CreatedAt,
|
StarTime: v.CreatedAt,
|
||||||
}
|
}
|
||||||
|
|
||||||
// 加载访问链接
|
|
||||||
response.LoadLink(v)
|
|
||||||
|
|
||||||
// 将转换后的结构体添加到新切片中
|
// 将转换后的结构体添加到新切片中
|
||||||
responses[i] = response
|
responses[i] = response
|
||||||
}
|
}
|
||||||
@ -174,11 +170,8 @@ func (r *ResProjectDto) LoadIsRecentlyUpdate(m *model.Case) *ResProjectDto {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LoadLink 加载访问链接
|
// LoadLink 加载访问链接
|
||||||
func (r *ResCaseDto) LoadLink(m *model.Case) *ResCaseDto {
|
func (r *ResCaseDto) LoadLink(link string) *ResCaseDto {
|
||||||
if m != nil {
|
r.Url = link
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user