Compare commits
10 Commits
6bcf2015c4
...
904c4d5e35
| Author | SHA1 | Date | |
|---|---|---|---|
| 904c4d5e35 | |||
| 57583058f6 | |||
| 802c789e95 | |||
| 8525e0263f | |||
| bafd5397be | |||
| 70159f722a | |||
| 8113acdef5 | |||
| 9fe67a6eb5 | |||
| 38748c45f0 | |||
| b896f6580d |
@ -104,7 +104,7 @@ func (r *Basic) GetBaseClass(c *gin.Context) {
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
// GetAreaList 获取分类列表
|
||||
// GetAreaList 获取地区列表
|
||||
func (r *Basic) GetAreaList(c *gin.Context) {
|
||||
basicRequest := requests.BasicRequest{}
|
||||
req := basicRequest.GetAreaList
|
||||
|
||||
@ -9,7 +9,6 @@ import (
|
||||
"hepa-calc-api/api/requests"
|
||||
"hepa-calc-api/api/responses"
|
||||
"hepa-calc-api/api/service"
|
||||
"hepa-calc-api/config"
|
||||
"hepa-calc-api/global"
|
||||
"hepa-calc-api/utils"
|
||||
"time"
|
||||
@ -32,36 +31,10 @@ func (r *Login) Login(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// 公众号登录
|
||||
if req.Source == 2 {
|
||||
if req.Mobile == "" || req.OpenId == "" {
|
||||
responses.FailWithMessage("登陆失败", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// 检测参数
|
||||
if req.Mobile != "" {
|
||||
// 检测验证码
|
||||
if config.C.Env != "dev" {
|
||||
if req.Source == 2 {
|
||||
if req.Code == "" {
|
||||
responses.FailWithMessage("请输入手机号验证码", c)
|
||||
return
|
||||
}
|
||||
|
||||
code, _ := global.Redis.Get(c, "login_code_"+req.Mobile).Result()
|
||||
if code == "" {
|
||||
responses.FailWithMessage("验证码失效", c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Code != code {
|
||||
responses.FailWithMessage("验证码错误", c)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
if req.Source == 2 && req.OpenId == "" {
|
||||
responses.FailWithMessage("登陆失败", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 开始事务
|
||||
@ -75,13 +48,10 @@ func (r *Login) Login(c *gin.Context) {
|
||||
}
|
||||
}()
|
||||
|
||||
var userInfo *model.UserInfo
|
||||
var err error
|
||||
|
||||
// 检测用户信息
|
||||
userDao := dao.UserDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["mobile"] = req.Mobile
|
||||
maps["open_id"] = req.OpenId
|
||||
user, _ := userDao.GetUser(maps)
|
||||
// 新用户处理方式
|
||||
if user == nil {
|
||||
@ -100,9 +70,7 @@ func (r *Login) Login(c *gin.Context) {
|
||||
|
||||
// 新增用户
|
||||
user = &model.User{
|
||||
UserName: "",
|
||||
AppIden: req.Uuid,
|
||||
Mobile: req.Mobile,
|
||||
UserName: req.UserName,
|
||||
RegisterSource: req.Source,
|
||||
OpenId: req.OpenId,
|
||||
UnionId: req.UnionId,
|
||||
@ -124,7 +92,7 @@ func (r *Login) Login(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 新增用户详情
|
||||
userInfo = &model.UserInfo{
|
||||
userInfo := &model.UserInfo{
|
||||
UserId: user.UserId,
|
||||
Height: "",
|
||||
Weight: "",
|
||||
@ -146,58 +114,10 @@ func (r *Login) Login(c *gin.Context) {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
// 获取用户详情数据
|
||||
userInfoDao := dao.UserInfoDao{}
|
||||
userInfo, err = userInfoDao.GetUserInfoByUserId(user.UserId)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理用户openid
|
||||
if req.OpenId != "" {
|
||||
userData := make(map[string]interface{})
|
||||
if req.OpenId != user.OpenId {
|
||||
userData["open_id"] = req.OpenId
|
||||
}
|
||||
|
||||
err := userDao.EditUserById(tx, user.UserId, userData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 处理app用户数据
|
||||
userService := service.UserService{}
|
||||
err = userService.GetAppUserInfo(tx, user, userInfo)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 处理app用户病例数据
|
||||
err = userService.GetAppUserCase(tx, user)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
|
||||
// 获取用户信息
|
||||
user, err = userDao.GetUserById(user.UserId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 下发token
|
||||
token := &utils.Token{
|
||||
UserId: fmt.Sprintf("%d", user.UserId),
|
||||
@ -211,7 +131,7 @@ func (r *Login) Login(c *gin.Context) {
|
||||
}
|
||||
|
||||
// 处理返回值
|
||||
g := dto.LoginMobileDto(user)
|
||||
g := dto.LoginWxDto(user)
|
||||
|
||||
// 加载token
|
||||
g.LoadToken(jwt)
|
||||
|
||||
@ -27,6 +27,8 @@ func (b *Public) GetCaptcha(c *gin.Context) {
|
||||
|
||||
// GetPhoneCode 获取手机验证码
|
||||
func (b *Public) GetPhoneCode(c *gin.Context) {
|
||||
responses.Ok(c)
|
||||
return
|
||||
publicRequest := requests.PublicRequest{}
|
||||
req := publicRequest.GetPhoneCode
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
|
||||
@ -77,7 +77,7 @@ func (b *Question) GetQuestionHot(c *gin.Context) {
|
||||
|
||||
// GetQuestion 获取问题详情
|
||||
func (r *Question) GetQuestion(c *gin.Context) {
|
||||
userId := c.GetInt64("UserId")
|
||||
userId := c.Query("user_id")
|
||||
|
||||
id := c.Param("question_id")
|
||||
if id == "" {
|
||||
@ -105,15 +105,33 @@ func (r *Question) GetQuestion(c *gin.Context) {
|
||||
// 处理问题优惠价格
|
||||
question.DiscountPrice = questionService.HandleQuestionDiscountPrice(question.DiscountPrice, question.DiscountEndTime)
|
||||
|
||||
// 检测用户收藏状态
|
||||
userCollectionService := service.UserCollectionService{}
|
||||
IsCollection := userCollectionService.GetUserCollectionQuestionStatus(userId, questionId)
|
||||
// 用户收藏状态
|
||||
IsCollection := false
|
||||
|
||||
// 获取用户首单价格
|
||||
firstTimePrice, err := questionService.GetUserFirstTimeBuyPrice(userId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("题目错误", c)
|
||||
return
|
||||
// 用户首单价格
|
||||
var firstTimePrice *float64
|
||||
|
||||
// 问题被购买数量
|
||||
var buyCount int
|
||||
if userId != "" {
|
||||
// 将 id 转换为 int64 类型
|
||||
uid, err := strconv.ParseInt(userId, 10, 64)
|
||||
if err != nil {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
userCollectionService := service.UserCollectionService{}
|
||||
IsCollection = userCollectionService.GetUserCollectionQuestionStatus(uid, questionId)
|
||||
|
||||
firstTimePrice, err = questionService.GetUserFirstTimeBuyPrice(uid)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("题目错误", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取问题被购买数量
|
||||
buyCount, _ = questionService.GetQuestionBuyCount(uid, questionId)
|
||||
}
|
||||
|
||||
g := dto.GetQuestionDto(question)
|
||||
@ -124,9 +142,6 @@ func (r *Question) GetQuestion(c *gin.Context) {
|
||||
// 加载数据-首次购买价格
|
||||
g.LoadFirstTimePrice(firstTimePrice)
|
||||
|
||||
// 获取问题被购买数量
|
||||
buyCount, _ := questionService.GetQuestionBuyCount(userId, questionId)
|
||||
|
||||
// 加载数据-问题被购买数量
|
||||
g.LoadBuyCount(buyCount)
|
||||
|
||||
|
||||
@ -170,61 +170,3 @@ func (r *User) PutBindUserName(c *gin.Context) {
|
||||
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
// GetUserCheck 检测用户数据绑定状态
|
||||
func (r *User) GetUserCheck(c *gin.Context) {
|
||||
userRequest := requests.UserRequest{}
|
||||
req := userRequest.GetUserCheck
|
||||
if err := c.ShouldBind(&req); err != nil {
|
||||
responses.FailWithMessage(err.Error(), c)
|
||||
return
|
||||
}
|
||||
|
||||
// 参数验证
|
||||
if err := global.Validate.Struct(req); err != nil {
|
||||
responses.FailWithMessage(utils.Translate(err), c)
|
||||
return
|
||||
}
|
||||
|
||||
if req.Mobile == "" && req.OpenId == "" {
|
||||
responses.FailWithMessage("缺少参数", c)
|
||||
return
|
||||
}
|
||||
|
||||
g := &dto.UserCheckDto{}
|
||||
|
||||
// 获取用户数据
|
||||
maps := make(map[string]interface{})
|
||||
if req.OpenId != "" {
|
||||
maps["open_id"] = req.OpenId
|
||||
}
|
||||
|
||||
if req.Mobile != "" {
|
||||
maps["mobile"] = req.Mobile
|
||||
}
|
||||
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUser(maps)
|
||||
if err != nil || user == nil {
|
||||
g.WxStatus = 0
|
||||
g.MobileStatus = 0
|
||||
responses.OkWithData(g, c)
|
||||
return
|
||||
}
|
||||
|
||||
if user.UserStatus == 2 {
|
||||
responses.FailWithMessage("用户已禁用", c)
|
||||
return
|
||||
}
|
||||
|
||||
if user.Mobile != "" {
|
||||
g.MobileStatus = 1
|
||||
g.Mobile = user.Mobile
|
||||
}
|
||||
|
||||
if user.OpenId != "" {
|
||||
g.WxStatus = 1
|
||||
}
|
||||
|
||||
responses.OkWithData(g, c)
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import (
|
||||
"hepa-calc-api/api/requests"
|
||||
"hepa-calc-api/api/responses"
|
||||
"hepa-calc-api/api/service"
|
||||
"hepa-calc-api/extend/app"
|
||||
"hepa-calc-api/global"
|
||||
"hepa-calc-api/utils"
|
||||
"strconv"
|
||||
@ -62,14 +61,6 @@ func (r *UserCase) PutUserCase(c *gin.Context) {
|
||||
|
||||
userId := c.GetInt64("UserId")
|
||||
|
||||
// 获取用户数据
|
||||
userDao := dao.UserDao{}
|
||||
user, err := userDao.GetUserById(userId)
|
||||
if err != nil {
|
||||
responses.FailWithMessage("用户数据错误", c)
|
||||
return
|
||||
}
|
||||
|
||||
// 获取用户数据-病例
|
||||
userCaseDao := dao.UserCaseDao{}
|
||||
userCase, err := userCaseDao.GetUserCaseByUserId(userId)
|
||||
@ -79,17 +70,6 @@ func (r *UserCase) PutUserCase(c *gin.Context) {
|
||||
}
|
||||
|
||||
userCaseData := make(map[string]interface{})
|
||||
appData := app.UpdateUserCaseRequest{
|
||||
IsAllergy: req.IsAllergyHistory,
|
||||
AllergyInfo: req.AllergyHistory,
|
||||
IsHospital: req.IsHospital,
|
||||
IsMedication: req.IsMedication,
|
||||
MedicationInfo: req.Medication,
|
||||
LiverStatus: req.LiverStatus,
|
||||
OtherDisease: req.ChronicDisease,
|
||||
PatientUuid: user.AppIden,
|
||||
DiseasesList: nil,
|
||||
}
|
||||
|
||||
// 是否医院就诊
|
||||
if req.IsHospital != nil {
|
||||
@ -163,9 +143,7 @@ func (r *UserCase) PutUserCase(c *gin.Context) {
|
||||
// 所患疾病列表
|
||||
if len(req.UserCaseDiseaseItem) > 0 {
|
||||
baseDiseaseClassDao := dao.BaseDiseaseClassDao{}
|
||||
diseasesLists := make([]*app.DiseasesListRequest, len(req.UserCaseDiseaseItem))
|
||||
|
||||
for i, item := range req.UserCaseDiseaseItem {
|
||||
for _, item := range req.UserCaseDiseaseItem {
|
||||
diseaseClassId, err := strconv.ParseInt(item.DiseaseClassId, 10, 64)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
@ -195,18 +173,7 @@ func (r *UserCase) PutUserCase(c *gin.Context) {
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
// app请求数据
|
||||
diseasesList := &app.DiseasesListRequest{
|
||||
Uuid: baseDiseaseClass.AppIden,
|
||||
Year: &item.Duration,
|
||||
Info: item.Genotype,
|
||||
Name: baseDiseaseClass.DiseaseClassName,
|
||||
}
|
||||
diseasesLists[i] = diseasesList
|
||||
}
|
||||
|
||||
appData.DiseasesList = diseasesLists
|
||||
}
|
||||
|
||||
// 病例数据
|
||||
@ -228,15 +195,6 @@ func (r *UserCase) PutUserCase(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
// app数据
|
||||
appData.PatientUuid = user.AppIden
|
||||
_, err = app.UpdateUserCase(appData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
responses.Fail(c)
|
||||
return
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
responses.Ok(c)
|
||||
}
|
||||
|
||||
@ -163,8 +163,14 @@ func (r *BaseClassDao) GetBaseClassListSearch(req requests.GetBaseClassList) (m
|
||||
// GetBaseClassExistsOrderList 获取列表-排序
|
||||
func (r *BaseClassDao) GetBaseClassExistsOrderList(maps interface{}) (m []*model.BaseClass, err error) {
|
||||
err = global.Db.Where(maps).
|
||||
Where("EXISTS (?)", global.Db.Model(&model.QuestionClass{}).Select("1").Where("question_class.class_id = base_class.class_id")).
|
||||
Order("sort desc").Find(&m).Error
|
||||
Where(
|
||||
"EXISTS (?)",
|
||||
global.Db.Model(&model.QuestionClass{}).Select("1").
|
||||
Where("question_class.class_id = base_class.class_id")).
|
||||
Order("sort desc").
|
||||
Order("convert(substring(class_name,1,1) using `GBK`) asc").
|
||||
Find(&m).
|
||||
Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
"hepa-calc-api/api/model"
|
||||
@ -187,7 +186,6 @@ func (r *QuestionDao) GetQuestionPageSearch(req requests.GetQuestionPage, page,
|
||||
|
||||
// 搜索关键字
|
||||
if req.Keyword != "" {
|
||||
fmt.Println(111)
|
||||
keyword := "%" + req.Keyword + "%" //
|
||||
|
||||
// 标题
|
||||
|
||||
@ -6,11 +6,9 @@ type LoginRequest struct {
|
||||
|
||||
// Login 登录
|
||||
type Login struct {
|
||||
Mobile string `json:"mobile" form:"mobile" label:"手机号" validate:"required,Mobile"`
|
||||
Code string `json:"code" form:"code" label:"验证码"`
|
||||
Source int `json:"source" form:"source" label:"来源" validate:"required"` // (1:app 2:公众号)
|
||||
OpenId string `json:"openid" form:"openid" label:"openid"`
|
||||
Source int `json:"source" form:"source" label:"来源" validate:"required,oneof=2"` // (1:app 2:公众号)
|
||||
OpenId string `json:"openid" form:"openid" label:"openid" validate:"required"`
|
||||
HeadImgUrl string `json:"headimgurl" form:"headimgurl" label:"头像"`
|
||||
UnionId string `json:"unionid" form:"unionid" label:"unionid"`
|
||||
Uuid string `json:"uuid" form:"uuid" label:"app唯一标识"`
|
||||
UnionId string `json:"unionid" form:"unionid" label:"unionid" validate:"required"`
|
||||
UserName string `json:"user_name" form:"user_name" label:"用户名称" validate:"required"`
|
||||
}
|
||||
|
||||
@ -30,6 +30,5 @@ type PutBindUserName struct {
|
||||
|
||||
// GetUserCheck 检测用户数据绑定状态
|
||||
type GetUserCheck struct {
|
||||
Mobile string `json:"mobile" form:"mobile" label:"mobile"`
|
||||
OpenId string `json:"openid" form:"openid" label:"openid"`
|
||||
OpenId string `json:"openid" form:"openid" label:"openid" validate:"required"`
|
||||
}
|
||||
|
||||
@ -79,13 +79,6 @@ func publicRouter(r *gin.Engine, api controller.Api) {
|
||||
loginGroup.POST("", api.Login.Login)
|
||||
}
|
||||
|
||||
// 用户
|
||||
centerGroup := r.Group("/user")
|
||||
{
|
||||
// 检测用户数据绑定状态
|
||||
centerGroup.GET("/check", api.User.GetUserCheck)
|
||||
}
|
||||
|
||||
// 验证码
|
||||
codeGroup := r.Group("/code")
|
||||
{
|
||||
@ -130,6 +123,42 @@ func publicRouter(r *gin.Engine, api controller.Api) {
|
||||
// 获取订单支付数据
|
||||
payGroup.POST("/order", api.Pay.GetPayOrder)
|
||||
}
|
||||
|
||||
// 会员配置
|
||||
memberGroup := r.Group("/member")
|
||||
{
|
||||
// 获取会员配置数据-最少立减金额
|
||||
memberGroup.GET("/least", api.SystemMember.GetSystemMemberLeast)
|
||||
}
|
||||
|
||||
// 问题
|
||||
questionGroup := r.Group("/question")
|
||||
{
|
||||
// 获取问题列表-分页
|
||||
questionGroup.POST("/page", api.Question.GetQuestionPage)
|
||||
|
||||
// 获取问题列表-热榜
|
||||
questionGroup.GET("/hot", api.Question.GetQuestionHot)
|
||||
|
||||
// 获取问题详情
|
||||
questionGroup.GET("/:question_id", api.Question.GetQuestion)
|
||||
|
||||
// 获取问题列表-猜你喜欢
|
||||
questionGroup.GET("/like", api.Question.GetGuessUserLikeList)
|
||||
}
|
||||
|
||||
// 分类
|
||||
classGroup := r.Group("/class")
|
||||
{
|
||||
// 获取分类列表
|
||||
classGroup.GET("/list", api.Basic.GetBaseClassList)
|
||||
|
||||
// 获取分类详情
|
||||
classGroup.GET("/:class_id", api.Basic.GetBaseClass)
|
||||
|
||||
// 获取分类列表-推荐搜索
|
||||
classGroup.GET("/recommend/list", api.Basic.GetBaseClassRecommendList)
|
||||
}
|
||||
}
|
||||
|
||||
// adminRouter 公共路由-验证权限
|
||||
@ -144,19 +173,6 @@ func adminRouter(r *gin.Engine, api controller.Api) {
|
||||
|
||||
// basicRouter 基础数据-验证权限
|
||||
func basicRouter(r *gin.Engine, api controller.Api) {
|
||||
// 分类
|
||||
classGroup := r.Group("/class")
|
||||
{
|
||||
// 获取分类列表
|
||||
classGroup.GET("/list", api.Basic.GetBaseClassList)
|
||||
|
||||
// 获取分类详情
|
||||
classGroup.GET("/:class_id", api.Basic.GetBaseClass)
|
||||
|
||||
// 获取分类列表-推荐搜索
|
||||
classGroup.GET("/recommend/list", api.Basic.GetBaseClassRecommendList)
|
||||
}
|
||||
|
||||
// 地区
|
||||
areaGroup := r.Group("/area")
|
||||
{
|
||||
@ -191,15 +207,6 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 问题
|
||||
questionGroup := r.Group("/question")
|
||||
{
|
||||
// 获取问题列表-分页
|
||||
questionGroup.POST("/page", api.Question.GetQuestionPage)
|
||||
|
||||
// 获取问题列表-热榜
|
||||
questionGroup.GET("/hot", api.Question.GetQuestionHot)
|
||||
|
||||
// 获取问题详情
|
||||
questionGroup.GET("/:question_id", api.Question.GetQuestion)
|
||||
|
||||
// 获取问题解锁状态
|
||||
questionGroup.GET("/unlock/status/:question_id", api.Question.GetQuestionUnlockStatus)
|
||||
|
||||
@ -212,9 +219,6 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
// 增加问题提交次数(提交个人信息进行了算算的人次)
|
||||
clickGroup.PUT("/submit/:question_id", api.Question.PutQuestionSubmitCount)
|
||||
}
|
||||
|
||||
// 获取问题列表-猜你喜欢
|
||||
questionGroup.GET("/like", api.Question.GetGuessUserLikeList)
|
||||
}
|
||||
|
||||
// 用户
|
||||
@ -338,8 +342,6 @@ func privateRouter(r *gin.Engine, api controller.Api) {
|
||||
{
|
||||
// 获取会员配置数据
|
||||
memberGroup.GET("", api.SystemMember.GetSystemMember)
|
||||
|
||||
// 获取会员配置数据-最少立减金额
|
||||
memberGroup.GET("/least", api.SystemMember.GetSystemMemberLeast)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -642,21 +642,6 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
|
||||
userData := make(map[string]interface{})
|
||||
userInfoData := make(map[string]interface{})
|
||||
appData := app.UpdateInfoRequest{
|
||||
Birthday: req.Birthday,
|
||||
IsPegnant: req.IsPregnant,
|
||||
Sex: nil,
|
||||
Weight: req.Weight,
|
||||
ExpectedDateOfChildbirth: req.ExpectedDate,
|
||||
IsHbv: nil,
|
||||
NationUuid: "",
|
||||
PatientUuid: "",
|
||||
Name: req.UserName,
|
||||
ProvId: nil,
|
||||
CityId: nil,
|
||||
CountyId: nil,
|
||||
Height: req.Height,
|
||||
}
|
||||
|
||||
// 用户名称
|
||||
if req.UserName != user.UserName {
|
||||
@ -681,15 +666,6 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
userData["age"] = nil
|
||||
}
|
||||
|
||||
// 性别
|
||||
if req.Sex == 1 {
|
||||
sex := 0
|
||||
appData.Sex = &sex
|
||||
} else if req.Sex == 2 {
|
||||
sex := 1
|
||||
appData.Sex = &sex
|
||||
}
|
||||
|
||||
if user.Sex != nil {
|
||||
if req.Sex != *user.Sex {
|
||||
userData["sex"] = req.Sex
|
||||
@ -741,51 +717,16 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
fmt.Println(req.NationId)
|
||||
if req.NationId != nationId {
|
||||
userInfoData["nation_id"] = req.NationId
|
||||
|
||||
// 获取民族数据
|
||||
baseNationDao := dao.BaseNationDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["nation_id"] = req.NationId
|
||||
baseNation, err := baseNationDao.GetBaseNation(maps)
|
||||
if err != nil {
|
||||
return false, errors.New("民族错误")
|
||||
}
|
||||
appData.NationUuid = baseNation.AppIden
|
||||
}
|
||||
} else {
|
||||
userInfoData["nation_id"] = req.NationId
|
||||
|
||||
// 获取民族数据
|
||||
baseNationDao := dao.BaseNationDao{}
|
||||
maps := make(map[string]interface{})
|
||||
maps["nation_id"] = req.NationId
|
||||
baseNation, err := baseNationDao.GetBaseNation(maps)
|
||||
if err != nil {
|
||||
return false, errors.New("民族错误")
|
||||
}
|
||||
appData.NationUuid = baseNation.AppIden
|
||||
}
|
||||
} else {
|
||||
if userInfo.NationId != nil {
|
||||
userInfoData["nation_id"] = nil
|
||||
appData.NationUuid = ""
|
||||
}
|
||||
}
|
||||
|
||||
// 是否存在家族病史
|
||||
// 有无 肝硬化或肝癌家族史 0无1有2未知
|
||||
// 是否存在家族病史(0:未知 1:是 2:否)
|
||||
// 转换双方状态
|
||||
var isHbv int
|
||||
if *req.IsFamilyHistory == 0 {
|
||||
isHbv = 2
|
||||
} else if *req.IsFamilyHistory == 1 {
|
||||
isHbv = 1
|
||||
} else if *req.IsFamilyHistory == 2 {
|
||||
isHbv = 0
|
||||
}
|
||||
|
||||
appData.IsHbv = &isHbv
|
||||
if req.IsFamilyHistory != nil {
|
||||
if userInfo.IsFamilyHistory != nil {
|
||||
if *req.IsFamilyHistory != *userInfo.IsFamilyHistory {
|
||||
@ -837,8 +778,6 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
return false, errors.New("省份错误")
|
||||
}
|
||||
|
||||
appData.ProvId = &provinceId
|
||||
|
||||
baseAreaDao := dao.BaseAreaDao{}
|
||||
baseArea, err := baseAreaDao.GetBaseAreaById(provinceId)
|
||||
if err != nil {
|
||||
@ -861,8 +800,6 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
return false, errors.New("城市错误")
|
||||
}
|
||||
|
||||
appData.CityId = &cityId
|
||||
|
||||
baseArea, err = baseAreaDao.GetBaseAreaById(cityId)
|
||||
if err != nil {
|
||||
return false, errors.New("城市错误")
|
||||
@ -884,7 +821,6 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
if err != nil {
|
||||
return false, errors.New("区县错误")
|
||||
}
|
||||
appData.CountyId = &countyId
|
||||
|
||||
baseArea, err = baseAreaDao.GetBaseAreaById(countyId)
|
||||
if err != nil {
|
||||
@ -928,14 +864,6 @@ func (r *UserService) PutUser(userId int64, req requests.PutUser) (bool, error)
|
||||
}
|
||||
}
|
||||
|
||||
// app数据
|
||||
appData.PatientUuid = user.AppIden
|
||||
_, err = app.UpdateInfo(appData)
|
||||
if err != nil {
|
||||
tx.Rollback()
|
||||
return false, err
|
||||
}
|
||||
|
||||
tx.Commit()
|
||||
return true, nil
|
||||
}
|
||||
|
||||
@ -25,7 +25,7 @@ redis:
|
||||
port: 30002
|
||||
password: gdxz2022&dj.
|
||||
pool-size: 100
|
||||
db: 3
|
||||
db: 5
|
||||
|
||||
# [jwt]
|
||||
jwt:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user