Commit 142ff977 by huangchengyi

Merge branch 'dev' of http://119.23.72.7/mushishixian/search_server into dev

# Conflicts:
#	pkg/gredis/redis.go
#	service/common_ly_service.go
parents ccfbc0bc a9fa6bb9
package main
import (
"flag"
"github.com/gin-gonic/gin"
"github.com/micro/go-micro/v2/client/grpc"
"github.com/micro/go-micro/v2/web"
"log"
"search_server/boot"
_ "search_server/controller"
"search_server/framework/gin_"
"search_server/pkg/config"
)
func main() {
var path string
flag.StringVar(&path, "config", "conf/config.ini", "配置文件")
flag.Parse()
if err := boot.Boot(path); err != nil {
log.Println(err)
}
r := gin.New()
gin_.BootStrap(r)
c:=grpc.NewClient()
r:=gin.New()
r.Handle("GET","/test", func(ctx *gin.Context) {
news
c:=Course.NewCourseService("api.jtthink.com.course",c)
course_rsp,_:=c.ListForTop(context.Background(),&Course.ListRequest{Size:10})
ctx.JSON(200,gin.H{"Result":course_rsp.Result})
})
service:=web.NewService(
web.Name("api.jtthink.com.http.course"),
web.Handler(r),
)
port := config.Get("web.port").String()
//web改成micro 就是grpc,并直接注册到etcd里面
service := web.NewService(
web.Name("go.micro.api.http.course"),
web.Handler(r),
web.Address(":"+port),
)
if err := service.Init(); err != nil {
log.Println(err)
}
if err := service.Run(); err != nil {
log.Println(err)
}
//
//var path string
//flag.StringVar(&path, "config", "conf/config.ini", "配置文件")
//flag.Parse()
//if err := boot.Boot(path); err != nil {
// log.Println(err)
//}
//
//r := gin.New()
//gin_.BootStrap(r)
//
//c:=grpc.NewClient()
//r:=gin.New()
//r.Handle("GET","/test", func(ctx *gin.Context) {
// news
// c:=Course.NewCourseService("api.jtthink.com.course",c)
// course_rsp,_:=c.ListForTop(context.Background(),&Course.ListRequest{Size:10})
// ctx.JSON(200,gin.H{"Result":course_rsp.Result})
//})
//service:=web.NewService(
// web.Name("api.jtthink.com.http.course"),
// web.Handler(r),
//)
//
//
//
//port := config.Get("web.port").String()
////web改成micro 就是grpc,并直接注册到etcd里面
//service := web.NewService(
// web.Name("go.micro.api.http.course"),
// web.Handler(r),
// web.Address(":"+port),
//)
//
//if err := service.Init(); err != nil {
// log.Println(err)
//}
//if err := service.Run(); err != nil {
// log.Println(err)
//}
}
[gorm]
mode = debug
[mysql]
user_name = root
password = root
host = 192.168.2.250
database = test1
table_prefix =
type = mysql
[bom]
user_name = root
password = root
host = 192.168.2.250
database = test
table_prefix =
type = mysql
\ No newline at end of file
[default_redis_read]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[default_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[api_redis_read]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
[api_redis_write]
host = 192.168.1.235:6379
password = icDb29mLy2s
max_idle = 50
max_active = 100
idle_timeout = 20
package controller
import (
"github.com/gin-gonic/gin"
"search_server/framework/gin_"
"search_server/protopb/course"
"search_server/service"
)
func init() {
courseService := service.NewCourseServiceImpl()
gin_.NewBuilder().WithService(courseService).
WithMiddleware(Check_Middleware()).
WithMiddleware(Cors_Middleware()).
WithEndpoint(Courselist_Endpoint(courseService)).
WithRequest(Courselist_Request()).
WithResponse(Course_Response()).Build("/course", "GET")
gin_.NewBuilder().WithService(courseService).
WithMiddleware(Check_Middleware()).
WithEndpoint(Coursedetail_Endpoint(courseService)).
WithRequest(Coursedetail_Request()).
WithResponse(Course_Response()).Build("/detail/:course_id", "GET")
}
//详细相关
func Coursedetail_Endpoint(c *service.CourseServiceImpl) gin_.Endpoint {
return func(context *gin.Context, request interface{}) (response interface{}, err error) {
rsp := &course.DetailResponse{Course: new(course.CourseModel), Counts: make([]*course.CourseCounts, 0)}
err = c.GetDetail(context, request.(*course.DetailRequest), rsp)
return rsp, err
}
}
//这个函数的作用是怎么处理请求
func Coursedetail_Request() gin_.EncodeRequestFunc {
return func(context *gin.Context) (i interface{}, e error) {
bReq := &course.DetailRequest{}
err := context.BindUri(bReq)
if err != nil {
return nil, err
}
err = context.BindHeader(bReq)
if err != nil {
return nil, err
}
return bReq, nil
}
}
//获取列表相关
func Courselist_Endpoint(c *service.CourseServiceImpl) gin_.Endpoint {
return func(context *gin.Context, request interface{}) (response interface{}, err error) {
rsp := &course.ListResponse{}
err = c.ListForTop(context, request.(*course.ListRequest), rsp)
return rsp, err
}
}
//这个函数的作用是怎么处理请求
func Courselist_Request() gin_.EncodeRequestFunc {
return func(context *gin.Context) (i interface{}, e error) {
bReq := &course.ListRequest{}
err := context.BindQuery(bReq) //使用的是query 参数
if err != nil {
return nil, err
}
return bReq, nil
}
}
//这个函数作用是:怎么处理响应结果
func Course_Response() gin_.DecodeResponseFunc {
return func(context *gin.Context, res interface{}) error {
context.JSON(200, res)
return nil
}
}
//func init() {
// courseService := service.NewCourseServiceImpl()
// gin_.NewBuilder().WithService(courseService).
// WithMiddleware(Check_Middleware()).
// WithMiddleware(Cors_Middleware()).
// WithEndpoint(Courselist_Endpoint(courseService)).
// WithRequest(Courselist_Request()).
// WithResponse(Course_Response()).Build("/course", "GET")
//
// gin_.NewBuilder().WithService(courseService).
// WithMiddleware(Check_Middleware()).
// WithEndpoint(Coursedetail_Endpoint(courseService)).
// WithRequest(Coursedetail_Request()).
// WithResponse(Course_Response()).Build("/detail/:course_id", "GET")
//
//}
//
////详细相关
//func Coursedetail_Endpoint(c *service.CourseServiceImpl) gin_.Endpoint {
// return func(context *gin.Context, request interface{}) (response interface{}, err error) {
// rsp := &course.DetailResponse{Course: new(course.CourseModel), Counts: make([]*course.CourseCounts, 0)}
// err = c.GetDetail(context, request.(*course.DetailRequest), rsp)
// return rsp, err
// }
//}
//
////这个函数的作用是怎么处理请求
//func Coursedetail_Request() gin_.EncodeRequestFunc {
// return func(context *gin.Context) (i interface{}, e error) {
// bReq := &course.DetailRequest{}
// err := context.BindUri(bReq)
// if err != nil {
// return nil, err
// }
// err = context.BindHeader(bReq)
// if err != nil {
// return nil, err
// }
// return bReq, nil
// }
//}
//
////获取列表相关
//func Courselist_Endpoint(c *service.CourseServiceImpl) gin_.Endpoint {
// return func(context *gin.Context, request interface{}) (response interface{}, err error) {
// rsp := &course.ListResponse{}
// err = c.ListForTop(context, request.(*course.ListRequest), rsp)
// return rsp, err
// }
//}
//
////这个函数的作用是怎么处理请求
//func Courselist_Request() gin_.EncodeRequestFunc {
// return func(context *gin.Context) (i interface{}, e error) {
// bReq := &course.ListRequest{}
// err := context.BindQuery(bReq) //使用的是query 参数
// if err != nil {
// return nil, err
// }
// return bReq, nil
// }
//}
//
////这个函数作用是:怎么处理响应结果
//func Course_Response() gin_.DecodeResponseFunc {
// return func(context *gin.Context, res interface{}) error {
// context.JSON(200, res)
// return nil
// }
//}
package controller
import (
"github.com/gin-gonic/gin"
"search_server/framework/gin_"
"search_server/protopb/course"
"search_server/service"
)
func init() {
courseService:=service.NewCourseTopicServiceImpl()
gin_.NewBuilder().WithService(courseService).
WithMiddleware(Check_Middleware()).
WithEndpoint(CourseTopicList_Endpoint(courseService)).
WithRequest(CourseTopicList_Request()).
WithResponse(Course_Response()).Build("/topic/:cid","GET")
}
func CourseTopicList_Endpoint(c *service.CourseTopicServiceImpl) gin_.Endpoint {
return func(context *gin.Context, request interface{}) (response interface{}, err error) {
rsp:=&course.TopicResponse{Result:make([]*course.CourseTopic,0)}
err=c.GetTopic(context,request.(*course.TopicRequest),rsp)
return rsp,err
}
}
//这个函数的作用是怎么处理请求
func CourseTopicList_Request() gin_.EncodeRequestFunc{
return func(context *gin.Context) (i interface{}, e error) {
bReq:=&course.TopicRequest{}
err:=context.BindUri(bReq) //使用的是query 参数
if err!=nil{
return nil,err
}
return bReq,nil
}
}
\ No newline at end of file
//func init() {
// courseService:=service.NewCourseTopicServiceImpl()
// gin_.NewBuilder().WithService(courseService).
// WithMiddleware(Check_Middleware()).
// WithEndpoint(CourseTopicList_Endpoint(courseService)).
// WithRequest(CourseTopicList_Request()).
// WithResponse(Course_Response()).Build("/topic/:cid","GET")
//}
//
//func CourseTopicList_Endpoint(c *service.CourseTopicServiceImpl) gin_.Endpoint {
// return func(context *gin.Context, request interface{}) (response interface{}, err error) {
// rsp:=&course.TopicResponse{Result:make([]*course.CourseTopic,0)}
// err=c.GetTopic(context,request.(*course.TopicRequest),rsp)
// return rsp,err
// }
//}
////这个函数的作用是怎么处理请求
//func CourseTopicList_Request() gin_.EncodeRequestFunc{
// return func(context *gin.Context) (i interface{}, e error) {
// bReq:=&course.TopicRequest{}
// err:=context.BindUri(bReq) //使用的是query 参数
// if err!=nil{
// return nil,err
// }
// return bReq,nil
// }
//}
\ No newline at end of file
package dao
import (
"github.com/jinzhu/gorm"
"search_server/pkg/vars"
"search_server/pkg/mysql"
)
func GetCourseList() *gorm.DB {
return mysql.GetDB().Table(vars.Table_CourseMain).
Order("course_id desc").Limit(3)
}
const course_list = "select * from course_main order by course_id desc limit ?"
func GetCourseListBySql(args ...interface{}) *gorm.DB {
return mysql.GetDB().Raw(course_list, args...)
}
func GetCourseDetail(course_id int) *gorm.DB {
return mysql.GetDB().Table(vars.Table_CourseMain).Where("course_id=?", course_id)
}
//取计数表
func GetCourseCounts(course_id int) *gorm.DB {
return mysql.GetDB().Table(vars.Table_CourseCounts).Where("course_id=?", course_id)
}
//func GetCourseList() *gorm.DB {
// return mysql.GetDB().Table(vars.Table_CourseMain).
// Order("course_id desc").Limit(3)
//}
//
//const course_list = "select * from course_main order by course_id desc limit ?"
//
//func GetCourseListBySql(args ...interface{}) *gorm.DB {
// return mysql.GetDB().Raw(course_list, args...)
//}
//func GetCourseDetail(course_id int) *gorm.DB {
// return mysql.GetDB().Table(vars.Table_CourseMain).Where("course_id=?", course_id)
//}
//
////取计数表
//func GetCourseCounts(course_id int) *gorm.DB {
// return mysql.GetDB().Table(vars.Table_CourseCounts).Where("course_id=?", course_id)
//}
......@@ -35,6 +35,7 @@ require (
github.com/tidwall/gjson v1.6.0
github.com/urfave/cli v1.22.4 // indirect
github.com/uniplaces/carbon v0.1.6
go.etcd.io/bbolt v1.3.4
go.uber.org/zap v1.14.1 // indirect
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 // indirect
golang.org/x/sys v0.0.0-20200523222454-059865788121 // indirect
......
......@@ -11,7 +11,8 @@ var (
func SetUp(path string) (err error) {
//引入多个文件
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/search.ini", path+"/redis_key.ini", path+"/rabmq_key.ini")
Cfg, err = ini.LooseLoad(path+"/config.ini", path+"/search.ini", path+"/redis_key.ini", path+"/rabmq_key.ini", path+"/database.ini",
path+"/redis_config.ini")
return
}
......
package config
type BaseDatabase struct {
UserName string
Password string
Host string
Database string
MaxIdleCons int
MaxOpenCons int
Prefix string
}
//多数据库配置
func BuildDatabaseList() (DatabaseList map[string]BaseDatabase) {
return map[string]BaseDatabase{
"mysql": {
UserName: Get("mysql.user_name").String(),
Password: Get("mysql.password").String(),
Host: Get("mysql.host").String(),
Database: Get("mysql.database").String(),
Prefix: Get("mysql.prefix").String(),
},
"bom": {
UserName: Get("bom.user_name").String(),
Password: Get("bom.password").String(),
Host: Get("bom.host").String(),
Database: Get("bom.database").String(),
Prefix: Get("mysql.prefix").String(),
},
}
}
package config
type RedisDatabase struct {
Password string
Host string
Database string
MaxIdle string
MaxActive string
MaxAIdleTimeoutctive string
Prefix string
}
//多数据库配置
func BuildRedisConfgs() (RedisDatabaseMap map[string]RedisDatabase) {
return map[string]RedisDatabase{
"search_read": {
Host: Get("default_redis_read.host").String(),
Password: Get("default_redis_read.password").String(),
MaxIdle: Get("default_redis_read.max_idle").String(),
MaxActive: Get("default_redis_read.max_active").String(),
},
"search_write": {
Host: Get("default_redis_write.host").String(),
Password: Get("default_redis_write.password").String(),
MaxIdle: Get("default_redis_read.max_idle").String(),
MaxActive: Get("default_redis_read.max_active").String(),
},
"spu_read": {
Host: Get("default_redis_read.host").String(),
Password: Get("default_redis_read.password").String(),
MaxIdle: Get("default_redis_read.max_idle").String(),
MaxActive: Get("default_redis_read.max_active").String(),
},
"spu_write": {
Host: Get("default_redis_write.host").String(),
Password: Get("default_redis_write.password").String(),
MaxIdle: Get("default_redis_read.max_idle").String(),
MaxActive: Get("default_redis_read.max_active").String(),
},
"api_read": {
Host: Get("api_redis_read.host").String(),
Password: Get("api_redis_read.password").String(),
MaxIdle: Get("api_redis_read.max_idle").String(),
MaxActive: Get("api_redis_read.max_active").String(),
},
"api_write": {
Host: Get("api_redis_write.host").String(),
Password: Get("api_redis_write.password").String(),
MaxIdle: Get("api_redis_write.max_idle").String(),
MaxActive: Get("api_redis_write.max_active").String(),
},
}
}
......@@ -7,24 +7,35 @@ import (
"time"
)
type IchuntRedis struct {
RedisList map[string]*redis.Pool
Current *redis.Pool
}
func(this *IchuntRedis) Connection(connection string) (*IchuntRedis){
this.Current = this.RedisList[connection]
return this
}
var writeConn, readConn *redis.Pool
func Setup() (err error) {
writeHost := config.Get("redis.write_host").String()
readHost := config.Get("redis.read_host").String()
writePassword := config.Get("redis.write_password").String()
readPassword := config.Get("redis.read_password").String()
writeConn, err = getConn(writeHost, writePassword)
if err != nil {
return
ichuntRedis := &IchuntRedis{}
ichuntRedis.RedisList = make(map[string]*redis.Pool,0)
RedisDatabaseMap := config.BuildRedisConfgs()
for redisKey,redisConfig := range RedisDatabaseMap{
ichuntRedis.RedisList[redisKey],err = getConn(redisConfig.Host, redisConfig.Password)
if err != nil{
panic(err)
}
readConn, err = getConn(readHost, readPassword)
if err != nil {
return
}
return nil
}
func getConn(writeHost, password string) (pool *redis.Pool, err error) {
maxIdle, _ := config.Get("redis.max_idle").Int()
maxActive, _ := config.Get("redis.max_active").Int()
......@@ -54,8 +65,8 @@ func getConn(writeHost, password string) (pool *redis.Pool, err error) {
//最基础的键值操作
func Set(key string, data interface{}) error {
conn := writeConn.Get()
func (this *IchuntRedis) Set(key string, data interface{}) error {
conn := this.Current.Get()
defer conn.Close()
value, err := json.Marshal(data)
......@@ -72,8 +83,8 @@ func Set(key string, data interface{}) error {
}
//Redis Setnx(SET if Not eXists) 命令在指定的 key 不存在时,为 key 设置指定的值。
func Setnx(key string, data interface{}) (bool,error) {
conn := writeConn.Get()
func(this *IchuntRedis) Setnx(key string, data interface{}) error {
conn := this.Current.Get()
defer conn.Close()
value, err := json.Marshal(data)
if err != nil {
......@@ -89,8 +100,8 @@ func EXP(key string, ttl int) (bool,error) {
return redis.Bool(conn.Do("EXP", key, ttl))
}
func Exists(key string) bool {
conn := readConn.Get()
func(this *IchuntRedis) Exists(key string) bool {
conn := this.Current.Get()
defer conn.Close()
exists, err := redis.Bool(conn.Do("EXISTS", key))
if err != nil {
......@@ -100,8 +111,8 @@ func Exists(key string) bool {
return exists
}
func Get(key string) (interface{}, error) {
conn := readConn.Get()
func(this *IchuntRedis) Get(key string) (interface{}, error) {
conn := this.Current.Get()
defer conn.Close()
reply, err := conn.Do("GET", key)
......@@ -112,8 +123,8 @@ func Get(key string) (interface{}, error) {
return reply, nil
}
func Delete(key string) (bool, error) {
conn := writeConn.Get()
func(this *IchuntRedis) Delete(key string) (bool, error) {
conn := this.Current.Get()
defer conn.Close()
return redis.Bool(conn.Do("DEL", key))
......@@ -121,8 +132,8 @@ func Delete(key string) (bool, error) {
//哈希操作
func HSet(key string, k interface{}, data interface{}) error {
conn := writeConn.Get()
func(this *IchuntRedis) HSet(key string, k interface{}, data interface{}) error {
conn := this.Current.Get()
defer conn.Close()
value, err := json.Marshal(data)
......@@ -138,8 +149,8 @@ func HSet(key string, k interface{}, data interface{}) error {
return nil
}
func HGet(key string, k interface{}) (interface{}, error) {
conn := readConn.Get()
func(this *IchuntRedis) HGet(key string, k interface{}) (interface{}, error) {
conn := this.Current.Get()
defer conn.Close()
reply, err := conn.Do("HGET", key, k)
......@@ -150,9 +161,10 @@ func HGet(key string, k interface{}) (interface{}, error) {
return reply, nil
}
func HDelete(key string, k interface{}) (bool, error) {
conn := writeConn.Get()
func(this *IchuntRedis) HDelete(key string, k interface{}) (bool, error) {
conn := this.Current.Get()
defer conn.Close()
return redis.Bool(conn.Do("HDEL", key, k))
}
......@@ -9,28 +9,51 @@ import (
)
//mysql相关
var mysqlDb *gorm.DB
var mysqlDb, bomDb *gorm.DB
var DatabaseConMap = map[string]*gorm.DB{
"mysql": mysqlDb,
"bom": bomDb,
}
func Setup() error {
DatabaseList := config.BuildDatabaseList()
var err error
userName := config.Get("database.user_name").String()
password := config.Get("database.password").String()
host := config.Get("database.host").String()
database := config.Get("database.database").String()
mysqlDb, err = gorm.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8&parseTime=True&loc=Local",
//循环生成数据库链接
for conName, db := range DatabaseList {
userName := db.UserName
password := db.Password
host := db.Host
database := db.Database
if db.Prefix != "" {
gorm.DefaultTableNameHandler = func(DB *gorm.DB, defaultTableName string) string {
return db.Prefix + defaultTableName
}
}
DatabaseConMap[conName], err = gorm.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s:3306)/%s?charset=utf8&parseTime=True&loc=Local",
userName, password, host, database))
if err != nil {
mysqlDb = nil
return e.NewFatalError(err.Error()) //这里返回致命异常
}
mysqlDb.SingularTable(true)
mysqlDb.DB().SetMaxIdleConns(10)
mysqlDb.DB().SetMaxOpenConns(100)
mysqlDb.LogMode(true)
DatabaseConMap[conName].SingularTable(true)
if db.MaxIdleCons == 0 {
db.MaxIdleCons = 10
}
if db.MaxOpenCons == 0 {
db.MaxOpenCons = 100
}
DatabaseConMap[conName].DB().SetMaxIdleConns(db.MaxIdleCons)
DatabaseConMap[conName].DB().SetMaxOpenConns(db.MaxOpenCons)
if config.Get("gorm.mode").String() == "debug" {
DatabaseConMap[conName].LogMode(true)
}
}
return nil
}
func GetDB() *gorm.DB {
return mysqlDb
func Connection(conName string) *gorm.DB {
return DatabaseConMap[conName]
}
package service
import (
"context"
"search_server/dao"
. "search_server/protopb/course"
)
......@@ -12,32 +10,32 @@ func NewCourseModel(id int32, name string) *CourseModel {
type CourseServiceImpl struct{}
func (this *CourseServiceImpl) ListForTop(ctx context.Context, req *ListRequest, rsp *ListResponse) error {
course := make([]*CourseModel, 0)
err := dao.GetCourseListBySql(req.Size).Find(&course).Error
if err != nil {
return err
}
rsp.Result = course
return nil
}
func (this *CourseServiceImpl) GetDetail(ctx context.Context, req *DetailRequest, rsp *DetailResponse) error {
//只取课程详细
if req.FetchType == 0 || req.FetchType == 1 || req.FetchType == 3 {
if err := dao.GetCourseDetail(int(req.CourseId)).Find(rsp.Course).Error; err != nil {
return err
}
}
//只取计数表详细
if req.FetchType == 2 || req.FetchType == 3 {
if err := dao.GetCourseCounts(int(req.CourseId)).Find(&rsp.Counts).Error; err != nil {
return err
}
}
return nil
}
//func (this *CourseServiceImpl) ListForTop(ctx context.Context, req *ListRequest, rsp *ListResponse) error {
// course := make([]*CourseModel, 0)
// err := dao.GetCourseListBySql(req.Size).Find(&course).Error
// if err != nil {
// return err
// }
// rsp.Result = course
// return nil
//}
//func (this *CourseServiceImpl) GetDetail(ctx context.Context, req *DetailRequest, rsp *DetailResponse) error {
// //只取课程详细
// if req.FetchType == 0 || req.FetchType == 1 || req.FetchType == 3 {
// if err := dao.GetCourseDetail(int(req.CourseId)).Find(rsp.Course).Error; err != nil {
// return err
// }
// }
// //只取计数表详细
// if req.FetchType == 2 || req.FetchType == 3 {
// if err := dao.GetCourseCounts(int(req.CourseId)).Find(&rsp.Counts).Error; err != nil {
// return err
// }
// }
//
// return nil
//
//}
func NewCourseServiceImpl() *CourseServiceImpl {
return &CourseServiceImpl{}
......
package service
import (
"context"
. "search_server/protopb/course"
"search_server/pkg/mysql"
)
type CourseTopicServiceImpl struct{}
func (this *CourseTopicServiceImpl) GetTopic(ctx context.Context, in *TopicRequest, out *TopicResponse) error {
if err := mysql.GetDB().Table("course_topic").Find(&out.Result).Error; err != nil {
return err
}
return nil
}
func NewCourseTopicServiceImpl() *CourseTopicServiceImpl {
return &CourseTopicServiceImpl{}
}
//func (this *CourseTopicServiceImpl) GetTopic(ctx context.Context, in *TopicRequest, out *TopicResponse) error {
// if err := mysql.GetDB().Table("course_topic").Find(&out.Result).Error; err != nil {
// return err
// }
// return nil
//}
//func NewCourseTopicServiceImpl() *CourseTopicServiceImpl {
// return &CourseTopicServiceImpl{}
//}
......@@ -4,7 +4,7 @@ import (
"flag"
"fmt"
"search_server/boot"
"search_server/pkg/config"
"search_server/pkg/mysql"
)
func main() {
......@@ -14,13 +14,20 @@ func main() {
if err := boot.Boot(path); err != nil {
fmt.Println(err)
}
//fmt.Println(model.GetExcludeBrandIds(1))
fmt.Println(config.GetSectionValues("supplier_all"))
fmt.Println(config.Cfg.Section("xxx").Key("xxx"))
//client := client.
//c := course.NewCourseService("go.micro.api.jtthink.course", client)
//course_rsp, _ := c.ListForTop(context.TODO(), &course.ListRequest{Size: 10})
//fmt.Println(course_rsp.Result)
type Result struct {
BinId int `json:"bin_id"`
Bin string `json:"bin"`
}
var result []Result
mysql.Connection("bom").Raw("SELECT * FROM lie_bin").Scan(&result)
//mysql.Connection()("bom").Table("bin").Find(&result)
fmt.Println(result)
type Result2 struct {
BusinessName string `json:"business_name"`
}
var result2 []Result2
mysql.Connection("mysql").Raw("SELECT * FROM lie_business").Scan(&result2)
//mysql.GetDB("bom").Table("bin").Find(&result)
fmt.Println(result2)
}
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