|
@@ -0,0 +1,108 @@
|
|
|
+package models
|
|
|
+
|
|
|
+import (
|
|
|
+ "github.com/beego/beego/v2/client/orm"
|
|
|
+ "github.com/rdlucklib/rdluck_tools/paging"
|
|
|
+ "time"
|
|
|
+)
|
|
|
+
|
|
|
+// 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:"更新时间"`
|
|
|
+}
|
|
|
+
|
|
|
+func (item *EnglishReportEmail) TableName() string {
|
|
|
+ return "english_report_email"
|
|
|
+}
|
|
|
+
|
|
|
+// EnglishReportEmailSaveReq 保存邮箱请求体
|
|
|
+type EnglishReportEmailSaveReq struct {
|
|
|
+ Id int `description:"邮箱ID, 大于0为编辑"`
|
|
|
+ Name string `description:"客户名称"`
|
|
|
+ Email string `description:"邮箱地址"`
|
|
|
+}
|
|
|
+
|
|
|
+func (item *EnglishReportEmail) Create() (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ id, err := o.Insert(item)
|
|
|
+ if err != nil {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ item.Id = int(id)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+func (item *EnglishReportEmail) Update(cols []string) (err error) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ _, err = o.Update(item, cols...)
|
|
|
+ return
|
|
|
+}
|
|
|
+
|
|
|
+// GetEnglishReportEmailById 主键获取邮箱
|
|
|
+func GetEnglishReportEmailById(id int) (item *EnglishReportEmail, err error) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ sql := `SELECT * FROM english_report_email WHERE 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) {
|
|
|
+ o := orm.NewOrmUsingDB("rddp")
|
|
|
+ sql := `DELETE FROM english_report_email WHERE id = ? LIMIT 1`
|
|
|
+ _, err = o.Raw(sql, id).Exec()
|
|
|
+ return
|
|
|
+}
|