123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- package models
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- // EnglishCompany 英文客户
- type EnglishCompany struct {
- CompanyId int `orm:"column(company_id);pk" description:"英文客户ID"`
- CompanyName string `description:"客户名称"`
- CountryCode string `description:"国家Code"`
- Country string `description:"国家"`
- SellerId int `description:"销售ID"`
- SellerName string `description:"销售姓名"`
- ViewTotal int `description:"累计点击量/阅读量"`
- IsDeleted int `description:"删除状态:0-正常;1-已删除"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- func (item *EnglishCompany) TableName() string {
- return "english_company"
- }
- func (item *EnglishCompany) Create() (err error) {
- o := orm.NewOrm()
- id, err := o.Insert(item)
- if err != nil {
- return
- }
- item.CompanyId = int(id)
- return
- }
- // EnglishCompanySaveReq 英文客户-保存请求体
- type EnglishCompanySaveReq struct {
- CompanyId int `description:"客户ID"`
- CompanyName string `description:"客户名称"`
- CountryCode string `description:"国家代码"`
- Country string `description:"国家"`
- SellerId int `description:"销售ID"`
- }
- func (item *EnglishCompany) Update(cols []string) (err error) {
- o := orm.NewOrm()
- _, err = o.Update(item, cols...)
- return
- }
- // GetEnglishCompanyById 主键获取客户
- func GetEnglishCompanyById(id int) (item *EnglishCompany, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM english_company WHERE is_deleted = 0 AND company_id = ? LIMIT 1`
- err = o.Raw(sql, id).QueryRow(&item)
- return
- }
- // GetEnglishCompanyByName 名称获取客户
- func GetEnglishCompanyByName(companyName string) (item *EnglishCompany, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM english_company WHERE is_deleted = 0 AND company_name = ? LIMIT 1`
- err = o.Raw(sql, companyName).QueryRow(&item)
- return
- }
- // UpdateEnglishCompanyViewTotal 更新英文客户阅读量
- func UpdateEnglishCompanyViewTotal(companyId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE english_company SET view_total = view_total+1 WHERE company_id = ? `
- _, err = o.Raw(sql, companyId).Exec()
- return
- }
- // UpdateTrialEnglishCompanyViewTotal 更新英文客户阅读量-ETA试用平台
- func UpdateTrialEnglishCompanyViewTotal(companyId int) (err error) {
- o := orm.NewOrm()
- sql := `UPDATE english_company SET view_total = view_total+1 WHERE company_id = ? `
- _, err = o.Raw(sql, companyId).Exec()
- return
- }
|