|
|
@@ -69,7 +69,8 @@ func (c *Client) CreateInternalUserSkipMobileConflict(p CreateUserParams) error
|
|
|
}
|
|
|
|
|
|
// UserSignSilentURL 获取个人签名静默授权页;authEnd 为空则默认 10 个月。
|
|
|
-func (c *Client) UserSignSilentURL(openUserID string, authEnd time.Time, completeToPage string) (string, error) {
|
|
|
+// applyCompany 传入当前体检机构(openCompanyId 通常等于 tenant_id),授权记录按机构维度拆分。
|
|
|
+func (c *Client) UserSignSilentURL(openUserID string, applyCompany ApplyCompanyParams, authEnd time.Time, completeToPage string) (string, error) {
|
|
|
if authEnd.IsZero() {
|
|
|
authEnd = time.Now().Add(DefaultPersonalAuthDuration)
|
|
|
}
|
|
|
@@ -81,6 +82,13 @@ func (c *Client) UserSignSilentURL(openUserID string, authEnd time.Time, complet
|
|
|
AuthorizedMode: []string{"FACEAUTH", "PINAUTH"},
|
|
|
CompleteToPage: completeToPage,
|
|
|
}
|
|
|
+ if applyCompany.OpenCompanyID != "" || applyCompany.Name != "" || applyCompany.RegisterNo != "" {
|
|
|
+ req.ApplyCompany = &common.PersonalApplyCompany{
|
|
|
+ Name: applyCompany.Name,
|
|
|
+ RegisterNo: applyCompany.RegisterNo,
|
|
|
+ OpenCompanyId: applyCompany.OpenCompanyID,
|
|
|
+ }
|
|
|
+ }
|
|
|
var resp struct {
|
|
|
apiResponse
|
|
|
Result v2auth_response.V2AuthPersonalsignsilentUrlResponse `json:"result"`
|
|
|
@@ -112,16 +120,39 @@ func (c *Client) QueryPersonalSignAuthRecords(openUserID, status string) ([]Auth
|
|
|
}
|
|
|
out := make([]AuthRecord, 0, len(resp.Result))
|
|
|
for _, item := range resp.Result {
|
|
|
- out = append(out, AuthRecord{
|
|
|
- Status: item.Status,
|
|
|
- EndTime: item.AuthEndDate,
|
|
|
- AuthScope: item.AuthScope,
|
|
|
- })
|
|
|
+ out = append(out, authRecordFromResponse(item))
|
|
|
}
|
|
|
return out, nil
|
|
|
}
|
|
|
|
|
|
-// IsUserSignAuthorized 是否存在有效个人静默授权。
|
|
|
+func authRecordFromResponse(item v2auth_response.V2AuthSignsilentRecordResponse) AuthRecord {
|
|
|
+ rec := AuthRecord{
|
|
|
+ Status: item.Status,
|
|
|
+ EndTime: item.AuthEndDate,
|
|
|
+ AuthScope: item.AuthScope,
|
|
|
+ }
|
|
|
+ if item.ApplyCompany != nil {
|
|
|
+ rec.ApplyCompanyOpenCompanyID = item.ApplyCompany.OpenCompanyId
|
|
|
+ rec.ApplyCompanyName = item.ApplyCompany.Name
|
|
|
+ }
|
|
|
+ return rec
|
|
|
+}
|
|
|
+
|
|
|
+// PersonalSignAuthRecordForCompany 查询指定 openUserId 对某法人单位的静默授权记录。
|
|
|
+func (c *Client) PersonalSignAuthRecordForCompany(openUserID, openCompanyID, status string) (*AuthRecord, bool, error) {
|
|
|
+ records, err := c.QueryPersonalSignAuthRecords(openUserID, status)
|
|
|
+ if err != nil {
|
|
|
+ return nil, false, err
|
|
|
+ }
|
|
|
+ for i := range records {
|
|
|
+ if records[i].ApplyCompanyOpenCompanyID == openCompanyID {
|
|
|
+ return &records[i], true, nil
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return nil, false, nil
|
|
|
+}
|
|
|
+
|
|
|
+// IsUserSignAuthorized 是否存在任意有效个人静默授权。
|
|
|
func (c *Client) IsUserSignAuthorized(openUserID string) (bool, error) {
|
|
|
records, err := c.QueryPersonalSignAuthRecords(openUserID, "EFFECT")
|
|
|
if err != nil {
|
|
|
@@ -130,6 +161,12 @@ func (c *Client) IsUserSignAuthorized(openUserID string) (bool, error) {
|
|
|
return len(records) > 0, nil
|
|
|
}
|
|
|
|
|
|
+// IsUserSignAuthorizedForCompany 是否已对指定法人单位完成有效个人静默授权。
|
|
|
+func (c *Client) IsUserSignAuthorizedForCompany(openUserID, openCompanyID string) (bool, error) {
|
|
|
+ _, found, err := c.PersonalSignAuthRecordForCompany(openUserID, openCompanyID, "EFFECT")
|
|
|
+ return found, err
|
|
|
+}
|
|
|
+
|
|
|
// structFormFields 将 struct 转为 multipart 表单字段(与旧系统 HttpMultipart 行为一致)。
|
|
|
func structFormFields(v any, arrayConnector string) (map[string]string, error) {
|
|
|
b, err := json.Marshal(v)
|