Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
飞一样的人
gin-vue-admin
提交
b782321e
G
gin-vue-admin
项目概览
飞一样的人
/
gin-vue-admin
与 Fork 源项目一致
Fork自
FLIPPED-AURORA / gin-vue-admin
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gin-vue-admin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b782321e
编写于
2月 25, 2020
作者:
Mr.奇淼(
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
资源权限功能示例
上级
c92b348d
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
216 addition
and
2 deletion
+216
-2
QMPlusServer/controller/api/exa_customer.go
QMPlusServer/controller/api/exa_customer.go
+119
-0
QMPlusServer/init/initRouter/init_router.go
QMPlusServer/init/initRouter/init_router.go
+1
-0
QMPlusServer/init/registTable/regist_table.go
QMPlusServer/init/registTable/regist_table.go
+1
-0
QMPlusServer/model/dbModel/exa_customer.go
QMPlusServer/model/dbModel/exa_customer.go
+67
-0
QMPlusServer/model/sysModel/sys_api.go
QMPlusServer/model/sysModel/sys_api.go
+6
-1
QMPlusServer/model/sysModel/sys_authority.go
QMPlusServer/model/sysModel/sys_authority.go
+5
-0
QMPlusServer/router/exp_customer.go
QMPlusServer/router/exp_customer.go
+17
-0
QMPlusVuePage/src/view/superAdmin/api/api.vue
QMPlusVuePage/src/view/superAdmin/api/api.vue
+0
-1
未找到文件。
QMPlusServer/controller/api/exa_customer.go
浏览文件 @
b782321e
package
api
import
(
"fmt"
"gin-vue-admin/controller/servers"
"gin-vue-admin/middleware"
"gin-vue-admin/model/dbModel"
"gin-vue-admin/model/modelInterface"
"github.com/gin-gonic/gin"
)
// @Tags SysApi
// @Summary 创建客户
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body dbModel.ExaCustomer true "创建客户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/createExaCustomer [post]
func
CreateExaCustomer
(
c
*
gin
.
Context
)
{
var
cu
dbModel
.
ExaCustomer
_
=
c
.
BindJSON
(
&
cu
)
claims
,
_
:=
c
.
Get
(
"claims"
)
waitUse
:=
claims
.
(
*
middleware
.
CustomClaims
)
cu
.
SysUserID
=
waitUse
.
ID
cu
.
SysUserAuthorityID
=
waitUse
.
AuthorityId
err
:=
cu
.
CreateExaCustomer
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags SysApi
// @Summary 删除客户
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body dbModel.ExaCustomer true "删除客户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/deleteExaCustomer [post]
func
DeleteExaCustomer
(
c
*
gin
.
Context
)
{
var
cu
dbModel
.
ExaCustomer
_
=
c
.
BindJSON
(
&
cu
)
err
:=
cu
.
DeleteExaCustomer
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags SysApi
// @Summary 更新客户信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body dbModel.ExaCustomer true "创建客户"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/updataExaCustomer [post]
func
UpdataExaCustomer
(
c
*
gin
.
Context
)
{
var
cu
dbModel
.
ExaCustomer
_
=
c
.
BindJSON
(
&
cu
)
err
:=
cu
.
UpdataExaCustomer
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{})
}
}
// @Tags SysApi
// @Summary 获取单一客户信息
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body dbModel.ExaCustomer true "获取单一客户信息"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/getExaCustomer [post]
func
GetExaCustomer
(
c
*
gin
.
Context
)
{
var
cu
dbModel
.
ExaCustomer
_
=
c
.
BindJSON
(
&
cu
)
err
,
customer
:=
cu
.
GetExaCustomer
()
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{
"customer"
:
customer
,
})
}
}
// @Tags SysApi
// @Summary 获取权限客户列表
// @Security ApiKeyAuth
// @accept application/json
// @Produce application/json
// @Param data body modelInterface.PageInfo true "获取权限客户列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /customer/getExaCustomerList [post]
func
GetExaCustomerList
(
c
*
gin
.
Context
)
{
claims
,
_
:=
c
.
Get
(
"claims"
)
waitUse
:=
claims
.
(
*
middleware
.
CustomClaims
)
var
cu
dbModel
.
ExaCustomer
cu
.
SysUserAuthorityID
=
waitUse
.
AuthorityId
var
pageInfo
modelInterface
.
PageInfo
_
=
c
.
BindJSON
(
&
pageInfo
)
err
,
customerList
,
total
:=
cu
.
GetInfoList
(
pageInfo
)
if
err
!=
nil
{
servers
.
ReportFormat
(
c
,
false
,
fmt
.
Sprintf
(
"创建失败:%v"
,
err
),
gin
.
H
{})
}
else
{
servers
.
ReportFormat
(
c
,
true
,
"创建成功"
,
gin
.
H
{
"customer"
:
customerList
,
"total"
:
total
,
"page"
:
pageInfo
.
Page
,
"pageSize"
:
pageInfo
.
PageSize
,
})
}
}
\ No newline at end of file
QMPlusServer/init/initRouter/init_router.go
浏览文件 @
b782321e
...
...
@@ -28,5 +28,6 @@ func InitRouter() *gin.Engine {
router
.
InitCasbinRouter
(
ApiGroup
)
// 权限相关路由
router
.
InitJwtRouter
(
ApiGroup
)
// jwt相关路由
router
.
InitSystemRouter
(
ApiGroup
)
// system相关路由
router
.
InitCustomerRouter
(
ApiGroup
)
// 客户路由
return
Router
}
QMPlusServer/init/registTable/regist_table.go
浏览文件 @
b782321e
...
...
@@ -19,5 +19,6 @@ func RegistTable(db *gorm.DB) {
dbModel
.
ExaFileUploadAndDownload
{},
dbModel
.
ExaFile
{},
dbModel
.
ExaFileChunk
{},
dbModel
.
ExaCustomer
{},
)
}
QMPlusServer/model/dbModel/exa_customer.go
浏览文件 @
b782321e
package
dbModel
import
(
"gin-vue-admin/controller/servers"
"gin-vue-admin/init/qmsql"
"gin-vue-admin/model/modelInterface"
"gin-vue-admin/model/sysModel"
"github.com/jinzhu/gorm"
)
type
ExaCustomer
struct
{
gorm
.
Model
CustomerName
string
`json:"customerName"`
CustomerPhoneData
string
`json:"customerPhoneData"`
SysUserID
uint
`json:"sysUserId"`
SysUserAuthorityID
string
`json:"sysUserAuthorityID"`
SysUser
sysModel
.
SysUser
`json:"sysUser"`
}
//创建用户
func
(
e
*
ExaCustomer
)
CreateExaCustomer
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Create
(
e
)
.
Error
return
err
}
//删除用户
func
(
e
*
ExaCustomer
)
DeleteExaCustomer
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Delete
(
e
)
.
Error
return
err
}
//更新用户
func
(
e
*
ExaCustomer
)
UpdataExaCustomer
()(
err
error
){
err
=
qmsql
.
DEFAULTDB
.
Save
(
e
)
.
Error
return
err
}
//获取用户信息
func
(
e
*
ExaCustomer
)
GetExaCustomer
()(
err
error
,
customer
ExaCustomer
){
err
=
qmsql
.
DEFAULTDB
.
Where
(
"id = ?"
,
e
.
ID
)
.
First
(
&
customer
)
.
Error
return
}
//获取用户列表
// 分页获取数据 需要分页实现这个接口即可
func
(
e
*
ExaCustomer
)
GetInfoList
(
info
modelInterface
.
PageInfo
)
(
err
error
,
list
interface
{},
total
int
)
{
// 封装分页方法 调用即可 传入 当前的结构体和分页信息
err
,
db
,
total
:=
servers
.
PagingServer
(
e
,
info
)
if
err
!=
nil
{
return
}
else
{
var
a
sysModel
.
SysAuthority
a
.
AuthorityId
=
e
.
SysUserAuthorityID
err
,
auth
:=
a
.
GetAuthorityInfo
()
var
dataId
[]
string
for
_
,
v
:=
range
auth
.
DataAuthorityId
{
dataId
=
append
(
dataId
,
v
.
AuthorityId
)
}
var
CustomerList
[]
ExaCustomer
err
=
db
.
Where
(
"sys_user_authority_id in (?)"
,
dataId
)
.
Find
(
&
CustomerList
)
.
Count
(
&
total
)
.
Error
if
err
!=
nil
{
return
err
,
CustomerList
,
total
}
else
{
err
=
db
.
Preload
(
"SysUser"
)
.
Where
(
"sys_user_authority_id in (?)"
,
dataId
)
.
Find
(
&
CustomerList
)
.
Error
}
return
err
,
CustomerList
,
total
}
}
\ No newline at end of file
QMPlusServer/model/sysModel/sys_api.go
浏览文件 @
b782321e
...
...
@@ -71,7 +71,12 @@ func (a *SysApi) GetInfoList(info modelInterface.PageInfo) (err error, list inte
return
}
else
{
var
apiList
[]
SysApi
err
=
db
.
Order
(
"group"
,
true
)
.
Where
(
"path LIKE ?"
,
"%"
+
a
.
Path
+
"%"
)
.
Find
(
&
apiList
)
.
Count
(
&
total
)
.
Error
err
=
qmsql
.
DEFAULTDB
.
Where
(
"path LIKE ?"
,
"%"
+
a
.
Path
+
"%"
)
.
Find
(
&
apiList
)
.
Count
(
&
total
)
.
Error
if
err
!=
nil
{
return
err
,
apiList
,
total
}
else
{
err
=
db
.
Order
(
"group"
,
true
)
.
Where
(
"path LIKE ?"
,
"%"
+
a
.
Path
+
"%"
)
.
Find
(
&
apiList
)
.
Error
}
return
err
,
apiList
,
total
}
}
QMPlusServer/model/sysModel/sys_authority.go
浏览文件 @
b782321e
...
...
@@ -74,3 +74,8 @@ func (a *SysAuthority) SetDataAuthority() error {
err
:=
qmsql
.
DEFAULTDB
.
Model
(
&
s
)
.
Association
(
"DataAuthorityId"
)
.
Replace
(
&
a
.
DataAuthorityId
)
.
Error
return
err
}
func
(
a
*
SysAuthority
)
GetAuthorityInfo
()
(
err
error
,
sa
SysAuthority
)
{
err
=
qmsql
.
DEFAULTDB
.
Preload
(
"DataAuthorityId"
)
.
Where
(
"authority_id = ?"
,
a
.
AuthorityId
)
.
First
(
&
sa
)
.
Error
return
err
,
sa
}
\ No newline at end of file
QMPlusServer/router/exp_customer.go
浏览文件 @
b782321e
package
router
import
(
"gin-vue-admin/controller/api"
"gin-vue-admin/middleware"
"github.com/gin-gonic/gin"
)
func
InitCustomerRouter
(
Router
*
gin
.
RouterGroup
)
{
ApiRouter
:=
Router
.
Group
(
"customer"
)
.
Use
(
middleware
.
JWTAuth
())
.
Use
(
middleware
.
CasbinHandler
())
{
ApiRouter
.
POST
(
"createExaCustomer"
,
api
.
CreateExaCustomer
)
// 创建客户
ApiRouter
.
POST
(
"updataExaCustomer"
,
api
.
UpdataExaCustomer
)
// 更新客户
ApiRouter
.
POST
(
"deleteExaCustomer"
,
api
.
DeleteExaCustomer
)
// 删除客户
ApiRouter
.
POST
(
"getExaCustomer"
,
api
.
GetExaCustomer
)
// 获取单一客户信息
ApiRouter
.
POST
(
"getExaCustomerList"
,
api
.
GetExaCustomerList
)
// 获取客户列表
}
}
QMPlusVuePage/src/view/superAdmin/api/api.vue
浏览文件 @
b782321e
<
template
>
<div>
<div
class=
"button-box clearflex"
></div>
<div
class=
"search-term"
>
<el-form
:inline=
"true"
:model=
"searchInfo"
class=
"demo-form-inline"
>
<el-form-item
label=
"路径"
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录