Closed miajio closed 1 month ago
What should I do if the date of the custom structure receiving the native SQL result is zero?
The issue has been automatically marked as stale as it missing playground pull request link, which is important to help others understand your issue effectively and make sure the issue hasn't been fixed on latest master, checkout https://github.com/go-gorm/playground for details. it will be closed in 30 days if no further activity occurs. if you are asking question, please use the Question
template, most likely your question already answered https://github.com/go-gorm/gorm/issues or described in the document https://gorm.io ✨ Search Before Asking ✨
// LoginResponse 登录响应 type LoginResponse struct { Token string
json:"token"
Id int64
json:"id"
AccountNo string
json:"accountNo"
Mobile string
json:"mobile"
Account string
json:"account"
Nickname string
json:"nickName"
AvatarId int64
json:"avatarId"
AvatarPath string
json:"avatarPath"
Sex string
json:"sex"
CreateTime db.Time
json:"createTime"
UpdateTime db.Timejson:"updateTime"
Status stringjson:"status"
}
var res *LoginResponse I use db.Raw(
select tai.id as 'id', tai.accountNo as 'accountNo', tai.mobile as 'mobile', tai.account as 'account', tai.nickname as 'nickname', tai.avatarId as 'avatarId', tfi.path as 'avatarPath', tai.sex as 'sex', tai.createTime as 'createTime', tai.updateTime as 'updateTime', tai.status as 'status' from tb_account_info as tai left join tb_file_info as tfi on tai.avatarId = tfi.id and tfi.deleteTime is null where tai.id = ?
, 1).Scan(&res)res in createTime and updateTime value is zero