feat:完善信息
This commit is contained in:
@ -10,6 +10,28 @@ import (
|
|||||||
|
|
||||||
type User struct{}
|
type User struct{}
|
||||||
|
|
||||||
|
type (
|
||||||
|
// userSettledForm 入驻平台参数
|
||||||
|
userSettledForm struct {
|
||||||
|
api.IDStringForm
|
||||||
|
api.ImageForm
|
||||||
|
Name string `json:"name" form:"name"`
|
||||||
|
Code string `json:"code" form:"code"`
|
||||||
|
config.Area
|
||||||
|
Introduce string `json:"introduce" form:"introduce"`
|
||||||
|
Industry uint64 `json:"industry" form:"industry"`
|
||||||
|
Keywords []string `json:"keywords" form:"keywords"`
|
||||||
|
}
|
||||||
|
// userBankForm 银行平台信息参数
|
||||||
|
userBankForm struct {
|
||||||
|
Name string `json:"name" form:"name" binding:"required"`
|
||||||
|
IDCard string `json:"id_card" form:"id_card" binding:"required"`
|
||||||
|
BackCard string `json:"back_card" form:"back_card" binding:"required"`
|
||||||
|
BackName string `json:"back_name" form:"back_name" binding:"required"`
|
||||||
|
Captcha string `json:"captcha" form:"captcha" binding:"required"`
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
func (a *User) Info(c *gin.Context) {
|
func (a *User) Info(c *gin.Context) {
|
||||||
data := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Info()
|
data := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).Info()
|
||||||
api.APISuccess(data)
|
api.APISuccess(data)
|
||||||
@ -20,20 +42,9 @@ func (a *User) Detail(c *gin.Context) {
|
|||||||
api.APIResponse(err, data)(c)
|
api.APIResponse(err, data)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
type SettledBasic struct {
|
|
||||||
api.IDStringForm
|
|
||||||
api.ImageForm
|
|
||||||
Name string `json:"name" form:"name"`
|
|
||||||
Code string `json:"code" form:"code"`
|
|
||||||
config.Area
|
|
||||||
Introduce string `json:"introduce" form:"introduce"`
|
|
||||||
Industry uint64 `json:"industry" form:"industry"`
|
|
||||||
Keywords []string `json:"keywords" form:"keywords"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Tenant) SettledCompany(c *gin.Context) {
|
func (a *Tenant) SettledCompany(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
SettledBasic
|
userSettledForm
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
api.APIFailure(err.(error))(c)
|
api.APIFailure(err.(error))(c)
|
||||||
@ -48,7 +59,7 @@ func (a *Tenant) SettledCompany(c *gin.Context) {
|
|||||||
|
|
||||||
func (a *Tenant) SettledExpert(c *gin.Context) {
|
func (a *Tenant) SettledExpert(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
SettledBasic
|
userSettledForm
|
||||||
config.IdentityForExpert
|
config.IdentityForExpert
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
@ -63,7 +74,7 @@ func (a *Tenant) SettledExpert(c *gin.Context) {
|
|||||||
|
|
||||||
func (a *Tenant) SettledResearch(c *gin.Context) {
|
func (a *Tenant) SettledResearch(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
SettledBasic
|
userSettledForm
|
||||||
config.IdentityForResearch
|
config.IdentityForResearch
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
@ -79,7 +90,7 @@ func (a *Tenant) SettledResearch(c *gin.Context) {
|
|||||||
|
|
||||||
func (a *Tenant) SettledLaboratory(c *gin.Context) {
|
func (a *Tenant) SettledLaboratory(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
SettledBasic
|
userSettledForm
|
||||||
config.IdentityForLaboratory
|
config.IdentityForLaboratory
|
||||||
}{}
|
}{}
|
||||||
if err := api.Bind(form)(c); err != nil {
|
if err := api.Bind(form)(c); err != nil {
|
||||||
@ -104,3 +115,35 @@ func (a *User) SwitchIdentity(c *gin.Context) {
|
|||||||
err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).SwitchIdentity(form.Identity)
|
err := user.NewInstance()(api.GetSession()(c).(*service.SessionEnterprise)).SwitchIdentity(form.Identity)
|
||||||
api.APIResponse(err)(c)
|
api.APIResponse(err)(c)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *User) Back(c *gin.Context) {
|
||||||
|
data, err := user.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).List()
|
||||||
|
api.APIResponse(err, data)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *User) BackBind(c *gin.Context) {
|
||||||
|
form := new(userBankForm)
|
||||||
|
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := user.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).Bind(&user.BackParams{
|
||||||
|
Name: form.Name,
|
||||||
|
IDCard: form.IDCard,
|
||||||
|
BackCard: form.BackCard,
|
||||||
|
BackName: form.BackName,
|
||||||
|
}, form.Captcha)
|
||||||
|
api.APIResponse(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *User) BackUnbind(c *gin.Context) {
|
||||||
|
form := new(api.IDStringForm)
|
||||||
|
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := user.NewBack()(api.GetSession()(c).(*service.SessionEnterprise)).Unbind(form.Convert())
|
||||||
|
api.APIResponse(err)
|
||||||
|
}
|
||||||
|
@ -3,6 +3,7 @@ package user
|
|||||||
import (
|
import (
|
||||||
model2 "SciencesServer/app/common/model"
|
model2 "SciencesServer/app/common/model"
|
||||||
"SciencesServer/app/enterprise/model"
|
"SciencesServer/app/enterprise/model"
|
||||||
|
"SciencesServer/app/handle"
|
||||||
"SciencesServer/app/service"
|
"SciencesServer/app/service"
|
||||||
"SciencesServer/utils"
|
"SciencesServer/utils"
|
||||||
"errors"
|
"errors"
|
||||||
@ -58,7 +59,16 @@ func (c *Back) List() ([]*BackInfo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bind 绑定
|
// Bind 绑定
|
||||||
func (c *Back) Bind(params *BackParams) error {
|
func (c *Back) Bind(params *BackParams, captcha string) error {
|
||||||
|
pass, err := handle.NewCaptcha().Validate(&handle.CaptchaSms{
|
||||||
|
Mobile: c.Mobile, Captcha: captcha,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !pass {
|
||||||
|
return errors.New("验证码错误或已过期")
|
||||||
|
}
|
||||||
|
|
||||||
if !params.checkIDCard() {
|
if !params.checkIDCard() {
|
||||||
return errors.New("身份证号信息错误")
|
return errors.New("身份证号信息错误")
|
||||||
}
|
}
|
||||||
@ -69,9 +79,7 @@ func (c *Back) Bind(params *BackParams) error {
|
|||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
err := model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("back_card", params.BackCard))
|
if err = model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("back_card", params.BackCard)); err != nil {
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
} else if count > 0 {
|
} else if count > 0 {
|
||||||
return errors.New("当前银行卡已被注册")
|
return errors.New("当前银行卡已被注册")
|
||||||
|
Reference in New Issue
Block a user