123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- package english_report_email
- import (
- "hongze/hongze_yb_en_api/global"
- "hongze/hongze_yb_en_api/models/base"
- "time"
- )
- // 英文研报-邮箱
- type Email struct {
- Id uint `gorm:"primaryKey;column:id" json:"id"`
- CompanyId uint `gorm:"column:company_id" json:"company_id"` //客户ID
- Name string `gorm:"column:name" json:"name"` //客户名称
- CompanyName string `gorm:"column:company_name" json:"company_name"` //公司名称
- Email string `gorm:"column:email" json:"email"` //邮箱地址
- ViewTotal uint `gorm:"column:view_total" json:"view_total"` //累计点击量/阅读量
- LastViewTime time.Time `gorm:"column:last_view_time" json:"last_view_time"` //最后阅读时间
- RegisterTime time.Time `gorm:"column:register_time" json:"register_time"` //注册时间
- IsDeleted uint8 `gorm:"column:is_deleted" json:"is_deleted"` //删除状态:0-正常;1-已删除
- AdminId uint `gorm:"column:admin_id" json:"admin_id"` //创建人ID
- AdminName string `gorm:"column:admin_name" json:"admin_name"` //创建人名称
- Enable int `gorm:"column:enabled" json:"enabled"`
- Status int `description:"1:正式,2:临时,3:终止"`
- Password string `gorm:"column:password" json:"password"`
- Mobile string `gorm:"column:mobile" json:"mobile"`
- CountryCode string `gorm:"column:country_code" json:"country_code"` //国家代码
- base.TimeBase
- }
- // TableName get sql table name.获取数据库表名
- func (e *Email) TableName() string {
- return "english_report_email"
- }
- // Add 新增
- func (e *Email) Add() (err error) {
- err = global.MYSQL["rddp"].Create(e).Error
- return
- }
- // 修改
- func (e *Email) Update(updateCols []string) (err error) {
- err = global.MYSQL["rddp"].Model(e).Select(updateCols).Updates(e).Error
- return
- }
- func (e *Email) GetById(id int) (item *Email, err error) {
- err = global.MYSQL["rddp"].Model(e).Where("is_deleted = 0 AND id= ?", id).First(&item).Error
- return
- }
- func (e *Email) UpdateViewTotalById(Id uint) (err error) {
- sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
- err = global.MYSQL["rddp"].Exec(sql, Id).Error
- return
- }
- func CheckUserPwd(loginType int, countryCode, account, password string) (item *Email, err error) {
- sql := ``
- if loginType == 1 {
- sql = `SELECT * FROM english_report_email WHERE email=? AND password=? AND is_deleted = 0 `
- err = global.MYSQL["rddp"].Raw(sql, account, password).Scan(&item).Error
- } else {
- sql = `SELECT * FROM english_report_email WHERE country_code = ? AND mobile=? AND password=? AND is_deleted = 0 `
- err = global.MYSQL["rddp"].Raw(sql, countryCode, account, password).Scan(&item).Error
- }
- return
- }
- func CheckUser(email string) (item *Email, err error) {
- sql := `SELECT * FROM english_report_email WHERE email=? AND is_deleted = 0 `
- err = global.MYSQL["rddp"].Raw(sql, email).First(&item).Error
- return
- }
- func (e *Email) GetByEmail(email string) (item *Email, err error) {
- err = global.MYSQL["rddp"].Model(e).Where("email = ? AND is_deleted = 0 ", email).First(&item).Error
- return
- }
- func (e *Email) GetByMobile(mobile, countryCode string) (item *Email, err error) {
- err = global.MYSQL["rddp"].Model(e).Where("mobile = ? AND country_code = ? AND is_deleted = 0 ", mobile, countryCode).First(&item).Error
- return
- }
|