一. 账号未登陆
{
"code": 401,
"data": null,
"msg": "账号未登录"
}
将接口中的 @PreAuthorize 注解删除, 使用 @PermitAll 注解,
设置 @PermitAll 无需认证
Spring Security 中的 YudaoWebSecurityConfigurerAdapter 有详细说明
@PostMapping("/openCreate")
@Operation(summary = "创建对话id")
@PermitAll // 无需认证
public CommonResult<Integer> openCreate(@Valid @RequestBody DialogVO vo) {
return success(dialogService.openCreate(vo));
}
二. 租户标识未传递
{
"code": 400,
"data": null,
"msg": "请求的租户标识未传递,请进行排查"
}
默认情况下,每个请求需要带上 tenant-id 的请求头。但是,部分请求是无需带上的,例如说短信回调、支付回调等 Open API!
TenantProperties 中有详细说明
application.yaml中找到 yudao.tenant 多租户相关配置项
1. ignore-urls: 需要忽略多租户的 url
2. ignore-tables: 需要忽略多租户 tenant_id 的表
3. ignore-caches: 需要忽略多租户缓存
tenant: # 多租户相关配置项
enable: true
ignore-urls:
- /admin-api/system/tenant/get-id-by-name # 基于名字获取租户,不许带租户编号
- /admin-api/system/tenant/get-by-website # 基于域名获取租户,不许带租户编号
- /admin-api/system/tenant/simple-list # 获取租户列表,不许带租户编号
- /admin-api/system/captcha/get # 获取图片验证码,和租户无关
- /admin-api/system/captcha/check # 校验图片验证码,和租户无关
- /admin-api/infra/file/*/get/** # 获取图片,和租户无关
- /admin-api/system/sms/callback/* # 短信回调接口,无法带上租户编号
- /admin-api/pay/notify/** # 支付回调通知,不携带租户编号
- /jmreport/* # 积木报表,无法携带租户编号
- /admin-api/mp/open/** # 微信公众号开放平台,微信回调接口,无法携带租户编号
# - /admin-api/agentDialog/dialog/openCreate # 开放对话id,无法带上租户编号
ignore-tables:
- system_tenant
- system_tenant_package
- system_dict_data
- system_dict_type
- system_error_code
- system_menu
- system_sms_channel
- system_sms_template
- system_sms_log
- system_sensitive_word
- system_oauth2_client
- system_mail_account
- system_mail_template
- system_mail_log
- system_notify_template
- infra_codegen_column
- infra_codegen_table
- infra_config
- infra_file_config
- infra_file
- infra_file_content
- infra_job
- infra_job_log
- infra_job_log
- iot_plugin_info
- iot_plugin_instance
- infra_data_source_config
- jimu_dict
- jimu_dict_item
- jimu_report
- jimu_report_data_source
- jimu_report_db
- jimu_report_db_field
- jimu_report_db_param
- jimu_report_link
- jimu_report_map
- jimu_report_share
- rep_demo_dxtj
- rep_demo_employee
- rep_demo_gongsi
- rep_demo_jianpiao
- tmp_report_data_1
- tmp_report_data_income
ignore-caches:
- user_role_ids
- permission_menu_ids
- oauth_client
- notify_template
- mail_account
- mail_template
- sms_template
- iot:device
- iot:thing_model_list