本文整理汇总了Golang中github.com/coraldane/ops-meta/db.NewOrm函数的典型用法代码示例。如果您正苦于以下问题:Golang NewOrm函数的具体用法?Golang NewOrm怎么用?Golang NewOrm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewOrm函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
}
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:10,代码来源:rel_agent_group.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:7,代码来源:endpoint_agent.go
示例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
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:30,代码来源:rel_endpoint_group.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:7,代码来源:user.go
示例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
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:28,代码来源:user.go
示例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
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:8,代码来源:endpoint_agent.go
示例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
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:8,代码来源:rel_agent_group.go
示例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()
}
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:18,代码来源:endpoint.go
示例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
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:9,代码来源:user.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:9,代码来源:user.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:10,代码来源:host_group.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:13,代码来源:rel_agent_group.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:13,代码来源:agent.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:13,代码来源:endpoint.go
示例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()
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:19,代码来源:rel_endpoint_group.go
示例16: QueryHostGroupList
func QueryHostGroupList(queryDto QueryHostGroupDto, pageInfo *PageInfo) ([]HostGroup, *PageInfo) {
var rows []HostGroup
query := db.NewOrm().QueryTable(HostGroup{})
if "" != queryDto.GroupName {
query = query.Filter("GroupName__contains", queryDto.GroupName)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("GroupName").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryHostGroupList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:21,代码来源:host_group.go
示例17: QueryEndpointList
func QueryEndpointList(queryDto QueryEndpointDto, pageInfo *PageInfo) ([]Endpoint, *PageInfo) {
var rows []Endpoint
query := db.NewOrm().QueryTable(Endpoint{})
if "" != queryDto.Hostname {
query = query.Filter("hostname__icontains", queryDto.Hostname)
}
if "" != queryDto.Ip {
query = query.Filter("ip__contains", queryDto.Ip)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("-GmtModified").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryEndpointList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:24,代码来源:endpoint.go
示例18: QueryAgentList
func QueryAgentList(queryDto QueryAgentDto, pageInfo *PageInfo) ([]Agent, *PageInfo) {
var rows []Agent
query := db.NewOrm().QueryTable(Agent{})
if "" != queryDto.AgentName {
query = query.Filter("Name", queryDto.AgentName)
}
if "" != queryDto.RunUser {
query = query.Filter("RunUser", queryDto.RunUser)
}
rowCount, err := query.Count()
if nil != err {
logger.Errorln("queryCount error", err)
pageInfo.SetRowCount(0)
return nil, pageInfo
}
pageInfo.SetRowCount(rowCount)
_, err = query.OrderBy("Name").Offset(pageInfo.GetStartIndex()).Limit(pageInfo.PageSize).All(&rows)
if nil != err {
logger.Errorln("QueryAgentList error", err)
}
return rows, pageInfo
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:24,代码来源:agent.go
示例19: Insert
func (this *User) Insert() (int64, error) {
this.LoginPwd = utils.Md5Hex(this.LoginPwd)
this.RoleName = "NORMAL"
this.AccountStatus = 1
return db.NewOrm().Insert(this)
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:6,代码来源:user.go
示例20: CheckLogin
func CheckLogin(userName, loginPwd string) (*User, error) {
var u User
strSql := `select id, user_name, real_name, phone_no, email, role_name, account_status from t_user where user_name=? and login_pwd=? and account_status=1`
err := db.NewOrm().Raw(strSql, userName, utils.Md5Hex(loginPwd)).QueryRow(&u)
return &u, err
}
开发者ID:coraldane,项目名称:ops-meta,代码行数:6,代码来源:user.go
注:本文中的github.com/coraldane/ops-meta/db.NewOrm函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论