Commit 023ab72f by 朱继来

temp

parent de4c9c78
package UserMain
import (
"database/sql"
_ "encoding/json"
"fmt"
_ "github.com/ichunt2019/logger"
"go-queue-server/dal/db"
"go-queue-server/util"
"log"
)
type UserMain struct {
UserId int `db:"user_id"`
Mobile string `db:"mobile"`
Email string `db:"email"`
CreateTime int `db:"create_time"`
Count int `db:"count"`
}
func initDb(dns string) (err error) {
err = db.Init(dns)
if err != nil {
return
}
return
}
// 多行查询
func QueryRepeatAccount(field string) {
initDb(util.Configs.Liexin_databases.Dns) //初始化db
var user_main []*UserMain
err := db.DB.Select(&user_main, "select "+ field +", count(*) as count from lie_user_main where ? != '' group by ? having count > 1", field, field)
if err == sql.ErrNoRows {
log.Printf("not found data of the id:%d", 1)
}
if err != nil {
panic(err)
}
if user_main == nil {
return
}
for _, v := range user_main {
fmt.Println(v)
}
}
\ No newline at end of file
package main
import (
"flag"
_ "fmt"
"github.com/ichunt2019/logger"
"go-queue-server/dal/user/UserMain"
"go-queue-server/util"
)
var ConfigDir string
var LogDir string
// 解析命令行参数
func initArgs() {
// worker -config ./worker.json
// worker -h
flag.StringVar(&ConfigDir, "configDir", "", "配置文件")
flag.StringVar(&LogDir, "logDir", "", "日志目录")
flag.Parse()
}
func main() {
initArgs()
//初始化配置文件
util.Init(ConfigDir)
logConfig := make(map[string]string)
logConfig["log_path"] = LogDir+"user/userRepeat"
logConfig["log_chan_size"] = "1000"
logger.InitLogger("file",logConfig)
logger.Init()
UserMain.QueryRepeatAccount("mobile")
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment