From 52dc8cb57da13797247f54a585443a21b7958847 Mon Sep 17 00:00:00 2001 From: henry Date: Wed, 13 Oct 2021 14:41:46 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=AE=8C=E5=96=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/basic/config/public.go | 6 +++--- app/common/model/common.go | 8 ++++---- app/enterprise/api/account.go | 4 ++-- app/enterprise/api/technology.go | 8 ++++---- app/enterprise/controller/account/login.go | 12 ++++++------ app/enterprise/controller/account/register.go | 8 ++++---- app/enterprise/controller/technology/instance.go | 6 +++--- app/enterprise/controller/technology/paper.go | 6 +++--- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/app/basic/config/public.go b/app/basic/config/public.go index ff11ec3..e06ee56 100644 --- a/app/basic/config/public.go +++ b/app/basic/config/public.go @@ -2,9 +2,9 @@ package config // Area 区域 type Area struct { - Province uint64 `json:"province" form:"province"` - City uint64 `json:"city" form:"city"` - District uint64 `json:"district" form:"district"` + Province string `json:"province" form:"province"` + City string `json:"city" form:"city"` + District string `json:"district" form:"district"` Address string `json:"address" form:"address"` } diff --git a/app/common/model/common.go b/app/common/model/common.go index 8c994cc..08263e2 100644 --- a/app/common/model/common.go +++ b/app/common/model/common.go @@ -52,7 +52,7 @@ func (m *Images) AnalysisSlice(domain string) []string { } type Local struct { - Local uint64 `gorm:"column:local;type:int(11);default:0;comment:数据位置来源" json:"-"` + Local string `gorm:"column:local;type:varchar(8);default:null;comment:数据位置来源" json:"-"` } // AccountStatus 账号状态 @@ -102,9 +102,9 @@ const ( ) type Area struct { - Province uint64 `gorm:"column:province;type:int;default:0;comment:所在省" json:"province"` - City uint64 `gorm:"column:city;type:int;default:0;comment:所在市" json:"city"` - District uint64 `gorm:"column:district;type:int;default:0;comment:所在区/县" json:"district"` + Province string `gorm:"column:province;type:varchar(8);default:null;comment:所在省" json:"province"` + City string `gorm:"column:city;type:varchar(8);default:null;comment:所在市" json:"city"` + District string `gorm:"column:district;type:varchar(8);default:null;comment:所在区/县" json:"district"` Address string `gorm:"column:address;type:varchar(255);default:null;comment:详细地址" json:"address"` } diff --git a/app/enterprise/api/account.go b/app/enterprise/api/account.go index 147e5a8..5e64331 100644 --- a/app/enterprise/api/account.go +++ b/app/enterprise/api/account.go @@ -33,7 +33,7 @@ func (a *Account) Login(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := account.NewLogin()(api.GetLocal()(c).(uint64)).Launch(account.LoginMode(form.Mode), &account.LoginParams{ + data, err := account.NewLogin()(api.GetLocal()(c).(string)).Launch(account.LoginMode(form.Mode), &account.LoginParams{ Captcha: struct { Mobile string Captcha string @@ -53,7 +53,7 @@ func (a *Account) Register(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := account.NewRegister()(api.GetLocal()(c).(uint64)).Launch(&account.RegisterParams{ + data, err := account.NewRegister()(api.GetLocal()(c).(string)).Launch(&account.RegisterParams{ Name: form.Name, Mobile: form.Mobile, Captcha: form.Captcha, Password: form.Password, RepeatPass: form.RepeatPass, Identity: form.Identity, }) diff --git a/app/enterprise/api/technology.go b/app/enterprise/api/technology.go index 060ae82..4437fcd 100644 --- a/app/enterprise/api/technology.go +++ b/app/enterprise/api/technology.go @@ -31,7 +31,7 @@ func (a *Technology) Paper(c *gin.Context) { api.APIFailure(err.(error))(c) return } - data, err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(uint64)). + data, err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). List(form.Title, form.Page, form.PageSize) api.APIResponse(err, data)(c) } @@ -43,7 +43,7 @@ func (a *Technology) PaperAdd(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(uint64)). + err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). Form(&technology.PaperParams{ Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt, Keyword: form.Keyword, Tags: form.Tags, Remark: form.Remark, @@ -60,7 +60,7 @@ func (a *Technology) PaperEdit(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(uint64)). + err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). Form(&technology.PaperParams{ ID: form.Convert(), Title: form.Title, Ext: form.Ext, Author: form.Author, PublishAt: form.PublishAt, Keyword: form.Keyword, Tags: form.Tags, Remark: form.Remark, @@ -75,7 +75,7 @@ func (a *Technology) PaperDelete(c *gin.Context) { api.APIFailure(err.(error))(c) return } - err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(uint64)). + err := technology.NewPaper()(api.GetSession()(c).(*service.SessionEnterprise), api.GetLocal()(c).(string)). Delete(form.Convert()) api.APIResponse(err)(c) } diff --git a/app/enterprise/controller/account/login.go b/app/enterprise/controller/account/login.go index 4ccc20e..71992c9 100644 --- a/app/enterprise/controller/account/login.go +++ b/app/enterprise/controller/account/login.go @@ -8,10 +8,10 @@ import ( "errors" ) -type Login struct{ local uint64 } +type Login struct{ local string } type ( - LoginHandle func(local uint64) *Login + LoginHandle func(local string) *Login ) type ( @@ -38,12 +38,12 @@ const ( LoginModeForQQ // QQ登陆 ) -var loginHandle = map[LoginMode]func(*LoginParams, uint64) (*InstanceLoginParams, error){ +var loginHandle = map[LoginMode]func(*LoginParams, string) (*InstanceLoginParams, error){ LoginModeForSmsCaptcha: loginForSmsCaptcha, LoginModeForPassword: loginForPassword, } // loginForSmsCaptcha 短信验证码登陆 -func loginForSmsCaptcha(params *LoginParams, local uint64) (*InstanceLoginParams, error) { +func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams, error) { if !utils.ValidateMobile(params.Captcha.Mobile) { return nil, errors.New("手机号码格式异常") } @@ -87,7 +87,7 @@ RETURNS: } // loginForPassword 密码登陆 -func loginForPassword(params *LoginParams, local uint64) (*InstanceLoginParams, error) { +func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams, error) { if !utils.ValidateMobile(params.Password.Mobile) { return nil, errors.New("手机号码格式异常") } @@ -140,7 +140,7 @@ func (c *Login) Launch(mode LoginMode, params *LoginParams) (*InstanceLoginRetur } func NewLogin() LoginHandle { - return func(local uint64) *Login { + return func(local string) *Login { return &Login{local: local} } } diff --git a/app/enterprise/controller/account/register.go b/app/enterprise/controller/account/register.go index 5ef4e8f..cd2627d 100644 --- a/app/enterprise/controller/account/register.go +++ b/app/enterprise/controller/account/register.go @@ -10,9 +10,9 @@ import ( "gorm.io/gorm" ) -type Register struct{ local uint64 } +type Register struct{ local string } -type RegisterHandle func(local uint64) *Register +type RegisterHandle func(local string) *Register type ( RegisterParams struct { @@ -29,7 +29,7 @@ func (c *RegisterParams) checkCaptcha() (bool, error) { return handle.NewCaptcha().Validate(&handle.CaptchaSms{Captcha: c.Captcha, Mobile: c.Mobile}) } -func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, local uint64) (bool, error) { +func (c *RegisterParams) checkUserExist(mUserInstance *model2.UserInstance, local string) (bool, error) { var count int64 if err := model2.Count(mUserInstance, &count, model2.NewWhere("mobile", c.Mobile), @@ -88,7 +88,7 @@ func (c *Register) Launch(params *RegisterParams) (*InstanceLoginReturn, error) } func NewRegister() RegisterHandle { - return func(local uint64) *Register { + return func(local string) *Register { return &Register{local: local} } } diff --git a/app/enterprise/controller/technology/instance.go b/app/enterprise/controller/technology/instance.go index 55c2845..9ca13e4 100644 --- a/app/enterprise/controller/technology/instance.go +++ b/app/enterprise/controller/technology/instance.go @@ -12,10 +12,10 @@ import ( // Instance 技术管理 type Instance struct { *service.SessionEnterprise - local uint64 + local string } -type InstanceHandle func(enterprise *service.SessionEnterprise, local uint64) *Instance +type InstanceHandle func(enterprise *service.SessionEnterprise, local string) *Instance type ( // InstanceInfo 详细信息 @@ -157,7 +157,7 @@ func (c *Instance) Delete(id uint64) error { } func NewInstance() InstanceHandle { - return func(enterprise *service.SessionEnterprise, local uint64) *Instance { + return func(enterprise *service.SessionEnterprise, local string) *Instance { return &Instance{enterprise, local} } } diff --git a/app/enterprise/controller/technology/paper.go b/app/enterprise/controller/technology/paper.go index 49974ac..a3fb380 100644 --- a/app/enterprise/controller/technology/paper.go +++ b/app/enterprise/controller/technology/paper.go @@ -13,10 +13,10 @@ import ( // Paper 论文管理 type Paper struct { *service.SessionEnterprise - local uint64 + local string } -type PaperHandle func(enterprise *service.SessionEnterprise, local uint64) *Paper +type PaperHandle func(enterprise *service.SessionEnterprise, local string) *Paper type ( PaperInfo struct { @@ -113,7 +113,7 @@ func (c *Paper) Delete(id uint64) error { } func NewPaper() PaperHandle { - return func(enterprise *service.SessionEnterprise, local uint64) *Paper { + return func(enterprise *service.SessionEnterprise, local string) *Paper { return &Paper{enterprise, local} } }