abp creatoruserid null

abp creatoruserid null

今天在做接口的时候,发现一个问题:创建一条数据时,CreatorUserId的值为null。
虽然CreationTime有值,但是CreatorUserId为null,这什么幺蛾子呢?

于是百度一通搜索,没找到任何有用信息。然后就用谷歌搜索关键字:abp creatoruserid null,你别说,国外友人还真有遇到这种情况的。
机翻+自己阅读,大致知道了原因。

意思是说:admin账号未分配租户,所以创建时没有找到租户,租户没找到就不给创建人赋值。可以看源代码:https://github.com/aspnetboilerplate/aspnetboilerplate/blob/2f79821b3c09132394ec01f1673b7fad8e6893af/src/Abp/Domain/Entities/Auditing/EntityAuditingHelper.cs#L50-L55

所以只需要在CreateOrUpdate()方法里给租户赋值就行了:input.xxx.TenantId = AbpSession.TenantId;


参考网址:
https://github.com/aspnetboilerplate/aspnetboilerplate/issues/5663
https://stackoverflow.com/questions/48109095/fullauditedentity-objectmapper-creatoruserid-null-when-creating-new-entry-or-d

posted @ 2022-07-13 15:04  屌丝大叔的笔记  阅读(145)  评论(0编辑  收藏  举报