|
@@ -62,9 +62,9 @@ func (*subaccount) UpdateSubAccount(ctx context.Context, request http_model.Upda
|
|
}
|
|
}
|
|
|
|
|
|
// DeleteSubAccount 删除子账号
|
|
// DeleteSubAccount 删除子账号
|
|
-func (*subaccount) DeleteSubAccount(ctx context.Context, request http_model.DeleteJobRequest) error {
|
|
|
|
|
|
+func (*subaccount) DeleteSubAccount(ctx context.Context, request http_model.DeleteSubAccountRequest) error {
|
|
var newSubAccount = gorm_model.YounggeeSubAccount{
|
|
var newSubAccount = gorm_model.YounggeeSubAccount{
|
|
- JobId: request.JobId,
|
|
|
|
|
|
+ SubAccountId: request.SubAccountId,
|
|
}
|
|
}
|
|
err := db.DeleteSubAccount(ctx, newSubAccount)
|
|
err := db.DeleteSubAccount(ctx, newSubAccount)
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -72,3 +72,41 @@ func (*subaccount) DeleteSubAccount(ctx context.Context, request http_model.Dele
|
|
}
|
|
}
|
|
return nil
|
|
return nil
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// FindSubAccountBySupplierId 根据服务商ID查找包含的所有子账号信息
|
|
|
|
+func (*subaccount) FindSubAccountBySupplierId(ctx context.Context, request http_model.FindAllSubAccountRequest) (*http_model.FindAllSubAccountData, error) {
|
|
|
|
+ var subAccountResp *http_model.FindAllSubAccountData
|
|
|
|
+ subAccountResp = &http_model.FindAllSubAccountData{}
|
|
|
|
+
|
|
|
|
+ // 1. 取出子账号基本信息
|
|
|
|
+ newSubAccount, total, subaccountErr := db.FindSubAccountBySupplierId(ctx, request.SupplierId)
|
|
|
|
+ if subaccountErr != nil {
|
|
|
|
+ return nil, subaccountErr
|
|
|
|
+ }
|
|
|
|
+ if newSubAccount != nil {
|
|
|
|
+ for _, s := range newSubAccount {
|
|
|
|
+ var subAccountInfo *http_model.FindAllSubAccountInfo
|
|
|
|
+ subAccountInfo = &http_model.FindAllSubAccountInfo{}
|
|
|
|
+ // fmt.Println("s:", s.SubAccountId)
|
|
|
|
+ subAccountInfo.SubAccountId = s.SubAccountId
|
|
|
|
+ subAccountInfo.SubAccountName = s.SubAccountName
|
|
|
|
+ subAccountInfo.JobId = s.JobId
|
|
|
|
+ subAccountInfo.UserId = s.UserId
|
|
|
|
+ subAccountInfo.PhoneNumber = s.PhoneNumber
|
|
|
|
+ subAccountInfo.SupplierId = s.SupplierId
|
|
|
|
+ subAccountInfo.AccountStatus = s.AccountStatus
|
|
|
|
+
|
|
|
|
+ // 2. 岗位信息
|
|
|
|
+ jobInfo, jobErr := db.FindJobByJobId(ctx, s.JobId)
|
|
|
|
+ if jobErr != nil {
|
|
|
|
+ return nil, jobErr
|
|
|
|
+ }
|
|
|
|
+ if jobInfo != nil {
|
|
|
|
+ subAccountInfo.JobName = jobInfo.JobName
|
|
|
|
+ }
|
|
|
|
+ subAccountResp.SubAccountInfo = append(subAccountResp.SubAccountInfo, subAccountInfo)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ subAccountResp.Total = total
|
|
|
|
+ return subAccountResp, nil
|
|
|
|
+}
|