新增获取民族列表
This commit is contained in:
parent
016eb7e089
commit
1907780873
@ -162,3 +162,24 @@ func (r *Basic) GetDiseaseList(c *gin.Context) {
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
// GetNationList 获取民族列表
|
||||
func (r *Basic) GetNationList(c *gin.Context) {
|
||||
// 获取分类数据
|
||||
baseNationDao := dao.BaseNationDao{}
|
||||
maps := make(map[string]interface{})
|
||||
baseNations, err := baseNationDao.GetBaseNationList(maps)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
g := dto.GetBaseNationListDto(baseNations)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
38
api/dto/BaseNation.go
Normal file
38
api/dto/BaseNation.go
Normal file
@ -0,0 +1,38 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"hepa-calc-api/api/model"
|
||||
)
|
||||
|
||||
// BaseNationDto 基础数据-民族
|
||||
type BaseNationDto struct {
|
||||
NationId string `json:"nation_id"` // 主键id
|
||||
AppIden string `json:"app_iden"` // app唯一标识
|
||||
NationName string `json:"nation_name"` // 民族名称
|
||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||
}
|
||||
|
||||
// GetBaseNationListDto 列表-基础数据-分类表
|
||||
func GetBaseNationListDto(m []*model.BaseNation) []*BaseNationDto {
|
||||
// 处理返回值
|
||||
responses := make([]*BaseNationDto, len(m))
|
||||
|
||||
if len(m) > 0 {
|
||||
for i, v := range m {
|
||||
response := &BaseNationDto{
|
||||
NationId: fmt.Sprintf("%d", v.NationId),
|
||||
AppIden: v.AppIden,
|
||||
NationName: v.NationName,
|
||||
CreatedAt: v.CreatedAt,
|
||||
UpdatedAt: v.UpdatedAt,
|
||||
}
|
||||
|
||||
// 将转换后的结构体添加到新切片中
|
||||
responses[i] = response
|
||||
}
|
||||
}
|
||||
|
||||
return responses
|
||||
}
|
||||
@ -174,6 +174,13 @@ func basicRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取疾病分类列表
|
||||
diseaseGroup.GET("/list", api.Basic.GetDiseaseList)
|
||||
}
|
||||
|
||||
// 民族
|
||||
nationGroup := r.Group("/nation")
|
||||
{
|
||||
// 获取民族列表
|
||||
nationGroup.GET("/list", api.Basic.GetNationList)
|
||||
}
|
||||
}
|
||||
|
||||
// privateRouter 私有路由-验证权限
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user