package models import ( "fmt" "mtp2_if/db" "github.com/xormplus/xorm" ) // GetUseresignRecord 通过ID获取记录 func GetUseresignRecord(id uint64) (useresignrecord *Useresignrecord, err error) { datas := make([]Useresignrecord, 0) err = db.GetEngine().Where("RECORDID = ?", id).Find(&datas) if err == nil { if len(datas) == 0 { err = xorm.ErrNotExist return } useresignrecord = &datas[0] } return } // GetUseresignRecordByFlowID 通过合同编号获取记录 func GetUseresignRecordByFlowID(flowId string) (useresignrecord *Useresignrecord, err error) { datas := make([]Useresignrecord, 0) err = db.GetEngine().Where("CONTRACTNO = ?", flowId).Find(&datas) if err == nil { if len(datas) == 0 { err = xorm.ErrNotExist return } useresignrecord = &datas[0] } return } func (t *Useresignrecord) Update(cols string) (err error) { _, err = db.GetEngine().Cols(cols).Where("RECORDID = ?", t.RECORDID).Update(t) return } func QueryUsereSignRecords(userId, memberUserId int, recordId, templateConfigId, templatetype *int) (records []Useresignrecord, err error) { records = make([]Useresignrecord, 0) session := db.GetEngine().Table("USERESIGNRECORD").Where("USERID = ? AND AREAUSERID = ?", userId, memberUserId) if recordId != nil { session = session.And("RECORDID = ?", recordId) } if templateConfigId != nil { session = session.And("TEMPLATECONFIGID = ?", templateConfigId) } if templatetype != nil { session = session.And("TEMPLATETYPE = ?", templatetype) } err = session.Find(&records) return } func QueryMdUserSwapProtocol(userId int, areaUserId *int64) (datas []Mduserswapprotocol, err error) { datas = make([]Mduserswapprotocol, 0) session := db.GetEngine().Table("MD_USERSWAPPROTOCOL").Where("USERID = ?", userId) if areaUserId != nil { session = session.And("AREAUSERID = ?", areaUserId) } err = session.Find(&datas) return } func (t *Mduserswapprotocol) Update(cols string) (err error) { _, err = db.GetEngine().Cols(cols).Where("USERID = ? AND AREAUSERID = ?", t.USERID, t.AREAUSERID).Update(t) return } func QueryEsignTemplateConfigs(esignType, templateType int) (datas []Esigntemplateconfig, err error) { err = db.GetEngine().Table("ESIGNTEMPLATECONFIG").Where("ESIGNTYPE = ? AND TEMPLATETYPE = ?", esignType, templateType).Find(&datas) return } func InsertMdUserSwapProtocol(userId, areaUserId, protocolStatus int, session *xorm.Session) (err error) { sql := fmt.Sprintf(` INSERT INTO MD_USERSWAPPROTOCOL (USERID,AREAUSERID,PROTOCOLSTATUS,AUDITTIME,UPDATETIME) VALUES (%v,%v,%v,sysdate,sysdate) `, userId, areaUserId, protocolStatus) _, err = session.Exec(sql) return } func InsertUserEsignRecord(userId, areaUserId int, econfig Esigntemplateconfig, session *xorm.Session) (err error) { sql := fmt.Sprintf(` INSERT INTO USERESIGNRECORD (RECORDID,USERID,TEMPLATECONFIGID,TEMPLATETYPE,TEMPLATENAME,ORDERINDEX,RECORDSTATUS,CREATETIME,UPDATETIME,AREAUSERID) VALUES (SEQ_USERESIGNRECORD.nextval,%v,%v,%v,'%v',%v,1,sysdate,sysdate,%v) `, userId, econfig.TEMPLATECONFIGID, econfig.TEMPLATETYPE, econfig.TEMPLATENAME, econfig.ORDERINDEX, areaUserId) _, err = session.Exec(sql) return }