Skip to content

Commit eb6175b

Browse files
author
奇淼(piexlmax
authored
Merge pull request #541 from flipped-aurora/gva_gormv2_dev
Gva gormv2 dev
2 parents 93b373d + 74cff90 commit eb6175b

File tree

11 files changed

+62
-25
lines changed

11 files changed

+62
-25
lines changed

server/api/v1/sys_authority.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"gin-vue-admin/model/response"
88
"gin-vue-admin/service"
99
"gin-vue-admin/utils"
10+
1011
"github.com/gin-gonic/gin"
1112
"go.uber.org/zap"
1213
)
@@ -30,6 +31,7 @@ func CreateAuthority(c *gin.Context) {
3031
global.GVA_LOG.Error("创建失败!", zap.Any("err", err))
3132
response.FailWithMessage("创建失败"+err.Error(), c)
3233
} else {
34+
_ = service.UpdateCasbin(authority.AuthorityId, request.DefaultCasbin())
3335
response.OkWithDetailed(response.SysAuthorityResponse{Authority: authBack}, "创建成功", c)
3436
}
3537
}

server/api/v1/sys_menu.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ func GetMenu(c *gin.Context) {
2424
global.GVA_LOG.Error("获取失败!", zap.Any("err", err))
2525
response.FailWithMessage("获取失败", c)
2626
} else {
27+
if menus == nil {
28+
menus = []model.SysMenu{}
29+
}
2730
response.OkWithDetailed(response.SysMenusResponse{Menus: menus}, "获取成功", c)
2831
}
2932
}

server/model/request/sys_casbin.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,7 @@ type CasbinInReceive struct {
1111
AuthorityId string `json:"authorityId"` // 权限id
1212
CasbinInfos []CasbinInfo `json:"casbinInfos"`
1313
}
14+
15+
func DefaultCasbin() []CasbinInfo {
16+
return []CasbinInfo{{Path: "/menu/getMenu", Method: "POST"}, {Path: "/jwt/jsonInBlacklist", Method: "POST"}}
17+
}

server/model/request/sys_menu.go

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
11
package request
22

3-
import "gin-vue-admin/model"
3+
import (
4+
"gin-vue-admin/global"
5+
"gin-vue-admin/model"
6+
)
47

58
// Add menu authority info structure
69
type AddMenuAuthorityInfo struct {
710
Menus []model.SysBaseMenu
811
AuthorityId string // 角色ID
912
}
13+
14+
func DefaultMenu() []model.SysBaseMenu {
15+
return []model.SysBaseMenu{{
16+
GVA_MODEL: global.GVA_MODEL{ID: 1},
17+
ParentId: "0",
18+
Path: "dashboard",
19+
Name: "dashboard",
20+
Component: "view/dashboard/index.vue",
21+
Sort: 1,
22+
Meta: model.Meta{
23+
Title: "仪表盘",
24+
Icon: "setting",
25+
},
26+
}}
27+
}

server/utils/directory.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ func CreateDir(dirs ...string) (err error) {
3737
}
3838
if !exist {
3939
global.GVA_LOG.Debug("create directory" + v)
40-
err = os.MkdirAll(v, os.ModePerm)
41-
if err != nil {
40+
if err := os.MkdirAll(v, os.ModePerm); err != nil {
4241
global.GVA_LOG.Error("create directory"+v, zap.Any(" error:", err))
42+
return err
4343
}
4444
}
4545
}

web/build.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = {
77
/**
88
* 如果设置path属性, { name: 'vue', scope: 'Vue', path: '/vue/2.6.9/vue.min.js' } 即编译出来以[baseCdnUrl][path]
99
* 否则自动拼写 [baseCdnUrl]/[name]/[version]/[name].min.js
10-
* */
10+
*/
1111
{ name: 'vue', scope: 'Vue' },
1212
{ name: 'vue-router', scope: 'VueRouter' },
1313
{ name: 'vuex', scope: 'Vuex' },

web/src/core/config.js

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,10 @@
1-
/*
2-
* 网站配置文件
3-
* */
4-
5-
6-
7-
const config ={
8-
9-
appName : 'Gin-Vue-Admin',
10-
11-
appLogo : 'https://www.gin-vue-admin.com/img/logo.png'
1+
/**
2+
* 网站配置文件
3+
*/
124

5+
const config = {
6+
appName: 'Gin-Vue-Admin',
7+
appLogo: 'https://www.gin-vue-admin.com/img/logo.png'
138
}
149

15-
export default config
10+
export default config

web/src/core/gin-vue-admin.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import APlayer from '@moefe/vue-aplayer'
1010
import '../../node_modules/timeline-vuejs/dist/timeline-vuejs.css'
1111
// 路由守卫
1212
import Bus from '@/utils/bus'
13-
//加载网站配置文件夹
13+
// 加载网站配置文件夹
1414
import config from './config'
1515
Vue.prototype.$GIN_VUE_ADMIN = config
16-
console.log(config)
1716
Vue.use(Bus)
1817
Vue.use(APlayer, {
1918
defaultCover: 'https://github.com/u3u.png',

web/src/utils/request.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,12 @@ service.interceptors.response.use(
8080
},
8181
error => {
8282
closeLoading()
83-
MessageBox.confirm(`检测到接口错误${error},此类错误内容常见于后台panic,如果影响您正常使用可强制登出清理缓存`, '接口报错', {
83+
MessageBox.confirm(`
84+
<p>检测到接口错误${error}</p>
85+
<p>错误码500:此类错误内容常见于后台panic,如果影响您正常使用可强制登出清理缓存</p>
86+
<p>错误码404:此类错误多为接口未注册(或未重启)或者请求路径(方法)与api路径(方法)不符</p>
87+
`, '接口报错', {
88+
dangerouslyUseHTMLString: true,
8489
distinguishCancelAndClose: true,
8590
confirmButtonText: '清理缓存',
8691
cancelButtonText: '取消'

web/src/view/init/index.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
<p class="init_p">1.您需有用一定的VUE和golang基础</p>
99
<p class="init_p">2.请您确认是否已经阅读过官方文档</p>
1010
<p class="init_p">3.请您确认是否了解后续的配置流程</p>
11+
<p class="init_p">注:开发组不为文档中书写过的内容提供无偿服务</p>
1112
<p class="init_btn">
1213
<el-button type="primary" @click="goDoc">
1314
阅读文档

0 commit comments

Comments
 (0)