本文整理汇总了Golang中github.com/safawo/fast/ds.DB函数的典型用法代码示例。如果您正苦于以下问题:Golang DB函数的具体用法?Golang DB怎么用?Golang DB使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DB函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例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)
}
示例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
}
示例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
}
示例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)
}
示例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
}
示例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
}
示例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()
}
示例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
}
}
示例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
}
示例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
}
示例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)
}
示例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)
}
示例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
}
}
示例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)
}