Here are some ideas to get you started:
- 🌱 Tech stack: Go & Rust & C++ & Python & React & Vue.
- 😄 Pronouns: Stay hungry,stay foolish.
A lightweight, flexible, elegant and full-featured RBAC scaffolding based on GIN + GORM 2.0 + Casbin 2.0 + Wire DI.
Home Page: http://101.42.232.163:8040
License: Apache License 2.0
能把关于casbin 相关的Mysql数据库表结构和数据文件倒出来吗?非常感谢。
github.com/LyricTian/gin-admin/src/web/context
正在完整的阅读你的代码,学习,发现这里写重复了
if v := o.SwaggerDir; v != "" {
cfg.Swagger = v
}
if v := o.SwaggerDir; v != "" {
cfg.Swagger = v
}
请求接口Header 不带token 直接绕过验证
例如/api/v1/users
go run main.go
panic: 加载casbin策略数据发生错误: Error 1146: Table 'goadmin.go_role' doesn't exist
按照社区提供的结构的话。swagger接口应该放到api下
我对比着写了一个代码生成器,来生成业务代码,感觉不是很理想
选择角色时获取的用户列表不正确
internal/app/model/impl/gorm/internal/model/m_user.go 47行 db = db.Where("record_id IN (?) ",subQuery)
IN后面多了一对括号,导致生成的查询语句执行结果与预期不符,去了括号就正确了
schema和entity是不是有点重复了,转来转去感觉有点复杂了。
package(my-shop/internal/app/ginadmin/routers/api/ctl) does not existed
// GetRootUser 获取root用户
func GetRootUser() *schema.User {
user := config.Global().Root
return &schema.User{
RecordID: user.UserName,
UserName: user.UserName,
RealName: user.RealName,
Password: util.MD5HashString(user.Password),//这里的密码是进行过加密处理的
}
}
func (a *Login) Verify(ctx context.Context, userName, password string) (*schema.User, error) {
// 检查是否是超级用户
root := GetRootUser()
if userName == root.UserName && root.Password == password {//而这里的password却没有进行加密再比较
return root, nil
}
result, err := a.UserModel.Query(ctx, schema.UserQueryParam{
UserName: userName,
})
刚go 初学,看了半天,没找到。
我是go语言小白,请教,以下问题如何解决呢?
我用了goproxy.io 代理
$ go build go: finding github.com/LyricTian latest
go: finding github.com latest
can't load package: package github.com/LyricTian/gin-admin: unknown import path
"github.com/LyricTian/gin-admin": cannot find module providing package github.com/LyricTian/gin-dmin
不用代理,则提示:
$ go build
can't load package: package github.com/LyricTian/gin-admin: unknown import path
"github.com/LyricTian/gin-admin": cannot find module providing package github.com/LyricTian /gin-dmin
谢谢
➜ gin-admin git:(master) go run cmd/server/main.go -c ./configs/config.toml -m ./configs/model.conf -swagger ./docs/swagger -menu ./configs/menu.json
stat cmd/server/main.go: no such file or directory
我是这么做的.
`
gin-admin-cli new -m -d ${GOPATH}/src/gin-admin -p gin-admin
cd ${GOPATH}/src/gin-admin `
make start
`
build github.com/LyricTian/gin-admin/cmd/server: cannot load gin-admin/internal/app: cannot find module providing package gin-admin/internal/app
make: *** [start] Error 1
`
根据您的项目修改了一些web服务器,但最近频繁出错重启进程,想请教一下 项目里面的日志跟踪
和服务监控 大概怎么使用? 能否给一些相关知识文档.因为服务重启了会丢一些内存中的数据,很头疼.
用的是net/http 包 不是用的gin吧
首先感谢开源,下面是一些小建议
1、QueryParam可以用gin的bind绑定整个实体,不用一个个属性赋值
2、QueryParam可以继承分页,不用每次调用方法GetPaginationParam
3、swagger不指定host
4、校验不通过,将详细的错误返回
5、实体增加required (cli)
As you may know, Casbin have users from different countries. Most of them use English. I think it will be better for them to use this project if it provides English UI and documentation.
live project url not working (http://gin-admin.tiannianshou.com) showing blank screen
I think Vue or React is more popular as a front-end framework than Ant Design. The users of your project will enlarge if you use those popular frameworks.
首先感谢作者开源。目前发现阅读起来太困难。代码结构目录层级太多。梳理逻辑关系上手太困难。
配置如下
# 跨域请求
[cors]
# 是否启用
enable = true
# 允许跨域请求的域名列表(*表示全部允许)
allow_origins = ["*"]
# 允许跨域请求的请求方式列表
allow_methods = ["GET","POST","PUT","DELETE","PATCH", "OPTIONS"]
# 允许客户端与跨域请求一起使用的非简单标头的列表
allow_headers = []
# 请求是否可以包含cookie,HTTP身份验证或客户端SSL证书等用户凭据
allow_credentials = true
# 可以缓存预检请求结果的时间(以秒为单位)
max_age = 7200
response headers 返回如下
Allow: GET,POST,OPTIONS,HEAD
Connection: Keep-Alive
Content-Length: 0
Date: Wed, 22 May 2019 15:27:55 GMT
Keep-Alive: timeout=5, max=100
Server: Apache/2.4.38 (Ubuntu)
我试过不开启和开启跨域配置 response headers 返回不变, 感觉像跨域配置没生效,请问是不是我哪里设置的不对?
ginplus.go line35 parent = logger.NewTraceIDContext(parent, GetTraceID(c)) 中的 GetTraceID(c)这次调用为冗余操作
func NewContext(c *gin.Context) context.Context {
parent := context.Background()
if v := GetTraceID(c); v != "" {
parent = icontext.NewTraceID(parent, v)
parent = logger.NewTraceIDContext(parent, GetTraceID(c))
}
if v := GetUserID(c); v != "" {
parent = icontext.NewUserID(parent, v)
parent = logger.NewUserIDContext(parent, v)
}
return parent
}
首先感谢作者开源;另外,想请教下为什么这里要这么多层ctx(在只有traceID和userID且均为已知的情况下)?
RT
演示站用户管理里面的搜索查询不生效
没出错,我理解错了
go get -v github.com/LyricTian/gin-admin/cmd/server
go: finding github.com/facebookgo/inject latest
go: finding github.com/LyricTian/retry latest
go: finding github.com/facebookgo/structtag latest
go: github.com/LyricTian/gin-admin/cmd/server imports
github.com/LyricTian/gin-admin/src imports
github.com/LyricTian/logrus-mysql-hook imports
github.com/Sirupsen/logrus: github.com/Sirupsen/[email protected]: parsing go.mod:
module declares its path as: github.com/sirupsen/logrus
but was required as: github.com/Sirupsen/logrus
更改完配置文件后,可以检测到文件变化,并且重新编译。
但是结束不掉原来的进程文件,导致端口bind失败。。
请问如何解决?
Lyric您好,我看您在4.0版引入了依赖注入的特性,我以前只是听做Java的朋友说过,但是从来没有用过。今天在重构4.0版里看见了这个特性,在阅读代码的时候发现没有以前版本的可读性高了,很多地方不理解。您能说说开发思路吗?引入了依赖注入对项目的优势是什么?谢谢
b_user.go 文件 LoadPolicy这个方法的AddRoleForUser一直没有执行 item.Roles查出来是一个nil
fatal error: concurrent map writes 导致崩溃
go build -o server
../../src/web/router/r_mw_recover.go:29:17: too many arguments in call to logger.System
have (string, string)
want ("context".Context)
../../src/web/router/r_mw_recover.go:36:5: ctx.Next undefined (type *"github.com/LyricTian/gin-admin/src/web/context".Context has no field or method Next)
`
$ make start
build cache is required, but could not be located: GOCACHE is not defined and %L ocalAppData% is not defined
make: *** [Makefile:15: start] Error 1
`
执行Makefile出错,但是我看了,这个编译代码,怎么会提示这个错误呢
下面的代码全部来自internal/app/model/impl/gorm/internal/entity/e_demo.go
// Demo demo实体
type Demo struct {
Model
RecordID string `gorm:"column:record_id;size:36;index;"` // 记录内码
Code *string `gorm:"column:code;size:50;index;"` // 编号
Name *string `gorm:"column:name;size:100;index;"` // 名称
Memo *string `gorm:"column:memo;size:200;"` // 备注
Status *int `gorm:"column:status;index;"` // 状态(1:启用 2:停用)
Creator *string `gorm:"column:creator;size:36;"` // 创建者
}
这里的 Code Name Memo是指针有什么其他考虑吗? 没理解这里是怎么考虑,为什么是指针.
这里用指针后,当修改demo实体的数据时,会把空值也覆盖掉,比如说修改用户信息,如果不填写新的用户密码,就会把密码一栏赋值为空,因为gorm只会判断是否是空值,空值不更新,非空值进行更新,改成指针后,就算指针指向的字符串是空值,也会把指针判断为非空值,因为指针的空值是null,这样就会把数据库原来的值覆盖掉,
我觉得这里应该不用指针,比如说用户的密码字段,因为没填数据的时候就应该不更改,而不是改为空
如果这里使用指针仅仅是因为想要提高效率,降低内存使用,我觉得没必要,因为Demo这个结构体实例化后,只要每次结构体传参数的时候都用指针就可以了,不会增加内存,因为传递的只是一个指针的空间,并没有整个结构体一起传参,比如说:
func (a Demo) String() string {
return toString(a)
}
// TableName 表名
func (a Demo) TableName() string {
return a.Model.TableName("demo")
}
改成下面这种,直接使用指针就可以
func (a *Demo) String() string {
return toString(a)
}
// TableName 表名
func (a *Demo) TableName() string {
return a.Model.TableName("demo")
}
$ ./server -c ../../config/config.toml -m ../../config/model.conf
开始运行服务,服务版本号:1.2.0-dev
INFO[0000] 服务已运行在[test]模式下,运行版本:1.2.0-dev,进程号:8878 span_function= span_id=61b97f94-b06d-418e-8f1f-5882e8851c0e span_title= started_at="2019-01-16 10:47:40.631298875 +0800 CST m=+0.105783090" trace_id=cdb4c6b1-f010-4ca3-8d17-d721afe353ba user_id=
INFO[0000] HTTP服务开始启动,监听地址为:[127.0.0.1:8086] span_function= span_id=1b38453f-12c3-43cb-bd02-6d63b484a4cf span_title= started_at="2019-01-16 10:47:40.63526605 +0800 CST m=+0.109750342" trace_id=cdb4c6b1-f010-4ca3-8d17-d721afe353ba user_id=
WARN[0009] [请求错误] 资源不存在
您好,在看您的代码的时候发现您仓库中github.com/LyricTian/captcha 这个代码和您vendor中的github.com/LyricTian/captcha 并不是一致的,可以更改成一致的么,还是说出于其他考虑没有更改,我这边直接用的go module 做的包管理,所以直接是go get github.com/LyricTian/captcha 但是包里是缺少redis_options.go 文件的
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.