本文整理汇总了Golang中github.com/coraldane/ops-meta/db.NewOrm函数的典型用法代码示例。如果您正苦于以下问题:Golang NewOrm函数的具体用法?Golang NewOrm怎么用?Golang NewOrm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewOrm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Insert
func (this *RelAgentGroup) Insert() (int64, error) {
this.GmtModified = time.Now()
if 0 < this.Id {
return db.NewOrm().Update(this)
} else {
this.GmtCreate = time.Now()
return db.NewOrm().Insert(this)
}
}
示例2: Delete
func (this *EndpointAgent) Delete(excludes []string) (int64, error) {
query := db.NewOrm().QueryTable(EndpointAgent{}).Filter("HostName", this.Hostname)
if 0 < len(excludes) {
query = query.Exclude("agent_name__in", excludes)
}
return query.Delete()
}
示例3: QueryRelEndpointGroupList
func QueryRelEndpointGroupList(queryDto QueryRelEndpointGroupDto, pageInfo *PageInfo) ([]RelEndpointGroup, *PageInfo) {
var rows []RelEndpointGroup
query := db.NewOrm().QueryTable(RelEndpointGroup{})
if 0 < queryDto.HostGroupId {
query = query.Filter("HostGroupId", queryDto.HostGroupId)
}
if "" != queryDto.RelType {
query = query.Filter("RelType", queryDto.RelType)
}
if "" != queryDto.PropName {
query = query.Filter("PropName", queryDto.PropName)
}
if "" != queryDto.PropValue {
query = query.Filter("PropValue", queryDto.PropValue)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("RelType").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryRelEndpointGroupList error", err)
}
return rows, pageInfo
}
示例4: ChangeLoginPasswd
func (this *User) ChangeLoginPasswd() (int64, error) {
result, err := db.NewOrm().Raw(`update t_user set login_pwd=? where user_name=?`, utils.Md5Hex(this.LoginPwd), this.UserName).Exec()
if nil != err {
return 0, err
}
return result.RowsAffected()
}
示例5: QueryUserList
func QueryUserList(queryDto QueryUserDto, pageInfo *PageInfo) ([]User, *PageInfo) {
var rows []User
query := db.NewOrm().QueryTable(User{})
if "" != queryDto.UserName {
query = query.Filter("user_name__contains", queryDto.UserName)
}
if "" != queryDto.RealName {
query = query.Filter("RealName", queryDto.RealName)
}
if "" != queryDto.RoleName {
query = query.Filter("RoleName", queryDto.RoleName)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("Id").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows,
"UserName", "RealName", "PhoneNo", "Email", "RoleName", "AccountStatus")
if nil != err {
logger.Errorln("QueryUserList error", err)
}
return rows, pageInfo
}
示例6: QueryEndpointAgentList
func QueryEndpointAgentList(hostname string) []EndpointAgent {
var rows []EndpointAgent
_, err := db.NewOrm().QueryTable(EndpointAgent{}).Filter("Hostname", hostname).All(&rows)
if nil != err {
logger.Errorln("QueryEndpointAgentList error", err)
}
return rows
}
示例7: QueryRelAgentGroupList
func QueryRelAgentGroupList(agentId int64) ([]RelAgentGroupDto, error) {
var rows []RelAgentGroupDto
_, err := db.NewOrm().Raw("select t.id, t.gmt_create,t.gmt_modified, t.host_group_id, a.group_name from t_rel_agent_group t, t_host_group a where t.agent_id=? and t.host_group_id=a.id", agentId).QueryRows(&rows)
if nil != err {
logger.Errorln("QueryRelAgentGroupList error", err)
}
return rows, err
}
示例8: Insert
func (this *Endpoint) Insert() (int64, error) {
num, err := db.NewOrm().QueryTable(Endpoint{}).Filter("Hostname", this.Hostname).Count()
if nil != err {
return 0, err
} else if 0 == num {
this.GmtCreate = time.Now()
this.GmtModified = time.Now()
return db.NewOrm().Insert(this)
} else {
strSql := `update t_endpoint set gmt_modified=?, ip = ?, updater_version = ?, run_user = ? where hostname=?`
result, err := db.NewOrm().Raw(strSql, utils.FormatUTCTime(time.Now()), this.Ip, this.UpdaterVersion, this.RunUser, this.Hostname).Exec()
if nil != err {
logger.Errorln("insert endpoint fail: ", err)
return 0, err
}
return result.RowsAffected()
}
}
示例9: GetUserById
func GetUserById(userId int64) *User {
var u User
strSql := `select id, user_name, real_name, phone_no, email, role_name, account_status from t_user where id=?`
err := db.NewOrm().Raw(strSql, userId).QueryRow(&u)
if nil != err {
logger.Errorln("query error", err)
}
return &u
}
示例10: Update
func (this *User) Update() (int64, error) {
strSql := `update t_user set real_name=?, phone_no=?, email=?, role_name=? where id=?`
result, err := db.NewOrm().Raw(strSql, this.RealName, this.PhoneNo, this.Email, this.RoleName, this.Id).Exec()
if nil != err {
logger.Errorln("update error", err)
return 0, err
}
return result.RowsAffected()
}
示例11: DeleteByCond
func (this *HostGroup) DeleteByCond() (int64, error) {
query := db.NewOrm().QueryTable(HostGroup{})
if 0 < this.Id {
query = query.Filter("Id", this.Id)
}
if "" != this.GroupName {
query = query.Filter("GroupName", this.GroupName)
}
return query.Delete()
}
示例12: DeleteByCond
func (this *RelAgentGroup) DeleteByCond() (int64, error) {
query := db.NewOrm().QueryTable(RelAgentGroup{})
if 0 < this.Id {
query = query.Filter("Id", this.Id)
}
if 0 < this.HostGroupId {
query = query.Filter("HostGroupId", this.HostGroupId)
}
if 0 < this.AgentId {
query = query.Filter("AgentId", this.AgentId)
}
return query.Delete()
}
示例13: DeleteByCond
func (this *Agent) DeleteByCond() (int64, error) {
query := db.NewOrm().QueryTable(Agent{})
if 0 < this.Id {
query = query.Filter("Id", this.Id)
}
if "" != this.Name {
query = query.Filter("Name", this.Name)
}
if "" != this.Version {
query = query.Filter("Version", this.Version)
}
return query.Delete()
}
示例14: DeleteByCond
func (this *Endpoint) DeleteByCond() (int64, error) {
query := db.NewOrm().QueryTable(Endpoint{})
if 0 < this.Id {
query = query.Filter("Id", this.Id)
}
if "" != this.Hostname {
query = query.Filter("Hostname", this.Hostname)
}
if "" != this.Ip {
query = query.Filter("Ip", this.Ip)
}
return query.Delete()
}
示例15: DeleteByCond
func (this *RelEndpointGroup) DeleteByCond() (int64, error) {
query := db.NewOrm().QueryTable(RelEndpointGroup{})
if 0 < this.Id {
query = query.Filter("Id", this.Id)
}
if 0 < this.HostGroupId {
query = query.Filter("HostGroupId", this.HostGroupId)
}
if "" != this.RelType {
query = query.Filter("RelType", this.RelType)
}
if "" != this.PropName {
query = query.Filter("PropName", this.PropName)
}
if "" != this.PropValue {
query = query.Filter("PropValue", this.PropValue)
}
return query.Delete()
}