parent
88d4e9de35
commit
5367a813e4
@ -0,0 +1,28 @@
|
||||
package MinIORelateDao
|
||||
|
||||
import (
|
||||
"dsCommonTools/Utils/DbUtil"
|
||||
)
|
||||
|
||||
var db = DbUtil.Engine
|
||||
|
||||
func TestSqlJson() (string, error) {
|
||||
sql := "select * from t_complaint_info"
|
||||
results, err := db.SQL(sql).Query().Json()
|
||||
return results, err
|
||||
}
|
||||
|
||||
func InsertFileInfo(fileMap map[string]string) error {
|
||||
sql := "insert into t_base_file (id, origin_name, storage_key, storage_bucket, storage_url_prefix, file_size, file_md5, system_id)" +
|
||||
" values (?,?,?,?,?,?,?,?)"
|
||||
_, err := db.Exec(sql, fileMap["id"], fileMap["origin_name"], fileMap["storage_key"], fileMap["storage_bucket"], fileMap["storage_url_prefix"], fileMap["file_size"], fileMap["file_md5"], fileMap["system_id"])
|
||||
return err
|
||||
}
|
||||
|
||||
func GetFileKey(id string) (string, error) {
|
||||
sql := "select storage_key from t_base_file where id=?"
|
||||
var key string
|
||||
_, err := db.SQL(sql, id).Get(&key)
|
||||
return key, err
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package RedisUtil
|
||||
|
||||
import (
|
||||
"dsCommonTools/Utils/ConfigUtil"
|
||||
"github.com/go-redis/redis"
|
||||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
RedisClient *redis.Client
|
||||
RedisHost string
|
||||
RedisDb int
|
||||
)
|
||||
|
||||
func init() {
|
||||
// 从配置文件获取redis的ip以及db
|
||||
RedisHost = ConfigUtil.RedisIp + ":" + ConfigUtil.RedisPort
|
||||
RedisClient = redis.NewClient(&redis.Options{
|
||||
Addr: RedisHost,
|
||||
DB: 0, // use default DB
|
||||
})
|
||||
}
|
||||
|
||||
func SET(key string, value string, expiration time.Duration) {
|
||||
RedisClient.Set(key, value, expiration*time.Second)
|
||||
}
|
||||
|
||||
func GET(key string) (string, error) {
|
||||
val, err := RedisClient.Get(key).Result()
|
||||
return val, err
|
||||
|
||||
}
|
||||
|
||||
func EXPIRE(key string, expiration time.Duration) {
|
||||
RedisClient.Expire(key, expiration*time.Second)
|
||||
}
|
||||
|
||||
func DEL(key string) {
|
||||
RedisClient.Del(key)
|
||||
}
|
||||
|
||||
func HMSET(key string, fields map[string]interface{}) {
|
||||
RedisClient.HMSet(key, fields)
|
||||
}
|
||||
|
||||
func HMGETALL(key string) map[string]string {
|
||||
resMap, _ := RedisClient.HGetAll(key).Result()
|
||||
return resMap
|
||||
}
|
Loading…
Reference in new issue