chore: user type

This commit is contained in:
zzw
2026-09-11 17:28:11 +08:00
parent b250e42033
commit 665bd12fdf
3 changed files with 5 additions and 26 deletions
+1
View File
@@ -8,4 +8,5 @@ type Client struct {
SubjectType string `gorm:"column:subject_type" json:"subject_type"`
StoreStaff uint8 `gorm:"column:store_staff" json:"store_staff"`
Status uint8 `gorm:"column:status" json:"status"`
Type uint8 `gorm:"column:type" json:"type"`
}
+1 -5
View File
@@ -216,11 +216,7 @@ func issueLoginToken(ctx context.Context, jwtAuth *config.JWTAuth, saleSvcName s
mobile := decryptMobile(row.Mobile)
var saleId int64
userType := dao.TypeUser
if client != nil {
userType = subjectTypeToUserType(client.SubjectType)
}
if userType == dao.TypeSale {
if client.Type == dao.TypeSale {
saleInfo, err := fetchSaleByUserId(ctx, saleSvcName, row.Id)
if err != nil {
return nil, err
+3 -21
View File
@@ -48,26 +48,8 @@ func decryptMobile(mobile string) string {
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 {
userType := dao.TypeUser
clientCode := utils.StringEmpty
if client != nil {
clientCode = client.Code
userType = subjectTypeToUserType(client.SubjectType)
}
return dao.UserLoginSession{
Id: info.Id,
Name: info.Name,
@@ -75,8 +57,8 @@ func toSession(info dao.UserRow, mobilePlain string, client *dao.Client, saleId
Mobile: mobilePlain,
Gender: info.Gender,
Birthday: info.Birthday.DateString(),
Type: userType,
ClientCode: clientCode,
Type: client.Type,
ClientCode: client.Code,
SaleId: saleId,
}
}