|
@@ -2,19 +2,22 @@ package models
|
|
|
|
|
|
import (
|
|
|
"github.com/beego/beego/v2/client/orm"
|
|
|
- "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
"time"
|
|
|
)
|
|
|
|
|
|
-// EnglishReportEmail 英文研报-邮箱
|
|
|
+// EnglishReportEmail 英文研报-邮箱/客户联系人
|
|
|
type EnglishReportEmail struct {
|
|
|
- Id int `orm:"column(id);pk" description:"邮箱ID"`
|
|
|
- Name string `description:"客户名称"`
|
|
|
- Email string `description:"邮箱地址"`
|
|
|
- AdminId int `description:"创建人ID"`
|
|
|
- AdminName string `description:"创建人姓名"`
|
|
|
- CreateTime time.Time `description:"创建时间"`
|
|
|
- ModifyTime time.Time `description:"更新时间"`
|
|
|
+ Id int `orm:"column(id);pk" description:"邮箱ID"`
|
|
|
+ CompanyId int `description:"客户ID"`
|
|
|
+ Name string `description:"联系人名称"`
|
|
|
+ Email string `description:"邮箱地址"`
|
|
|
+ ViewTotal int `description:"累计点击量/阅读量"`
|
|
|
+ LastViewTime time.Time `description:"最后阅读时间"`
|
|
|
+ IsDeleted int `description:"删除状态:0-正常;1-已删除"`
|
|
|
+ AdminId int `description:"创建人ID"`
|
|
|
+ AdminName string `description:"创建人姓名"`
|
|
|
+ CreateTime time.Time `description:"创建时间"`
|
|
|
+ ModifyTime time.Time `description:"更新时间"`
|
|
|
}
|
|
|
|
|
|
func (item *EnglishReportEmail) TableName() string {
|
|
@@ -47,62 +50,15 @@ func (item *EnglishReportEmail) Update(cols []string) (err error) {
|
|
|
// GetEnglishReportEmailById 主键获取邮箱
|
|
|
func GetEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
|
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := `SELECT * FROM english_report_email WHERE id = ? LIMIT 1`
|
|
|
+ sql := `SELECT * FROM english_report_email WHERE is_deleted = 0 AND id = ? LIMIT 1`
|
|
|
err = o.Raw(sql, id).QueryRow(&item)
|
|
|
return
|
|
|
}
|
|
|
|
|
|
-// EnglishReportEmailPageListResp 分页列表响应体
|
|
|
-type EnglishReportEmailPageListResp struct {
|
|
|
- List []*EnglishReportEmailResp
|
|
|
- Paging *paging.PagingItem `description:"分页数据"`
|
|
|
-}
|
|
|
-
|
|
|
-// EnglishReportEmailResp 邮箱响应体
|
|
|
-type EnglishReportEmailResp struct {
|
|
|
- Id int `description:"邮箱ID"`
|
|
|
- Name string `description:"客户名称"`
|
|
|
- Email string `description:"邮箱地址"`
|
|
|
- AdminName string `description:"创建人姓名"`
|
|
|
- CreateTime string `description:"创建时间"`
|
|
|
-}
|
|
|
-
|
|
|
-// GetEnglishReportEmailPageList 获取邮箱列表-分页
|
|
|
-func GetEnglishReportEmailPageList(condition string, pars []interface{}, order string, startSize, pageSize int) (total int, list []*EnglishReportEmail, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := `SELECT * FROM english_report_email WHERE 1 = 1 `
|
|
|
- sql += condition
|
|
|
- if order != "" {
|
|
|
- sql += order
|
|
|
- } else {
|
|
|
- sql += ` ORDER BY create_time DESC`
|
|
|
- }
|
|
|
- totalSQl := `SELECT COUNT(1) total FROM (` + sql + `) z`
|
|
|
- if err = o.Raw(totalSQl, pars).QueryRow(&total); err != nil {
|
|
|
- return
|
|
|
- }
|
|
|
- sql += ` LIMIT ?,?`
|
|
|
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&list)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// GetEnglishReportEmailByEmail 地址获取邮箱
|
|
|
-func GetEnglishReportEmailByEmail(email string) (item *EnglishReportEmail, err error) {
|
|
|
- o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := `SELECT * FROM english_report_email WHERE email = ? LIMIT 1`
|
|
|
- err = o.Raw(sql, email).QueryRow(&item)
|
|
|
- return
|
|
|
-}
|
|
|
-
|
|
|
-// EnglishReportEmailDelReq 删除邮箱请求体
|
|
|
-type EnglishReportEmailDelReq struct {
|
|
|
- EmailId int `description:"邮箱ID"`
|
|
|
-}
|
|
|
-
|
|
|
-// DelEnglishReportEmail 删除邮箱
|
|
|
-func DelEnglishReportEmail(id int) (err error) {
|
|
|
+// UpdateEnglishReportEmailViewTotal 更新英文联系人阅读量
|
|
|
+func UpdateEnglishReportEmailViewTotal(emailId int) (err error) {
|
|
|
o := orm.NewOrmUsingDB("rddp")
|
|
|
- sql := `DELETE FROM english_report_email WHERE id = ? LIMIT 1`
|
|
|
- _, err = o.Raw(sql, id).Exec()
|
|
|
+ sql := `UPDATE english_report_email SET view_total = view_total+1, last_view_time = NOW() WHERE id = ? `
|
|
|
+ _, err = o.Raw(sql, emailId).Exec()
|
|
|
return
|
|
|
}
|