65 lines
2.2 KiB
Go
65 lines
2.2 KiB
Go
/**
|
|
* @Author: ZhaoYadong
|
|
* @Date: 2024-02-27 21:09:45
|
|
* @LastEditors: ZhaoYadong
|
|
* @LastEditTime: 2024-02-28 09:13:35
|
|
* @FilePath: /server/Users/edy/go/src/sample/internal/models/sample_account.go
|
|
*/
|
|
// Models generated by mesh dev cli,@Author: David Yan(david.yan@qq.com).
|
|
package models
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"git.apinb.com/bsm-sdk/core/database"
|
|
"git.apinb.com/bsm-sdk/core/errcode"
|
|
"git.apinb.com/bsm-sdk/core/types"
|
|
"git.apinb.com/bsm-sdk/sample/internal/impl"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
/*
|
|
* sampleAccount
|
|
* Comment: 通行证帐号表
|
|
* Version: 10
|
|
* Created: 2022-04-12 10:44:51 , Updated:0001-01-01 00:00:00
|
|
*/
|
|
type sampleAccount struct {
|
|
types.Std_IICUDS
|
|
Account string `gorm:"column:account;type:varchar(255);default:'';" json:"account"` // 帐号
|
|
Phone string `gorm:"column:phone;type:varchar(20);default:'';" json:"phone"` // 手机号
|
|
Email string `gorm:"column:email;type:varchar(255);default:'';" json:"email"` // Email
|
|
Password string `gorm:"column:password;type:varchar(255);not null;" json:"password"` // 密码
|
|
Salt string `gorm:"column:salt;type:varchar(255);not null;" json:"salt"` // 密码盐
|
|
Rights string `gorm:"column:rights;type:varchar(255);default:'';" json:"rights"` // 权限
|
|
AgencyId uint `gorm:"column:agency_id;default:0;" json:"agency_id"` // 分销代理id
|
|
StaffId uint `gorm:"column:staff_id;default:0;" json:"staff_id"` // 工作人员id
|
|
OwnerId uint `gorm:"column:owner_id;default:0;" json:"owner_id"` // 所属唯一id
|
|
}
|
|
|
|
func init() {
|
|
database.MigrateTables = append(database.MigrateTables, &sampleAccount{})
|
|
}
|
|
|
|
// TableName .
|
|
func (table *sampleAccount) TableName() string {
|
|
return "sample_account" //对应数据库表名
|
|
}
|
|
|
|
// GetsampleAccountByField 根据特定字段值获取sampleAccount对象
|
|
func GetsampleAccountByField(field string, value interface{}) (*sampleAccount, error) {
|
|
var (
|
|
data sampleAccount
|
|
condition = map[string]any{field: value}
|
|
)
|
|
err := impl.DBService.Where(condition).First(&data).Error
|
|
if err != nil {
|
|
if errors.Is(err, gorm.ErrRecordNotFound) {
|
|
return nil, errcode.ErrNotFound(404, "Account not found")
|
|
}
|
|
return nil, errcode.ErrDB
|
|
}
|
|
|
|
return &data, nil
|
|
}
|