新增了获取用户数据-详情信息,获取用户数据-病例。修改了获取用户列表-基本信息-分页,用户信息是否完善字段
This commit is contained in:
parent
d5881671af
commit
87bcb6e755
@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
type User struct{}
|
type User struct{}
|
||||||
|
|
||||||
// GetUserPage 获取用户列表-分页
|
// GetUserPage 获取用户列表-基本信息-分页
|
||||||
func (b *User) GetUserPage(c *gin.Context) {
|
func (b *User) GetUserPage(c *gin.Context) {
|
||||||
userRequest := requests.UserRequest{}
|
userRequest := requests.UserRequest{}
|
||||||
req := userRequest.GetUserPage
|
req := userRequest.GetUserPage
|
||||||
@ -85,7 +85,7 @@ func (b *User) GetUserPage(c *gin.Context) {
|
|||||||
responses.OkWithData(result, c)
|
responses.OkWithData(result, c)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUser 获取用户详情
|
// GetUser 获取用户详情-基本信息
|
||||||
func (b *User) GetUser(c *gin.Context) {
|
func (b *User) GetUser(c *gin.Context) {
|
||||||
id := c.Param("user_id")
|
id := c.Param("user_id")
|
||||||
if id == "" {
|
if id == "" {
|
||||||
@ -100,7 +100,7 @@ func (b *User) GetUser(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取订单数据
|
// 获取数据
|
||||||
userDao := dao.UserDao{}
|
userDao := dao.UserDao{}
|
||||||
user, err := userDao.GetUserById(userId)
|
user, err := userDao.GetUserById(userId)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -176,3 +176,85 @@ func (b *User) PutUserStatus(c *gin.Context) {
|
|||||||
tx.Commit()
|
tx.Commit()
|
||||||
responses.Ok(c)
|
responses.Ok(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserInfo 获取用户数据-详情信息
|
||||||
|
func (r *User) GetUserInfo(c *gin.Context) {
|
||||||
|
id := c.Param("user_id")
|
||||||
|
if id == "" {
|
||||||
|
responses.FailWithMessage("缺少参数", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
userId, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户数据
|
||||||
|
userInfoDao := dao.UserInfoDao{}
|
||||||
|
userInfo, err := userInfoDao.GetUserInfoByUserId(userId)
|
||||||
|
if err != nil || userInfo == nil {
|
||||||
|
responses.FailWithMessage("用户数据错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
g := dto.GetUserInfoDto(userInfo)
|
||||||
|
|
||||||
|
// 加载数据-民族
|
||||||
|
g.LoadNationId(userInfo.NationId)
|
||||||
|
|
||||||
|
// 加载数据-预产期
|
||||||
|
g.LoadExpectedDate(userInfo.ExpectedDate)
|
||||||
|
|
||||||
|
// 处理身高
|
||||||
|
h, err := utils.StrToFloat64(userInfo.Height)
|
||||||
|
g.Height = h
|
||||||
|
|
||||||
|
// 处理体重
|
||||||
|
w, err := utils.StrToFloat64(userInfo.Weight)
|
||||||
|
g.Weight = w
|
||||||
|
|
||||||
|
responses.OkWithData(g, c)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCase 获取用户数据-病例
|
||||||
|
func (r *User) GetUserCase(c *gin.Context) {
|
||||||
|
id := c.Param("user_id")
|
||||||
|
if id == "" {
|
||||||
|
responses.FailWithMessage("缺少参数", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将 id 转换为 int64 类型
|
||||||
|
userId, err := strconv.ParseInt(id, 10, 64)
|
||||||
|
if err != nil {
|
||||||
|
responses.Fail(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取用户数据-病例
|
||||||
|
userCaseDao := dao.UserCaseDao{}
|
||||||
|
userCase, err := userCaseDao.GetUserCaseByUserId(userId)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage("用户数据错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取疾病列表
|
||||||
|
userCaseDiseaseItemDao := dao.UserCaseDiseaseItemDao{}
|
||||||
|
userCaseDiseaseItems, err := userCaseDiseaseItemDao.GetUserCaseDiseaseItemListPreloadByUserCaseId(userCase.UserCaseId)
|
||||||
|
if err != nil {
|
||||||
|
responses.FailWithMessage("用户数据错误", c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理返回数据
|
||||||
|
g := dto.GetUserCaseDto(userCase)
|
||||||
|
|
||||||
|
// 加载数据-疾病列表
|
||||||
|
g.LoadUserCaseDiseaseItem(userCaseDiseaseItems)
|
||||||
|
|
||||||
|
responses.OkWithData(g, c)
|
||||||
|
}
|
||||||
|
|||||||
@ -126,6 +126,9 @@ func (r *UserDao) GetUserPageSearch(req requests.GetUserPage, page, pageSize int
|
|||||||
// 构建查询条件
|
// 构建查询条件
|
||||||
query := global.Db.Model(&model.User{})
|
query := global.Db.Model(&model.User{})
|
||||||
|
|
||||||
|
// 用户详情
|
||||||
|
query = query.Preload("UserInfo")
|
||||||
|
|
||||||
// 用户id
|
// 用户id
|
||||||
if req.UserId != "" {
|
if req.UserId != "" {
|
||||||
query = query.Where("user_id = ?", req.UserId)
|
query = query.Where("user_id = ?", req.UserId)
|
||||||
|
|||||||
126
api/dao/UserCase.go
Normal file
126
api/dao/UserCase.go
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/clause"
|
||||||
|
"hepa-calc-admin-api/api/model"
|
||||||
|
"hepa-calc-admin-api/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserCaseDao struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseById 获取数据-id
|
||||||
|
func (r *UserCaseDao) GetUserCaseById(UserCaseId int64) (m *model.UserCase, err error) {
|
||||||
|
err = global.Db.First(&m, UserCaseId).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCasePreloadById 获取数据-加载全部关联-id
|
||||||
|
func (r *UserCaseDao) GetUserCasePreloadById(UserCaseId int64) (m *model.UserCase, err error) {
|
||||||
|
err = global.Db.Preload(clause.Associations).First(&m, UserCaseId).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseByUserId 获取数据-user_id
|
||||||
|
func (r *UserCaseDao) GetUserCaseByUserId(userId int64) (m *model.UserCase, err error) {
|
||||||
|
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCasePreloadByUserId 获取数据-user_id
|
||||||
|
func (r *UserCaseDao) GetUserCasePreloadByUserId(userId int64) (m *model.UserCase, err error) {
|
||||||
|
err = global.Db.Preload(clause.Associations).Where("user_id = ?", userId).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserCase 删除
|
||||||
|
func (r *UserCaseDao) DeleteUserCase(tx *gorm.DB, maps interface{}) error {
|
||||||
|
err := tx.Where(maps).Delete(&model.UserCase{}).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserCaseById 删除-id
|
||||||
|
func (r *UserCaseDao) DeleteUserCaseById(tx *gorm.DB, UserCaseId int64) error {
|
||||||
|
if err := tx.Delete(&model.UserCase{}, UserCaseId).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditUserCase 修改
|
||||||
|
func (r *UserCaseDao) EditUserCase(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||||
|
err := tx.Model(&model.UserCase{}).Where(maps).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditUserCaseById 修改-id
|
||||||
|
func (r *UserCaseDao) EditUserCaseById(tx *gorm.DB, UserCaseId int64, data interface{}) error {
|
||||||
|
err := tx.Model(&model.UserCase{}).Where("user_case_id = ?", UserCaseId).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseList 获取列表
|
||||||
|
func (r *UserCaseDao) GetUserCaseList(maps interface{}) (m []*model.UserCase, err error) {
|
||||||
|
err = global.Db.Where(maps).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseCount 获取数量
|
||||||
|
func (r *UserCaseDao) GetUserCaseCount(maps interface{}) (total int64, err error) {
|
||||||
|
err = global.Db.Model(&model.UserCase{}).Where(maps).Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return total, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseListRand 获取列表-随机
|
||||||
|
func (r *UserCaseDao) GetUserCaseListRand(maps interface{}, limit int) (m []*model.UserCase, err error) {
|
||||||
|
err = global.Db.Where(maps).Order("rand()").Limit(limit).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddUserCase 新增
|
||||||
|
func (r *UserCaseDao) AddUserCase(tx *gorm.DB, model *model.UserCase) (*model.UserCase, error) {
|
||||||
|
if err := tx.Create(model).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return model, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCase 获取
|
||||||
|
func (r *UserCaseDao) GetUserCase(maps interface{}) (m *model.UserCase, err error) {
|
||||||
|
err = global.Db.Where(maps).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
134
api/dao/UserCaseDiseaseItem.go
Normal file
134
api/dao/UserCaseDiseaseItem.go
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
package dao
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"gorm.io/gorm/clause"
|
||||||
|
"hepa-calc-admin-api/api/model"
|
||||||
|
"hepa-calc-admin-api/global"
|
||||||
|
)
|
||||||
|
|
||||||
|
type UserCaseDiseaseItemDao struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemById 获取数据-id
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemById(itemId int64) (m *model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.First(&m, itemId).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemPreloadById 获取数据-加载全部关联-id
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemPreloadById(itemId int64) (m *model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.Preload(clause.Associations).First(&m, itemId).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemByUserCaseId 获取数据-user_case_id
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemByUserCaseId(userCaseId int64) (m *model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.Where("user_case_id = ?", userCaseId).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemListPreloadByUserCaseId 获取数据-user_case_id
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemListPreloadByUserCaseId(userCaseId int64) (m []*model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.Preload(clause.Associations).Where("user_case_id = ?", userCaseId).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserCaseDiseaseItem 删除
|
||||||
|
func (r *UserCaseDiseaseItemDao) DeleteUserCaseDiseaseItem(tx *gorm.DB, maps interface{}) error {
|
||||||
|
err := tx.Where(maps).Delete(&model.UserCaseDiseaseItem{}).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserCaseDiseaseItemById 删除-id
|
||||||
|
func (r *UserCaseDiseaseItemDao) DeleteUserCaseDiseaseItemById(tx *gorm.DB, UserCaseDiseaseItemId int64) error {
|
||||||
|
if err := tx.Delete(&model.UserCaseDiseaseItem{}, UserCaseDiseaseItemId).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteUserCaseDiseaseItemByUserCaseIdId 删除-id
|
||||||
|
func (r *UserCaseDiseaseItemDao) DeleteUserCaseDiseaseItemByUserCaseIdId(tx *gorm.DB, userCaseId int64) error {
|
||||||
|
if err := tx.Where("user_case_id = ?", userCaseId).Delete(&model.UserCaseDiseaseItem{}).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditUserCaseDiseaseItem 修改
|
||||||
|
func (r *UserCaseDiseaseItemDao) EditUserCaseDiseaseItem(tx *gorm.DB, maps interface{}, data interface{}) error {
|
||||||
|
err := tx.Model(&model.UserCaseDiseaseItem{}).Where(maps).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// EditUserCaseDiseaseItemById 修改-id
|
||||||
|
func (r *UserCaseDiseaseItemDao) EditUserCaseDiseaseItemById(tx *gorm.DB, itemId int64, data interface{}) error {
|
||||||
|
err := tx.Model(&model.UserCaseDiseaseItem{}).Where("item_id = ?", itemId).Updates(data).Error
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemList 获取列表
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemList(maps interface{}) (m []*model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.Where(maps).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemCount 获取数量
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemCount(maps interface{}) (total int64, err error) {
|
||||||
|
err = global.Db.Model(&model.UserCaseDiseaseItem{}).Where(maps).Count(&total).Error
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
return total, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemListRand 获取列表-随机
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItemListRand(maps interface{}, limit int) (m []*model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.Where(maps).Order("rand()").Limit(limit).Find(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// AddUserCaseDiseaseItem 新增
|
||||||
|
func (r *UserCaseDiseaseItemDao) AddUserCaseDiseaseItem(tx *gorm.DB, model *model.UserCaseDiseaseItem) (*model.UserCaseDiseaseItem, error) {
|
||||||
|
if err := tx.Create(model).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return model, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItem 获取
|
||||||
|
func (r *UserCaseDiseaseItemDao) GetUserCaseDiseaseItem(maps interface{}) (m *model.UserCaseDiseaseItem, err error) {
|
||||||
|
err = global.Db.Where(maps).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
@ -28,6 +28,15 @@ func (r *UserInfoDao) GetUserInfoPreloadById(UserInfoId int64) (m *model.UserInf
|
|||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetUserInfoByUserId 获取数据-user_id
|
||||||
|
func (r *UserInfoDao) GetUserInfoByUserId(userId int64) (m *model.UserInfo, err error) {
|
||||||
|
err = global.Db.Where("user_id = ?", userId).First(&m).Error
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return m, nil
|
||||||
|
}
|
||||||
|
|
||||||
// DeleteUserInfo 删除
|
// DeleteUserInfo 删除
|
||||||
func (r *UserInfoDao) DeleteUserInfo(tx *gorm.DB, maps interface{}) error {
|
func (r *UserInfoDao) DeleteUserInfo(tx *gorm.DB, maps interface{}) error {
|
||||||
err := tx.Where(maps).Delete(&model.UserInfo{}).Error
|
err := tx.Where(maps).Delete(&model.UserInfo{}).Error
|
||||||
|
|||||||
@ -16,7 +16,7 @@ type UserDto struct {
|
|||||||
OpenId string `json:"open_id"` // 用户微信标识
|
OpenId string `json:"open_id"` // 用户微信标识
|
||||||
UnionId string `json:"union_id"` // 微信开放平台标识
|
UnionId string `json:"union_id"` // 微信开放平台标识
|
||||||
Age *uint `json:"age"` // 年龄
|
Age *uint `json:"age"` // 年龄
|
||||||
Sex uint `json:"sex"` // 性别(0:未知 1:男 2:女)
|
Sex *int `json:"sex"` // 性别(0:未知 1:男 2:女)
|
||||||
Avatar string `json:"avatar"` // 头像
|
Avatar string `json:"avatar"` // 头像
|
||||||
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
IsMember int `json:"is_member"` // 是否会员(0:否 1:是)
|
||||||
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
MemberExpireDate *model.LocalTime `json:"member_expire_date"` // 会员到期时间(非会员时为null)
|
||||||
@ -27,7 +27,7 @@ type UserDto struct {
|
|||||||
LoginIp string `json:"login_ip"` // 登陆ip
|
LoginIp string `json:"login_ip"` // 登陆ip
|
||||||
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
IsInfoComplete int `json:"is_info_complete"` // 信息完善状态 0:否 1:是
|
IsInfoComplete bool `json:"is_info_complete"` // 信息完善状态 0:否 1:是
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetUserListDto 列表
|
// GetUserListDto 列表
|
||||||
@ -44,7 +44,7 @@ func GetUserListDto(m []*model.User) []*UserDto {
|
|||||||
UserStatus: v.UserStatus,
|
UserStatus: v.UserStatus,
|
||||||
RegisterSource: v.RegisterSource,
|
RegisterSource: v.RegisterSource,
|
||||||
Age: v.Age,
|
Age: v.Age,
|
||||||
Sex: uint(v.Sex),
|
Sex: &v.Sex,
|
||||||
Avatar: utils.AddOssDomain(v.Avatar),
|
Avatar: utils.AddOssDomain(v.Avatar),
|
||||||
IsMember: v.IsMember,
|
IsMember: v.IsMember,
|
||||||
MemberExpireDate: v.MemberExpireDate,
|
MemberExpireDate: v.MemberExpireDate,
|
||||||
@ -79,7 +79,7 @@ func GetUserDto(m *model.User) *UserDto {
|
|||||||
UserStatus: m.UserStatus,
|
UserStatus: m.UserStatus,
|
||||||
RegisterSource: m.RegisterSource,
|
RegisterSource: m.RegisterSource,
|
||||||
Age: m.Age,
|
Age: m.Age,
|
||||||
Sex: uint(m.Sex),
|
Sex: &m.Sex,
|
||||||
Avatar: utils.AddOssDomain(m.Avatar),
|
Avatar: utils.AddOssDomain(m.Avatar),
|
||||||
IsMember: m.IsMember,
|
IsMember: m.IsMember,
|
||||||
MemberExpireDate: m.MemberExpireDate,
|
MemberExpireDate: m.MemberExpireDate,
|
||||||
@ -95,10 +95,21 @@ func GetUserDto(m *model.User) *UserDto {
|
|||||||
|
|
||||||
// LoadIsInfoComplete 加载信息完善状态
|
// LoadIsInfoComplete 加载信息完善状态
|
||||||
func (r *UserDto) LoadIsInfoComplete(m *model.UserInfo) *UserDto {
|
func (r *UserDto) LoadIsInfoComplete(m *model.UserInfo) *UserDto {
|
||||||
|
isCompleteInfo := false
|
||||||
if m != nil {
|
if m != nil {
|
||||||
if m.DiseaseClassId != 0 && m.FamilyHistoryId != 0 {
|
if m.Height == "" {
|
||||||
r.IsInfoComplete = 1
|
isCompleteInfo = false
|
||||||
|
} else if m.Weight == "" {
|
||||||
|
isCompleteInfo = false
|
||||||
|
} else if m.IsFamilyHistory == nil {
|
||||||
|
isCompleteInfo = false
|
||||||
|
} else if m.ProvinceId == "" {
|
||||||
|
isCompleteInfo = false
|
||||||
|
} else {
|
||||||
|
isCompleteInfo = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r.IsInfoComplete = isCompleteInfo
|
||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|||||||
48
api/dto/UserCase.go
Normal file
48
api/dto/UserCase.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"hepa-calc-admin-api/api/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserCaseDto 用户表-病例
|
||||||
|
type UserCaseDto struct {
|
||||||
|
UserCaseId string `json:"user_case_id"` // 主键id
|
||||||
|
UserId string `json:"user_id"` // 用户id
|
||||||
|
IsHospital *int `json:"is_hospital"` // 是否医院就诊(0:否 1:是)
|
||||||
|
LiverStatus string `json:"liver_status"` // 肝脏状态
|
||||||
|
IsMedication *int `json:"is_medication"` // 是否服药(0:否 1:是)
|
||||||
|
Medication string `json:"medication"` // 服药名称
|
||||||
|
ChronicDisease string `json:"chronic_disease"` // 慢性疾病名称(逗号分隔)
|
||||||
|
IsAllergyHistory *int `json:"is_allergy_history"` // 过敏史(0:否 1:是)
|
||||||
|
AllergyHistory string `json:"allergy_history"` // 过敏史描述
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
|
UserCaseDiseaseItem []*UserCaseDiseaseItemDto `json:"user_case_disease_item"` // 所患疾病列表
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDto 详情
|
||||||
|
func GetUserCaseDto(m *model.UserCase) *UserCaseDto {
|
||||||
|
return &UserCaseDto{
|
||||||
|
UserCaseId: fmt.Sprintf("%d", m.UserCaseId),
|
||||||
|
UserId: fmt.Sprintf("%d", m.UserId),
|
||||||
|
IsHospital: m.IsHospital,
|
||||||
|
LiverStatus: m.LiverStatus,
|
||||||
|
IsMedication: m.IsMedication,
|
||||||
|
Medication: m.Medication,
|
||||||
|
ChronicDisease: m.ChronicDisease,
|
||||||
|
IsAllergyHistory: m.IsAllergyHistory,
|
||||||
|
AllergyHistory: m.AllergyHistory,
|
||||||
|
CreatedAt: m.CreatedAt,
|
||||||
|
UpdatedAt: m.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadUserCaseDiseaseItem 加载数据-疾病列表
|
||||||
|
func (r *UserCaseDto) LoadUserCaseDiseaseItem(m []*model.UserCaseDiseaseItem) *UserCaseDto {
|
||||||
|
if len(m) > 0 {
|
||||||
|
r.UserCaseDiseaseItem = GetUserCaseDiseaseItemListDto(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
59
api/dto/UserCaseDiseaseItem.go
Normal file
59
api/dto/UserCaseDiseaseItem.go
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"hepa-calc-admin-api/api/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserCaseDiseaseItemDto 用户-病例-所患疾病列表
|
||||||
|
type UserCaseDiseaseItemDto struct {
|
||||||
|
ItemId string `json:"item_id"` // 主键id
|
||||||
|
UserCaseId string `json:"user_case_id"` // 用户病例id
|
||||||
|
DiseaseClassId string `json:"disease_class_id"` // 疾病分类id
|
||||||
|
DiseaseClassName string `json:"disease_class_name"` // 疾病分类名称
|
||||||
|
AppIden string `json:"app_iden"` // app唯一标识
|
||||||
|
Duration *int `json:"duration"` // 患病时长(年)
|
||||||
|
Genotype string `json:"genotype"` // 基因型(仅丙肝存在)
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserCaseDiseaseItemListDto 列表-分页
|
||||||
|
func GetUserCaseDiseaseItemListDto(m []*model.UserCaseDiseaseItem) []*UserCaseDiseaseItemDto {
|
||||||
|
// 处理返回值
|
||||||
|
responses := make([]*UserCaseDiseaseItemDto, len(m))
|
||||||
|
|
||||||
|
if len(m) > 0 {
|
||||||
|
for i, v := range m {
|
||||||
|
response := &UserCaseDiseaseItemDto{
|
||||||
|
ItemId: fmt.Sprintf("%d", v.ItemId),
|
||||||
|
UserCaseId: fmt.Sprintf("%d", v.UserCaseId),
|
||||||
|
DiseaseClassId: fmt.Sprintf("%d", v.DiseaseClassId),
|
||||||
|
AppIden: v.AppIden,
|
||||||
|
Duration: v.Duration,
|
||||||
|
Genotype: v.Genotype,
|
||||||
|
CreatedAt: v.CreatedAt,
|
||||||
|
UpdatedAt: v.UpdatedAt,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 加载数据-疾病名称
|
||||||
|
if v.BaseDiseaseClass != nil {
|
||||||
|
response = response.LoadDiseaseClassName(v.BaseDiseaseClass)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将转换后的结构体添加到新切片中
|
||||||
|
responses[i] = response
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return responses
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadDiseaseClassName 加载数据-疾病名称
|
||||||
|
func (r *UserCaseDiseaseItemDto) LoadDiseaseClassName(m *model.BaseDiseaseClass) *UserCaseDiseaseItemDto {
|
||||||
|
if m != nil {
|
||||||
|
r.DiseaseClassName = m.DiseaseClassName
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
64
api/dto/UserInfo.go
Normal file
64
api/dto/UserInfo.go
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"hepa-calc-admin-api/api/model"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserInfoDto 用户表-基础信息
|
||||||
|
type UserInfoDto struct {
|
||||||
|
UserInfoId string `json:"user_info_id"` // 主键id
|
||||||
|
UserId string `json:"user_id"` // 用户id
|
||||||
|
Height *float64 `json:"height"` // 身高(cm)
|
||||||
|
Weight *float64 `json:"weight"` // 体重(kg)
|
||||||
|
NationId string `json:"nation_id"` // 民族id
|
||||||
|
IsFamilyHistory *int `json:"is_family_history"` // 是否存在家族病史(0:未知 1:是 2:否)
|
||||||
|
IsPregnant *int `json:"is_pregnant"` // 是否怀孕(1:无计划 2:计划中 3:已怀孕 4:家有宝宝)
|
||||||
|
ExpectedDate *string `json:"expected_date"` // 预产期
|
||||||
|
ProvinceId string `json:"province_id"` // 省份id
|
||||||
|
Province string `json:"province"` // 省份
|
||||||
|
CityId string `json:"city_id"` // 城市id
|
||||||
|
City string `json:"city"` // 城市
|
||||||
|
CountyId string `json:"county_id"` // 区县id
|
||||||
|
County string `json:"county"` // 区县
|
||||||
|
CreatedAt model.LocalTime `json:"created_at"` // 创建时间
|
||||||
|
UpdatedAt model.LocalTime `json:"updated_at"` // 更新时间
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetUserInfoDto 用户基础信息详情
|
||||||
|
func GetUserInfoDto(m *model.UserInfo) *UserInfoDto {
|
||||||
|
return &UserInfoDto{
|
||||||
|
UserInfoId: fmt.Sprintf("%d", m.UserInfoId),
|
||||||
|
UserId: fmt.Sprintf("%d", m.UserInfoId),
|
||||||
|
IsFamilyHistory: m.IsFamilyHistory,
|
||||||
|
IsPregnant: m.IsPregnant,
|
||||||
|
ProvinceId: m.ProvinceId,
|
||||||
|
Province: m.Province,
|
||||||
|
CityId: m.CityId,
|
||||||
|
City: m.City,
|
||||||
|
CountyId: m.CountyId,
|
||||||
|
County: m.County,
|
||||||
|
CreatedAt: m.CreatedAt,
|
||||||
|
UpdatedAt: m.UpdatedAt,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadExpectedDate 加载数据-预产期
|
||||||
|
func (r *UserInfoDto) LoadExpectedDate(expectedDate *model.LocalTime) *UserInfoDto {
|
||||||
|
if expectedDate != nil {
|
||||||
|
t := time.Time(*expectedDate).Format("2006-01-02")
|
||||||
|
r.ExpectedDate = &t
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
|
|
||||||
|
// LoadNationId 加载数据-民族
|
||||||
|
func (r *UserInfoDto) LoadNationId(nationId *int64) *UserInfoDto {
|
||||||
|
if nationId != nil {
|
||||||
|
r.NationId = fmt.Sprintf("%d", *nationId)
|
||||||
|
}
|
||||||
|
|
||||||
|
return r
|
||||||
|
}
|
||||||
34
api/model/BaseDiseaseClass.go
Normal file
34
api/model/BaseDiseaseClass.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hepa-calc-admin-api/global"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BaseDiseaseClass 基础-疾病分类
|
||||||
|
type BaseDiseaseClass struct {
|
||||||
|
DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);primary_key;comment:主键id" json:"disease_class_id"`
|
||||||
|
AppIden string `gorm:"column:app_iden;type:varchar(50);comment:app唯一标识" json:"app_iden"`
|
||||||
|
DiseaseClassName string `gorm:"column:disease_class_name;type:varchar(255);comment:疾病分类名称" json:"disease_class_name"`
|
||||||
|
Sort int `gorm:"column:sort;type:int(5);default:0;comment:排序值" json:"sort"`
|
||||||
|
Model
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseDiseaseClass) TableName() string {
|
||||||
|
return "base_disease_class"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *BaseDiseaseClass) BeforeCreate(tx *gorm.DB) error {
|
||||||
|
if m.DiseaseClassId == 0 {
|
||||||
|
m.DiseaseClassId = global.Snowflake.Generate().Int64()
|
||||||
|
}
|
||||||
|
|
||||||
|
m.CreatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||||
|
|
||||||
|
m.UpdatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
40
api/model/UserCase.go
Normal file
40
api/model/UserCase.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hepa-calc-admin-api/global"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserCase 用户表-病例
|
||||||
|
type UserCase struct {
|
||||||
|
UserCaseId int64 `gorm:"column:user_case_id;type:bigint(19);primary_key;comment:主键id" json:"user_case_id"`
|
||||||
|
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id;NOT NULL" json:"user_id"`
|
||||||
|
IsHospital *int `gorm:"column:is_hospital;type:tinyint(1);comment:是否医院就诊(0:否 1:是)" json:"is_hospital"`
|
||||||
|
LiverStatus string `gorm:"column:liver_status;type:varchar(30);comment:肝脏状态" json:"liver_status"`
|
||||||
|
IsMedication *int `gorm:"column:is_medication;type:tinyint(1);comment:是否服药(0:否 1:是)" json:"is_medication"`
|
||||||
|
Medication string `gorm:"column:medication;type:varchar(20);comment:服药名称" json:"medication"`
|
||||||
|
ChronicDisease string `gorm:"column:chronic_disease;type:varchar(500);comment:慢性疾病名称(逗号分隔)" json:"chronic_disease"`
|
||||||
|
IsAllergyHistory *int `gorm:"column:is_allergy_history;type:tinyint(1);comment:过敏史(0:否 1:是)" json:"is_allergy_history"`
|
||||||
|
AllergyHistory string `gorm:"column:allergy_history;type:varchar(100);comment:过敏史描述" json:"allergy_history"`
|
||||||
|
Model
|
||||||
|
UserCaseDiseaseItem []*UserCaseDiseaseItem `gorm:"foreignKey:UserCaseId;references:user_case_id" json:"user_case_disease_item"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *UserCase) TableName() string {
|
||||||
|
return "user_case"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *UserCase) BeforeCreate(tx *gorm.DB) error {
|
||||||
|
if m.UserCaseId == 0 {
|
||||||
|
m.UserCaseId = global.Snowflake.Generate().Int64()
|
||||||
|
}
|
||||||
|
|
||||||
|
m.CreatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||||
|
|
||||||
|
m.UpdatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
37
api/model/UserCaseDiseaseItem.go
Normal file
37
api/model/UserCaseDiseaseItem.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"hepa-calc-admin-api/global"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UserCaseDiseaseItem 用户-病例-所患疾病列表
|
||||||
|
type UserCaseDiseaseItem struct {
|
||||||
|
ItemId int64 `gorm:"column:item_id;type:bigint(19);primary_key;comment:主键id" json:"item_id"`
|
||||||
|
UserCaseId int64 `gorm:"column:user_case_id;type:bigint(19);comment:用户病例id" json:"user_case_id"`
|
||||||
|
DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);comment:疾病分类id" json:"disease_class_id"`
|
||||||
|
AppIden string `gorm:"column:app_iden;type:varchar(50);comment:app唯一标识" json:"app_iden"`
|
||||||
|
Duration *int `gorm:"column:duration;type:int(5);comment:患病时长(年)" json:"duration"`
|
||||||
|
Genotype string `gorm:"column:genotype;type:varchar(20);comment:基因型(仅丙肝存在)" json:"genotype"`
|
||||||
|
Model
|
||||||
|
BaseDiseaseClass *BaseDiseaseClass `gorm:"foreignKey:DiseaseClassId;references:disease_class_id" json:"disease_class"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *UserCaseDiseaseItem) TableName() string {
|
||||||
|
return "user_case_disease_item"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *UserCaseDiseaseItem) BeforeCreate(tx *gorm.DB) error {
|
||||||
|
if m.ItemId == 0 {
|
||||||
|
m.ItemId = global.Snowflake.Generate().Int64()
|
||||||
|
}
|
||||||
|
|
||||||
|
m.CreatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("CreatedAt", m.CreatedAt)
|
||||||
|
|
||||||
|
m.UpdatedAt = LocalTime(time.Now())
|
||||||
|
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
@ -8,19 +8,20 @@ import (
|
|||||||
|
|
||||||
// UserInfo 用户表-基础信息
|
// UserInfo 用户表-基础信息
|
||||||
type UserInfo struct {
|
type UserInfo struct {
|
||||||
UserInfoId int64 `gorm:"column:user_info_id;type:bigint(19);primary_key;comment:主键id" json:"user_info_id"`
|
UserInfoId int64 `gorm:"column:user_info_id;type:bigint(19);primary_key;comment:主键id" json:"user_info_id"`
|
||||||
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
|
UserId int64 `gorm:"column:user_id;type:bigint(19);comment:用户id" json:"user_id"`
|
||||||
Height string `gorm:"column:height;type:varchar(20);comment:身高(cm)" json:"height"`
|
Height string `gorm:"column:height;type:varchar(20);comment:身高(cm)" json:"height"`
|
||||||
Weight string `gorm:"column:weight;type:varchar(20);comment:体重(kg)" json:"weight"`
|
Weight string `gorm:"column:weight;type:varchar(20);comment:体重(kg)" json:"weight"`
|
||||||
NationId int64 `gorm:"column:nation_id;type:bigint(19);comment:民族id" json:"nation_id"`
|
NationId *int64 `gorm:"column:nation_id;type:bigint(19);comment:民族id" json:"nation_id"`
|
||||||
FamilyHistoryId int64 `gorm:"column:family_history_id;type:bigint(19);comment:家族病史id" json:"family_history_id"`
|
IsFamilyHistory *int `gorm:"column:is_family_history;type:tinyint(1);comment:是否存在家族病史(0:未知 1:是 2:否)" json:"is_family_history"`
|
||||||
ProvinceId int `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
IsPregnant *int `gorm:"column:is_pregnant;type:tinyint(1);comment:是否怀孕(1:无计划 2:计划中 3:已怀孕 4:家有宝宝)" json:"is_pregnant"`
|
||||||
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
|
ExpectedDate *LocalTime `gorm:"column:expected_date;type:datetime;comment:预产期" json:"expected_date"`
|
||||||
CityId int `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
ProvinceId string `gorm:"column:province_id;type:int(11);comment:省份id" json:"province_id"`
|
||||||
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
Province string `gorm:"column:province;type:varchar(40);comment:省份" json:"province"`
|
||||||
CountyId int `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
CityId string `gorm:"column:city_id;type:int(11);comment:城市id" json:"city_id"`
|
||||||
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
City string `gorm:"column:city;type:varchar(50);comment:城市" json:"city"`
|
||||||
DiseaseClassId int64 `gorm:"column:disease_class_id;type:bigint(19);comment:疾病分类id" json:"disease_class_id"`
|
CountyId string `gorm:"column:county_id;type:int(11);comment:区县id" json:"county_id"`
|
||||||
|
County string `gorm:"column:county;type:varchar(255);comment:区县" json:"county"`
|
||||||
Model
|
Model
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package requests
|
package requests
|
||||||
|
|
||||||
type UserRequest struct {
|
type UserRequest struct {
|
||||||
GetUserPage // 获取用户列表-分页
|
GetUserPage // 获取用户列表-基本信息-分页
|
||||||
PutUserStatus // 操作用户状态
|
PutUserStatus // 操作用户状态
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -144,17 +144,20 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
|||||||
// 用户
|
// 用户
|
||||||
userGroup := adminGroup.Group("/user")
|
userGroup := adminGroup.Group("/user")
|
||||||
{
|
{
|
||||||
// 获取用户列表-分页
|
// 获取用户列表-基本信息-分页
|
||||||
userGroup.POST("/page", api.User.GetUserPage)
|
userGroup.POST("/page", api.User.GetUserPage)
|
||||||
|
|
||||||
// 获取用户详情
|
// 获取用户详情-基本信息
|
||||||
userGroup.GET("/:user_id", api.User.GetUser)
|
userGroup.GET("/:user_id", api.User.GetUser)
|
||||||
|
|
||||||
// 操作用户状态
|
// 操作用户状态
|
||||||
userGroup.PUT("/status/:user_id", api.User.PutUserStatus)
|
userGroup.PUT("/status/:user_id", api.User.PutUserStatus)
|
||||||
|
|
||||||
// 获取用户信息详情
|
// 获取用户数据-详情信息
|
||||||
|
userGroup.GET("/info/:user_id", api.User.GetUserInfo)
|
||||||
|
|
||||||
|
// 获取用户数据-病例
|
||||||
|
userGroup.GET("/case/:user_id", api.User.GetUserCase)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 优惠卷
|
// 优惠卷
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hepa-calc-admin-api/api/dao"
|
"hepa-calc-admin-api/api/dao"
|
||||||
|
"hepa-calc-admin-api/api/model"
|
||||||
"hepa-calc-admin-api/extend/aliyun"
|
"hepa-calc-admin-api/extend/aliyun"
|
||||||
"io"
|
"io"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
@ -67,3 +68,28 @@ func (r *UserService) CheckUserBuyOrderMember(userId int64) bool {
|
|||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckUserInfo 检测用户信息是否补全
|
||||||
|
func (r *UserService) CheckUserInfo(userInfo *model.UserInfo) bool {
|
||||||
|
if userInfo == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if userInfo.Height == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if userInfo.Weight == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if userInfo.IsFamilyHistory == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if userInfo.ProvinceId == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|||||||
28
utils/type.go
Normal file
28
utils/type.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package utils
|
||||||
|
|
||||||
|
import (
|
||||||
|
"strconv"
|
||||||
|
)
|
||||||
|
|
||||||
|
// StrToFloat32 字符串转float32
|
||||||
|
func StrToFloat32(s string) (f *float32, err error) {
|
||||||
|
f64, err := strconv.ParseFloat(s, 32)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将float64转换为float32
|
||||||
|
f32 := float32(f64)
|
||||||
|
|
||||||
|
return &f32, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// StrToFloat64 字符串转float64
|
||||||
|
func StrToFloat64(s string) (f *float64, err error) {
|
||||||
|
f64, err := strconv.ParseFloat(s, 64)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return &f64, nil
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user