123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- /*
- * @description: 安全巡检数据库操作相关
- * @Author: LanJianRong
- * @Date: 2020-11-20
- * @FilePath: \construction_management\dao\safe_dao.go
- */
- package dao
- import (
- "fmt"
- "github.com/go-xorm/xorm"
- "go.mod/web/viewmodels"
- )
- //数据库操作引擎
- type SafeAuditDao struct {
- engine *xorm.Engine
- }
- //获得一个DAO对象
- func NewSafeAuditDao(engine *xorm.Engine) *SafeAuditDao {
- return &SafeAuditDao{
- engine: engine,
- }
- }
- // 根据当前times,获取审批人(包括原报)
- func (d *SafeAuditDao) GetAuditors(id int, times int, cur_uid int) []viewmodels.Auditors {
- auditors := make([]viewmodels.Auditors, 0)
- // 原报
- auditor := viewmodels.Auditors{}
- _, err := d.engine.Sql("select `name` from `cm_project_account` where id = ?", cur_uid).Get(&auditor)
- if err != nil {
- fmt.Println(err)
- }
- auditors = append(auditors, auditor)
- d.engine.Sql("select pa.`name` from `cm_project_account` as pa, `cm_safe_audit` as ca where ca.`safe_id` = ? and ca.`times` = ? and ca.audit_id = pa.id order by `audit_order`", id, times).Find(&auditors)
- return auditors
- }
- // times从0开始循环,往history里面push
- // func (d *SafeAuditDao) GetAuditHistory(id int, times int) {
- // auditorHistory := make([]models.CmSafeAudit, 0)
- // d.engine.Sql("select pa.`name`, pa.`position`,ca.`create_time`, ca.`end_time`, ca.`opinion`, ca.`status`, from `cm_project_account` as pa, `cm_safe_audit` as ca where ca.`safe_id` = ? and ca.audit_id = pa.id order by `audit_order`", id, times).Find(&auditors)
- // }
|