本文整理汇总了Golang中github.com/safawo/fast/ds.DB函数的典型用法代码示例。如果您正苦于以下问题:Golang DB函数的具体用法?Golang DB怎么用?Golang DB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DB函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Post
func (this *AllocSafeRoleAction) Post() {
reqMsg := &AllocSafeRoleRequest{}
if !this.GetReqJson(reqMsg) {
return
}
db := ds.DB()
defer db.Close()
unAllocSql := "delete from fast.roleAlloc where roleId=$1 and userId=$2"
allocSql := "insert into fast.roleAlloc values($1,$2)"
unAllocStmt, err := db.Prepare(unAllocSql)
utils.VerifyErr(err)
for _, v := range reqMsg.UnAllocs {
unAllocStmt.Exec(v.RoleId, v.UserId)
}
unAllocStmt.Close()
allocStmt, err := db.Prepare(allocSql)
utils.VerifyErr(err)
for _, v := range reqMsg.Allocs {
allocStmt.Exec(v.RoleId, v.UserId)
}
allocStmt.Close()
rspMsg := &AllocSafeRoleResponse{}
rspMsg.Init(reqMsg)
this.SendJson(rspMsg)
}
开发者ID:safawo,项目名称:fast,代码行数:31,代码来源:SafeRoleAction.go
示例2: Post
func (this *SafeOperateAuthAction) Post() {
reqMsg := &SafeOperateAuthRequest{}
this.GetReqJson(reqMsg)
db := ds.DB()
defer db.Close()
unAuthSql := "delete from fast.operateAuth where operateId=$1 and roleId=$2"
authSql := "insert into fast.operateAuth values($1,$2)"
unAuthStmt, err := db.Prepare(unAuthSql)
utils.VerifyErr(err)
for _, v := range reqMsg.UnAuths {
unAuthStmt.Exec(v.OperateId, v.RoleId)
}
unAuthStmt.Close()
authStmt, err := db.Prepare(authSql)
utils.VerifyErr(err)
for _, v := range reqMsg.Auths {
authStmt.Exec(v.OperateId, v.RoleId)
}
authStmt.Close()
rspMsg := &SafeOperateAuthResponse{}
rspMsg.Init(reqMsg)
this.SendJson(rspMsg)
}
开发者ID:safawo,项目名称:fast,代码行数:31,代码来源:SafeOperateAction.go
示例3: ChangePara
func (this *fastSysParaMgr) ChangePara(paraName, paraValue string) {
paraName = strings.TrimSpace(paraName)
paraValue = strings.TrimSpace(paraValue)
if paraName == comm.NULL_STR || paraValue == comm.NULL_STR {
return
}
para, ok := this.mapPara[paraName]
if !ok {
return
}
para.ParaValue = paraValue
db := ds.DB()
defer db.Close()
changeSql := "update fast.sysParaConf set paraValue=$1 where paraName=$2"
changeStmt, err := db.Prepare(changeSql)
VerifyErr(err)
changeStmt.Exec(paraValue, paraName)
changeStmt.Close()
return
}
开发者ID:safawo,项目名称:fast,代码行数:26,代码来源:FastSysParaMgr.go
示例4: getDatas
func (this *FastSysParaAgent) getDatas() []utils.FastSysPara {
paras := []utils.FastSysPara{}
db := ds.DB()
defer db.Close()
querySql := "select * from fast.sysParaConf"
rows, err := db.Query(querySql)
utils.VerifyErr(err)
for rows.Next() {
newPara := utils.FastSysPara{}
err = rows.Scan(
&newPara.Catalog,
&newPara.ParaName,
&newPara.ParaValue,
&newPara.ParaType,
&newPara.ParaRemark)
paras = append(paras, newPara)
}
return paras
}
开发者ID:safawo,项目名称:fast,代码行数:25,代码来源:FastSysParaAgent.go
示例5: Post
func (this *UnLockUserAction) Post() {
reqMsg := &UnLockUserRequest{}
if !this.GetReqJson(reqMsg) {
return
}
reqMsg.UserId = strings.TrimSpace(reqMsg.UserId)
rspMsg := &UnLockUserResponse{}
rspMsg.Init(reqMsg)
if reqMsg.UserId == comm.NULL_STR {
this.SendJson(rspMsg)
return
}
db := ds.DB()
defer db.Close()
unLockUserSql := "update fast.safeUser set isLock=$1, lockReason=$2 where id=$3"
unLockUserStmt, err := db.Prepare(unLockUserSql)
utils.VerifyErr(err)
unLockUserStmt.Exec(false, comm.NULL_STR, reqMsg.UserId)
unLockUserStmt.Close()
rspMsg.Init(reqMsg)
this.SendJson(rspMsg)
}
开发者ID:safawo,项目名称:fast,代码行数:28,代码来源:SafeUserAction.go
示例6: getDatas
func (this *SafeOperateAgent) getDatas() []SafeOperate {
datas := []SafeOperate{}
db := ds.DB()
defer db.Close()
operateSql := "select * from fast.safeOperate where 1=1"
operateRows, err := db.Query(operateSql)
utils.VerifyErr(err)
for operateRows.Next() {
operate := SafeOperate{}
operateRows.Scan(
&operate.Id,
&operate.SerialId,
&operate.OperateCode,
&operate.Subsys,
&operate.OperateGroup,
&operate.OperateName,
&operate.OperateDetail,
&operate.OperateRemark,
&operate.IsAuth,
&operate.IsLog)
operate.Departs = []string{}
operate.Users = []string{}
operate.Roles = []string{}
datas = append(datas, operate)
}
return datas
}
开发者ID:safawo,项目名称:fast,代码行数:33,代码来源:SafeOperateAgent.go
示例7: CreateObject
func (this *safeObjectMgrImpl) CreateObject(safeObj *SafeObject) (msgId string, ok bool) {
msgId = comm.NULL_STR
ok = false
if safeObj == nil {
return
}
db := ds.DB()
defer db.Close()
createSql := "insert into fast.safeObject values($1,$2,$3,$4,$5,$6,$7,$8)"
createStmt, err := db.Prepare(createSql)
utils.VerifyErr(err)
createStmt.Exec(
safeObj.Id,
safeObj.SerialId,
safeObj.ObjectType,
safeObj.ParentPath,
safeObj.ObjectName,
safeObj.ObjectText,
safeObj.ObjectImage,
safeObj.ObjectRemark)
createStmt.Close()
msgId = msg.MSG_SUCCESS
ok = true
return
}
开发者ID:safawo,项目名称:fast,代码行数:31,代码来源:SafeObjectMgr.go
示例8: WriteRawLog
func (this *logMgrImpl) WriteRawLog(log *OperateLog) {
if log == nil {
return
}
if log.IsEmpty() {
return
}
db := ds.DB()
defer db.Close()
logSql := "insert into fast.operateLog values($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13)"
logStmt, err := db.Prepare(logSql)
utils.VerifyErr(err)
logStmt.Exec(
log.UserName,
log.Subsys,
log.OperateGroup,
log.OperateName,
log.OperateRet,
log.OperateRetDetail,
log.OperateObj,
log.OperateContent,
log.UserIpAddress,
log.UserHostName,
log.OperateTime,
log.LogType,
log.SerialNum)
logStmt.Close()
}
开发者ID:safawo,项目名称:fast,代码行数:32,代码来源:LogMgr.go
示例9: init
func (this *operateMgrImpl) init() {
fmt.Println(" Init Operate Mgr")
this.mapOperate = map[string](*SafeOperate){}
db := ds.DB()
defer db.Close()
querySql := "select * from fast.safeOperate"
operateRows, err := db.Query(querySql)
utils.VerifyErr(err)
for operateRows.Next() {
operate := &SafeOperate{}
operateRows.Scan(
&operate.Id,
&operate.SerialId,
&operate.OperateCode,
&operate.Subsys,
&operate.OperateGroup,
&operate.OperateName,
&operate.OperateDetail,
&operate.OperateRemark,
&operate.IsAuth,
&operate.IsLog)
this.mapOperate[operate.OperateCode] = operate
}
}
开发者ID:safawo,项目名称:fast,代码行数:29,代码来源:OperateMgr.go
示例10: QueryAuthsByType
func (this *safeObjectMgrImpl) QueryAuthsByType(objectType string) (objects []ObjectAuthInfo) {
objects = []ObjectAuthInfo{}
db := ds.DB()
defer db.Close()
objectType = strings.TrimSpace(objectType)
querySql := "select distinct objectAuth.* from fast.objectAuth"
if objectType != comm.NULL_STR {
querySql += ",fast.safeObject where objectAuth.objectId=safeObject.id "
querySql += " and safeObject.objectType='" + objectType + "'"
}
authRows, err := db.Query(querySql)
utils.VerifyErr(err)
for authRows.Next() {
auth := ObjectAuthInfo{}
authRows.Scan(&auth.ObjectId, &auth.RoleId)
objects = append(objects, auth)
}
return
}
开发者ID:safawo,项目名称:fast,代码行数:25,代码来源:SafeObjectMgr.go
示例11: QueryObjectsByType
func (this *safeObjectMgrImpl) QueryObjectsByType(objectType string) (objects []SafeObject) {
objects = [](SafeObject){}
objectType = strings.TrimSpace(objectType)
querySql := "select distinct * from fast.safeObject"
if objectType != comm.NULL_STR {
querySql += " where objectType='" + objectType + "'"
}
db := ds.DB()
defer db.Close()
objectRows, err := db.Query(querySql)
utils.VerifyErr(err)
for objectRows.Next() {
object := SafeObject{}
objectRows.Scan(
&object.Id,
&object.SerialId,
&object.ObjectType,
&object.ParentPath,
&object.ObjectName,
&object.ObjectText,
&object.ObjectImage,
&object.ObjectRemark)
objects = append(objects, object)
}
return
}
开发者ID:safawo,项目名称:fast,代码行数:33,代码来源:SafeObjectMgr.go
示例12: Post
func (this *QuerySafeSubSysAction) Post() {
reqMsg := &QuerySafeSubSysRequest{}
if !this.GetReqJson(reqMsg) {
return
}
db := ds.DB()
defer db.Close()
subSysSql := "select * from fast.subSys"
subSysRows, err := db.Query(subSysSql)
utils.VerifyErr(err)
rspMsg := &QuerySafeSubSysResponse{}
rspMsg.Init(reqMsg)
for subSysRows.Next() {
subSys := SubSys{}
subSysRows.Scan(
&subSys.Id,
&subSys.Name)
rspMsg.SubSyss = append(rspMsg.SubSyss, subSys)
}
this.SendJson(rspMsg)
}
开发者ID:safawo,项目名称:fast,代码行数:29,代码来源:SafeSubSysAction.go
示例13: Post
func (this *SelfModUserInfoAction) Post() {
reqMsg := &SelfModUserInfoRequest{}
if !this.GetReqJson(reqMsg) {
return
}
db := ds.DB()
defer db.Close()
selfModSql := "update fast.safeUser set nickName=$1,firstName=$2,lastName=$3,"
selfModSql += "mobile=$4,email=$5 where id=$6"
selfModStmt, err := db.Prepare(selfModSql)
utils.VerifyErr(err)
selfModStmt.Exec(reqMsg.NickName,
reqMsg.FirstName,
reqMsg.LastName,
reqMsg.Mobile,
reqMsg.Email,
reqMsg.Id)
selfModStmt.Close()
rspMsg := &SelfModUserInfoResponse{}
rspMsg.SafeUser = reqMsg.SafeUser
rspMsg.Init(reqMsg)
this.SendJson(rspMsg)
}
开发者ID:safawo,项目名称:fast,代码行数:28,代码来源:SafeSelfAction.go
示例14: init
func (this *userMgrImpl) init() {
fmt.Println(" Init User Mgr")
this.mapUser = map[string](*SafeUser){}
db := ds.DB()
defer db.Close()
querySql := "select * from fast.safeUser"
userRows, err := db.Query(querySql)
utils.VerifyErr(err)
for userRows.Next() {
user := &SafeUser{}
userRows.Scan(
&user.Id,
&user.DepartId,
&user.Name,
&user.Password,
&user.EmployeeId,
&user.NickName,
&user.FirstName,
&user.LastName,
&user.Mobile,
&user.Email,
&user.UserRemark,
&user.IsLock,
&user.LockReason,
&user.IsForever,
&user.AccountExpired)
this.mapUser[user.Id] = user
}
}
开发者ID:safawo,项目名称:fast,代码行数:34,代码来源:UserMgr.go
示例15: Post
func (this *QueryMyAccessObjectAction) Post() {
reqMsg := &QueryMyAccessObjectRequest{}
if !this.GetReqJson(reqMsg) {
return
}
reqMsg.ObjectType = strings.TrimSpace(reqMsg.ObjectType)
rspMsg := &QueryMyAccessObjectResponse{}
rspMsg.Init(reqMsg)
sessionId := reqMsg.GetReqSessionId()
session, ok := SessionMgr().GetSession(sessionId)
if !ok {
rspMsg.SetRspRetId(msg.MSG_FAIL)
this.SendJson(rspMsg)
return
}
userId := session.GetUserId()
db := ds.DB()
defer db.Close()
querySql := comm.NULL_STR
if !session.IsAdmin() {
querySql += "select distinct obj.id,obj.objectName from fast.safeObject obj, fast.objectAuth auth where "
querySql += "obj.id = auth.objectId "
if reqMsg.ObjectType != comm.NULL_STR {
querySql += "and obj.objectType='" + reqMsg.ObjectType + "' "
}
querySql += "and (auth.roleId='" + userId + "' or auth.roleId in(select distinct alloc.roleId "
querySql += "from fast.roleAlloc alloc where alloc.userId='" + userId + "'))"
} else {
querySql += "select distinct obj.id,obj.objectName from fast.safeObject obj where 1=1 "
if reqMsg.ObjectType != comm.NULL_STR {
querySql += "and obj.objectType='" + reqMsg.ObjectType + "' "
}
}
fmt.Println("query access object sql:", querySql)
objRows, err := db.Query(querySql)
utils.VerifyErr(err)
objectId := comm.NULL_STR
objectName := comm.NULL_STR
for objRows.Next() {
objRows.Scan(&objectId, &objectName)
rspMsg.ObjectIds = append(rspMsg.ObjectIds, objectId)
rspMsg.ObjectNames = append(rspMsg.ObjectNames, objectName)
}
this.SendJson(rspMsg)
}
开发者ID:safawo,项目名称:fast,代码行数:56,代码来源:SafeAccessAction.go
示例16: DelObjectByName
func (this *safeObjectMgrImpl) DelObjectByName(objectName string) {
objectName = strings.TrimSpace(objectName)
db := ds.DB()
defer db.Close()
delSql := "delete from fast.safeObject where objectName=$1"
delStmt, err := db.Prepare(delSql)
utils.VerifyErr(err)
delStmt.Exec(objectName)
delStmt.Close()
return
}
开发者ID:safawo,项目名称:fast,代码行数:15,代码来源:SafeObjectMgr.go
示例17: UnAuth
func (this *safeObjectMgrImpl) UnAuth(unAuths []ObjectAuthInfo) {
db := ds.DB()
defer db.Close()
unAuthSql := "delete from fast.objectAuth where objectId=$1 and roleId=$2"
unAuthStmt, err := db.Prepare(unAuthSql)
utils.VerifyErr(err)
for _, v := range unAuths {
unAuthStmt.Exec(v.ObjectId, v.RoleId)
}
unAuthStmt.Close()
return
}
开发者ID:safawo,项目名称:fast,代码行数:16,代码来源:SafeObjectMgr.go
示例18: Auth
func (this *safeObjectMgrImpl) Auth(auths []ObjectAuthInfo) {
db := ds.DB()
defer db.Close()
authSql := "insert into fast.objectAuth values($1,$2)"
authStmt, err := db.Prepare(authSql)
utils.VerifyErr(err)
for _, v := range auths {
authStmt.Exec(v.ObjectId, v.RoleId)
}
authStmt.Close()
return
}
开发者ID:safawo,项目名称:fast,代码行数:16,代码来源:SafeObjectMgr.go
示例19: unAuthByObj
func (this *safeObjectMgrImpl) unAuthByObj(objectName, objectType string) {
objectName = strings.TrimSpace(objectName)
objectType = strings.TrimSpace(objectType)
db := ds.DB()
defer db.Close()
unAuthSql := "delete from fast.objectAuth where objectId in (select id from fast.safeObject where"
unAuthSql += " objectName=$1 and objectType=$2)"
unAuthStmt, err := db.Prepare(unAuthSql)
utils.VerifyErr(err)
unAuthStmt.Exec(objectName, objectType)
unAuthStmt.Close()
return
}
开发者ID:safawo,项目名称:fast,代码行数:18,代码来源:SafeObjectMgr.go
示例20: init
func (this *sessionMgrImpl) init() {
fmt.Println(" Init User Session")
this.mapSessions = map[string](*SafeSession){}
this.badSessions = map[string](*SafeSession){}
db := ds.DB()
defer db.Close()
initSql := "truncate table fast.safeSession"
initStmt, err := db.Prepare(initSql)
utils.VerifyErr(err)
initStmt.Exec()
initStmt.Close()
}
开发者ID:safawo,项目名称:fast,代码行数:18,代码来源:SessionMgr.go
注:本文中的github.com/safawo/fast/ds.DB函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论