當前位置: 首頁>>代碼示例>>Golang>>正文


Golang models.GetDB函數代碼示例

本文整理匯總了Golang中models.GetDB函數的典型用法代碼示例。如果您正苦於以下問題:Golang GetDB函數的具體用法?Golang GetDB怎麽用?Golang GetDB使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetDB函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: Edit

func (requireList *RequireList) Edit(name, newName string) (err error) {
	o := models.GetDB()
	err = o.Begin()
	//事務處理過程
	_, SomeError := models.GetDB().QueryTable(models.TABLE_NAME_REQUIRE).Filter("name", name).Update(orm.Params{"name": newName})
	_, SomeError = models.GetDB().QueryTable(models.TABLE_NAME_JOB).Filter("type", name).Update(orm.Params{"type": newName})
	_, SomeError = models.GetDB().QueryTable(models.TABLE_NAME_JOBHISTORY).Filter("type", name).Update(orm.Params{"type": newName})
	if SomeError != nil {
		err = o.Rollback()
	} else {
		err = o.Commit()
	}
	return

}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:15,代碼來源:require.go

示例2: CreateProgress

func CreateProgress() {
	d := []models.Progress{
		models.Progress{
			Id:   1,
			Name: "立項",
		},
		models.Progress{
			Id:   2,
			Name: "美術設計",
		},
		models.Progress{
			Id:   3,
			Name: "網站搭建",
		},

		models.Progress{
			Id:   4,
			Name: "製作完畢",
		},
		models.Progress{
			Id:   5,
			Name: "開通報名",
		},
		models.Progress{
			Id:   6,
			Name: "關閉報名",
		},
		models.Progress{
			Id:   7,
			Name: "照片下載(證書下載)",
		},
	}
	num, err := models.GetDB().InsertMulti(1, d)
	log.Println("CreateProgress: num=%v, err=%v", num, err)
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:35,代碼來源:main.go

示例3: GetComplainList

//獲取投訴列表
func GetComplainList(filter map[string]interface{}) (compalins []*models.JobComplaint, cnt int64, err error) {
	defer func() {
		if err != nil {
			utils.GetLog().Error("services.job.GetList : error : %s", err.Error())
		} else {
			utils.GetLog().Debug("services.job.GetList : debug : filter=%s, compalints=%v", utils.Sdump(filter), utils.Sdump(compalins))
		}
	}()

	q := models.GetDB().QueryTable("job_complaints").OrderBy("-created").RelatedSel("Job", "User", "Project", "Employee")

	//按照傳入的條件進行過濾查詢結果
	for k, v := range filter {
		if k != "limit" && k != "offset" && v != "" {
			q = q.Filter(k, v)
		}
	}
	cnt, _ = q.Count()

	if filter["limit"] != nil {
		q = q.Limit(filter["limit"].(int))
	}

	if filter["offset"] != nil {
		q = q.Offset(filter["offset"].(int))
	}

	_, err = q.All(&compalins)

	return

}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:33,代碼來源:complaint.go

示例4: Do

func (c *Creation) Do() (err error) {
	defer func() {
		if err != nil {
			utils.GetLog().Error("user.Creatin.Do : err = %v , obj = %s ", err, c)
		}
	}()

	if err = c.valid(); err != nil {
		return
	}

	c.password.GenSalt()
	c.password.GenPwd()

	u := models.User{
		Name:          c.name,
		Email:         c.email.EmailAddress(),
		Password:      c.password.Encryped(),
		Salt:          c.password.Salt(),
		Company:       &models.Company{Id: uint(c.companyId)},
		Roles:         c.roles.String(),
		LastLoginTime: time.Now(),
	}

	models.GetDB().Insert(&u)

	return
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:28,代碼來源:creation.go

示例5: getJob

func (jv *JobClaim) getJob() (err error) {
	err = models.GetDB().QueryTable(models.TABLE_NAME_JOB).Filter("id", jv.jobId).RelatedSel("CreateUser").One(jv.job)
	if err != nil {
		return
	}
	return
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:7,代碼來源:job_claim.go

示例6: GetJobAllFiles

func (self *QueryFile) GetJobAllFiles() (jobFiles []*models.File, err error) {
	_, err = models.GetDB().Raw("SELECT f.id, f.url, f.name FROM "+models.TABLE_NAME_FILE+
		" f join "+models.TABLE_NAME_JOBHISTORY+" h on f.rel_id=h.id join "+models.TABLE_NAME_JOB+
		" j on j.id=h.job_id WHERE j.id = ? and f.type<3", self.conditions["rel_id"]).QueryRows(&jobFiles)

	return
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:7,代碼來源:query_file.go

示例7: NewUserWithId

func NewUserWithId(id uint) (u *User, err error) {
	u = &User{
		user: &models.User{Id: id},
	}
	err = models.GetDB().QueryTable("users").Filter("id", id).RelatedSel().One(u.user)
	return
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:7,代碼來源:user.go

示例8: AddHistory

func AddHistory(j *models.Job, user *models.User, isCreate bool) (jid uint, err error) {
	defer func() {
		if err != nil {
			utils.GetLog().Error("services.job.AddHistory : error : %s, ", err.Error())
		} else {
			utils.GetLog().Debug("services.job.AddHistory : debug : Job=%s", utils.Sdump(j))
		}
	}()

	var jh models.JobHistory
	jh.Job = j
	jh.IsCreate = isCreate
	jh.Code = j.Code
	jh.CreateUser = j.CreateUser
	jh.Project = j.Project
	jh.Employee = j.Employee
	jh.Type = j.Type
	jh.Department = j.Department
	jh.Target = j.Target
	jh.TargetUrl = j.TargetUrl
	jh.Desc = j.Desc
	jh.Message = j.Message
	jh.FinishTime = j.FinishTime
	jh.ValidTime = j.ValidTime
	jh.ClaimTime = j.ClaimTime
	jh.ValidStatus = j.ValidStatus
	jh.ClaimStatus = j.ClaimStatus
	jh.SubmitStatus = j.SubmitStatus

	var insertId int64
	insertId, err = models.GetDB().Insert(&jh)
	jid = uint(insertId)

	return
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:35,代碼來源:job_utils.go

示例9: GetToUser

func (cp ComplaintCreator) GetToUser() (*models.User, error) {
	user := &models.User{}
	err := models.GetDB().QueryTable(models.TABLE_NAME_USER).Filter("id", cp.compliant.Employee.Id).One(user)
	if err != nil {
		return nil, err
	}
	return user, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:8,代碼來源:complaint_create.go

示例10: GetComplaint

func (cp ComplaintCreator) GetComplaint(complaintId uint) (*models.JobComplaint, error) {
	complain := &models.JobComplaint{}
	err := models.GetDB().QueryTable(models.TABLE_NAME_JOBCOMPLAINT).Filter("id", complaintId).One(complain)
	if err != nil {
		return nil, err
	}
	return complain, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:8,代碼來源:complaint_create.go

示例11: GetToUser

func (cpr ComplaintReplytor) GetToUser() (*models.User, error) {
	user := &models.User{}
	err := models.GetDB().QueryTable(models.TABLE_NAME_USER).Filter("id", cpr.complain.User.Id).One(user)
	if err != nil {
		return nil, err
	}
	return user, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:8,代碼來源:complaint_reply.go

示例12: GetUserName

func (joblist *JobList) GetUserName(employId uint) (*models.User, error) {
	user := &models.User{}
	err := models.GetDB().QueryTable(models.TABLE_NAME_USER).Filter("id", employId).One(user)
	if err != nil {
		return nil, err
	}
	return user, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:8,代碼來源:job.go

示例13: GetAllProjectNames

func (pl *ProjectList) GetAllProjectNames() ([]*models.Project, error) {
	_, err := models.GetDB().Raw("SELECT id, name FROM projects").QueryRows(&pl.projectList)
	if err != nil {
		return nil, err
	}

	return pl.projectList, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:8,代碼來源:project_list.go

示例14: getUser

func (ja *JobAssignment) getUser(userId uint) (*models.User, error) {
	user := &models.User{}
	err := models.GetDB().QueryTable(models.TABLE_NAME_USER).Filter("id", userId).One(user)
	if err != nil {
		return nil, err
	}
	return user, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:8,代碼來源:assign.go

示例15: GetProgressByID

//根據 項目進程id ,獲取process
func (p *Project) GetProgressByID(id uint) (*models.Progress, error) {
	progress := &models.Progress{}
	err := models.GetDB().QueryTable(models.TABLE_NAME_PROGRESS).Filter("id", id).One(progress)
	if err != nil {
		return nil, err
	}
	return progress, nil
}
開發者ID:zbzzbd,項目名稱:beego,代碼行數:9,代碼來源:project.go


注:本文中的models.GetDB函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。