123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- package ProjectFiling
- import (
- "ERP_storage/logs"
- _ "github.com/astaxie/beego/cache/redis"
- "github.com/beego/beego/v2/adapter/orm"
- orm2 "github.com/beego/beego/v2/client/orm"
- _ "github.com/go-sql-driver/mysql"
- "gogs.baozhida.cn/zoie/ERP_libs/lib"
- )
- // 验证项目
- type ProjectFiling struct {
- Id int `orm:"column(ID);size(11);auto;pk"`
- T_date string `orm:"size(256);null"` // 备案时间
- T_sales_personnel string `orm:"size(256);null"` // 销售人员
- T_customers string `orm:"size(256);null"` // 客户名称
- T_customers_type string `orm:"size(256);null"` // 客户类型
- T_service_type string `orm:"size(256);null"` // 服务类型
- T_content string `orm:"size(256);null"` // 具体内容
- T_estimate_contract_amount string `orm:"size(256);null"` // 预计合同金额
- T_sign_bill_time string `orm:"size(256);null"` // 预计签单时间
- T_prepare_content string `orm:"size(256);null"` // 提前准备内容
- T_remark string `orm:"size(256);null"` // 备注
- T_state int `orm:"size(2);default(1)"` // 0 删除(伪删除) 1 正常
- T_uuid string `orm:"index;size(32);null"` // 申请人
- }
- func (t *ProjectFiling) TableName() string {
- return "project_filing" // 数据库名称 // ************** 替换 FormulaList **************
- }
- func init() {
- //注册模型
- orm.RegisterModel(new(ProjectFiling))
- }
- // 获取 ById
- func Read_ProjectFiling_ById(Id int) (r ProjectFiling, err error) {
- o := orm.NewOrm()
- qs := o.QueryTable(new(ProjectFiling))
- err = qs.Filter("Id", Id).Filter("T_state", 1).One(&r)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- }
- return
- }
- // 获取列表
- func Read_ProjectFiling_List(T_uuid string, T_sales_personnel, T_customers string, page, page_z int) (r_ []ProjectFiling, cnt int64) {
- o := orm.NewOrm()
- // 也可以直接使用 Model 结构体作为表名
- qs := o.QueryTable(new(ProjectFiling))
- var offset int64
- if page <= 1 {
- offset = 0
- } else {
- offset = int64((page - 1) * page_z)
- }
- // 过滤
- cond := orm.NewCondition()
- cond = cond.And("T_state", 1)
- if len(T_uuid) > 0 {
- cond = cond.And("T_uuid", T_uuid)
- }
- if len(T_sales_personnel) > 0 {
- cond = cond.And("T_sales_personnel__icontains", T_sales_personnel)
- }
- if len(T_customers) > 0 {
- cond = cond.And("T_customers__icontains", T_customers)
- }
- // 查询
- var r []ProjectFiling
- _, err := qs.Limit(page_z, offset).SetCond((*orm2.Condition)(cond)).OrderBy("Id").All(&r)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- return
- }
- cnt, err = qs.SetCond((*orm2.Condition)(cond)).Count()
- if err != nil {
- logs.Error(lib.FuncName(), err)
- return
- }
- return r, cnt
- }
- // 修改
- func Update_ProjectFiling(m ProjectFiling, cols ...string) error {
- o := orm.NewOrm()
- _, err := o.Update(&m, cols...)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- return err
- }
- return nil
- }
- // 删除
- func Delete_ProjectFiling(v ProjectFiling) error {
- o := orm.NewOrm()
- v.T_state = 0
- _, err := o.Update(&v, "T_state")
- if err != nil {
- logs.Error(lib.FuncName(), err)
- }
- return err
- }
- // 添加
- func Add_ProjectFiling(r ProjectFiling) (id int64, err error) {
- o := orm.NewOrm()
- id, err = o.Insert(&r)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- }
- return id, err
- }
- // 获取 ById
- func Read_ProjectFiling_ByT_customers(T_customers string) (r ProjectFiling, err error) {
- o := orm.NewOrm()
- qs := o.QueryTable(new(ProjectFiling))
- err = qs.Filter("T_customers", T_customers).Filter("T_state", 1).One(&r)
- if err != nil {
- logs.Error(lib.FuncName(), err)
- }
- return
- }
|