chore: user type
This commit is contained in:
@@ -8,4 +8,5 @@ type Client struct {
|
|||||||
SubjectType string `gorm:"column:subject_type" json:"subject_type"`
|
SubjectType string `gorm:"column:subject_type" json:"subject_type"`
|
||||||
StoreStaff uint8 `gorm:"column:store_staff" json:"store_staff"`
|
StoreStaff uint8 `gorm:"column:store_staff" json:"store_staff"`
|
||||||
Status uint8 `gorm:"column:status" json:"status"`
|
Status uint8 `gorm:"column:status" json:"status"`
|
||||||
|
Type uint8 `gorm:"column:type" json:"type"`
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -216,11 +216,7 @@ func issueLoginToken(ctx context.Context, jwtAuth *config.JWTAuth, saleSvcName s
|
|||||||
mobile := decryptMobile(row.Mobile)
|
mobile := decryptMobile(row.Mobile)
|
||||||
|
|
||||||
var saleId int64
|
var saleId int64
|
||||||
userType := dao.TypeUser
|
if client.Type == dao.TypeSale {
|
||||||
if client != nil {
|
|
||||||
userType = subjectTypeToUserType(client.SubjectType)
|
|
||||||
}
|
|
||||||
if userType == dao.TypeSale {
|
|
||||||
saleInfo, err := fetchSaleByUserId(ctx, saleSvcName, row.Id)
|
saleInfo, err := fetchSaleByUserId(ctx, saleSvcName, row.Id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|||||||
@@ -48,26 +48,8 @@ func decryptMobile(mobile string) string {
|
|||||||
return plain
|
return plain
|
||||||
}
|
}
|
||||||
|
|
||||||
func subjectTypeToUserType(subjectType string) uint8 {
|
|
||||||
switch subjectType {
|
|
||||||
case dao.SubjectTypeSale:
|
|
||||||
return dao.TypeSale
|
|
||||||
case dao.SubjectTypeStore:
|
|
||||||
return dao.TypeStore
|
|
||||||
case dao.SubjectTypeUser:
|
|
||||||
return dao.TypeUser
|
|
||||||
default:
|
|
||||||
return dao.TypeUser
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func toSession(info dao.UserRow, mobilePlain string, client *dao.Client, saleId int64) dao.UserLoginSession {
|
func toSession(info dao.UserRow, mobilePlain string, client *dao.Client, saleId int64) dao.UserLoginSession {
|
||||||
userType := dao.TypeUser
|
|
||||||
clientCode := utils.StringEmpty
|
|
||||||
if client != nil {
|
|
||||||
clientCode = client.Code
|
|
||||||
userType = subjectTypeToUserType(client.SubjectType)
|
|
||||||
}
|
|
||||||
return dao.UserLoginSession{
|
return dao.UserLoginSession{
|
||||||
Id: info.Id,
|
Id: info.Id,
|
||||||
Name: info.Name,
|
Name: info.Name,
|
||||||
@@ -75,8 +57,8 @@ func toSession(info dao.UserRow, mobilePlain string, client *dao.Client, saleId
|
|||||||
Mobile: mobilePlain,
|
Mobile: mobilePlain,
|
||||||
Gender: info.Gender,
|
Gender: info.Gender,
|
||||||
Birthday: info.Birthday.DateString(),
|
Birthday: info.Birthday.DateString(),
|
||||||
Type: userType,
|
Type: client.Type,
|
||||||
ClientCode: clientCode,
|
ClientCode: client.Code,
|
||||||
SaleId: saleId,
|
SaleId: saleId,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user