fonchain-artistinfo/cmd/model/view_user.go

95 lines
3.9 KiB
Go
Raw Normal View History

2023-02-27 07:51:04 +00:00
// Package model -----------------------------
2023-03-13 06:24:11 +00:00
// @file : view_user.go
2023-02-27 07:51:04 +00:00
// @author : JJXu
// @contact : wavingbear@163.com
// @time : 2023/2/27 13:51
// -------------------------------------------
package model
import (
"gorm.io/gorm"
"time"
)
type UserView struct {
UserId int64 `json:"userId" gorm:"column:user_id;comment:用户表id"`
AccId int64 `json:"accId" gorm:"column:mgmt_acc_id;comment:账号id"`
ArtistUid string `json:"artistUid" gorm:"column:mgmt_artist_uid;comment:账号id"`
TelNum string `json:"telNum" gorm:"column:tel_num;comment:电话号码"`
InviteCode string `json:"inviteCode" gorm:"column:invited_code;comment:邀请码"`
Account string `json:"account" gorm:"column:account;comment:账号"`
Photo string `json:"photo" gorm:"column:photo;comment:个人近照"`
IsRealName int64 `json:"isRealName" gorm:"column:is_real_name;comment:是否实名认证"`
FddState int64 `json:"fddState" gorm:"column:fdd_state;comment:法大大状态"`
2023-03-13 09:09:43 +00:00
IsRead int64 `json:"isRead" gorm:"column:is_read;comment:是否已读 0未读 1已读"`
2023-02-27 07:51:04 +00:00
IsLock bool `json:"isLock" gorm:"column:is_lock;comment:是否锁定"`
2023-03-02 09:22:10 +00:00
LatestLockTime string `json:"latestLockTime" gorm:"column:latest_lock_time;comment:"`
2023-02-27 07:51:04 +00:00
RealName string `json:"realName" gorm:"column:real_name;comment:真实姓名"`
IdNum string `json:"idNum" gorm:"column:id_num;comment:证件号码"`
Sex SexType `json:"sex" gorm:"column:sex;comment:性别"`
Age int64 `json:"age" gorm:"column:age;comment:年龄"`
RealAddress string `json:"address" gorm:"column:real_address;comment:真实地址"`
IdcardBack string `json:"idcardBack" gorm:"column:idcard_back;comment:身份证背面"`
2023-03-13 09:09:43 +00:00
IdcardFront string `json:"idcardFront" gorm:"column:idcard_front;comment:身份证反面"`
2023-03-08 07:26:38 +00:00
JoinAssoTime string `json:"joinAssoTime" gorm:"column:join_asso_time;comment:入会时间"`
2023-02-27 07:51:04 +00:00
InviterInviteCode string `json:"inviterInviteCode" gorm:"column:inviter_invite_code;comment:邀请人的邀请码"`
InviterRealName string `json:"inviterRealName" gorm:"column:inviter_name;comment:邀请人的真实姓名"`
CreatedAt time.Time `json:"createdAt" gorm:"column:created_at;comment:"`
UpdatedAt time.Time `json:"updatedAt" gorm:"column:updated_at;comment:"`
DeletedAt int64 `json:"deletedAt" gorm:"column:deleted_at;comment:"`
2023-03-08 07:26:38 +00:00
CertificateNum string `json:"certificateNum" gorm:"column:certificate_num;comment:"`
CertificateImg string `json:"certificateImg" gorm:"column:certificate_img;comment:"`
2023-03-13 09:09:43 +00:00
BankName string `json:"bankName" gorm:"column:bank_name;comment:"`
BankNum string `json:"bankNum" gorm:"column:bank_num;comment:"`
WxAccount string `json:"wxAccount" gorm:"column:wx_account;comment:企业微信账号"`
2023-02-27 07:51:04 +00:00
}
func (u UserView) TableName() string {
return "user_view"
}
func CreateUserView(db *gorm.DB) error {
var sql = `
CREATE OR REPLACE VIEW user_view AS
SELECT
su.id user_id,
su.mgmt_acc_id,
su.mgmt_artist_uid,
su.tel_num,
su.invited_code,
su.account,
su.photo,
su.is_real_name,
su.fdd_state,
su.is_read,
su.is_lock,
rn.name real_name,
rn.idcard_front,
rn.idcard_back,
rn.address real_address,
rn.id_num,
rn.sex,
rn.age,
su.created_at,
su.updated_at,
su.deleted_at,
inviter.invited_code inviter_invite_code,
2023-03-02 09:22:10 +00:00
inviter_rn.name inviter_name,
2023-03-08 07:26:38 +00:00
su.latest_lock_time,
su.join_asso_time,
su.certificate_num,
2023-03-08 09:46:17 +00:00
su.certificate_img,
su.wx_account
2023-03-08 07:26:38 +00:00
2023-02-27 07:51:04 +00:00
FROM sys_user su
LEFT JOIN real_name rn ON rn.id = su.real_name_id
-- 邀请者信息
LEFT JOIN invite ON invite.invited_id = su.id
LEFT JOIN sys_user inviter ON inviter.id = invite.user_id
LEFT JOIN real_name inviter_rn ON inviter_rn.id = inviter.real_name_id
WHERE
su.deleted_at = 0
`
db.Exec(sql)
return nil
}