新增了病例详情
This commit is contained in:
@@ -97,3 +97,72 @@ func (b *Project) GetProjectPage(c *gin.Context) {
|
||||
result["data"] = g
|
||||
responses.OkWithData(result, c)
|
||||
}
|
||||
|
||||
// GetProject 获取详情
|
||||
func (b *Project) GetProject(c *gin.Context) {
|
||||
id := c.Param("project_id")
|
||||
if id == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 将 id 转换为 int64 类型
|
||||
projectId, err := strconv.ParseInt(id, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
platformId := c.GetInt64("PlatformId") // 平台id
|
||||
if platformId == 0 {
|
||||
responses.FailWithMessage("内部错误", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取病例关联平台
|
||||
projectPlatformDao := dao.ProjectPlatformDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["project_id"] = projectId
|
||||
maps["platform_id"] = platformId
|
||||
projectPlatform, _ := projectPlatformDao.GetProjectPlatform(maps)
|
||||
if projectPlatform == nil {
|
||||
responses.FailWithMessage("非法数据", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取病例详情
|
||||
projectDao := dao.ProjectDao{}
|
||||
project, err := projectDao.GetProjectById(projectId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
g := dto.GetProjectDto(project)
|
||||
|
||||
// 获取最近7天的病例
|
||||
now := time.Now()
|
||||
t := now.AddDate(0, 0, -7)
|
||||
|
||||
caseDao := dao.CaseDao{}
|
||||
maps = make(map[string]interface{})
|
||||
maps["project_id"] = g.ProjectId
|
||||
result, _ := caseDao.GetCaseFormPastDay(maps, t)
|
||||
if result != nil {
|
||||
if result.CaseStatus == 1 {
|
||||
// 加载最近更新情况
|
||||
g.LoadIsRecentlyUpdate(result)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取项目福利存在情况
|
||||
projectService := service.ProjectService{}
|
||||
isHaveWelfare := projectService.GetProjectIsHaveWelfare(projectId, platformId)
|
||||
|
||||
// 加载是否开启福利
|
||||
if isHaveWelfare {
|
||||
g.IsWelfare = 1
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
@@ -94,6 +94,9 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取列表-分页
|
||||
projectGroup.GET("/page", api.Project.GetProjectPage)
|
||||
|
||||
// 获取列表-分页
|
||||
projectGroup.GET("/:project_id", api.Project.GetProject)
|
||||
|
||||
// 平台
|
||||
projectPlatformGroup := projectGroup.Group("/platform")
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user