diff --git a/app/hdl/hdl_account.go b/app/hdl/hdl_account.go new file mode 100644 index 0000000..dfbe949 --- /dev/null +++ b/app/hdl/hdl_account.go @@ -0,0 +1,52 @@ +package hdl + +import ( + "applet/app/e" + "applet/app/lib/validate" + "applet/app/md" + "applet/app/svc" + "github.com/gin-gonic/gin" +) + +// AccountBase +// @Summary 账号信息 +// @Tags 账号中心------嘉俊 +// @Description 账号信息 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Success 200 {object} md.AccountBase "具体看返回内容" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/account/base [GET] +func AccountBase(c *gin.Context) { + svc.AccountBase(c) +} + +// AccountUpdatePassword +// @Summary 企业认证保存 +// @Tags 账号中心------嘉俊 +// @Description 资质认证-企业认证保存 +// @param Authorization header string true "验证参数Bearer和token空格拼接" +// @Accept json +// @Produce json +// @Param args body md.AccountUpdatePasswordReq true "请求参数" +// @Success 200 {string} "具体看返回内容" +// @Failure 400 {object} md.Response "具体错误" +// @Router /api/account/update/password [POST] +func AccountUpdatePassword(c *gin.Context) { + var req md.AccountUpdatePasswordReq + err := c.ShouldBindJSON(&req) + if err != nil { + err = validate.HandleValidateErr(err) + err1 := err.(e.E) + e.OutErr(c, err1.Code, err1.Error()) + return + } + err = svc.AccountUpdatePassword(c, req) + if err != nil { + e.OutErr(c, 400, err) + return + } + e.OutSuc(c, "success", nil) + return +} diff --git a/app/hdl/hdl_qualification.go b/app/hdl/hdl_qualification.go index 1a4f42e..a3c180f 100644 --- a/app/hdl/hdl_qualification.go +++ b/app/hdl/hdl_qualification.go @@ -10,35 +10,35 @@ import ( // QualificationInfo // @Summary 基本信息 -// @Tags 资质认证------嘉俊 +// @Tags 账号中心------嘉俊 // @Description 资质认证-基本信息 // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Accept json // @Produce json // @Success 200 {string} "具体看返回内容" // @Failure 400 {object} md.Response "具体错误" -// @Router /api/qualification/info [GET] +// @Router /api/account/qualification/info [GET] func QualificationInfo(c *gin.Context) { svc.QualificationInfo(c) } // QualificationSelectBase // @Summary 认证下拉框选择内容 -// @Tags 资质认证------嘉俊 +// @Tags 账号中心------嘉俊 // @Description 资质认证-认证下拉框选择内容 // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Accept json // @Produce json // @Success 200 {string} "具体看返回内容" // @Failure 400 {object} md.Response "具体错误" -// @Router /api/qualification/select/base [GET] +// @Router /api/account/qualification/select/base [GET] func QualificationSelectBase(c *gin.Context) { svc.QualificationSelectBase(c) } // QualificationEnterpriseSave // @Summary 企业认证保存 -// @Tags 资质认证------嘉俊 +// @Tags 账号中心------嘉俊 // @Description 资质认证-企业认证保存 // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Accept json @@ -46,7 +46,7 @@ func QualificationSelectBase(c *gin.Context) { // @Param args body md.MediumList true "请求参数" // @Success 200 {string} "具体看返回内容" // @Failure 400 {object} md.Response "具体错误" -// @Router /api/qualification/enterprise/save [POST] +// @Router /api/account/qualification/enterprise/save [POST] func QualificationEnterpriseSave(c *gin.Context) { var req md.MediumList err := c.ShouldBindJSON(&req) @@ -67,7 +67,7 @@ func QualificationEnterpriseSave(c *gin.Context) { // QualificationBankSave // @Summary 银行资质保存 -// @Tags 资质认证------嘉俊 +// @Tags 账号中心------嘉俊 // @Description 资质认证-银行资质保存 // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Accept json @@ -75,7 +75,7 @@ func QualificationEnterpriseSave(c *gin.Context) { // @Param args body md.MediumBankInfo true "请求参数" // @Success 200 {string} "具体看返回内容" // @Failure 400 {object} md.Response "具体错误" -// @Router /api/qualification/bank/save [POST] +// @Router /api/account/qualification/bank/save [POST] func QualificationBankSave(c *gin.Context) { var req md.MediumBankInfo err := c.ShouldBindJSON(&req) @@ -96,7 +96,7 @@ func QualificationBankSave(c *gin.Context) { // QualificationContactSave // @Summary 联系方式保存 -// @Tags 资质认证------嘉俊 +// @Tags 账号中心------嘉俊 // @Description 资质认证-联系方式保存 // @param Authorization header string true "验证参数Bearer和token空格拼接" // @Accept json @@ -104,7 +104,7 @@ func QualificationBankSave(c *gin.Context) { // @Param args body md.MediumContactInfo true "请求参数" // @Success 200 {string} "具体看返回内容" // @Failure 400 {object} md.Response "具体错误" -// @Router /api/qualification/contact/save [POST] +// @Router /api/account/qualification/contact/save [POST] func QualificationContactSave(c *gin.Context) { var req md.MediumContactInfo err := c.ShouldBindJSON(&req) diff --git a/app/hdl/hdl_sms.go b/app/hdl/hdl_sms.go index 605acf9..8898dbf 100644 --- a/app/hdl/hdl_sms.go +++ b/app/hdl/hdl_sms.go @@ -40,6 +40,14 @@ func Sms(c *gin.Context) { return } } + if args.Type == "update_password" { + admin, _ := svc.CheckUser(c) + if admin == nil { + e.OutErr(c, 400, e.NewErr(400, "账号未注册")) + return + } + args.Phone = admin.Username + } NewSysCfgDb := implement2.NewSysCfgDb(svc.MasterDb(c), c.GetString("mid")) key := NewSysCfgDb.SysCfgGetWithDb("mob_app_key") if key == "" { diff --git a/app/md/md_account.go b/app/md/md_account.go new file mode 100644 index 0000000..24d3ae8 --- /dev/null +++ b/app/md/md_account.go @@ -0,0 +1,19 @@ +package md + +type AccountBase struct { + AdminPhone string `json:"admin_phone" example:"管理员手机号"` + Nickname string `json:"nickname" example:"昵称"` + CompanyName string `json:"company_name" example:"公司名称"` + CompanyAbbreviation string `json:"company_abbreviation" example:"公司简称"` + MediumId string `json:"medium_id" example:"账户ID"` + ContactName string `json:"contact_name" example:"联系人"` + ContactEmail string `json:"contact_email" example:"邮箱"` + ContactPhone string `json:"contact_phone" example:"联系电话"` + ContactAddress string `json:"contact_address" example:"联系地址"` + CurrencyConf string `json:"currency_conf" example:"结算币种"` + CountryRegion string `json:"country_region" example:"国家地区"` +} +type AccountUpdatePasswordReq struct { + PassWord string `json:"password" example:"登录密码"` + Captcha string `json:"captcha" example:"验证码"` +} diff --git a/app/md/md_qulification.go b/app/md/md_qulification.go new file mode 100644 index 0000000..a30fdae --- /dev/null +++ b/app/md/md_qulification.go @@ -0,0 +1,12 @@ +package md + +var Country = []map[string]string{ + { + "value": "1", "name": "中国/国内", + }, +} +var CurrencyConf = []map[string]string{ + { + "value": "0", "name": "人民币", + }, +} diff --git a/app/md/sms.go b/app/md/sms.go index efdc7bb..f208085 100644 --- a/app/md/sms.go +++ b/app/md/sms.go @@ -2,5 +2,5 @@ package md type SmsReq struct { Phone string `json:"phone"` - Type string `json:"type" example:"手机号登陆:fast_login 注册:register"` + Type string `json:"type" example:"手机号登陆:fast_login 注册:register 修改密码(不用传手机号):update_password"` } diff --git a/app/router/router.go b/app/router/router.go index 950da31..7cef74a 100644 --- a/app/router/router.go +++ b/app/router/router.go @@ -64,10 +64,11 @@ func route(r *gin.RouterGroup) { r.POST("/qiniuyun/upload", hdl.ImgReqUpload) //七牛云上传 r.POST("/sms", hdl.Sms) //短信发送 } - r.Use(mw.Auth) // 以下接口需要JWT验证 - rRole(r.Group("/role")) //权限管理 - rQualification(r.Group("/qualification")) //资质 - rApplication(r.Group("/application")) //应用管理 + r.Use(mw.Auth) // 以下接口需要JWT验证 + rRole(r.Group("/role")) //权限管理 + + rApplication(r.Group("/application")) //应用管理 + rAccount(r.Group("/account")) //账号中心 } func rRole(r *gin.RouterGroup) { @@ -86,12 +87,14 @@ func rRole(r *gin.RouterGroup) { r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息 r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色 } -func rQualification(r *gin.RouterGroup) { - r.GET("/info", hdl.QualificationInfo) //资质认证-基本信息 - r.GET("/select/base", hdl.QualificationSelectBase) //资质认证-认证选择内容 - r.POST("/enterprise/save", hdl.QualificationEnterpriseSave) //资质认证-企业认证保存 - r.POST("/bank/save", hdl.QualificationBankSave) //资质认证-银行资质保存 - r.POST("/contact/save", hdl.QualificationContactSave) //资质认证-联系方式保存 +func rAccount(r *gin.RouterGroup) { + r.GET("/base", hdl.AccountBase) //账号信息 + r.POST("/update/password", hdl.AccountUpdatePassword) //账号信息-修改密码 + r.GET("/qualification/info", hdl.QualificationInfo) //资质认证-基本信息 + r.GET("/qualification/select/base", hdl.QualificationSelectBase) //资质认证-认证选择内容 + r.POST("/qualification/enterprise/save", hdl.QualificationEnterpriseSave) //资质认证-企业认证保存 + r.POST("/qualification/bank/save", hdl.QualificationBankSave) //资质认证-银行资质保存 + r.POST("/qualification/contact/save", hdl.QualificationContactSave) //资质认证-联系方式保存 } func rApplication(r *gin.RouterGroup) { r.POST("/applet/list", hdl.AppletApplicationList) //小程序应用-列表数据 diff --git a/app/svc/svc_account.go b/app/svc/svc_account.go new file mode 100644 index 0000000..c85d636 --- /dev/null +++ b/app/svc/svc_account.go @@ -0,0 +1,69 @@ +package svc + +import ( + "applet/app/e" + "applet/app/md" + "applet/app/utils" + db "code.fnuoos.com/zhimeng/model.git/src" + "code.fnuoos.com/zhimeng/model.git/src/super/implement" + "github.com/gin-gonic/gin" +) + +func AccountBase(c *gin.Context) { + user := GetUser(c) + res := md.AccountBase{ + Nickname: user.Username, + AdminPhone: user.Username, + CompanyName: "", + CompanyAbbreviation: "", + MediumId: utils.IntToStr(user.MediumId), + ContactName: "", + ContactEmail: "", + ContactPhone: user.Username, + ContactAddress: "", + CurrencyConf: "", + CountryRegion: "", + } + MediumListDb := implement.NewMediumListDb(db.Db) + medium, _ := MediumListDb.GetMediumList(user.MediumId) + if medium != nil { + Country := md.Country + res.CompanyAbbreviation = medium.CompanyAbbreviation + res.Nickname = medium.CompanyAbbreviation + res.CompanyName = medium.CompanyName + for _, v := range Country { + if utils.StrToInt(v["value"]) == medium.CountryRegionId { + res.CountryRegion = v["name"] + } + } + } + NewMediumBankInfoDb := implement.NewMediumBankInfoDb(db.Db) + bank, _ := NewMediumBankInfoDb.GetMediumBankInfoList(user.MediumId) + if bank != nil { + for _, v := range md.CurrencyConf { + if utils.StrToInt(v["value"]) == bank.CurrencyConf { + res.CurrencyConf = v["name"] + } + } + } + NewMediumContactInfoDb := implement.NewMediumContactInfoDb(db.Db) + contact, _ := NewMediumContactInfoDb.GetMediumContactInfoList(user.MediumId) + if contact != nil { + res.ContactName = contact.Name + res.ContactAddress = contact.Address + res.ContactEmail = contact.Email + res.ContactPhone = contact.Phone + } + e.OutSuc(c, res, nil) + return +} +func AccountUpdatePassword(c *gin.Context, req md.AccountUpdatePasswordReq) error { + user := GetUser(c) + check, err := SmsCheck(c, user.Username, req.Captcha) + if check == false { + return err + } + user.Password = utils.Md5(req.PassWord) + MasterDb(c).Where("id=?", user.Id).Cols("password").Update(user) + return nil +} diff --git a/app/svc/svc_qualification.go b/app/svc/svc_qualification.go index 115b0ee..d785336 100644 --- a/app/svc/svc_qualification.go +++ b/app/svc/svc_qualification.go @@ -65,21 +65,13 @@ func QualificationSelectBase(c *gin.Context) { res := map[string]interface{}{ "register_area": country, "idcard_type": IdcardTypeList, - "country": []map[string]interface{}{ - { - "value": "1", "name": "中国/国内", - }, - }, + "country": md.Country, "user_type": []map[string]interface{}{ { "value": "1", "name": "企业", }, }, - "currency_conf": []map[string]interface{}{ - { - "value": "0", "name": "人民币", - }, - }, + "currency_conf": md.CurrencyConf, } e.OutSuc(c, res, nil) return diff --git a/go.mod b/go.mod index be209a8..4f6b45e 100644 --- a/go.mod +++ b/go.mod @@ -2,10 +2,10 @@ module applet go 1.18 -//replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models +replace code.fnuoos.com/zhimeng/model.git => E:/company/ad/models require ( - code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240822095043-f18aa08f09b1 + code.fnuoos.com/zhimeng/model.git v0.0.3-0.20240823034048-34202e969e8d github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 github.com/boombuler/barcode v1.0.1 github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5