feat:完善信息
This commit is contained in:
@ -10,8 +10,8 @@ import (
|
|||||||
type UserManage struct {
|
type UserManage struct {
|
||||||
Model
|
Model
|
||||||
ModelTenant
|
ModelTenant
|
||||||
UID uint64 `gorm:"column:uid;index:idx_user_tenant_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
UID uint64 `gorm:"column:uid;index:idx_user_manage_uid;type:int;default:0;comment:用户表UUID" json:"-"`
|
||||||
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_tenant_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
UUID uint64 `gorm:"column:uuid;uniqueIndex:idx_user_manage_uuid;type:int;default:0;comment:用户唯一UUID" json:"-"`
|
||||||
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
Name string `gorm:"column:name;type:varchar(20);default:null;comment:真实姓名" json:"name"`
|
||||||
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
Email string `gorm:"column:email;type:varchar(50);default:null;comment:邮箱" json:"email"`
|
||||||
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
Job string `gorm:"column:job;type:varchar(50);default:null;comment:职务" json:"job"`
|
||||||
|
|||||||
30
app/common/model/user_transaction.go
Normal file
30
app/common/model/user_transaction.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
// UserManageBank 用户银行卡管理
|
||||||
|
type UserManageBank struct {
|
||||||
|
Model
|
||||||
|
ModelTenant
|
||||||
|
UID uint64 `gorm:"column:uid;type:int;default:0;comment:用户管理uuid" json:"-"`
|
||||||
|
Name string `gorm:"column:name;type:varchar(30);default:null;comment:姓名" json:"name"`
|
||||||
|
IDCard string `gorm:"column:id_card;type:varchar(18);default:null;comment:身份证号" json:"id_card"`
|
||||||
|
BankCard string `gorm:"column:bank_card;type:varchar(18);default:null;comment:银行卡号" json:"bank_card"`
|
||||||
|
BackName string `gorm:"column:back_name;type:varchar(15);default:null;comment:银行名称" json:"back_name"`
|
||||||
|
IsDefault UserManageBankDefault `gorm:"column:is_default;type:tinyint(1);default:0;comment:默认使用(0:不默认,1:默认)" json:"-"`
|
||||||
|
ModelDeleted
|
||||||
|
ModelAt
|
||||||
|
}
|
||||||
|
|
||||||
|
type UserManageBankDefault int
|
||||||
|
|
||||||
|
const (
|
||||||
|
UserManageBankDefaultForNot UserManageBankDefault = iota
|
||||||
|
UserManageBankDefaultForYes
|
||||||
|
)
|
||||||
|
|
||||||
|
func (m *UserManageBank) TableName() string {
|
||||||
|
return m.NewTableName("user_manage_bank")
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserManageBank() *UserManageBank {
|
||||||
|
return &UserManageBank{}
|
||||||
|
}
|
||||||
@ -1,84 +1,3 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
|
||||||
"SciencesServer/app/basic/api"
|
|
||||||
"SciencesServer/app/basic/config"
|
|
||||||
"SciencesServer/app/enterprise/controller/tenant"
|
|
||||||
"SciencesServer/app/service"
|
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
)
|
|
||||||
|
|
||||||
type Tenant struct{}
|
type Tenant struct{}
|
||||||
|
|
||||||
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) {
|
|
||||||
form := &struct {
|
|
||||||
SettledBasic
|
|
||||||
}{}
|
|
||||||
if err := api.Bind(form)(c); err != nil {
|
|
||||||
api.APIFailure(err.(error))(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Company(&tenant.SettledParams{
|
|
||||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
|
||||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
|
||||||
}, nil)
|
|
||||||
api.APIResponse(err)(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Tenant) SettledExpert(c *gin.Context) {
|
|
||||||
form := &struct {
|
|
||||||
SettledBasic
|
|
||||||
config.IdentityForExpert
|
|
||||||
}{}
|
|
||||||
if err := api.Bind(form)(c); err != nil {
|
|
||||||
api.APIFailure(err.(error))(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Expert(&tenant.SettledParams{
|
|
||||||
ID: form.Convert(), Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
|
||||||
}, &form.IdentityForExpert)
|
|
||||||
api.APIResponse(err)(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Tenant) SettledResearch(c *gin.Context) {
|
|
||||||
form := &struct {
|
|
||||||
SettledBasic
|
|
||||||
config.IdentityForResearch
|
|
||||||
}{}
|
|
||||||
if err := api.Bind(form)(c); err != nil {
|
|
||||||
api.APIFailure(err.(error))(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Research(&tenant.SettledParams{
|
|
||||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
|
||||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
|
||||||
}, &form.IdentityForResearch)
|
|
||||||
api.APIResponse(err)(c)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (a *Tenant) SettledLaboratory(c *gin.Context) {
|
|
||||||
form := &struct {
|
|
||||||
SettledBasic
|
|
||||||
config.IdentityForLaboratory
|
|
||||||
}{}
|
|
||||||
if err := api.Bind(form)(c); err != nil {
|
|
||||||
api.APIFailure(err.(error))(c)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
err := tenant.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Laboratory(&tenant.SettledParams{
|
|
||||||
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
|
||||||
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
|
||||||
}, &form.IdentityForLaboratory)
|
|
||||||
api.APIResponse(err)(c)
|
|
||||||
}
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"SciencesServer/app/basic/api"
|
"SciencesServer/app/basic/api"
|
||||||
|
"SciencesServer/app/basic/config"
|
||||||
"SciencesServer/app/enterprise/controller/user"
|
"SciencesServer/app/enterprise/controller/user"
|
||||||
"SciencesServer/app/service"
|
"SciencesServer/app/service"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -19,6 +20,79 @@ 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) {
|
||||||
|
form := &struct {
|
||||||
|
SettledBasic
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Company(&user.SettledParams{
|
||||||
|
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||||
|
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||||
|
}, nil)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Tenant) SettledExpert(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
SettledBasic
|
||||||
|
config.IdentityForExpert
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Expert(&user.SettledParams{
|
||||||
|
ID: form.Convert(), Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||||
|
}, &form.IdentityForExpert)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Tenant) SettledResearch(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
SettledBasic
|
||||||
|
config.IdentityForResearch
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Research(&user.SettledParams{
|
||||||
|
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||||
|
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||||
|
}, &form.IdentityForResearch)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *Tenant) SettledLaboratory(c *gin.Context) {
|
||||||
|
form := &struct {
|
||||||
|
SettledBasic
|
||||||
|
config.IdentityForLaboratory
|
||||||
|
}{}
|
||||||
|
if err := api.Bind(form)(c); err != nil {
|
||||||
|
api.APIFailure(err.(error))(c)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err := user.NewSettled()(api.GetSession()(c).(*service.SessionEnterprise)).Laboratory(&user.SettledParams{
|
||||||
|
ID: form.Convert(), Image: form.FilterImageURL(), Name: form.Name, Code: form.Code,
|
||||||
|
Area: form.Area, Introduce: form.Introduce, Industry: form.Industry, Keywords: form.Keywords,
|
||||||
|
}, &form.IdentityForLaboratory)
|
||||||
|
api.APIResponse(err)(c)
|
||||||
|
}
|
||||||
|
|
||||||
func (a *User) SwitchIdentity(c *gin.Context) {
|
func (a *User) SwitchIdentity(c *gin.Context) {
|
||||||
form := &struct {
|
form := &struct {
|
||||||
Identity int `json:"identity" form:"identity" binding:"required"`
|
Identity int `json:"identity" form:"identity" binding:"required"`
|
||||||
|
|||||||
@ -15,7 +15,7 @@ type InstanceLoginCallback func(params *InstanceLoginParams) *InstanceLoginRetur
|
|||||||
|
|
||||||
type (
|
type (
|
||||||
InstanceLoginParams struct {
|
InstanceLoginParams struct {
|
||||||
UID, TenantID, TenantUID uint64
|
UID, TenantID, ManageUID uint64
|
||||||
Name, Mobile string
|
Name, Mobile string
|
||||||
Identity, SelectIdentity int
|
Identity, SelectIdentity int
|
||||||
Status model.AccountStatusKind
|
Status model.AccountStatusKind
|
||||||
@ -35,7 +35,7 @@ func (c *Instance) Login() InstanceLoginCallback {
|
|||||||
session.Token = token
|
session.Token = token
|
||||||
session.UID = params.UID
|
session.UID = params.UID
|
||||||
session.TenantID = params.TenantID
|
session.TenantID = params.TenantID
|
||||||
session.TenantUID = params.TenantUID
|
session.ManageUID = params.ManageUID
|
||||||
session.Name = params.Name
|
session.Name = params.Name
|
||||||
session.Mobile = params.Mobile
|
session.Mobile = params.Mobile
|
||||||
session.Identity = params.Identity
|
session.Identity = params.Identity
|
||||||
|
|||||||
@ -79,7 +79,7 @@ func loginForSmsCaptcha(params *LoginParams, local string) (*InstanceLoginParams
|
|||||||
}
|
}
|
||||||
RETURNS:
|
RETURNS:
|
||||||
return &InstanceLoginParams{
|
return &InstanceLoginParams{
|
||||||
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, TenantUID: mUserManage.UUID,
|
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, ManageUID: mUserManage.UUID,
|
||||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||||
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
||||||
Status: mUserInstance.Status,
|
Status: mUserInstance.Status,
|
||||||
@ -111,7 +111,7 @@ func loginForPassword(params *LoginParams, local string) (*InstanceLoginParams,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return &InstanceLoginParams{
|
return &InstanceLoginParams{
|
||||||
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, TenantUID: mUserManage.UUID,
|
UID: mUserInstance.UUID, TenantID: mUserManage.TenantID, ManageUID: mUserManage.UUID,
|
||||||
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
Name: mUserInstance.Name, Mobile: mUserInstance.Mobile,
|
||||||
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
Identity: mUserInstance.Identity, SelectIdentity: mUserManage.Identity,
|
||||||
Status: mUserInstance.Status,
|
Status: mUserInstance.Status,
|
||||||
|
|||||||
@ -73,7 +73,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
|||||||
return err
|
return err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("信息不存在")
|
return errors.New("信息不存在")
|
||||||
} else if c.TenantUID != mTechnologyInstance.UID {
|
} else if c.ManageUID != mTechnologyInstance.UID {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
|
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForDraft &&
|
||||||
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
|
mTechnologyInstance.Status != model2.TechnologyInstanceStatusForRefuse {
|
||||||
@ -105,7 +105,7 @@ func (c *Instance) Form(params *InstanceParams) error {
|
|||||||
mTechnologyInstance.UpdatedAt = time.Now()
|
mTechnologyInstance.UpdatedAt = time.Now()
|
||||||
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
|
return model2.Updates(mTechnologyInstance.TechnologyInstance, mTechnologyInstance.TechnologyInstance)
|
||||||
}
|
}
|
||||||
mTechnologyInstance.UID = c.TenantUID
|
mTechnologyInstance.UID = c.ManageUID
|
||||||
mTechnologyInstance.Local.Local = c.local
|
mTechnologyInstance.Local.Local = c.local
|
||||||
mTechnologyInstance.TenantID = c.TenantID
|
mTechnologyInstance.TenantID = c.TenantID
|
||||||
|
|
||||||
@ -122,7 +122,7 @@ func (c *Instance) Shelf(id uint64, status int) error {
|
|||||||
return err
|
return err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("信息不存在")
|
return errors.New("信息不存在")
|
||||||
} else if c.TenantUID != mTechnologyInstance.UID {
|
} else if c.ManageUID != mTechnologyInstance.UID {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
|
} else if mTechnologyInstance.Status != model2.TechnologyInstanceStatusForAgree {
|
||||||
return errors.New("操作错误,当前状态不允许处理上下架")
|
return errors.New("操作错误,当前状态不允许处理上下架")
|
||||||
@ -147,7 +147,7 @@ func (c *Instance) Delete(id uint64) error {
|
|||||||
return err
|
return err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("信息不存在")
|
return errors.New("信息不存在")
|
||||||
} else if c.TenantUID != mTechnologyInstance.UID {
|
} else if c.ManageUID != mTechnologyInstance.UID {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
|
if err = model2.Delete(mTechnologyInstance.TechnologyInstance); err != nil {
|
||||||
@ -158,6 +158,6 @@ func (c *Instance) Delete(id uint64) error {
|
|||||||
|
|
||||||
func NewInstance() InstanceHandle {
|
func NewInstance() InstanceHandle {
|
||||||
return func(enterprise *service.SessionEnterprise, local string) *Instance {
|
return func(enterprise *service.SessionEnterprise, local string) *Instance {
|
||||||
return &Instance{enterprise, local}
|
return &Instance{SessionEnterprise: enterprise, local: local}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ func (c *Paper) Form(params *PaperParams) error {
|
|||||||
return err
|
return err
|
||||||
} else if !isExist {
|
} else if !isExist {
|
||||||
return errors.New("当前论文信息不存在")
|
return errors.New("当前论文信息不存在")
|
||||||
} else if mTechnologyPaper.UID != c.TenantUID {
|
} else if mTechnologyPaper.UID != c.ManageUID {
|
||||||
return errors.New("无权限操作")
|
return errors.New("无权限操作")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ func (c *Paper) Form(params *PaperParams) error {
|
|||||||
|
|
||||||
if params.ID <= 0 {
|
if params.ID <= 0 {
|
||||||
mTechnologyPaper.TenantID = c.TenantID
|
mTechnologyPaper.TenantID = c.TenantID
|
||||||
mTechnologyPaper.UID = c.TenantUID
|
mTechnologyPaper.UID = c.ManageUID
|
||||||
mTechnologyPaper.Local.Local = c.local
|
mTechnologyPaper.Local.Local = c.local
|
||||||
return model2.Create(mTechnologyPaper.TechnologyPaper)
|
return model2.Create(mTechnologyPaper.TechnologyPaper)
|
||||||
}
|
}
|
||||||
@ -99,7 +99,7 @@ func (c *Paper) Delete(id uint64) error {
|
|||||||
|
|
||||||
var count int64
|
var count int64
|
||||||
|
|
||||||
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.TenantUID))
|
err := model2.Count(mTechnologyPaper.TechnologyPaper, &count, model2.NewWhere("id", id), model2.NewWhere("uid", c.ManageUID))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -114,6 +114,6 @@ func (c *Paper) Delete(id uint64) error {
|
|||||||
|
|
||||||
func NewPaper() PaperHandle {
|
func NewPaper() PaperHandle {
|
||||||
return func(enterprise *service.SessionEnterprise, local string) *Paper {
|
return func(enterprise *service.SessionEnterprise, local string) *Paper {
|
||||||
return &Paper{enterprise, local}
|
return &Paper{SessionEnterprise: enterprise, local: local}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
114
app/enterprise/controller/user/bank.go
Normal file
114
app/enterprise/controller/user/bank.go
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
package user
|
||||||
|
|
||||||
|
import (
|
||||||
|
model2 "SciencesServer/app/common/model"
|
||||||
|
"SciencesServer/app/enterprise/model"
|
||||||
|
"SciencesServer/app/service"
|
||||||
|
"SciencesServer/utils"
|
||||||
|
"errors"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Back struct {
|
||||||
|
*service.SessionEnterprise
|
||||||
|
}
|
||||||
|
|
||||||
|
type BackHandle func(enterprise *service.SessionEnterprise) *Back
|
||||||
|
|
||||||
|
type (
|
||||||
|
// BackInfo 银行卡信息
|
||||||
|
BackInfo struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
*model2.UserManageBank
|
||||||
|
}
|
||||||
|
// BackParams 银行卡参数信息
|
||||||
|
BackParams struct {
|
||||||
|
Name, IDCard, BackCard, BackName string
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// checkIDCard 验证身份证号
|
||||||
|
func (c *BackParams) checkIDCard() bool {
|
||||||
|
return utils.ValidateIDCard(c.IDCard)
|
||||||
|
}
|
||||||
|
|
||||||
|
// checkBankCard 验证银行卡号
|
||||||
|
func (c *BackParams) checkBankCard() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// List 列表信息
|
||||||
|
func (c *Back) List() ([]*BackInfo, error) {
|
||||||
|
mUserManageBack := model.NewUserManageBank()
|
||||||
|
|
||||||
|
out := make([]*model2.UserManageBank, 0)
|
||||||
|
|
||||||
|
where := []*model2.ModelWhereOrder{&model2.ModelWhereOrder{
|
||||||
|
Where: model2.NewWhere("uid", c.ManageUID),
|
||||||
|
Order: model2.NewOrder("is_default", model2.OrderModeToDesc),
|
||||||
|
}}
|
||||||
|
if err := model2.Find(mUserManageBack.UserManageBank, &out, where...); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
list := make([]*BackInfo, 0)
|
||||||
|
|
||||||
|
for _, v := range out {
|
||||||
|
list = append(list, &BackInfo{ID: v.GetEncodeID(), UserManageBank: v})
|
||||||
|
}
|
||||||
|
return list, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind 绑定
|
||||||
|
func (c *Back) Bind(params *BackParams) error {
|
||||||
|
if !params.checkIDCard() {
|
||||||
|
return errors.New("身份证号信息错误")
|
||||||
|
}
|
||||||
|
if !params.checkBankCard() {
|
||||||
|
return errors.New("银行卡信息错误")
|
||||||
|
}
|
||||||
|
mUserManageBack := model.NewUserManageBank()
|
||||||
|
|
||||||
|
var count int64
|
||||||
|
|
||||||
|
err := model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("back_card", params.BackCard))
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if count > 0 {
|
||||||
|
return errors.New("当前银行卡已被注册")
|
||||||
|
}
|
||||||
|
mUserManageBack.UID = c.ManageUID
|
||||||
|
mUserManageBack.Name = params.Name
|
||||||
|
mUserManageBack.IDCard = params.IDCard
|
||||||
|
mUserManageBack.BankCard = params.BackCard
|
||||||
|
mUserManageBack.BackName = params.BackName
|
||||||
|
|
||||||
|
if err = model2.Count(mUserManageBack.UserManageBank, &count, model2.NewWhere("uid", c.ManageUID)); err != nil {
|
||||||
|
return err
|
||||||
|
} else if count <= 0 {
|
||||||
|
mUserManageBack.IsDefault = model2.UserManageBankDefaultForYes
|
||||||
|
}
|
||||||
|
return model2.Create(mUserManageBack.UserManageBank)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unbind 解绑,直接删除
|
||||||
|
func (c *Back) Unbind(id uint64) error {
|
||||||
|
mUserManageBack := model.NewUserManageBank()
|
||||||
|
mUserManageBack.ID = id
|
||||||
|
|
||||||
|
isExist, err := model2.FirstField(mUserManageBack.UserManageBank, []string{"id", "uid"})
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
} else if !isExist {
|
||||||
|
return errors.New("操作错误,绑定信息不存在")
|
||||||
|
} else if mUserManageBack.UID != c.ManageUID {
|
||||||
|
return errors.New("无权限操作")
|
||||||
|
}
|
||||||
|
return model2.Delete(mUserManageBack)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBack() BackHandle {
|
||||||
|
return func(enterprise *service.SessionEnterprise) *Back {
|
||||||
|
return &Back{enterprise}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -83,7 +83,7 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
|||||||
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
if err = orm.GetDB().Transaction(func(tx *gorm.DB) error {
|
||||||
if err = model2.UpdatesWhere(mUserManage.UserManage, map[string]interface{}{
|
if err = model2.UpdatesWhere(mUserManage.UserManage, map[string]interface{}{
|
||||||
"selected": model2.UserManageSelectedForNo, "updated_at": now,
|
"selected": model2.UserManageSelectedForNo, "updated_at": now,
|
||||||
}, []*model2.ModelWhere{model2.NewWhere("uid", c.TenantUID)}, tx); err != nil {
|
}, []*model2.ModelWhere{model2.NewWhere("uid", c.ManageUID)}, tx); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return model2.Updates(mUserManage.UserManage, map[string]interface{}{
|
return model2.Updates(mUserManage.UserManage, map[string]interface{}{
|
||||||
@ -94,7 +94,7 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
c.TenantID = mUserManage.TenantID
|
c.TenantID = mUserManage.TenantID
|
||||||
c.TenantUID = mUserManage.UUID
|
c.ManageUID = mUserManage.UUID
|
||||||
}
|
}
|
||||||
c.SelectIdentity = identity
|
c.SelectIdentity = identity
|
||||||
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.SessionEnterprise)
|
service.Publish(config2.EventForAccountLoginProduce, config2.RedisKeyForAccount, c.UIDToString(), c.SessionEnterprise)
|
||||||
@ -103,6 +103,6 @@ func (c *Instance) SwitchIdentity(identity int) error {
|
|||||||
|
|
||||||
func NewInstance() InstanceHandle {
|
func NewInstance() InstanceHandle {
|
||||||
return func(enterprise *service.SessionEnterprise) *Instance {
|
return func(enterprise *service.SessionEnterprise) *Instance {
|
||||||
return &Instance{enterprise}
|
return &Instance{SessionEnterprise: enterprise}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package tenant
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"SciencesServer/app/basic/config"
|
"SciencesServer/app/basic/config"
|
||||||
@ -57,7 +57,7 @@ func (c *SettledParams) pass(uid, mUID uint64, mStatus model2.ExamineStatusKind)
|
|||||||
func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompany) error {
|
func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompany) error {
|
||||||
mManageCompany := model.NewManageCompany()
|
mManageCompany := model.NewManageCompany()
|
||||||
|
|
||||||
err := params.effect(c.TenantUID, mManageCompany.ManageCompany)
|
err := params.effect(c.ManageUID, mManageCompany.ManageCompany)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -73,10 +73,10 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
|||||||
mManageCompany.Introduce = params.Introduce
|
mManageCompany.Introduce = params.Introduce
|
||||||
|
|
||||||
if mManageCompany.ID <= 0 {
|
if mManageCompany.ID <= 0 {
|
||||||
mManageCompany.UID = c.TenantUID
|
mManageCompany.UID = c.ManageUID
|
||||||
return model2.Create(mManageCompany.ManageCompany)
|
return model2.Create(mManageCompany.ManageCompany)
|
||||||
}
|
}
|
||||||
if !params.pass(c.TenantUID, mManageCompany.UID, mManageCompany.Status) {
|
if !params.pass(c.ManageUID, mManageCompany.UID, mManageCompany.Status) {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
mManageCompany.Status = model2.ExamineStatusForOngoing
|
mManageCompany.Status = model2.ExamineStatusForOngoing
|
||||||
@ -87,7 +87,7 @@ func (c *Settled) Company(params *SettledParams, other *config.IdentityForCompan
|
|||||||
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert) error {
|
||||||
mManageExpert := model.NewManageExpert()
|
mManageExpert := model.NewManageExpert()
|
||||||
|
|
||||||
err := params.effect(c.TenantUID, mManageExpert.ManageExpert)
|
err := params.effect(c.ManageUID, mManageExpert.ManageExpert)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -108,10 +108,10 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
|||||||
mManageExpert.Research = utils.AnyToJSON(other.Research)
|
mManageExpert.Research = utils.AnyToJSON(other.Research)
|
||||||
|
|
||||||
if mManageExpert.ID <= 0 {
|
if mManageExpert.ID <= 0 {
|
||||||
mManageExpert.UID = c.TenantUID
|
mManageExpert.UID = c.ManageUID
|
||||||
return model2.Create(mManageExpert.ManageExpert)
|
return model2.Create(mManageExpert.ManageExpert)
|
||||||
}
|
}
|
||||||
if !params.pass(c.TenantUID, mManageExpert.UID, mManageExpert.Status) {
|
if !params.pass(c.ManageUID, mManageExpert.UID, mManageExpert.Status) {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
mManageExpert.Status = model2.ExamineStatusForOngoing
|
mManageExpert.Status = model2.ExamineStatusForOngoing
|
||||||
@ -122,7 +122,7 @@ func (c *Settled) Expert(params *SettledParams, other *config.IdentityForExpert)
|
|||||||
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
func (c *Settled) Research(params *SettledParams, other *config.IdentityForResearch) error {
|
||||||
mManageResearch := model.NewManageResearch()
|
mManageResearch := model.NewManageResearch()
|
||||||
|
|
||||||
err := params.effect(c.TenantUID, mManageResearch.ManageResearch)
|
err := params.effect(c.ManageUID, mManageResearch.ManageResearch)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -137,10 +137,10 @@ func (c *Settled) Research(params *SettledParams, other *config.IdentityForResea
|
|||||||
mManageResearch.Research = other.Research
|
mManageResearch.Research = other.Research
|
||||||
|
|
||||||
if mManageResearch.ID <= 0 {
|
if mManageResearch.ID <= 0 {
|
||||||
mManageResearch.UID = c.TenantUID
|
mManageResearch.UID = c.ManageUID
|
||||||
return model2.Create(mManageResearch.ManageResearch)
|
return model2.Create(mManageResearch.ManageResearch)
|
||||||
}
|
}
|
||||||
if !params.pass(c.TenantUID, mManageResearch.UID, mManageResearch.Status) {
|
if !params.pass(c.ManageUID, mManageResearch.UID, mManageResearch.Status) {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
mManageResearch.Status = model2.ExamineStatusForOngoing
|
mManageResearch.Status = model2.ExamineStatusForOngoing
|
||||||
@ -151,7 +151,7 @@ func (c *Settled) Research(params *SettledParams, other *config.IdentityForResea
|
|||||||
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLaboratory) error {
|
||||||
mManageLaboratory := model.NewManageLaboratory()
|
mManageLaboratory := model.NewManageLaboratory()
|
||||||
|
|
||||||
err := params.effect(c.TenantUID, mManageLaboratory.ManageLaboratory)
|
err := params.effect(c.ManageUID, mManageLaboratory.ManageLaboratory)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -169,10 +169,10 @@ func (c *Settled) Laboratory(params *SettledParams, other *config.IdentityForLab
|
|||||||
mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
mManageLaboratory.Research = utils.AnyToJSON(other.Research)
|
||||||
|
|
||||||
if mManageLaboratory.ID <= 0 {
|
if mManageLaboratory.ID <= 0 {
|
||||||
mManageLaboratory.UID = c.TenantUID
|
mManageLaboratory.UID = c.ManageUID
|
||||||
return model2.Create(mManageLaboratory.ManageLaboratory)
|
return model2.Create(mManageLaboratory.ManageLaboratory)
|
||||||
}
|
}
|
||||||
if !params.pass(c.TenantUID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
if !params.pass(c.ManageUID, mManageLaboratory.UID, mManageLaboratory.Status) {
|
||||||
return errors.New("操作错误,无权限操作")
|
return errors.New("操作错误,无权限操作")
|
||||||
}
|
}
|
||||||
mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
mManageLaboratory.Status = model2.ExamineStatusForOngoing
|
||||||
11
app/enterprise/model/user_manage_bank.go
Normal file
11
app/enterprise/model/user_manage_bank.go
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "SciencesServer/app/common/model"
|
||||||
|
|
||||||
|
type UserManageBank struct {
|
||||||
|
*model.UserManageBank
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewUserManageBank() *UserManageBank {
|
||||||
|
return &UserManageBank{model.NewUserManageBank()}
|
||||||
|
}
|
||||||
@ -31,7 +31,7 @@ func NewSession() *Session {
|
|||||||
type SessionEnterprise struct {
|
type SessionEnterprise struct {
|
||||||
UID uint64 `json:"uid"` // 唯一标识ID
|
UID uint64 `json:"uid"` // 唯一标识ID
|
||||||
TenantID uint64 `json:"tenant_id"` // 租户ID
|
TenantID uint64 `json:"tenant_id"` // 租户ID
|
||||||
TenantUID uint64 `json:"tenant_uid"` // 租户下用户唯一ID
|
ManageUID uint64 `json:"manage_uid"` // 管理平台用户唯一ID
|
||||||
Token string `json:"token"` // token
|
Token string `json:"token"` // token
|
||||||
Name string `json:"name"` // 名称
|
Name string `json:"name"` // 名称
|
||||||
Mobile string `json:"mobile"` // 手机号码
|
Mobile string `json:"mobile"` // 手机号码
|
||||||
|
|||||||
@ -18,6 +18,17 @@ func ValidateUrl(url string) {
|
|||||||
//reg := regexp.MustCompile("^([hH][tT]{2}[pP]:|||[hH][tT]{2}[pP][sS]:|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$")
|
//reg := regexp.MustCompile("^([hH][tT]{2}[pP]:|||[hH][tT]{2}[pP][sS]:|www\.)(([A-Za-z0-9-~]+)\.)+([A-Za-z0-9-~\/])+$")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ValidateIDCard(obj string) bool {
|
||||||
|
reg := regexp.MustCompile("^[1-9]\\d{5}(18|19|([23]\\d))\\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\\d{3}[0-9Xx]$")
|
||||||
|
return reg.MatchString(obj)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func ValidateIP(ip string) bool {
|
||||||
|
reg := regexp.MustCompile("^((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})(\\.((2(5[0-5]|[0-4]\\d))|[0-1]?\\d{1,2})){3}$")
|
||||||
|
return reg.MatchString(ip)
|
||||||
|
}
|
||||||
|
|
||||||
func ValidateCompile(obj, compile string) bool {
|
func ValidateCompile(obj, compile string) bool {
|
||||||
reg := regexp.MustCompile(compile)
|
reg := regexp.MustCompile(compile)
|
||||||
return reg.MatchString(obj)
|
return reg.MatchString(obj)
|
||||||
|
|||||||
Reference in New Issue
Block a user