本文整理汇总了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
}
示例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)
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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
}