123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146 |
- package company
- import (
- "github.com/beego/beego/v2/client/orm"
- "time"
- )
- type CompanyNoRenewedAscribe struct {
- NoRenewedAscribeId int `orm:"column(no_renewed_ascribe_id);pk" description:"主键ID"`
- CompanyAscribeId int `description:"归因ID"`
- AscribeContent string `description:"归因说明"`
- Content string `description:"内容说明"`
- AdminId int `description:"管理员ID"`
- CompanyId int `description:"公司ID"`
- ProductId int `description:"产品id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- type CompanyNoRenewedAscribeLog struct {
- NoRenewedAscribeId int `orm:"column(no_renewed_ascribe_id);pk" description:"主键ID"`
- CompanyAscribeId int `description:"归因ID"`
- AscribeContent string `description:"归因说明"`
- Content string `description:"内容说明"`
- AdminId int `description:"管理员ID"`
- CompanyId int `description:"公司ID"`
- ProductId int `description:"产品id"`
- CreateTime time.Time `description:"创建时间"`
- ModifyTime time.Time `description:"更新时间"`
- }
- type CompanyNoRenewedAscribeResp struct {
- NoRenewedAscribeId int `description:"主键ID"`
- CompanyAscribeId int `description:"归因ID"`
- AscribeContent string `description:"归因说明"`
- ProductId int `description:"产品id"`
- Content string `description:"内容说明"`
- AdminId int `description:"管理员ID"`
- CompanyId int `description:"公司ID"`
- CreateTime string `description:"创建时间"`
- ModifyTime string `description:"更新时间"`
- }
- type CompanyNoRenewedAscribeListResp struct {
- List []*CompanyNoRenewedAscribeResp
- }
- type CompanyNoRenewedAscribeDetailResp struct {
- Detail *CompanyNoRenewedAscribeResp
- }
- type CompanyNoRenewedAscribeReq struct {
- CompanyAscribeId int `description:"归因ID"`
- ProductId int `description:"产品id"`
- Content string `description:"内容说明"`
- CompanyId int `description:"公司ID"`
- }
- // 添加
- func AddCompanyNoRenewedAscribe(item *CompanyNoRenewedAscribe, itemLog *CompanyNoRenewedAscribeLog) (err error) {
- o := orm.NewOrm()
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- _, err = to.Insert(item)
- if err != nil {
- return
- }
- _, err = to.Insert(itemLog)
- return
- }
- // 修改
- func UpdateCompanyNoRenewedAscribe(item *CompanyNoRenewedAscribe, itemLog *CompanyNoRenewedAscribeLog) (err error) {
- o := orm.NewOrm()
- to, err := o.Begin()
- if err != nil {
- return
- }
- defer func() {
- if err != nil {
- _ = to.Rollback()
- } else {
- _ = to.Commit()
- }
- }()
- updateParams := make(map[string]interface{})
- updateParams["CompanyAscribeId"] = item.CompanyAscribeId
- updateParams["ModifyTime"] = item.ModifyTime
- updateParams["Content"] = item.Content
- updateParams["AscribeContent"] = item.AscribeContent
- ptrStructOrTableName := "company_no_renewed_ascribe"
- whereParam := map[string]interface{}{"company_id": item.CompanyId, "product_id": item.ProductId}
- qs := to.QueryTable(ptrStructOrTableName)
- for expr, exprV := range whereParam {
- qs = qs.Filter(expr, exprV)
- }
- _, err = qs.Update(updateParams)
- if err != nil {
- return
- }
- _, err = to.Insert(itemLog)
- return
- }
- // 获取数量
- func GetCompanyNoRenewedAscribeCount(condition string, pars []interface{}) (count int, err error) {
- sqlCount := ` SELECT COUNT(1) AS count FROM company_no_renewed_ascribe as a WHERE 1= 1 `
- if condition != "" {
- sqlCount += condition
- }
- o := orm.NewOrm()
- err = o.Raw(sqlCount, pars).QueryRow(&count)
- return
- }
- // 通过ID获取详情
- func GetCompanyNoRenewedAscribeDetail(companyId, productId int) (item *CompanyNoRenewedAscribeResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM company_no_renewed_ascribe WHERE company_id=? AND product_id = ? `
- err = o.Raw(sql, companyId, productId).QueryRow(&item)
- return
- }
- // 列表
- func GetCompanyNoRenewedAscribeList(condition string, pars []interface{}, startSize, pageSize int) (items []*CompanyNoRenewedAscribeResp, err error) {
- o := orm.NewOrm()
- sql := `SELECT * FROM company_no_renewed_ascribe as a WHERE 1= 1 `
- if condition != "" {
- sql += condition
- }
- if startSize+pageSize > 0 {
- sql += ` LIMIT ?,? `
- _, err = o.Raw(sql, pars, startSize, pageSize).QueryRows(&items)
- }
- _, err = o.Raw(sql, pars).QueryRows(&items)
- return
- }
|