mirror of
https://gitee.com/julywhj/sms-getway.git
synced 2026-04-22 22:57:10 +08:00
!1 支持nacos注册中心和配置中心
* 支持nacos配置 * Merge remote-tracking branch 'origin/develop' into develop * 修改k8s发布镜像 * add default pipeline template yaml * 修改k8s发布镜像 * 修改k8s发布镜像 * 修改DockerFile添加k8s部署文件 * 优化代码,支持阿里云短信 * 优化短信网关代码 * 优化短信网关代码 * 修改登录背景 * 精简项目
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
version: '1.0'
|
||||
name: branch-pipeline
|
||||
displayName: BranchPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@golang
|
||||
name: build_golang
|
||||
displayName: Golang 构建
|
||||
# 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本
|
||||
golangVersion: 1.12
|
||||
# 构建命令
|
||||
commands: |
|
||||
mkdir output
|
||||
GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go
|
||||
GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go
|
||||
GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go
|
||||
GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go
|
||||
GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go
|
||||
chmod +X output/main.linux32
|
||||
./output/main.linux32
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./output
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_golang
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
exclude:
|
||||
- master
|
||||
include:
|
||||
- .*
|
||||
@@ -0,0 +1,56 @@
|
||||
version: '1.0'
|
||||
name: master-pipeline
|
||||
displayName: MasterPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@golang
|
||||
name: build_golang
|
||||
displayName: Golang 构建
|
||||
# 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本
|
||||
golangVersion: 1.12
|
||||
# 构建命令
|
||||
commands: |
|
||||
mkdir output
|
||||
GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go
|
||||
GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go
|
||||
GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go
|
||||
GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go
|
||||
GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go
|
||||
chmod +X output/main.linux32
|
||||
./output/main.linux32
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,24小时后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./output
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_golang
|
||||
- stage:
|
||||
name: release
|
||||
displayName: 发布
|
||||
steps:
|
||||
- step: publish@release_artifacts
|
||||
name: publish_release_artifacts
|
||||
displayName: '发布'
|
||||
# 上游上传制品任务的产出
|
||||
dependArtifact: output
|
||||
# 发布制品版本号
|
||||
version: '1.0.0.0'
|
||||
# 是否开启版本号自增,默认开启
|
||||
autoIncrement: true
|
||||
triggers:
|
||||
push:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
@@ -0,0 +1,43 @@
|
||||
version: '1.0'
|
||||
name: pr-pipeline
|
||||
displayName: PRPipeline
|
||||
stages:
|
||||
- stage:
|
||||
name: compile
|
||||
displayName: 编译
|
||||
steps:
|
||||
- step: build@golang
|
||||
name: build_golang
|
||||
displayName: Golang 构建
|
||||
# 支持1.8、1.10、1.11、1.12、1.13、1.14、1.15、1.16八个版本
|
||||
golangVersion: 1.12
|
||||
# 构建命令
|
||||
commands: |
|
||||
mkdir output
|
||||
GOOS=linux GOARCH=amd64 go build -o output/main.amd64 main.go
|
||||
GOOS=linux GOARCH=386 go build -o output/main.linux32 main.go
|
||||
GOOS=windows GOARCH=amd64 go build -o output/main.win64.exe main.go
|
||||
GOOS=windows GOARCH=386 go build -o output/main.win32.exe main.go
|
||||
GOOS=darwin GOARCH=amd64 go build -o output/main.darwin main.go
|
||||
chmod +X output/main.linux32
|
||||
./output/main.linux32
|
||||
# 非必填字段,开启后表示将构建产物暂存,但不会上传到制品库中,7天后自动清除
|
||||
artifacts:
|
||||
# 构建产物名字,作为产物的唯一标识可向下传递,支持自定义,默认为BUILD_ARTIFACT。在下游可以通过${BUILD_ARTIFACT}方式引用来获取构建物地址
|
||||
- name: BUILD_ARTIFACT
|
||||
# 构建产物获取路径,是指代码编译完毕之后构建物的所在路径
|
||||
path:
|
||||
- ./output
|
||||
- step: publish@general_artifacts
|
||||
name: publish_general_artifacts
|
||||
displayName: 上传制品
|
||||
# 上游构建任务定义的产物名,默认BUILD_ARTIFACT
|
||||
dependArtifact: BUILD_ARTIFACT
|
||||
# 上传到制品库时的制品命名,默认output
|
||||
artifactName: output
|
||||
dependsOn: build_golang
|
||||
triggers:
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- master
|
||||
@@ -21,6 +21,8 @@ COPY --from=builder /go/release/go-admin /
|
||||
|
||||
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
|
||||
|
||||
COPY config/settings.yml /config/settings.yml
|
||||
|
||||
EXPOSE 8000
|
||||
|
||||
CMD ["/go-admin","server","-c", "/config/settings.yml"]
|
||||
@@ -0,0 +1,56 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"go-admin/app/admin/service"
|
||||
)
|
||||
|
||||
type SmsDashboard struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
func (e SmsDashboard) GetAllCount(c *gin.Context) {
|
||||
s := service.SmsDashboard{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
count := s.GetAllCount()
|
||||
e.OK(count, "查询成功")
|
||||
}
|
||||
|
||||
func (e SmsDashboard) GetSuccessCount(c *gin.Context) {
|
||||
s := service.SmsDashboard{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
count := s.GetSuccessCount()
|
||||
e.OK(count, "查询成功")
|
||||
}
|
||||
|
||||
func (e SmsDashboard) GetRequestCount(c *gin.Context) {
|
||||
s := service.SmsDashboard{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
count := s.GetRequestCount()
|
||||
e.OK(count, "查询成功")
|
||||
}
|
||||
@@ -24,11 +24,11 @@ func (e *SmsSendMessage) SendMessage(c *gin.Context) {
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
message, _ := s.SendMessage(&req)
|
||||
//message, _ := s.SendMessage(&req)
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
e.OK(200, message)
|
||||
e.OK(200, "message")
|
||||
}
|
||||
|
||||
@@ -1,237 +0,0 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
tdmq "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq/v20200217"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Mq struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// DescribeClusters
|
||||
// @Summary 获取集群列表
|
||||
// @Description 获取JSON
|
||||
// @Tags TDMQ
|
||||
// @Success 200 {object} response.Response "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/mq/describe-clusters [get]
|
||||
// @Security Bearer
|
||||
func (e Mq) DescribeClusters(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DescribeClusters()
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.OK(response.Response, "查询成功")
|
||||
}
|
||||
|
||||
func (e Mq) SelectClusters(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DescribeClusters()
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
l := make([]dto.SelectClusters, 0)
|
||||
for _, i := range response.Response.ClusterSet {
|
||||
d := dto.SelectClusters{
|
||||
ClusterId: *i.ClusterId,
|
||||
ClusterName: *i.ClusterName,
|
||||
}
|
||||
l = append(l, d)
|
||||
}
|
||||
e.OK(l, "查询成功")
|
||||
}
|
||||
|
||||
func (e Mq) PageDescribeClusters(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
list := make([]tdmq.Cluster, 0)
|
||||
var count int64
|
||||
response, err := s.DescribeClusters()
|
||||
count = *response.Response.TotalCount
|
||||
for _, cluster := range response.Response.ClusterSet {
|
||||
list = append(list, *cluster)
|
||||
}
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.PageOK(list, int(count), 1, 20, "查询成功")
|
||||
}
|
||||
|
||||
// SelectEnvironments 命名空间下拉选择
|
||||
func (e Mq) SelectEnvironments(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
cluster := dto.Clusters{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&cluster, nil).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DescribeEnvironments(cluster.ClusterId)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
l := make([]dto.SelectEnvironments, 0)
|
||||
for _, i := range response.Response.EnvironmentSet {
|
||||
d := dto.SelectEnvironments{
|
||||
EnvironmentId: *i.EnvironmentId,
|
||||
Remark: *i.EnvironmentId + "[" + *i.Remark + "]",
|
||||
}
|
||||
l = append(l, d)
|
||||
}
|
||||
e.OK(l, "查询成功")
|
||||
}
|
||||
|
||||
func (e Mq) DescribeEnvironments(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
cluster := dto.Clusters{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&cluster, nil).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DescribeEnvironments(cluster.ClusterId)
|
||||
list := make([]tdmq.Environment, 0)
|
||||
var count uint64
|
||||
count = *response.Response.TotalCount
|
||||
for _, environment := range response.Response.EnvironmentSet {
|
||||
list = append(list, *environment)
|
||||
}
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.PageOK(list, int(count), 1, 20, "查询成功")
|
||||
}
|
||||
|
||||
// CreateEnvironments 创建命名空间
|
||||
func (e Mq) CreateEnvironments(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
environment := dto.Environment{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&environment, binding.JSON).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.CreateEnvironments(&environment)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.OK(response.Response, "创建命名空间成功")
|
||||
}
|
||||
|
||||
// DeleteEnvironments 删除命名空间
|
||||
func (e Mq) DeleteEnvironments(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
environment := dto.Environment{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&environment, binding.JSON).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DeleteEnvironments(&environment)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.OK(response.Response, "命名空间删除成功")
|
||||
}
|
||||
|
||||
// CreateTopic 创建Topic
|
||||
func (e Mq) CreateTopic(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
topic := dto.CreateTopic{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&topic, binding.JSON).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.CreateTopic(&topic)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "创建失败")
|
||||
return
|
||||
}
|
||||
e.OK(response.Response, "Topic创建成功")
|
||||
}
|
||||
|
||||
// DescribeTopics 查询Topic
|
||||
func (e Mq) DescribeTopics(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
describeTopics := dto.DescribeTopics{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&describeTopics, binding.JSON).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DescribeTopics(&describeTopics)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.OK(response.Response, "Topic查询成功")
|
||||
}
|
||||
|
||||
// PageDescribeTopics Topic 分页查询
|
||||
func (e Mq) PageDescribeTopics(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
describeTopics := dto.DescribeTopics{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&describeTopics, binding.JSON).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DescribeTopics(&describeTopics)
|
||||
list := make([]tdmq.Topic, 0)
|
||||
var count uint64
|
||||
if err != nil {
|
||||
e.PageOK(list, 0, 1, 20, "查询成功")
|
||||
return
|
||||
}
|
||||
count = *response.Response.TotalCount
|
||||
for _, topic := range response.Response.TopicSets {
|
||||
list = append(list, *topic)
|
||||
}
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.PageOK(list, int(count), 1, 20, "查询成功")
|
||||
}
|
||||
|
||||
// DeleteTopic 删除Topic
|
||||
func (e Mq) DeleteTopic(c *gin.Context) {
|
||||
s := service.Mq{}
|
||||
deleteTopics := dto.DeleteTopics{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&deleteTopics, binding.JSON).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
response, err := s.DeleteTopics(&deleteTopics)
|
||||
if err != nil {
|
||||
e.Error(http.StatusUnprocessableEntity, err, "查询失败")
|
||||
return
|
||||
}
|
||||
e.OK(response.Response, "Topic删除成功")
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
type TArticle struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// GetPage 获取文章内容表列表
|
||||
// @Summary 获取文章内容表列表
|
||||
// @Description 获取文章内容表列表
|
||||
// @Tags 文章内容表
|
||||
// @Param pageSize query int false "页条数"
|
||||
// @Param pageIndex query int false "页码"
|
||||
// @Success 200 {object} response.Response{data=response.Page{list=[]models.TArticle}} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/t-article [get]
|
||||
// @Security Bearer
|
||||
func (e TArticle) GetPage(c *gin.Context) {
|
||||
req := dto.TArticleGetPageReq{}
|
||||
s := service.TArticle{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
list := make([]models.TArticle, 0)
|
||||
var count int64
|
||||
|
||||
err = s.GetPage(&req, p, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取文章内容表 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// Get 获取文章内容表
|
||||
// @Summary 获取文章内容表
|
||||
// @Description 获取文章内容表
|
||||
// @Tags 文章内容表
|
||||
// @Param id path string false "id"
|
||||
// @Success 200 {object} response.Response{data=models.TArticle} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/t-article/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e TArticle) Get(c *gin.Context) {
|
||||
req := dto.TArticleGetReq{}
|
||||
s := service.TArticle{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
var object models.TArticle
|
||||
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
err = s.Get(&req, p, &object)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取文章内容表失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK( object, "查询成功")
|
||||
}
|
||||
|
||||
// Insert 创建文章内容表
|
||||
// @Summary 创建文章内容表
|
||||
// @Description 创建文章内容表
|
||||
// @Tags 文章内容表
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.TArticleInsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
|
||||
// @Router /api/v1/t-article [post]
|
||||
// @Security Bearer
|
||||
func (e TArticle) Insert(c *gin.Context) {
|
||||
req := dto.TArticleInsertReq{}
|
||||
s := service.TArticle{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
req.SetCreateBy(user.GetUserId(c))
|
||||
|
||||
err = s.Insert(&req)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("创建文章内容表 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(req.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// Update 修改文章内容表
|
||||
// @Summary 修改文章内容表
|
||||
// @Description 修改文章内容表
|
||||
// @Tags 文章内容表
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.TArticleUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
|
||||
// @Router /api/v1/t-article/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e TArticle) Update(c *gin.Context) {
|
||||
req := dto.TArticleUpdateReq{}
|
||||
s := service.TArticle{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.Update(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("修改文章内容表 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( req.GetId(), "修改成功")
|
||||
}
|
||||
|
||||
// Delete 删除文章内容表
|
||||
// @Summary 删除文章内容表
|
||||
// @Description 删除文章内容表
|
||||
// @Tags 文章内容表
|
||||
// @Param ids body []int false "ids"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
|
||||
// @Router /api/v1/t-article [delete]
|
||||
// @Security Bearer
|
||||
func (e TArticle) Delete(c *gin.Context) {
|
||||
s := service.TArticle{}
|
||||
req := dto.TArticleDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.Remove(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("删除文章内容表失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( req.GetId(), "删除成功")
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
package apis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth/user"
|
||||
_ "github.com/go-admin-team/go-admin-core/sdk/pkg/response"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
type TArticleType struct {
|
||||
api.Api
|
||||
}
|
||||
|
||||
// GetPage 获取文章分类表列表
|
||||
// @Summary 获取文章分类表列表
|
||||
// @Description 获取文章分类表列表
|
||||
// @Tags 文章分类表
|
||||
// @Param pageSize query int false "页条数"
|
||||
// @Param pageIndex query int false "页码"
|
||||
// @Success 200 {object} response.Response{data=response.Page{list=[]models.TArticleType}} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/t-article-type [get]
|
||||
// @Security Bearer
|
||||
func (e TArticleType) GetPage(c *gin.Context) {
|
||||
req := dto.TArticleTypeGetPageReq{}
|
||||
s := service.TArticleType{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
list := make([]models.TArticleType, 0)
|
||||
var count int64
|
||||
|
||||
err = s.GetPage(&req, p, &list, &count)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取文章分类表 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.PageOK(list, int(count), req.GetPageIndex(), req.GetPageSize(), "查询成功")
|
||||
}
|
||||
|
||||
// Get 获取文章分类表
|
||||
// @Summary 获取文章分类表
|
||||
// @Description 获取文章分类表
|
||||
// @Tags 文章分类表
|
||||
// @Param id path string false "id"
|
||||
// @Success 200 {object} response.Response{data=models.TArticleType} "{"code": 200, "data": [...]}"
|
||||
// @Router /api/v1/t-article-type/{id} [get]
|
||||
// @Security Bearer
|
||||
func (e TArticleType) Get(c *gin.Context) {
|
||||
req := dto.TArticleTypeGetReq{}
|
||||
s := service.TArticleType{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
var object models.TArticleType
|
||||
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
err = s.Get(&req, p, &object)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("获取文章分类表失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK( object, "查询成功")
|
||||
}
|
||||
|
||||
// Insert 创建文章分类表
|
||||
// @Summary 创建文章分类表
|
||||
// @Description 创建文章分类表
|
||||
// @Tags 文章分类表
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.TArticleTypeInsertReq true "data"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "添加成功"}"
|
||||
// @Router /api/v1/t-article-type [post]
|
||||
// @Security Bearer
|
||||
func (e TArticleType) Insert(c *gin.Context) {
|
||||
req := dto.TArticleTypeInsertReq{}
|
||||
s := service.TArticleType{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
// 设置创建人
|
||||
req.SetCreateBy(user.GetUserId(c))
|
||||
|
||||
err = s.Insert(&req)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("创建文章分类表 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
e.OK(req.GetId(), "创建成功")
|
||||
}
|
||||
|
||||
// Update 修改文章分类表
|
||||
// @Summary 修改文章分类表
|
||||
// @Description 修改文章分类表
|
||||
// @Tags 文章分类表
|
||||
// @Accept application/json
|
||||
// @Product application/json
|
||||
// @Param data body dto.TArticleTypeUpdateReq true "body"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "修改成功"}"
|
||||
// @Router /api/v1/t-article-type/{id} [put]
|
||||
// @Security Bearer
|
||||
func (e TArticleType) Update(c *gin.Context) {
|
||||
req := dto.TArticleTypeUpdateReq{}
|
||||
s := service.TArticleType{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.Update(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("修改文章分类表 失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( req.GetId(), "修改成功")
|
||||
}
|
||||
|
||||
// Delete 删除文章分类表
|
||||
// @Summary 删除文章分类表
|
||||
// @Description 删除文章分类表
|
||||
// @Tags 文章分类表
|
||||
// @Param ids body []int false "ids"
|
||||
// @Success 200 {object} response.Response "{"code": 200, "message": "删除成功"}"
|
||||
// @Router /api/v1/t-article-type [delete]
|
||||
// @Security Bearer
|
||||
func (e TArticleType) Delete(c *gin.Context) {
|
||||
s := service.TArticleType{}
|
||||
req := dto.TArticleTypeDeleteReq{}
|
||||
err := e.MakeContext(c).
|
||||
MakeOrm().
|
||||
Bind(&req).
|
||||
MakeService(&s.Service).
|
||||
Errors
|
||||
if err != nil {
|
||||
e.Logger.Error(err)
|
||||
e.Error(500, err, err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
// req.SetUpdateBy(user.GetUserId(c))
|
||||
p := actions.GetPermissionFromContext(c)
|
||||
|
||||
err = s.Remove(&req, p)
|
||||
if err != nil {
|
||||
e.Error(500, err, fmt.Sprintf("删除文章分类表失败,\r\n失败信息 %s", err.Error()))
|
||||
return
|
||||
}
|
||||
e.OK( req.GetId(), "删除成功")
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
"go-admin/common/models"
|
||||
)
|
||||
|
||||
type TArticle struct {
|
||||
models.Model
|
||||
|
||||
ArticleNo string `json:"articleNo" gorm:"type:varchar(32);comment:文章编号"`
|
||||
ArticleType string `json:"articleType" gorm:"type:varchar(32);comment:文章分类"`
|
||||
ArticleName string `json:"articleName" gorm:"type:varchar(100);comment:文章名称"`
|
||||
ArticleTitle string `json:"articleTitle" gorm:"type:varchar(100);comment:文章标题"`
|
||||
ArticleAuthor string `json:"articleAuthor" gorm:"type:varchar(100);comment:文章作者"`
|
||||
ArticleSubtitle string `json:"articleSubtitle" gorm:"type:varchar(200);comment:副标题"`
|
||||
ArticleText string `json:"articleText" gorm:"type:text;comment:文章内容HTML"`
|
||||
Status string `json:"status" gorm:"type:bit(10);comment:状态"`
|
||||
models.ModelTime
|
||||
models.ControlBy
|
||||
}
|
||||
|
||||
func (TArticle) TableName() string {
|
||||
return "t_article"
|
||||
}
|
||||
|
||||
func (e *TArticle) Generate() models.ActiveRecord {
|
||||
o := *e
|
||||
return &o
|
||||
}
|
||||
|
||||
func (e *TArticle) GetId() interface{} {
|
||||
return e.Id
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
package models
|
||||
|
||||
import (
|
||||
|
||||
"go-admin/common/models"
|
||||
|
||||
)
|
||||
|
||||
type TArticleType struct {
|
||||
models.Model
|
||||
|
||||
TypeNo string `json:"typeNo" gorm:"type:varchar(32);comment:分类编号"`
|
||||
TypeName string `json:"typeName" gorm:"type:varchar(50);comment:分类名称"`
|
||||
Status string `json:"status" gorm:"type:bit(1);comment:状态"`
|
||||
models.ModelTime
|
||||
models.ControlBy
|
||||
}
|
||||
|
||||
func (TArticleType) TableName() string {
|
||||
return "t_article_type"
|
||||
}
|
||||
|
||||
func (e *TArticleType) Generate() models.ActiveRecord {
|
||||
o := *e
|
||||
return &o
|
||||
}
|
||||
|
||||
func (e *TArticleType) GetId() interface{} {
|
||||
return e.Id
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
"go-admin/app/admin/apis"
|
||||
"go-admin/common/actions"
|
||||
"go-admin/common/middleware"
|
||||
)
|
||||
|
||||
func init() {
|
||||
routerCheckRole = append(routerCheckRole, registerMqrRouter)
|
||||
}
|
||||
|
||||
// 需认证的路由代码
|
||||
func registerMqrRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.Mq{}
|
||||
r := v1.Group("/mq").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole()).Use(actions.PermissionAction())
|
||||
{
|
||||
r.GET("/describe-clusters", api.DescribeClusters)
|
||||
r.GET("/describe-page-clusters", api.PageDescribeClusters)
|
||||
r.GET("/describe-select-clusters", api.SelectClusters)
|
||||
r.GET("/describe-select-environments/:clusterId", api.SelectEnvironments)
|
||||
r.GET("/describe-environments/:clusterId", api.DescribeEnvironments)
|
||||
r.POST("/create-environments", api.CreateEnvironments)
|
||||
r.POST("/delete-environments", api.DeleteEnvironments)
|
||||
r.POST("/create-topic", api.CreateTopic)
|
||||
r.POST("/describe-topics", api.DescribeTopics)
|
||||
r.POST("/page-describe-topics", api.PageDescribeTopics)
|
||||
r.POST("/delete-topic", api.DeleteTopic)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
"go-admin/app/admin/apis"
|
||||
"go-admin/common/middleware"
|
||||
)
|
||||
|
||||
func init() {
|
||||
routerCheckRole = append(routerCheckRole, smsDashboardRouter)
|
||||
}
|
||||
|
||||
// registerSmsSendLogRouter
|
||||
func smsDashboardRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.SmsDashboard{}
|
||||
r := v1.Group("/sms-dashboard").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
r.GET("/count", api.GetAllCount)
|
||||
r.GET("/get-success-count", api.GetSuccessCount)
|
||||
r.GET("/get-request-count", api.GetRequestCount)
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
|
||||
"go-admin/app/admin/apis"
|
||||
"go-admin/common/middleware"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
func init() {
|
||||
routerCheckRole = append(routerCheckRole, registerTArticleRouter)
|
||||
}
|
||||
|
||||
// registerTArticleRouter
|
||||
func registerTArticleRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.TArticle{}
|
||||
r := v1.Group("/t-article").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
r.GET("", actions.PermissionAction(), api.GetPage)
|
||||
r.GET("/:id", actions.PermissionAction(), api.Get)
|
||||
r.POST("", api.Insert)
|
||||
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
||||
r.DELETE("", api.Delete)
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package router
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
jwt "github.com/go-admin-team/go-admin-core/sdk/pkg/jwtauth"
|
||||
|
||||
"go-admin/app/admin/apis"
|
||||
"go-admin/common/middleware"
|
||||
"go-admin/common/actions"
|
||||
)
|
||||
|
||||
func init() {
|
||||
routerCheckRole = append(routerCheckRole, registerTArticleTypeRouter)
|
||||
}
|
||||
|
||||
// registerTArticleTypeRouter
|
||||
func registerTArticleTypeRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||
api := apis.TArticleType{}
|
||||
r := v1.Group("/t-article-type").Use(authMiddleware.MiddlewareFunc()).Use(middleware.AuthCheckRole())
|
||||
{
|
||||
r.GET("", actions.PermissionAction(), api.GetPage)
|
||||
r.GET("/:id", actions.PermissionAction(), api.Get)
|
||||
r.POST("", api.Insert)
|
||||
r.PUT("/:id", actions.PermissionAction(), api.Update)
|
||||
r.DELETE("", api.Delete)
|
||||
}
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package dto
|
||||
|
||||
type Clusters struct {
|
||||
ClusterId string `uri:"clusterId"`
|
||||
}
|
||||
|
||||
type SelectClusters struct {
|
||||
ClusterId string `json:"value"`
|
||||
ClusterName string `json:"label"`
|
||||
}
|
||||
|
||||
type SelectEnvironments struct {
|
||||
EnvironmentId string `json:"value"`
|
||||
Remark string `json:"label"`
|
||||
}
|
||||
|
||||
type Environment struct {
|
||||
// 环境(命名空间)名称,不支持中字以及除了短线和下划线外的特殊字符且不超过16个字符。
|
||||
EnvironmentId *string `json:"EnvironmentId,omitempty" name:"EnvironmentId"`
|
||||
|
||||
// 未消费消息过期时间,单位:秒,最小60,最大1296000,(15天)。
|
||||
MsgTTL *uint64 `json:"MsgTTL,omitempty" name:"MsgTTL"`
|
||||
|
||||
// 说明,128个字符以内。
|
||||
Remark *string `json:"Remark,omitempty" name:"Remark"`
|
||||
|
||||
// Pulsar 集群的ID
|
||||
ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"`
|
||||
|
||||
// 消息保留策略
|
||||
RetentionPolicy *RetentionPolicy `json:"RetentionPolicy,omitempty" name:"RetentionPolicy"`
|
||||
|
||||
// 删除命名空间 最多20个
|
||||
EnvironmentIds []*string `json:"EnvironmentIds,omitempty" name:"EnvironmentIds"`
|
||||
}
|
||||
|
||||
type RetentionPolicy struct {
|
||||
|
||||
// 消息保留时长
|
||||
TimeInMinutes *int64 `json:"TimeInMinutes,omitempty" name:"TimeInMinutes"`
|
||||
|
||||
// 消息保留大小
|
||||
SizeInMB *int64 `json:"SizeInMB,omitempty" name:"SizeInMB"`
|
||||
}
|
||||
|
||||
type CreateTopic struct {
|
||||
// 环境(命名空间)名称。
|
||||
EnvironmentId *string `json:"EnvironmentId,omitempty" name:"EnvironmentId"`
|
||||
|
||||
// 主题名,不支持中字以及除了短线和下划线外的特殊字符且不超过64个字符。
|
||||
TopicName *string `json:"TopicName,omitempty" name:"TopicName"`
|
||||
|
||||
// 0:非分区topic,无分区;非0:具体分区topic的分区数,最大不允许超过128。
|
||||
Partitions *uint64 `json:"Partitions,omitempty" name:"Partitions"`
|
||||
|
||||
// 0: 普通消息;
|
||||
// 1 :全局顺序消息;
|
||||
// 2 :局部顺序消息;
|
||||
// 3 :重试队列;
|
||||
// 4 :死信队列。
|
||||
TopicType *uint64 `json:"TopicType,omitempty" name:"TopicType"`
|
||||
|
||||
// 备注,128字符以内。
|
||||
Remark *string `json:"Remark,omitempty" name:"Remark"`
|
||||
|
||||
// Pulsar 集群的ID
|
||||
ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"`
|
||||
}
|
||||
|
||||
type DescribeTopics struct {
|
||||
// 环境(命名空间)名称。
|
||||
EnvironmentId *string `json:"EnvironmentId,omitempty" name:"EnvironmentId"`
|
||||
|
||||
// 主题名模糊匹配。
|
||||
TopicName *string `json:"TopicName,omitempty" name:"TopicName"`
|
||||
|
||||
// 起始下标,不填默认为0。
|
||||
Offset *uint64 `json:"Offset,omitempty" name:"Offset"`
|
||||
|
||||
// 返回数量,不填则默认为10,最大值为20。
|
||||
Limit *uint64 `json:"Limit,omitempty" name:"Limit"`
|
||||
|
||||
// topic类型描述:
|
||||
// 0:普通消息;
|
||||
// 1:全局顺序消息;
|
||||
// 2:局部顺序消息;
|
||||
// 3:重试队列;
|
||||
// 4:死信队列;
|
||||
// 5:事务消息。
|
||||
TopicType *uint64 `json:"TopicType,omitempty" name:"TopicType"`
|
||||
|
||||
// Pulsar 集群的ID
|
||||
ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"`
|
||||
}
|
||||
|
||||
type DeleteTopics struct {
|
||||
|
||||
// 主题集合,每次最多删除20个。
|
||||
TopicName *string `json:"TopicName,omitempty" name:"TopicName"`
|
||||
|
||||
// pulsar集群Id。
|
||||
ClusterId *string `json:"ClusterId,omitempty" name:"ClusterId"`
|
||||
|
||||
// 环境(命名空间)名称。
|
||||
EnvironmentId *string `json:"EnvironmentId,omitempty" name:"EnvironmentId"`
|
||||
|
||||
// 是否强制删除,默认为false
|
||||
Force *bool `json:"Force,omitempty" name:"Force"`
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package dto
|
||||
|
||||
import ("time"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type TArticleGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
TArticleOrder
|
||||
}
|
||||
|
||||
type TArticleOrder struct {Id int `form:"idOrder" search:"type:order;column:id;table:t_article"`
|
||||
ArticleNo string `form:"articleNoOrder" search:"type:order;column:article_no;table:t_article"`
|
||||
ArticleType string `form:"articleTypeOrder" search:"type:order;column:article_type;table:t_article"`
|
||||
ArticleName string `form:"articleNameOrder" search:"type:order;column:article_name;table:t_article"`
|
||||
ArticleTitle string `form:"articleTitleOrder" search:"type:order;column:article_title;table:t_article"`
|
||||
ArticleAuthor string `form:"articleAuthorOrder" search:"type:order;column:article_author;table:t_article"`
|
||||
ArticleSubtitle string `form:"articleSubtitleOrder" search:"type:order;column:article_subtitle;table:t_article"`
|
||||
ArticleText string `form:"articleTextOrder" search:"type:order;column:article_text;table:t_article"`
|
||||
Status string `form:"statusOrder" search:"type:order;column:status;table:t_article"`
|
||||
CreateBy string `form:"createByOrder" search:"type:order;column:create_by;table:t_article"`
|
||||
UpdateBy string `form:"updateByOrder" search:"type:order;column:update_by;table:t_article"`
|
||||
CreatedAt time.Time `form:"createdAtOrder" search:"type:order;column:created_at;table:t_article"`
|
||||
UpdatedAt time.Time `form:"updatedAtOrder" search:"type:order;column:updated_at;table:t_article"`
|
||||
DeletedAt time.Time `form:"deletedAtOrder" search:"type:order;column:deleted_at;table:t_article"`
|
||||
|
||||
}
|
||||
|
||||
func (m *TArticleGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type TArticleInsertReq struct {
|
||||
Id int `json:"-" comment:"主键"` // 主键
|
||||
ArticleNo string `json:"articleNo" comment:"文章编号"`
|
||||
ArticleType string `json:"articleType" comment:"文章分类"`
|
||||
ArticleName string `json:"articleName" comment:"文章名称"`
|
||||
ArticleTitle string `json:"articleTitle" comment:"文章标题"`
|
||||
ArticleAuthor string `json:"articleAuthor" comment:"文章作者"`
|
||||
ArticleSubtitle string `json:"articleSubtitle" comment:"副标题"`
|
||||
ArticleText string `json:"articleText" comment:"文章内容HTML"`
|
||||
Status string `json:"status" comment:"状态"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *TArticleInsertReq) Generate(model *models.TArticle) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{ Id: s.Id }
|
||||
}
|
||||
model.ArticleNo = s.ArticleNo
|
||||
model.ArticleType = s.ArticleType
|
||||
model.ArticleName = s.ArticleName
|
||||
model.ArticleTitle = s.ArticleTitle
|
||||
model.ArticleAuthor = s.ArticleAuthor
|
||||
model.ArticleSubtitle = s.ArticleSubtitle
|
||||
model.ArticleText = s.ArticleText
|
||||
model.Status = s.Status
|
||||
model.CreateBy = s.CreateBy // 添加这而,需要记录是被谁创建的
|
||||
}
|
||||
|
||||
func (s *TArticleInsertReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type TArticleUpdateReq struct {
|
||||
Id int `uri:"id" comment:"主键"` // 主键
|
||||
ArticleNo string `json:"articleNo" comment:"文章编号"`
|
||||
ArticleType string `json:"articleType" comment:"文章分类"`
|
||||
ArticleName string `json:"articleName" comment:"文章名称"`
|
||||
ArticleTitle string `json:"articleTitle" comment:"文章标题"`
|
||||
ArticleAuthor string `json:"articleAuthor" comment:"文章作者"`
|
||||
ArticleSubtitle string `json:"articleSubtitle" comment:"副标题"`
|
||||
ArticleText string `json:"articleText" comment:"文章内容HTML"`
|
||||
Status string `json:"status" comment:"状态"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *TArticleUpdateReq) Generate(model *models.TArticle) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{ Id: s.Id }
|
||||
}
|
||||
model.ArticleNo = s.ArticleNo
|
||||
model.ArticleType = s.ArticleType
|
||||
model.ArticleName = s.ArticleName
|
||||
model.ArticleTitle = s.ArticleTitle
|
||||
model.ArticleAuthor = s.ArticleAuthor
|
||||
model.ArticleSubtitle = s.ArticleSubtitle
|
||||
model.ArticleText = s.ArticleText
|
||||
model.Status = s.Status
|
||||
model.UpdateBy = s.UpdateBy // 添加这而,需要记录是被谁更新的
|
||||
}
|
||||
|
||||
func (s *TArticleUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// TArticleGetReq 功能获取请求参数
|
||||
type TArticleGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
func (s *TArticleGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// TArticleDeleteReq 功能删除请求参数
|
||||
type TArticleDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *TArticleDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
@@ -1,83 +0,0 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
)
|
||||
|
||||
type TArticleTypeGetPageReq struct {
|
||||
dto.Pagination `search:"-"`
|
||||
TArticleTypeOrder
|
||||
}
|
||||
|
||||
type TArticleTypeOrder struct {Id int `form:"idOrder" search:"type:order;column:id;table:t_article_type"`
|
||||
TypeNo string `form:"typeNoOrder" search:"type:order;column:type_no;table:t_article_type"`
|
||||
TypeName string `form:"typeNameOrder" search:"type:order;column:type_name;table:t_article_type"`
|
||||
Status string `form:"statusOrder" search:"type:order;column:status;table:t_article_type"`
|
||||
|
||||
}
|
||||
|
||||
func (m *TArticleTypeGetPageReq) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
type TArticleTypeInsertReq struct {
|
||||
Id int `json:"-" comment:"主键"` // 主键
|
||||
TypeNo string `json:"typeNo" comment:"分类编号"`
|
||||
TypeName string `json:"typeName" comment:"分类名称"`
|
||||
Status string `json:"status" comment:"状态"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *TArticleTypeInsertReq) Generate(model *models.TArticleType) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{ Id: s.Id }
|
||||
}
|
||||
model.TypeNo = s.TypeNo
|
||||
model.TypeName = s.TypeName
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
func (s *TArticleTypeInsertReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
type TArticleTypeUpdateReq struct {
|
||||
Id int `uri:"id" comment:"主键"` // 主键
|
||||
TypeNo string `json:"typeNo" comment:"分类编号"`
|
||||
TypeName string `json:"typeName" comment:"分类名称"`
|
||||
Status string `json:"status" comment:"状态"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *TArticleTypeUpdateReq) Generate(model *models.TArticleType) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{ Id: s.Id }
|
||||
}
|
||||
model.TypeNo = s.TypeNo
|
||||
model.TypeName = s.TypeName
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
func (s *TArticleTypeUpdateReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// TArticleTypeGetReq 功能获取请求参数
|
||||
type TArticleTypeGetReq struct {
|
||||
Id int `uri:"id"`
|
||||
}
|
||||
func (s *TArticleTypeGetReq) GetId() interface{} {
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// TArticleTypeDeleteReq 功能删除请求参数
|
||||
type TArticleTypeDeleteReq struct {
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (s *TArticleTypeDeleteReq) GetId() interface{} {
|
||||
return s.Ids
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/go-admin-team/go-admin-core/sdk/service"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
|
||||
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/regions"
|
||||
tdmq "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq/v20200217"
|
||||
"go-admin/app/admin/service/dto"
|
||||
)
|
||||
|
||||
type Mq struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// DescribeClusters 获取集群列表
|
||||
func (e *Mq) DescribeClusters() (model *tdmq.DescribeClustersResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewDescribeClustersRequest()
|
||||
return client.DescribeClusters(request)
|
||||
}
|
||||
|
||||
// DescribeEnvironments 获取指定集群下命名空间
|
||||
func (e *Mq) DescribeEnvironments(clusterId string) (model *tdmq.DescribeEnvironmentsResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewDescribeEnvironmentsRequest()
|
||||
request.ClusterId = common.StringPtr(clusterId)
|
||||
return client.DescribeEnvironments(request)
|
||||
}
|
||||
|
||||
// CreateEnvironments 创建命名空间
|
||||
func (e *Mq) CreateEnvironments(environment *dto.Environment) (model *tdmq.CreateEnvironmentResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewCreateEnvironmentRequest()
|
||||
request.ClusterId = environment.ClusterId
|
||||
request.EnvironmentId = environment.EnvironmentId
|
||||
request.Remark = environment.Remark
|
||||
request.MsgTTL = environment.MsgTTL
|
||||
return client.CreateEnvironment(request)
|
||||
}
|
||||
|
||||
// DeleteEnvironments 删除命名空间
|
||||
func (e *Mq) DeleteEnvironments(environment *dto.Environment) (model *tdmq.DeleteEnvironmentsResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewDeleteEnvironmentsRequest()
|
||||
request.ClusterId = environment.ClusterId
|
||||
request.EnvironmentIds = environment.EnvironmentIds
|
||||
return client.DeleteEnvironments(request)
|
||||
}
|
||||
|
||||
// CreateTopic 创建Topic
|
||||
func (e *Mq) CreateTopic(topic *dto.CreateTopic) (model *tdmq.CreateTopicResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewCreateTopicRequest()
|
||||
request.EnvironmentId = topic.EnvironmentId
|
||||
request.ClusterId = topic.ClusterId
|
||||
request.TopicName = topic.TopicName
|
||||
request.Remark = topic.Remark
|
||||
request.Partitions = topic.Partitions
|
||||
request.TopicType = topic.TopicType
|
||||
return client.CreateTopic(request)
|
||||
}
|
||||
|
||||
// DescribeTopics 查询Topic
|
||||
func (e *Mq) DescribeTopics(topic *dto.DescribeTopics) (response *tdmq.DescribeTopicsResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewDescribeTopicsRequest()
|
||||
request.EnvironmentId = topic.EnvironmentId
|
||||
request.ClusterId = topic.ClusterId
|
||||
request.TopicName = topic.TopicName
|
||||
request.Limit = topic.Limit
|
||||
request.Offset = topic.Offset
|
||||
return client.DescribeTopics(request)
|
||||
}
|
||||
|
||||
// DeleteTopics 删除topic
|
||||
func (e *Mq) DeleteTopics(topic *dto.DeleteTopics) (response *tdmq.DeleteTopicsResponse, err error) {
|
||||
credential := common.NewCredential("AKIDf8KFuIQHq89tLWQ3OTO2PUJr88sKVO2P", "8zb3OcgcNxMadXPBk47tOcZFenfGady9")
|
||||
client, err := tdmq.NewClient(credential, regions.Nanjing, profile.NewClientProfile())
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
request := tdmq.NewDeleteTopicsRequest()
|
||||
request.TopicSets = append(request.TopicSets, &tdmq.TopicRecord{
|
||||
EnvironmentId: topic.EnvironmentId,
|
||||
TopicName: topic.TopicName,
|
||||
})
|
||||
request.ClusterId = topic.ClusterId
|
||||
request.EnvironmentId = topic.EnvironmentId
|
||||
return client.DeleteTopics(request)
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"github.com/go-admin-team/go-admin-core/sdk/service"
|
||||
"go-admin/app/admin/models"
|
||||
)
|
||||
|
||||
type SmsDashboard struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
func (d *SmsDashboard) GetAllCount() int64 {
|
||||
var smsSendLog models.SmsSendLog
|
||||
count := int64(0)
|
||||
err := d.Orm.Model(smsSendLog).Count(&count).Error
|
||||
if err != nil {
|
||||
d.Log.Errorf("SmsDashboard GetAllCount error:%s \r\n", err)
|
||||
return 0
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func (d *SmsDashboard) GetSuccessCount() int64 {
|
||||
var smsSendLog models.SmsSendLog
|
||||
count := int64(0)
|
||||
err := d.Orm.Model(smsSendLog).Where(models.SmsSendLog{
|
||||
Code: "OK",
|
||||
}).Count(&count).Error
|
||||
if err != nil {
|
||||
d.Log.Errorf("SmsDashboard GetSuccessCount error:%s \r\n", err)
|
||||
return 0
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func (d *SmsDashboard) GetRequestCount() int64 {
|
||||
var sysOperaLog models.SysOperaLog
|
||||
count := int64(0)
|
||||
err := d.Orm.Model(sysOperaLog).Count(&count).Error
|
||||
if err != nil {
|
||||
d.Log.Errorf("SmsDashboard GetRequestCount error:%s \r\n", err)
|
||||
return 0
|
||||
}
|
||||
return count
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/go-admin-team/go-admin-core/sdk/service"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
)
|
||||
|
||||
type TArticle struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// GetPage 获取TArticle列表
|
||||
func (e *TArticle) GetPage(c *dto.TArticleGetPageReq, p *actions.DataPermission, list *[]models.TArticle, count *int64) error {
|
||||
var err error
|
||||
var data models.TArticle
|
||||
|
||||
err = e.Orm.Model(&data).
|
||||
Scopes(
|
||||
cDto.MakeCondition(c.GetNeedSearch()),
|
||||
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
|
||||
actions.Permission(data.TableName(), p),
|
||||
).
|
||||
Find(list).Limit(-1).Offset(-1).
|
||||
Count(count).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("TArticleService GetPage error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get 获取TArticle对象
|
||||
func (e *TArticle) Get(d *dto.TArticleGetReq, p *actions.DataPermission, model *models.TArticle) error {
|
||||
var data models.TArticle
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).
|
||||
First(model, d.GetId()).Error
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
err = errors.New("查看对象不存在或无权查看")
|
||||
e.Log.Errorf("Service GetTArticle error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Insert 创建TArticle对象
|
||||
func (e *TArticle) Insert(c *dto.TArticleInsertReq) error {
|
||||
var err error
|
||||
var data models.TArticle
|
||||
c.Generate(&data)
|
||||
err = e.Orm.Create(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("TArticleService Insert error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update 修改TArticle对象
|
||||
func (e *TArticle) Update(c *dto.TArticleUpdateReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var data = models.TArticle{}
|
||||
e.Orm.Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).First(&data, c.GetId())
|
||||
c.Generate(&data)
|
||||
|
||||
db := e.Orm.Save(&data)
|
||||
if db.Error != nil {
|
||||
e.Log.Errorf("TArticleService Save error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove 删除TArticle
|
||||
func (e *TArticle) Remove(d *dto.TArticleDeleteReq, p *actions.DataPermission) error {
|
||||
var data models.TArticle
|
||||
|
||||
db := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).Delete(&data, d.GetId())
|
||||
if err := db.Error; err != nil {
|
||||
e.Log.Errorf("Service RemoveTArticle error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权删除该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,109 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/go-admin-team/go-admin-core/sdk/service"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
)
|
||||
|
||||
type TArticleType struct {
|
||||
service.Service
|
||||
}
|
||||
|
||||
// GetPage 获取TArticleType列表
|
||||
func (e *TArticleType) GetPage(c *dto.TArticleTypeGetPageReq, p *actions.DataPermission, list *[]models.TArticleType, count *int64) error {
|
||||
var err error
|
||||
var data models.TArticleType
|
||||
|
||||
err = e.Orm.Model(&data).
|
||||
Scopes(
|
||||
cDto.MakeCondition(c.GetNeedSearch()),
|
||||
cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
|
||||
actions.Permission(data.TableName(), p),
|
||||
).
|
||||
Find(list).Limit(-1).Offset(-1).
|
||||
Count(count).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("TArticleTypeService GetPage error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Get 获取TArticleType对象
|
||||
func (e *TArticleType) Get(d *dto.TArticleTypeGetReq, p *actions.DataPermission, model *models.TArticleType) error {
|
||||
var data models.TArticleType
|
||||
|
||||
err := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).
|
||||
First(model, d.GetId()).Error
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
err = errors.New("查看对象不存在或无权查看")
|
||||
e.Log.Errorf("Service GetTArticleType error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
e.Log.Errorf("db error:%s", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Insert 创建TArticleType对象
|
||||
func (e *TArticleType) Insert(c *dto.TArticleTypeInsertReq) error {
|
||||
var err error
|
||||
var data models.TArticleType
|
||||
c.Generate(&data)
|
||||
err = e.Orm.Create(&data).Error
|
||||
if err != nil {
|
||||
e.Log.Errorf("TArticleTypeService Insert error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update 修改TArticleType对象
|
||||
func (e *TArticleType) Update(c *dto.TArticleTypeUpdateReq, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var data = models.TArticleType{}
|
||||
e.Orm.Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).First(&data, c.GetId())
|
||||
c.Generate(&data)
|
||||
|
||||
db := e.Orm.Save(&data)
|
||||
if db.Error != nil {
|
||||
e.Log.Errorf("TArticleTypeService Save error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Remove 删除TArticleType
|
||||
func (e *TArticleType) Remove(d *dto.TArticleTypeDeleteReq, p *actions.DataPermission) error {
|
||||
var data models.TArticleType
|
||||
|
||||
db := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).Delete(&data, d.GetId())
|
||||
if err := db.Error; err != nil {
|
||||
e.Log.Errorf("Service RemoveTArticleType error:%s \r\n", err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权删除该数据")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
+23
-3
@@ -11,13 +11,14 @@ import (
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/go-admin-team/go-admin-core/config/source/file"
|
||||
"github.com/go-admin-team/go-admin-core/config/source/nacos"
|
||||
"github.com/go-admin-team/go-admin-core/sdk"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/config"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/pkg"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/runtime"
|
||||
"github.com/go-admin-team/go-admin-core/tools/naming"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/router"
|
||||
"go-admin/app/jobs"
|
||||
@@ -62,6 +63,10 @@ func setup() {
|
||||
//1. 读取配置
|
||||
config.Setup(
|
||||
file.NewSource(file.WithPath(configYml)),
|
||||
)
|
||||
//2.读取nacos配置文件
|
||||
config.Setup(
|
||||
nacos.NewSource(config.NacosConfig.Host, config.NacosConfig.Port, config.NacosConfig.NameSpace, config.NacosConfig.Group, config.NacosConfig.DataId),
|
||||
database.Setup,
|
||||
storage.Setup,
|
||||
)
|
||||
@@ -90,13 +95,28 @@ func run() error {
|
||||
Addr: fmt.Sprintf("%s:%d", config.ApplicationConfig.Host, config.ApplicationConfig.Port),
|
||||
Handler: sdk.Runtime.GetEngine(),
|
||||
}
|
||||
//将服务注册到nacos
|
||||
server := naming.DefaultService{
|
||||
Id: config.ApplicationConfig.Name,
|
||||
Name: config.ApplicationConfig.Name,
|
||||
Address: pkg.GetLocaHonst(),
|
||||
Port: config.ApplicationConfig.Port,
|
||||
Namespace: config.NacosConfig.NameSpace,
|
||||
Group: config.NacosConfig.Group,
|
||||
}
|
||||
newNaming, err := naming.NewNaming(config.NacosConfig.Host, config.NacosConfig.Port, config.NacosConfig.NameSpace)
|
||||
|
||||
getConfig, err := newNaming.GetConfig(config.NacosConfig.Group, config.ApplicationConfig.Name)
|
||||
|
||||
fmt.Println(getConfig)
|
||||
|
||||
err = newNaming.Register(server)
|
||||
if err != nil {
|
||||
}
|
||||
go func() {
|
||||
jobs.InitJob()
|
||||
jobs.Setup(sdk.Runtime.GetDb())
|
||||
|
||||
}()
|
||||
|
||||
if apiCheck {
|
||||
var routers = sdk.Runtime.GetRouter()
|
||||
q := sdk.Runtime.GetMemoryQueue("")
|
||||
|
||||
+1
-1
@@ -36,7 +36,7 @@ var rootCmd = &cobra.Command{
|
||||
|
||||
func tip() {
|
||||
usageStr := `欢迎使用 ` + pkg.Green(`go-admin `+global.Version) + ` 可以使用 ` + pkg.Red(`-h`) + ` 查看命令`
|
||||
usageStr1 := `也可以参考 https://doc.go-admin.dev/guide/ksks.html 里边的【启动】章节`
|
||||
usageStr1 := ` 里边的【启动】章节`
|
||||
fmt.Printf("%s\n", usageStr)
|
||||
fmt.Printf("%s\n", usageStr1)
|
||||
}
|
||||
|
||||
+3
-3
@@ -8,7 +8,7 @@ import (
|
||||
func GetClientIP(c *gin.Context) string {
|
||||
ClientIP := c.ClientIP()
|
||||
//fmt.Println("ClientIP:", ClientIP)
|
||||
RemoteIP, _ := c.RemoteIP()
|
||||
RemoteIP := c.RemoteIP()
|
||||
//fmt.Println("RemoteIP:", RemoteIP)
|
||||
ip := c.Request.Header.Get("X-Forwarded-For")
|
||||
if strings.Contains(ip, "127.0.0.1") || ip == "" {
|
||||
@@ -17,8 +17,8 @@ func GetClientIP(c *gin.Context) string {
|
||||
if ip == "" {
|
||||
ip = "127.0.0.1"
|
||||
}
|
||||
if RemoteIP.String() != "127.0.0.1" {
|
||||
ip = RemoteIP.String()
|
||||
if RemoteIP != "127.0.0.1" {
|
||||
ip = RemoteIP
|
||||
}
|
||||
if ClientIP != "127.0.0.1" {
|
||||
ip = ClientIP
|
||||
|
||||
+7
-65
@@ -1,17 +1,10 @@
|
||||
settings:
|
||||
application:
|
||||
# dev开发环境 test测试环境 prod线上环境
|
||||
mode: dev
|
||||
# 服务器ip,默认使用 0.0.0.0
|
||||
host: 0.0.0.0
|
||||
# 服务名称
|
||||
name: careerGuidance
|
||||
# 端口号
|
||||
port: 8000 # 服务端口号
|
||||
readtimeout: 1
|
||||
writertimeout: 2
|
||||
# 数据权限功能开关
|
||||
enabledp: false
|
||||
nacos:
|
||||
host: 192.168.1.15
|
||||
port: 8848
|
||||
namespace: dev
|
||||
group: dev
|
||||
dataid: sms-gateway
|
||||
logger:
|
||||
# 日志存放路径
|
||||
path: temp/logs
|
||||
@@ -20,55 +13,4 @@ settings:
|
||||
# 日志等级, trace, debug, info, warn, error, fatal
|
||||
level: trace
|
||||
# 数据库日志开关
|
||||
enableddb: true
|
||||
jwt:
|
||||
# token 密钥,生产环境时及的修改
|
||||
secret: go-admin
|
||||
# token 过期时间 单位:秒
|
||||
timeout: 3600
|
||||
database:
|
||||
# 数据库类型 mysql, sqlite3, postgres, sqlserver
|
||||
# sqlserver: sqlserver://用户名:密码@地址?database=数据库名
|
||||
driver: mysql
|
||||
# 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
||||
source: root:123456@tcp(127.0.0.1:3306)/career_guidance?charset=utf8&parseTime=True&loc=Local&timeout=10000ms
|
||||
# databases:
|
||||
# 'locaohost:8000':
|
||||
# driver: mysql
|
||||
# # 数据库连接字符串 mysql 缺省信息 charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
||||
# source: user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
||||
# registers:
|
||||
# - sources:
|
||||
# - user:password@tcp(127.0.0.1:3306)/dbname?charset=utf8&parseTime=True&loc=Local&timeout=1000ms
|
||||
gen:
|
||||
# 代码生成读取的数据库名称
|
||||
dbname: career_guidance
|
||||
# 代码生成是使用前端代码存放位置,需要指定到src文件夹,相对路径
|
||||
frontpath: ../go-admin-ui/src
|
||||
extend: # 扩展项使用说明
|
||||
demo:
|
||||
name: data
|
||||
cache:
|
||||
# redis:
|
||||
# addr: 127.0.0.1:6379
|
||||
# password: xxxxxx
|
||||
# db: 2
|
||||
# key存在即可
|
||||
memory: ''
|
||||
queue:
|
||||
memory:
|
||||
poolSize: 100
|
||||
# redis:
|
||||
# addr: 127.0.0.1:6379
|
||||
# password: xxxxxx
|
||||
# producer:
|
||||
# streamMaxLength: 100
|
||||
# approximateMaxLength: true
|
||||
# consumer:
|
||||
# visibilityTimeout: 60
|
||||
# bufferSize: 100
|
||||
# concurrency: 10
|
||||
# blockingTimeout: 5
|
||||
# reclaimInterval: 1
|
||||
locker:
|
||||
redis:
|
||||
enableddb: true
|
||||
@@ -8,19 +8,19 @@ require (
|
||||
github.com/alibabacloud-go/darabonba-openapi v0.1.18
|
||||
github.com/alibabacloud-go/dysmsapi-20170525/v2 v2.0.16
|
||||
github.com/alibabacloud-go/tea v1.1.17
|
||||
github.com/alibabacloud-go/tea-utils v1.4.5
|
||||
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20190307165228-86c17b95fcd5
|
||||
github.com/bitly/go-simplejson v0.5.0
|
||||
github.com/bytedance/go-tagexpr/v2 v2.7.12
|
||||
github.com/casbin/casbin/v2 v2.25.1
|
||||
github.com/gin-gonic/gin v1.7.3
|
||||
github.com/casbin/casbin/v2 v2.37.4
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-admin-team/go-admin-core v1.3.8
|
||||
github.com/go-admin-team/go-admin-core/sdk v1.3.9
|
||||
github.com/google/uuid v1.2.0
|
||||
github.com/huaweicloud/huaweicloud-sdk-go-obs v3.21.12+incompatible
|
||||
github.com/mssola/user_agent v0.5.2
|
||||
github.com/nyaruka/phonenumbers v1.1.0 // indirect
|
||||
github.com/opentracing/opentracing-go v1.1.0
|
||||
github.com/prometheus/client_golang v1.11.0
|
||||
github.com/prometheus/client_golang v1.12.2
|
||||
github.com/qiniu/go-sdk/v7 v7.11.1
|
||||
github.com/robfig/cron/v3 v3.0.1
|
||||
github.com/shirou/gopsutil/v3 v3.22.1
|
||||
@@ -33,10 +33,16 @@ require (
|
||||
github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tdmq v1.0.330
|
||||
github.com/unrolled/secure v1.0.8
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect
|
||||
gorm.io/driver/mysql v1.0.4-0.20201206014609-ae5fd10184f6
|
||||
gorm.io/driver/postgres v1.0.6-0.20201208020313-1ed927cfab53
|
||||
gorm.io/driver/sqlite v1.1.5-0.20201206014648-c84401fbe3ba
|
||||
gorm.io/driver/sqlserver v1.0.4
|
||||
gorm.io/gorm v1.21.11
|
||||
gorm.io/driver/mysql v1.3.5
|
||||
gorm.io/driver/postgres v1.3.8
|
||||
gorm.io/driver/sqlite v1.3.1
|
||||
gorm.io/driver/sqlserver v1.3.2
|
||||
gorm.io/gorm v1.23.8
|
||||
)
|
||||
|
||||
replace github.com/go-admin-team/go-admin-core/sdk => github.com/hongjieWang/go-admin-core/sdk v1.3.12-0.20220727023055-ebc134c5b01d
|
||||
|
||||
replace github.com/go-admin-team/go-admin-core => github.com/hongjieWang/go-admin-core v1.3.9-0.20220727023055-ebc134c5b01d
|
||||
|
||||
//replace github.com/go-admin-team/go-admin-core/sdk => /Users/wanghongjie/GolandProjects/go-admin-core/sdk
|
||||
//replace github.com/go-admin-team/go-admin-core => /Users/wanghongjie/GolandProjects/go-admin-core
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: sms-gateway
|
||||
spec:
|
||||
selector:
|
||||
matchLabels:
|
||||
app: sms-gateway
|
||||
replicas: 1
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: sms-gateway
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: jdd-cloud
|
||||
containers:
|
||||
- name: sms-gateway
|
||||
imagePullPolicy: Always
|
||||
image: wellyspring.tencentcloudcr.com/jdd/new-jdd-sms-gateway:latest
|
||||
resources:
|
||||
requests:
|
||||
memory: 1024Mi
|
||||
cpu: 500m
|
||||
limits:
|
||||
memory: 1024Mi
|
||||
cpu: 500m
|
||||
ports:
|
||||
- name: http-port
|
||||
containerPort: 3000
|
||||
volumeMounts:
|
||||
- name: business-log
|
||||
mountPath: /home/yaoll/logs
|
||||
volumes:
|
||||
- name: business-log
|
||||
emptyDir: { }
|
||||
---
|
||||
#service
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: sms-gateway
|
||||
spec:
|
||||
selector:
|
||||
app: sms-gateway
|
||||
ports:
|
||||
- port: 3000
|
||||
protocol: TCP
|
||||
targetPort: 3000
|
||||
type: ClusterIP
|
||||
@@ -1,289 +0,0 @@
|
||||
# go-admin
|
||||
|
||||
<img align="right" width="320" src="https://gitee.com/mydearzwj/image/raw/master/img/go-admin.svg">
|
||||
|
||||
|
||||
[](https://github.com/go-admin-team/go-admin)
|
||||
[](https://github.com/go-admin-team/go-admin/releases)
|
||||
[](https://github.com/go-admin-team/go-admin)
|
||||
|
||||
[English](https://github.com/go-admin-team/go-admin/blob/master/README.md) | 简体中文
|
||||
|
||||
|
||||
基于Gin + Vue + Element UI的前后端分离权限管理系统,系统初始化极度简单,只需要配置文件中,修改数据库连接,系统支持多指令操作,迁移指令可以让初始化数据库信息变得更简单,服务指令可以很简单的启动api服务
|
||||
|
||||
[在线文档](https://doc.go-admin.dev)
|
||||
|
||||
[github在线文档](https://wenjianzhang.github.io)
|
||||
|
||||
[gitee在线文档](http://mydearzwj.gitee.io/go-admin-doc/)
|
||||
|
||||
[后端项目](https://github.com/go-admin-team/go-admin)
|
||||
|
||||
[视频教程](https://space.bilibili.com/565616721/channel/detail?cid=125737)
|
||||
|
||||
## ✨ 特性
|
||||
|
||||
- 遵循 RESTful API 设计规范
|
||||
|
||||
- 基于 GIN WEB API 框架,提供了丰富的中间件支持(用户认证、跨域、访问日志、追踪ID等)
|
||||
|
||||
- 基于Casbin的 RBAC 访问控制模型
|
||||
|
||||
- JWT 认证
|
||||
|
||||
- 支持 Swagger 文档(基于swaggo)
|
||||
|
||||
- 基于 GORM 的数据库存储,可扩展多种类型数据库
|
||||
|
||||
- 配置文件简单的模型映射,快速能够得到想要的配置
|
||||
|
||||
- 代码生成工具
|
||||
|
||||
- 表单构建工具
|
||||
|
||||
- 多指令模式
|
||||
|
||||
- TODO: 单元测试
|
||||
|
||||
|
||||
## 🎁 内置
|
||||
|
||||
1. 用户管理:用户是系统操作者,该功能主要完成系统用户配置。
|
||||
2. 部门管理:配置系统组织机构(公司、部门、小组),树结构展现支持数据权限。
|
||||
3. 岗位管理:配置系统用户所属担任职务。
|
||||
4. 菜单管理:配置系统菜单,操作权限,按钮权限标识,接口权限等。
|
||||
5. 角色管理:角色菜单权限分配、设置角色按机构进行数据范围权限划分。
|
||||
6. 字典管理:对系统中经常使用的一些较为固定的数据进行维护。
|
||||
7. 参数管理:对系统动态配置常用参数。
|
||||
8. 操作日志:系统正常操作日志记录和查询;系统异常信息日志记录和查询。
|
||||
9. 登录日志:系统登录日志记录查询包含登录异常。
|
||||
1. 接口文档:根据业务代码自动生成相关的api接口文档。
|
||||
1. 代码生成:根据数据表结构生成对应的增删改查相对应业务,全程可视化操作,让基本业务可以零代码实现。
|
||||
1. 表单构建:自定义页面样式,拖拉拽实现页面布局。
|
||||
1. 服务监控:查看一些服务器的基本信息。
|
||||
1. 内容管理:demo功能,下设分类管理、内容管理。可以参考使用方便快速入门。
|
||||
|
||||
## 准备工作
|
||||
|
||||
你需要在本地安装 [go] [gin] [node](http://nodejs.org/) 和 [git](https://git-scm.com/)
|
||||
|
||||
同时配套了系列教程包含视频和文档,如何从下载完成到熟练使用,强烈建议大家先看完这些教程再来实践本项目!!!
|
||||
|
||||
### 轻松实现go-admin写出第一个应用 - 文档教程
|
||||
|
||||
[步骤一 - 基础内容介绍](http://doc.zhangwj.com/go-admin-site/guide/intro/tutorial01.html)
|
||||
|
||||
[步骤二 - 实际应用 - 编写增删改查](http://doc.zhangwj.com/go-admin-site/guide/intro/tutorial02.html)
|
||||
|
||||
### 手把手教你从入门到放弃 - 视频教程
|
||||
|
||||
[如何启动go-admin](https://www.bilibili.com/video/BV1z5411x7JG)
|
||||
|
||||
[使用生成工具轻松实现业务](https://www.bilibili.com/video/BV1Dg4y1i79D)
|
||||
|
||||
[v1.1.0版本代码生成工具-释放双手](https://www.bilibili.com/video/BV1N54y1i71P) [进阶]
|
||||
|
||||
[多命令启动方式讲解以及IDE配置](https://www.bilibili.com/video/BV1Fg4y1q7ph)
|
||||
|
||||
[go-admin菜单的配置说明](https://www.bilibili.com/video/BV1Wp4y1D715) [必看]
|
||||
|
||||
[如何配置菜单信息以及接口信息](https://www.bilibili.com/video/BV1zv411B7nG) [必看]
|
||||
|
||||
[go-admin权限配置使用说明](https://www.bilibili.com/video/BV1rt4y197d3) [必看]
|
||||
|
||||
[go-admin数据权限使用说明](https://www.bilibili.com/video/BV1LK4y1s71e) [必看]
|
||||
|
||||
|
||||
**如有问题请先看上述使用文档和文章,若不能满足,欢迎 issue 和 pr ,视频教程和文档持续更新中**
|
||||
|
||||
## 📦 本地开发
|
||||
|
||||
### 开发目录创建
|
||||
|
||||
```bash
|
||||
|
||||
# 创建开发目录
|
||||
mkdir goadmin
|
||||
cd goadmin
|
||||
```
|
||||
|
||||
### 获取代码
|
||||
|
||||
> 重点注意:两个项目必须放在同一文件夹下;
|
||||
|
||||
```bash
|
||||
# 获取后端代码
|
||||
git clone https://github.com/go-admin-team/go-admin.git
|
||||
|
||||
# 获取前端代码
|
||||
git clone https://github.com/go-admin-team/go-admin-ui.git
|
||||
|
||||
```
|
||||
|
||||
|
||||
### 启动说明
|
||||
|
||||
#### 服务端启动说明
|
||||
|
||||
```bash
|
||||
# 进入 go-admin 后端项目
|
||||
cd ./go-admin
|
||||
|
||||
# 编译项目
|
||||
go build
|
||||
|
||||
# 修改配置
|
||||
# 文件路径 go-admin/config/settings.yml
|
||||
vi ./config/setting.yml
|
||||
|
||||
# 1. 配置文件中修改数据库信息
|
||||
# 注意: settings.database 下对应的配置数据
|
||||
# 2. 确认log路径
|
||||
```
|
||||
|
||||
:::tip ⚠️注意 在windows环境如果没有安装中CGO,会出现这个问题;
|
||||
|
||||
```bash
|
||||
E:\go-admin>go build
|
||||
# github.com/mattn/go-sqlite3
|
||||
cgo: exec /missing-cc: exec: "/missing-cc": file does not exist
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
D:\Code\go-admin>go build
|
||||
# github.com/mattn/go-sqlite3
|
||||
cgo: exec gcc: exec: "gcc": executable file not found in %PATH%
|
||||
```
|
||||
|
||||
[解决cgo问题进入](https://doc.go-admin.dev/guide/other/faq.html#_5-cgo-exec-missing-cc-exec-missing-cc-file-does-not-exist)
|
||||
|
||||
:::
|
||||
|
||||
#### 初始化数据库,以及服务启动
|
||||
|
||||
``` bash
|
||||
# 首次配置需要初始化数据库资源信息
|
||||
# macOS or linux 下使用
|
||||
$ ./go-admin migrate -c=config/settings.dev.yml
|
||||
|
||||
# ⚠️注意:windows 下使用
|
||||
$ go-admin.exe migrate -c=config/settings.dev.yml
|
||||
|
||||
|
||||
# 启动项目,也可以用IDE进行调试
|
||||
# macOS or linux 下使用
|
||||
$ ./go-admin server -c config/settings.yml
|
||||
|
||||
|
||||
# ⚠️注意:windows 下使用
|
||||
$ go-admin.exe server -c config/settings.yml
|
||||
```
|
||||
|
||||
#### 使用docker 编译启动
|
||||
|
||||
```shell
|
||||
# 编译镜像
|
||||
docker build -t go-admin .
|
||||
|
||||
# 启动容器,第一个go-admin是容器名字,第二个go-admin是镜像名称
|
||||
# -v 映射配置文件 本地路径:容器路径
|
||||
docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### 文档生成
|
||||
|
||||
```bash
|
||||
go generate
|
||||
```
|
||||
|
||||
#### 交叉编译
|
||||
```bash
|
||||
# windows
|
||||
env GOOS=windows GOARCH=amd64 go build main.go
|
||||
|
||||
# or
|
||||
# linux
|
||||
env GOOS=linux GOARCH=amd64 go build main.go
|
||||
```
|
||||
|
||||
### UI交互端启动说明
|
||||
|
||||
```bash
|
||||
# 安装依赖
|
||||
npm install
|
||||
|
||||
# 建议不要直接使用 cnpm 安装依赖,会有各种诡异的 bug。可以通过如下操作解决 npm 下载速度慢的问题
|
||||
npm install --registry=https://registry.npm.taobao.org
|
||||
|
||||
# 启动服务
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## 🎬 在线体验
|
||||
> admin / 123456
|
||||
|
||||
演示地址:[http://www.go-admin.dev](http://www.go-admin.dev/#/login)
|
||||
|
||||
|
||||
## 📨 互动
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/wx.png" width="180px"></td>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq.png" width="200px"></td>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq2.png" width="200px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>微信</td>
|
||||
<td>此群已满</td>
|
||||
<td><a target="_blank" href="https://shang.qq.com/wpa/qunwpa?idkey=0f2bf59f5f2edec6a4550c364242c0641f870aa328e468c4ee4b7dbfb392627b"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="go-admin技术交流乙号" title="go-admin技术交流乙号"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 💎 主要成员
|
||||
|
||||
<a href="https://github.com/wenjianzhang"> <img src="https://avatars.githubusercontent.com/u/3890175?s=460&u=20eac63daef81588fbac611da676b99859319251&v=4" width="80px"></a>
|
||||
<a href="https://github.com/lwnmengjing"> <img src="https://avatars.githubusercontent.com/u/12806223?s=400&u=a89272dce50100b77b4c0d5c81c718bf78ebb580&v=4" width="80px"></a>
|
||||
<a href="https://github.com/chengxiao"> <img src="https://avatars.githubusercontent.com/u/1379545?s=460&u=557da5503d0ac4a8628df6b4075b17853d5edcd9&v=4" width="80px"></a>
|
||||
<a href="https://github.com/bing127"> <img src="https://avatars.githubusercontent.com/u/31166183?s=460&u=c085bff88df10bb7676c8c0351ba9dcd031d1fb3&v=4" width="80px"></a>
|
||||
|
||||
|
||||
|
||||
## JetBrains 开源证书支持
|
||||
|
||||
`go-admin` 项目一直以来都是在 JetBrains 公司旗下的 GoLand 集成开发环境中进行开发,基于 **free JetBrains Open Source license(s)** 正版免费授权,在此表达我的谢意。
|
||||
|
||||
<a href="https://www.jetbrains.com/?from=kubeadm-ha" target="_blank"><img src="https://raw.githubusercontent.com/panjf2000/illustrations/master/jetbrains/jetbrains-variant-4.png" width="250" align="middle"/></a>
|
||||
|
||||
|
||||
## 🤝 特别感谢
|
||||
1. [chengxiao](https://github.com/chengxiao)
|
||||
2. [gin](https://github.com/gin-gonic/gin)
|
||||
2. [casbin](https://github.com/casbin/casbin)
|
||||
2. [spf13/viper](https://github.com/spf13/viper)
|
||||
2. [gorm](https://github.com/jinzhu/gorm)
|
||||
2. [gin-swagger](https://github.com/swaggo/gin-swagger)
|
||||
2. [jwt-go](https://github.com/dgrijalva/jwt-go)
|
||||
2. [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
|
||||
2. [ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue)
|
||||
2. [form-generator](https://github.com/JakHuang/form-generator)
|
||||
|
||||
## 🤟 打赏
|
||||
|
||||
> 如果你觉得这个项目帮助到了你,你可以帮作者买一杯果汁表示鼓励 :tropical_drink:
|
||||
|
||||
<img class="no-margin" src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/pay.png" height="200px" >
|
||||
|
||||
## 🤝 链接
|
||||
[Go开发者成长线路图](http://www.golangroadmap.com/)
|
||||
|
||||
## 🔑 License
|
||||
|
||||
[MIT](https://github.com/go-admin-team/go-admin/blob/master/LICENSE.md)
|
||||
|
||||
Copyright (c) 2020 wenjianzhang
|
||||
@@ -1,276 +0,0 @@
|
||||
# go-admin
|
||||
|
||||
<img align="right" width="320" src="https://gitee.com/mydearzwj/image/raw/master/img/go-admin.svg">
|
||||
|
||||
|
||||
[](https://github.com/go-admin-team/go-admin)
|
||||
[](https://github.com/go-admin-team/go-admin/releases)
|
||||
[](https://github.com/go-admin-team/go-admin)
|
||||
|
||||
English | [简体中文](https://github.com/go-admin-team/go-admin/blob/master/README.Zh-cn.md)
|
||||
|
||||
The front-end and back-end separation authority management system based on Gin + Vue + Element UI is extremely simple to initialize the system. You only need to modify the database connection in the configuration file. The system supports multi-instruction operations. Migration instructions can make it easier to initialize database information. Service instructions It's easy to start the api service.
|
||||
|
||||
[documentation](https://doc.go-admin.dev)
|
||||
|
||||
[Backend project](https://github.com/go-admin-team/go-admin)
|
||||
|
||||
[Video tutorial](https://space.bilibili.com/565616721/channel/detail?cid=125737)
|
||||
|
||||
## ✨ Feature
|
||||
|
||||
- Follow RESTful API design specifications
|
||||
|
||||
- Based on the GIN WEB API framework, it provides rich middleware support (user authentication, cross-domain, access log, tracking ID, etc.)
|
||||
|
||||
- RBAC access control model based on Casbin
|
||||
|
||||
- JWT authentication
|
||||
|
||||
- Support Swagger documents (based on swaggo)
|
||||
|
||||
- Database storage based on GORM, which can expand multiple types of databases
|
||||
|
||||
- Simple model mapping of configuration files to quickly get the desired configuration
|
||||
|
||||
- Code generation tool
|
||||
|
||||
- Form builder
|
||||
|
||||
- Multi-command mode
|
||||
|
||||
- TODO: unit test
|
||||
|
||||
|
||||
## 🎁 Internal
|
||||
|
||||
1. User management: The user is the system operator, this function mainly completes the system user configuration.
|
||||
2. Department management: configure the system organization (company, department, group), and display the tree structure to support data permissions.
|
||||
3. Position management: configure the positions of system users.
|
||||
4. Menu management: configure the system menu, operation authority, button authority identification, interface authority, etc.
|
||||
5. Role management: Role menu permission assignment and role setting are divided into data scope permissions by organization.
|
||||
6. Dictionary management: Maintain some relatively fixed data frequently used in the system.
|
||||
7. Parameter management: dynamically configure common parameters for the system.
|
||||
8. Operation log: system normal operation log record and query; system abnormal information log record and query.
|
||||
9. Login log: The system login log record query contains login exceptions.
|
||||
1. Interface documentation: Automatically generate related api interface documents according to the business code.
|
||||
1. Code generation: According to the data table structure, generate the corresponding addition, deletion, modification, and check corresponding business, and the whole process of visual operation, so that the basic business can be implemented with zero code.
|
||||
1. Form construction: Customize the page style, drag and drop to realize the page layout.
|
||||
1. Service monitoring: View the basic information of some servers.
|
||||
1. Content management: demo function, including classification management and content management. You can refer to the easy to use quick start.
|
||||
|
||||
## Ready to work
|
||||
|
||||
You need to install locally [go] [gin] [node](http://nodejs.org/) 和 [git](https://git-scm.com/)
|
||||
|
||||
At the same time, a series of tutorials including videos and documents are provided. How to complete the downloading to the proficient use, it is strongly recommended that you read these tutorials before you practice this project! ! !
|
||||
|
||||
### Easily implement go-admin to write the first application-documentation tutorial
|
||||
|
||||
[Step 1 - basic content introduction](http://doc.zhangwj.com/go-admin-site/guide/intro/tutorial01.html)
|
||||
|
||||
[Step 2 - Practical application - writing database operations](http://doc.zhangwj.com/go-admin-site/guide/intro/tutorial02.html)
|
||||
|
||||
### Teach you from getting started to giving up-video tutorial
|
||||
|
||||
[How to start go-admin](https://www.bilibili.com/video/BV1z5411x7JG)
|
||||
|
||||
[Easily implement business using build tools](https://www.bilibili.com/video/BV1Dg4y1i79D)
|
||||
|
||||
[v1.1.0 version code generation tool-free your hands](https://www.bilibili.com/video/BV1N54y1i71P) [Advanced]
|
||||
|
||||
[Explanation of multi-command startup mode and IDE configuration](https://www.bilibili.com/video/BV1Fg4y1q7ph)
|
||||
|
||||
[Configuration instructions for go-admin menu](https://www.bilibili.com/video/BV1Wp4y1D715) [Must see]
|
||||
|
||||
[How to configure menu information and interface information](https://www.bilibili.com/video/BV1zv411B7nG) [Must see]
|
||||
|
||||
[go-admin permission configuration instructions](https://www.bilibili.com/video/BV1rt4y197d3) [Must see]
|
||||
|
||||
[Instructions for use of go-admin data permissions](https://www.bilibili.com/video/BV1LK4y1s71e) [Must see]
|
||||
|
||||
**If you have any questions, please read the above-mentioned usage documents and articles first. If you are not satisfied, welcome to issue and pr. Video tutorials and documents are being updated continuously.**
|
||||
|
||||
## 📦 Local development
|
||||
|
||||
### Development directory creation
|
||||
|
||||
```bash
|
||||
|
||||
# Create a development directory
|
||||
mkdir goadmin
|
||||
cd goadmin
|
||||
```
|
||||
|
||||
### Get the code
|
||||
|
||||
> Important note: the two projects must be placed in the same folder;
|
||||
|
||||
```bash
|
||||
# Get backend code
|
||||
git clone https://github.com/go-admin-team/go-admin.git
|
||||
|
||||
# Get the front-end code
|
||||
git clone https://github.com/go-admin-team/go-admin-ui.git
|
||||
|
||||
```
|
||||
|
||||
### Startup instructions
|
||||
|
||||
#### Server startup instructions
|
||||
|
||||
```bash
|
||||
# Enter the go-admin backend project
|
||||
cd ./go-admin
|
||||
|
||||
# Compile the project
|
||||
go build
|
||||
|
||||
# Change setting
|
||||
# File path go-admin/config/settings.yml
|
||||
vi ./config/setting.yml
|
||||
|
||||
# 1. Modify the database information in the configuration file
|
||||
# Note: The corresponding configuration data under settings.database
|
||||
# 2. Confirm the log path
|
||||
```
|
||||
|
||||
:::tip ⚠️Note that this problem will occur if CGO is not installed in the windows environment;
|
||||
|
||||
```bash
|
||||
E:\go-admin>go build
|
||||
# github.com/mattn/go-sqlite3
|
||||
cgo: exec /missing-cc: exec: "/missing-cc": file does not exist
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
D:\Code\go-admin>go build
|
||||
# github.com/mattn/go-sqlite3
|
||||
cgo: exec gcc: exec: "gcc": executable file not found in %PATH%
|
||||
```
|
||||
|
||||
[Solve the cgo problem and enter](https://doc.go-admin.dev/guide/other/faq.html#_5-cgo-exec-missing-cc-exec-missing-cc-file-does-not-exist)
|
||||
|
||||
:::
|
||||
|
||||
#### Initialize the database, and start the service
|
||||
|
||||
``` bash
|
||||
# The first configuration needs to initialize the database resource information
|
||||
# Use under macOS or linux
|
||||
$ ./go-admin migrate -c=config/settings.dev.yml
|
||||
|
||||
# ⚠️Note: Use under windows
|
||||
$ go-admin.exe migrate -c=config/settings.dev.yml
|
||||
|
||||
# Start the project, you can also use the IDE for debugging
|
||||
# Use under macOS or linux
|
||||
$ ./go-admin server -c config/settings.yml
|
||||
|
||||
# ⚠️Note: Use under windows
|
||||
$ go-admin.exe server -c config/settings.yml
|
||||
```
|
||||
|
||||
#### Use docker to compile and start
|
||||
|
||||
```shell
|
||||
# Compile the image
|
||||
docker build -t go-admin .
|
||||
|
||||
|
||||
# Start the container, the first go-admin is the container name, and the second go-admin is the image name
|
||||
# -v Mapping configuration file Local path: container path
|
||||
docker run --name go-admin -p 8000:8000 -v /config/settings.yml:/config/settings.yml -d go-admin-server
|
||||
```
|
||||
|
||||
|
||||
|
||||
#### Generation Document
|
||||
|
||||
```bash
|
||||
go generate
|
||||
```
|
||||
|
||||
#### Cross compile
|
||||
```bash
|
||||
# windows
|
||||
env GOOS=windows GOARCH=amd64 go build main.go
|
||||
|
||||
# or
|
||||
# linux
|
||||
env GOOS=linux GOARCH=amd64 go build main.go
|
||||
```
|
||||
|
||||
### UI interactive terminal startup instructions
|
||||
|
||||
```bash
|
||||
# Installation dependencies
|
||||
npm install # or cnpm install
|
||||
|
||||
# Start service
|
||||
npm run dev
|
||||
```
|
||||
|
||||
## 🎬 Online Demo
|
||||
> admin / 123456
|
||||
|
||||
演示地址:[http://www.go-admin.dev](http://www.go-admin.dev/#/login)
|
||||
|
||||
|
||||
## 📨 Interactive
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/wx.png" width="180px"></td>
|
||||
<td><img src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/qq2.png" width="200px"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Wechat</td>
|
||||
<td><a target="_blank" href="https://shang.qq.com/wpa/qunwpa?idkey=0f2bf59f5f2edec6a4550c364242c0641f870aa328e468c4ee4b7dbfb392627b"><img border="0" src="https://pub.idqqimg.com/wpa/images/group.png" alt="go-admin技术交流乙号" title="go-admin技术交流乙号"></a></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
## 💎 Members
|
||||
|
||||
<a href="https://github.com/wenjianzhang"> <img src="https://avatars.githubusercontent.com/u/3890175?s=460&u=20eac63daef81588fbac611da676b99859319251&v=4" width="80px"></a>
|
||||
<a href="https://github.com/lwnmengjing"> <img src="https://avatars.githubusercontent.com/u/12806223?s=400&u=a89272dce50100b77b4c0d5c81c718bf78ebb580&v=4" width="80px"></a>
|
||||
<a href="https://github.com/chengxiao"> <img src="https://avatars.githubusercontent.com/u/1379545?s=460&u=557da5503d0ac4a8628df6b4075b17853d5edcd9&v=4" width="80px"></a>
|
||||
<a href="https://github.com/bing127"> <img src="https://avatars.githubusercontent.com/u/31166183?s=460&u=c085bff88df10bb7676c8c0351ba9dcd031d1fb3&v=4" width="80px"></a>
|
||||
|
||||
|
||||
|
||||
## JetBrains open source certificate support
|
||||
|
||||
The `go-admin` project has always been developed in the GoLand integrated development environment under JetBrains, based on the **free JetBrains Open Source license(s)** genuine free license. I would like to express my gratitude.
|
||||
|
||||
<a href="https://www.jetbrains.com/?from=kubeadm-ha" target="_blank"><img src="https://raw.githubusercontent.com/panjf2000/illustrations/master/jetbrains/jetbrains-variant-4.png" width="250" align="middle"/></a>
|
||||
|
||||
|
||||
## 🤝 Thanks
|
||||
1. [chengxiao](https://github.com/chengxiao)
|
||||
2. [gin](https://github.com/gin-gonic/gin)
|
||||
2. [casbin](https://github.com/casbin/casbin)
|
||||
2. [spf13/viper](https://github.com/spf13/viper)
|
||||
2. [gorm](https://github.com/jinzhu/gorm)
|
||||
2. [gin-swagger](https://github.com/swaggo/gin-swagger)
|
||||
2. [jwt-go](https://github.com/dgrijalva/jwt-go)
|
||||
2. [vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
|
||||
2. [ruoyi-vue](https://gitee.com/y_project/RuoYi-Vue)
|
||||
2. [form-generator](https://github.com/JakHuang/form-generator)
|
||||
|
||||
## 🤟 Sponsor Us
|
||||
|
||||
> If you think this project helped you, you can buy a glass of juice for the author to show encouragement :tropical_drink:
|
||||
|
||||
<img class="no-margin" src="https://raw.githubusercontent.com/wenjianzhang/image/master/img/pay.png" height="200px" >
|
||||
|
||||
## 🤝 Link
|
||||
[Go developer growth roadmap](http://www.golangroadmap.com/)
|
||||
|
||||
## 🔑 License
|
||||
|
||||
[MIT](https://github.com/go-admin-team/go-admin/blob/master/LICENSE.md)
|
||||
|
||||
Copyright (c) 2020 wenjianzhang
|
||||
@@ -1,47 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询TArticleType列表
|
||||
export function listTArticleType(query) {
|
||||
return request({
|
||||
url: '/api/v1/t-article-type',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询TArticleType详细
|
||||
export function getTArticleType (id) {
|
||||
return request({
|
||||
url: '/api/v1/t-article-type/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 新增TArticleType
|
||||
export function addTArticleType(data) {
|
||||
return request({
|
||||
url: '/api/v1/t-article-type',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改TArticleType
|
||||
export function updateTArticleType(data) {
|
||||
return request({
|
||||
url: '/api/v1/t-article-type/'+data.id,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除TArticleType
|
||||
export function delTArticleType(data) {
|
||||
return request({
|
||||
url: '/api/v1/t-article-type',
|
||||
method: 'delete',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 查询TArticle列表
|
||||
export function listTArticle(query) {
|
||||
return request({
|
||||
url: '/api/v1/t-article',
|
||||
method: 'get',
|
||||
params: query
|
||||
})
|
||||
}
|
||||
|
||||
// 查询TArticle详细
|
||||
export function getTArticle (id) {
|
||||
return request({
|
||||
url: '/api/v1/t-article/' + id,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
// 新增TArticle
|
||||
export function addTArticle(data) {
|
||||
return request({
|
||||
url: '/api/v1/t-article',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 修改TArticle
|
||||
export function updateTArticle(data) {
|
||||
return request({
|
||||
url: '/api/v1/t-article/'+data.id,
|
||||
method: 'put',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// 删除TArticle
|
||||
export function delTArticle(data) {
|
||||
return request({
|
||||
url: '/api/v1/t-article',
|
||||
method: 'delete',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
// 获取验证码
|
||||
export function getAllCount() {
|
||||
return request({
|
||||
url: '/api/v1/sms-dashboard/count',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getSuccessCount() {
|
||||
return request({
|
||||
url: '/api/v1/sms-dashboard/get-success-count',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getRequestCount() {
|
||||
return request({
|
||||
url: '/api/v1/sms-dashboard/get-request-count',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询集群列表
|
||||
export function listClusters(query) {
|
||||
return request({
|
||||
url: "/api/v1/mq/describe-page-clusters",
|
||||
method: "get",
|
||||
params: query,
|
||||
});
|
||||
}
|
||||
//查询集群列表-Select
|
||||
export function describeSelectClusters() {
|
||||
return request({
|
||||
url: "/api/v1/mq/describe-select-clusters",
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询集群列表
|
||||
export function listEnvironments(clustersId) {
|
||||
return request({
|
||||
url: "/api/v1/mq/describe-environments/" + clustersId,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
//获取命名空间下拉
|
||||
export function selectEnvironments(clustersId) {
|
||||
return request({
|
||||
url: "/api/v1/mq/describe-select-environments/" + clustersId,
|
||||
method: "get",
|
||||
});
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
import request from "@/utils/request";
|
||||
|
||||
// 查询集群列表
|
||||
export function listTopic(data) {
|
||||
return request({
|
||||
url: "/api/v1/mq/page-describe-topics",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
// 创建topic
|
||||
export function addTopic(data) {
|
||||
return request({
|
||||
url: "/api/v1/mq/create-topic",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
//删除topic
|
||||
export function delTopic(data) {
|
||||
return request({
|
||||
url: "/api/v1/mq/delete-topic",
|
||||
method: "post",
|
||||
data: data,
|
||||
});
|
||||
}
|
||||
@@ -1,316 +0,0 @@
|
||||
|
||||
<template>
|
||||
<BasicLayout>
|
||||
<template #wrapper>
|
||||
<el-card class="box-card">
|
||||
<el-form
|
||||
ref="queryForm"
|
||||
:model="queryParams"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
||||
>重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
v-permisaction="['admin:tArticleType:add']"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
v-permisaction="['admin:tArticleType:edit']"
|
||||
type="success"
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
v-permisaction="['admin:tArticleType:remove']"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tArticleTypeList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="分类编号" prop="typeNo" />
|
||||
<el-table-column label="分类名称" prop="typeName" />
|
||||
<el-table-column label="状态" prop="status" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-popconfirm
|
||||
class="delete-popconfirm"
|
||||
title="确认要修改吗?"
|
||||
confirm-button-text="修改"
|
||||
@onConfirm="handleUpdate(scope.row)"
|
||||
>
|
||||
<el-button
|
||||
slot="reference"
|
||||
v-permisaction="['admin:tArticleType:edit']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
<el-popconfirm
|
||||
class="delete-popconfirm"
|
||||
title="确认要删除吗?"
|
||||
confirm-button-text="删除"
|
||||
@onConfirm="handleDelete(scope.row)"
|
||||
>
|
||||
<el-button
|
||||
slot="reference"
|
||||
v-permisaction="['admin:tArticleType:remove']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageIndex"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="分类编号" prop="typeNo">
|
||||
<el-input v-model="form.typeNo" placeholder="分类编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="分类名称" prop="typeName">
|
||||
<el-input v-model="form.typeName" placeholder="分类名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-input v-model="form.status" placeholder="状态" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
addTArticleType,
|
||||
delTArticleType,
|
||||
getTArticleType,
|
||||
listTArticleType,
|
||||
updateTArticleType,
|
||||
} from "@/api/admin/t-article-type";
|
||||
|
||||
export default {
|
||||
name: "TArticleType",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
isEdit: false,
|
||||
// 类型数据字典
|
||||
typeOptions: [],
|
||||
tArticleTypeList: [],
|
||||
|
||||
// 关系表类型
|
||||
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
status: true,
|
||||
},
|
||||
// 表单校验
|
||||
rules: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询参数列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listTArticleType(
|
||||
this.addDateRange(this.queryParams, this.dateRange)
|
||||
).then((response) => {
|
||||
this.tArticleTypeList = response.data.list;
|
||||
this.total = response.data.count;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
typeNo: undefined,
|
||||
typeName: undefined,
|
||||
status: undefined,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
getImgList: function () {
|
||||
this.form[this.fileIndex] =
|
||||
this.$refs["fileChoose"].resultList[0].fullUrl;
|
||||
},
|
||||
fileClose: function () {
|
||||
this.fileOpen = false;
|
||||
},
|
||||
// 关系
|
||||
// 文件
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageIndex = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加文章分类表";
|
||||
this.isEdit = false;
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids;
|
||||
getTArticleType(id).then((response) => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改文章分类表";
|
||||
this.isEdit = true;
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.id !== undefined) {
|
||||
updateTArticleType(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
addTArticleType(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
var Ids = (row.id && [row.id]) || this.ids;
|
||||
|
||||
this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(function () {
|
||||
return delTArticleType({ ids: Ids });
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,337 +0,0 @@
|
||||
|
||||
<template>
|
||||
<BasicLayout>
|
||||
<template #wrapper>
|
||||
<el-card class="box-card">
|
||||
<el-form
|
||||
ref="queryForm"
|
||||
:model="queryParams"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
size="mini"
|
||||
@click="handleQuery"
|
||||
>搜索</el-button
|
||||
>
|
||||
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
|
||||
>重置</el-button
|
||||
>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
v-permisaction="['admin:tArticle:add']"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
v-permisaction="['admin:tArticle:edit']"
|
||||
type="success"
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
:disabled="single"
|
||||
@click="handleUpdate"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-col>
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
v-permisaction="['admin:tArticle:remove']"
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
:disabled="multiple"
|
||||
@click="handleDelete"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="tArticleList"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="文章编号" prop="articleNo" />
|
||||
<el-table-column label="文章名称" prop="articleName" />
|
||||
<el-table-column label="文章分类" prop="articleType" />
|
||||
<el-table-column label="文章标题" prop="articleTitle" />
|
||||
<el-table-column label="文章作者" prop="articleAuthor" />
|
||||
<el-table-column label="副标题" prop="articleSubtitle" />
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="center"
|
||||
class-name="small-padding fixed-width"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-popconfirm
|
||||
class="delete-popconfirm"
|
||||
title="确认要修改吗?"
|
||||
confirm-button-text="修改"
|
||||
@onConfirm="handleUpdate(scope.row)"
|
||||
>
|
||||
<el-button
|
||||
slot="reference"
|
||||
v-permisaction="['admin:tArticle:edit']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
>修改
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
<el-popconfirm
|
||||
class="delete-popconfirm"
|
||||
title="确认要删除吗?"
|
||||
confirm-button-text="删除"
|
||||
@onConfirm="handleDelete(scope.row)"
|
||||
>
|
||||
<el-button
|
||||
slot="reference"
|
||||
v-permisaction="['admin:tArticle:remove']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
>删除
|
||||
</el-button>
|
||||
</el-popconfirm>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageIndex"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改对话框 -->
|
||||
<el-dialog :title="title" :visible.sync="open" width="500px">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="文章编号" prop="articleNo">
|
||||
<el-input v-model="form.articleNo" placeholder="文章编号" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文章分类" prop="articleType">
|
||||
<el-input v-model="form.articleType" placeholder="文章分类" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文章名称" prop="articleName">
|
||||
<el-input v-model="form.articleName" placeholder="文章名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文章标题" prop="articleTitle">
|
||||
<el-input v-model="form.articleTitle" placeholder="文章标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文章作者" prop="articleAuthor">
|
||||
<el-input v-model="form.articleAuthor" placeholder="文章作者" />
|
||||
</el-form-item>
|
||||
<el-form-item label="副标题" prop="articleSubtitle">
|
||||
<el-input v-model="form.articleSubtitle" placeholder="副标题" />
|
||||
</el-form-item>
|
||||
<el-form-item label="文章内容HTML" prop="articleText">
|
||||
<el-input v-model="form.articleText" placeholder="文章内容HTML" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-input v-model="form.status" placeholder="状态" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
addTArticle,
|
||||
delTArticle,
|
||||
getTArticle,
|
||||
listTArticle,
|
||||
updateTArticle,
|
||||
} from "@/api/admin/t-article";
|
||||
|
||||
export default {
|
||||
name: "TArticle",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
isEdit: false,
|
||||
// 类型数据字典
|
||||
typeOptions: [],
|
||||
tArticleList: [],
|
||||
|
||||
// 关系表类型
|
||||
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
},
|
||||
// 表单参数
|
||||
form: {},
|
||||
// 表单校验
|
||||
rules: {},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
},
|
||||
methods: {
|
||||
/** 查询参数列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listTArticle(this.addDateRange(this.queryParams, this.dateRange)).then(
|
||||
(response) => {
|
||||
this.tArticleList = response.data.list;
|
||||
this.total = response.data.count;
|
||||
this.loading = false;
|
||||
}
|
||||
);
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.form = {
|
||||
id: undefined,
|
||||
articleNo: undefined,
|
||||
articleType: undefined,
|
||||
articleName: undefined,
|
||||
articleTitle: undefined,
|
||||
articleAuthor: undefined,
|
||||
articleSubtitle: undefined,
|
||||
articleText: undefined,
|
||||
status: undefined,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
getImgList: function () {
|
||||
this.form[this.fileIndex] =
|
||||
this.$refs["fileChoose"].resultList[0].fullUrl;
|
||||
},
|
||||
fileClose: function () {
|
||||
this.fileOpen = false;
|
||||
},
|
||||
// 关系
|
||||
// 文件
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageIndex = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加文章内容表";
|
||||
this.isEdit = false;
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.id);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.reset();
|
||||
const id = row.id || this.ids;
|
||||
getTArticle(id).then((response) => {
|
||||
this.form = response.data;
|
||||
this.open = true;
|
||||
this.title = "修改文章内容表";
|
||||
this.isEdit = true;
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.id !== undefined) {
|
||||
updateTArticle(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
addTArticle(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
var Ids = (row.id && [row.id]) || this.ids;
|
||||
|
||||
this.$confirm('是否确认删除编号为"' + Ids + '"的数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
})
|
||||
.then(function () {
|
||||
return delTArticle({ ids: Ids });
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,54 +1,113 @@
|
||||
<template>
|
||||
<div class="dashboard-editor-container">
|
||||
<el-row :gutter="12">
|
||||
<el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
|
||||
<chart-card title="总销售额" total="¥126,560">
|
||||
<el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
|
||||
<el-col
|
||||
:sm="24"
|
||||
:xs="24"
|
||||
:md="6"
|
||||
:xl="6"
|
||||
:lg="6"
|
||||
:style="{ marginBottom: '12px' }"
|
||||
>
|
||||
<chart-card title="总发送条数" :total="count">
|
||||
<el-tooltip
|
||||
slot="action"
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="指标说明"
|
||||
placement="top-start"
|
||||
>
|
||||
<i class="el-icon-warning-outline" />
|
||||
</el-tooltip>
|
||||
<div>
|
||||
<trend flag="top" style="margin-right: 16px;" rate="12">
|
||||
<trend flag="top" style="margin-right: 16px" rate="12">
|
||||
<span slot="term">周同比</span>
|
||||
</trend>
|
||||
<trend flag="bottom" rate="11">
|
||||
<span slot="term">日同比</span>
|
||||
</trend>
|
||||
</div>
|
||||
<template slot="footer">日均销售额<span>¥ 234.56</span></template>
|
||||
<template slot="footer">日均短信条数: <span>10 条</span></template>
|
||||
</chart-card>
|
||||
</el-col>
|
||||
<el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
|
||||
<chart-card title="访问量" :total="8846">
|
||||
<el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
|
||||
<el-col
|
||||
:sm="24"
|
||||
:xs="24"
|
||||
:md="6"
|
||||
:xl="6"
|
||||
:lg="6"
|
||||
:style="{ marginBottom: '12px' }"
|
||||
>
|
||||
<chart-card title="成功条数" :total="successCount">
|
||||
<el-tooltip
|
||||
slot="action"
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="指标说明"
|
||||
placement="top-start"
|
||||
>
|
||||
<i class="el-icon-warning-outline" />
|
||||
</el-tooltip>
|
||||
<div>
|
||||
<mini-area />
|
||||
</div>
|
||||
<template slot="footer">日访问量<span> {{ '1234' }}</span></template>
|
||||
<template
|
||||
slot="footer"
|
||||
>日成功<span> {{ "200条" }}</span></template>
|
||||
</chart-card>
|
||||
</el-col>
|
||||
<el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
|
||||
<chart-card title="支付笔数" :total="6560">
|
||||
<el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
|
||||
<el-col
|
||||
:sm="24"
|
||||
:xs="24"
|
||||
:md="6"
|
||||
:xl="6"
|
||||
:lg="6"
|
||||
:style="{ marginBottom: '12px' }"
|
||||
>
|
||||
<chart-card title="接口请求次数" :total="requestCount">
|
||||
<el-tooltip
|
||||
slot="action"
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="指标说明"
|
||||
placement="top-start"
|
||||
>
|
||||
<i class="el-icon-warning-outline" />
|
||||
</el-tooltip>
|
||||
<div>
|
||||
<mini-bar />
|
||||
</div>
|
||||
<template slot="footer">转化率 <span>60%</span></template>
|
||||
<template slot="footer">成功率 <span>100%</span></template>
|
||||
</chart-card>
|
||||
</el-col>
|
||||
<el-col :sm="24" :xs="24" :md="6" :xl="6" :lg="6" :style="{ marginBottom: '12px' }">
|
||||
<el-col
|
||||
:sm="24"
|
||||
:xs="24"
|
||||
:md="6"
|
||||
:xl="6"
|
||||
:lg="6"
|
||||
:style="{ marginBottom: '12px' }"
|
||||
>
|
||||
<chart-card title="运营活动效果" total="78%">
|
||||
<el-tooltip slot="action" class="item" effect="dark" content="指标说明" placement="top-start">
|
||||
<el-tooltip
|
||||
slot="action"
|
||||
class="item"
|
||||
effect="dark"
|
||||
content="指标说明"
|
||||
placement="top-start"
|
||||
>
|
||||
<i class="el-icon-warning-outline" />
|
||||
</el-tooltip>
|
||||
<div>
|
||||
<mini-progress color="rgb(19, 194, 194)" :target="80" :percentage="78" height="8px" />
|
||||
<mini-progress
|
||||
color="rgb(19, 194, 194)"
|
||||
:target="80"
|
||||
:percentage="78"
|
||||
height="8px"
|
||||
/>
|
||||
</div>
|
||||
<template slot="footer">
|
||||
<trend flag="top" style="margin-right: 16px;" rate="12">
|
||||
<trend flag="top" style="margin-right: 16px" rate="12">
|
||||
<span slot="term">同周比</span>
|
||||
</trend>
|
||||
<trend flag="bottom" rate="80">
|
||||
@@ -59,33 +118,25 @@
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-card :bordered="false" :body-style="{padding: '0'}">
|
||||
<el-card :bordered="false" :body-style="{ padding: '0' }">
|
||||
<div class="salesCard">
|
||||
<el-tabs>
|
||||
<el-tab-pane label="销售额">
|
||||
<el-tab-pane label="发送量">
|
||||
<el-row>
|
||||
<el-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
|
||||
<bar :list="barData" title="销售额排行" />
|
||||
<el-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
|
||||
<rank-list title="应用剩余额度" :list="rankList" />
|
||||
</el-col>
|
||||
<el-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
|
||||
<rank-list title="门店销售排行榜" :list="rankList" />
|
||||
<el-col :xl="16" :lg="8" :md="8" :sm="24" :xs="24">
|
||||
<bar :list="barData" title="应用发送量排行榜" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-tab-pane>
|
||||
<el-tab-pane label="访问量">
|
||||
<el-row>
|
||||
<el-col :xl="16" :lg="12" :md="12" :sm="24" :xs="24">
|
||||
<bar :list="barData2" title="销售额趋势" />
|
||||
</el-col>
|
||||
<el-col :xl="8" :lg="12" :md="12" :sm="24" :xs="24">
|
||||
<rank-list title="门店销售排行榜" :list="rankList" />
|
||||
<el-col :xl="8" :lg="8" :md="8" :sm="24" :xs="24">
|
||||
<rank-list title="业务发送量排行榜" :list="rankList" />
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
</div>
|
||||
</el-card>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -97,6 +148,8 @@ import MiniBar from '@/components/MiniBar'
|
||||
import MiniProgress from '@/components/MiniProgress'
|
||||
import RankList from '@/components/RankList/index'
|
||||
import Bar from '@/components/Bar.vue'
|
||||
import { getAllCount, getSuccessCount, getRequestCount } from '@/api/dashboard'
|
||||
import { listSmsAppConfig } from '@/api/admin/sms-app-config'
|
||||
|
||||
const barData = []
|
||||
const barData2 = []
|
||||
@@ -111,14 +164,6 @@ for (let i = 0; i < 12; i += 1) {
|
||||
})
|
||||
}
|
||||
|
||||
const rankList = []
|
||||
for (let i = 0; i < 7; i++) {
|
||||
rankList.push({
|
||||
name: '白鹭岛 ' + (i + 1) + ' 号店',
|
||||
total: 1234.56 - i * 100
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
name: 'DashboardAdmin',
|
||||
components: {
|
||||
@@ -134,10 +179,46 @@ export default {
|
||||
return {
|
||||
barData,
|
||||
barData2,
|
||||
rankList
|
||||
rankList: [],
|
||||
count: 0,
|
||||
successCount: 0,
|
||||
requestCount: 0
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.getAllCount()
|
||||
this.getSuccessCount()
|
||||
this.getRequestCount()
|
||||
this.getAppList()
|
||||
},
|
||||
methods: {
|
||||
getAllCount() {
|
||||
getAllCount().then((res) => {
|
||||
this.count = res.data
|
||||
})
|
||||
},
|
||||
|
||||
getSuccessCount() {
|
||||
getSuccessCount().then((res) => {
|
||||
this.successCount = res.data
|
||||
})
|
||||
},
|
||||
getRequestCount() {
|
||||
getRequestCount().then((res) => {
|
||||
this.requestCount = res.data
|
||||
})
|
||||
},
|
||||
|
||||
getAppList() {
|
||||
listSmsAppConfig({ page: 1, size: 10 }).then((resp) => {
|
||||
resp.data.list.forEach((item) => {
|
||||
this.rankList.push({
|
||||
name: item.appName,
|
||||
total: item.useNumber
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -162,13 +243,13 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .el-tabs__item{
|
||||
padding-left: 16px!important;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
::v-deep .el-tabs__item {
|
||||
padding-left: 16px !important;
|
||||
height: 50px;
|
||||
line-height: 50px;
|
||||
}
|
||||
|
||||
@media (max-width:1024px) {
|
||||
@media (max-width: 1024px) {
|
||||
.chart-wrapper {
|
||||
padding: 8px;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<template>
|
||||
<div class="login-container">
|
||||
<div id="particles-js">
|
||||
<div id="particles-js" class="my_login">
|
||||
<!-- <vue-particles
|
||||
v-if="refreshParticles"
|
||||
color="#dedede"
|
||||
@@ -24,8 +24,13 @@
|
||||
<div class="login-weaper animated bounceInDown">
|
||||
<div class="login-left">
|
||||
<div class="login-time" v-text="currentTime" />
|
||||
<img :src="sysInfo.sys_app_logo" alt="" class="img">
|
||||
<p class="title" v-text="sysInfo.sys_app_name" />
|
||||
<img :src="sysInfo.sys_app_logo" alt="杰子学编程" class="img">
|
||||
<p />
|
||||
<a
|
||||
class="title"
|
||||
href="https://julywhj.cn"
|
||||
v-text="sysInfo.sys_app_name"
|
||||
/>
|
||||
</div>
|
||||
<div class="login-border">
|
||||
<div class="login-main">
|
||||
@@ -152,9 +157,12 @@
|
||||
style="visibility: visible; width: 100%"
|
||||
>
|
||||
<div class="s-bottom-layer-content">
|
||||
|
||||
<div class="lh">
|
||||
<a class="text-color" href="https://beian.miit.gov.cn" target="_blank">
|
||||
<a
|
||||
class="text-color"
|
||||
href="https://beian.miit.gov.cn"
|
||||
target="_blank"
|
||||
>
|
||||
沪ICP备XXXXXXXXX号-1
|
||||
</a>
|
||||
</div>
|
||||
@@ -458,10 +466,9 @@ $cursor: #fff;
|
||||
}
|
||||
}
|
||||
.footer {
|
||||
background-color: #0e6cff;
|
||||
background: #0e6cff;
|
||||
margin-bottom: -20px;
|
||||
}
|
||||
|
||||
.login-container {
|
||||
display: -webkit-box;
|
||||
display: -ms-flexbox;
|
||||
@@ -472,8 +479,32 @@ $cursor: #fff;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0 auto;
|
||||
background: url("../../assets/login.png") no-repeat;
|
||||
background-color: #0e6cff;
|
||||
background: linear-gradient(235deg, #ffffff 0%, #000f25 100%),
|
||||
linear-gradient(180deg, #6100ff 0%, #000000 100%),
|
||||
linear-gradient(
|
||||
235deg,
|
||||
#ffa3ac 0%,
|
||||
#ffa3ac 40%,
|
||||
#00043c calc(40% + 1px),
|
||||
#00043c 60%,
|
||||
#005d6c calc(60% + 1px),
|
||||
#005d6c 70%,
|
||||
#00c9b1 calc(70% + 1px),
|
||||
#00c9b1 100%
|
||||
),
|
||||
linear-gradient(
|
||||
125deg,
|
||||
#ffa3ac 0%,
|
||||
#ffa3ac 40%,
|
||||
#00043c calc(40% + 1px),
|
||||
#00043c 60%,
|
||||
#005d6c calc(60% + 1px),
|
||||
#005d6c 70%,
|
||||
#00c9b1 calc(70% + 1px),
|
||||
#00c9b1 100%
|
||||
);
|
||||
background-blend-mode: soft-light, screen, darken, normal;
|
||||
|
||||
position: relative;
|
||||
background-size: cover;
|
||||
height: 100vh;
|
||||
@@ -540,7 +571,7 @@ $cursor: #fff;
|
||||
text-align: center;
|
||||
color: #fff;
|
||||
letter-spacing: 2px;
|
||||
font-size: 16px;
|
||||
font-size: 26px;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,584 +0,0 @@
|
||||
<template>
|
||||
<BasicLayout>
|
||||
<template #wrapper>
|
||||
<el-card class="box-card">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="roleList"
|
||||
border
|
||||
@selection-change="handleSelectionChange"
|
||||
@sort-change="handleSortChang"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
label="集群ID"
|
||||
sortable="custom"
|
||||
prop="ClusterId"
|
||||
width="180"
|
||||
/>
|
||||
<el-table-column
|
||||
label="名称"
|
||||
sortable="custom"
|
||||
prop="ClusterName"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="版本"
|
||||
sortable="custom"
|
||||
prop="Version"
|
||||
width="80"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="接入点"
|
||||
sortable="custom"
|
||||
prop="EndPointNum"
|
||||
width="80"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="最大命名空间数量"
|
||||
sortable="custom"
|
||||
prop="MaxNamespaceNum"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="命名空间数量"
|
||||
sortable="custom"
|
||||
prop="NamespaceNum"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="最大Topic数量"
|
||||
sortable="custom"
|
||||
prop="MaxTopicNum"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="已创建主题数"
|
||||
sortable="custom"
|
||||
prop="TopicNum"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
sortable="custom"
|
||||
prop="CreateTime"
|
||||
width="160"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.CreateTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="left"
|
||||
class-name="small-padding fixed-width"
|
||||
width="80"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
v-permisaction="['admin:sysRole:update']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-edit"
|
||||
@click="handleUpdate(scope.row)"
|
||||
>详情</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageIndex"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改角色配置对话框 -->
|
||||
<el-dialog
|
||||
v-if="open"
|
||||
:title="title"
|
||||
:visible.sync="open"
|
||||
width="500px"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="角色名称" prop="roleName">
|
||||
<el-input
|
||||
v-model="form.roleName"
|
||||
placeholder="请输入角色名称"
|
||||
:disabled="isEdit"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="权限字符" prop="roleKey">
|
||||
<el-input
|
||||
v-model="form.roleKey"
|
||||
placeholder="请输入权限字符"
|
||||
:disabled="isEdit"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="角色顺序" prop="roleSort">
|
||||
<el-input-number
|
||||
v-model="form.roleSort"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-radio-group v-model="form.status">
|
||||
<el-radio
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.value"
|
||||
:label="dict.value"
|
||||
>{{ dict.label }}</el-radio
|
||||
>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单权限">
|
||||
<el-tree
|
||||
ref="menuTree"
|
||||
:data="menuOptions"
|
||||
show-checkbox
|
||||
node-key="id"
|
||||
:empty-text="menuOptionsAlert"
|
||||
style="height: 171px; overflow-y: auto; overflow-x: hidden"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
type="textarea"
|
||||
placeholder="请输入内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 分配角色数据权限对话框 -->
|
||||
<el-dialog
|
||||
v-if="openDataScope"
|
||||
:title="title"
|
||||
:visible.sync="openDataScope"
|
||||
width="500px"
|
||||
>
|
||||
<el-form :model="form" label-width="80px">
|
||||
<el-form-item label="角色名称">
|
||||
<el-input v-model="form.roleName" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item label="权限字符">
|
||||
<el-input v-model="form.roleKey" :disabled="true" />
|
||||
</el-form-item>
|
||||
<el-form-item label="权限范围">
|
||||
<el-select v-model="form.dataScope">
|
||||
<el-option
|
||||
v-for="item in dataScopeOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="form.dataScope == 2" label="数据权限">
|
||||
<el-tree
|
||||
ref="dept"
|
||||
:data="deptOptions"
|
||||
show-checkbox
|
||||
default-expand-all
|
||||
node-key="id"
|
||||
empty-text="加载中,请稍后"
|
||||
:props="defaultProps"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitDataScope">确 定</el-button>
|
||||
<el-button @click="cancelDataScope">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { listClusters } from "@/api/tdmq/clusters";
|
||||
import { roleMenuTreeselect } from "@/api/admin/sys-menu";
|
||||
import {
|
||||
treeselect as deptTreeselect,
|
||||
roleDeptTreeselect,
|
||||
} from "@/api/admin/sys-dept";
|
||||
import { formatJson } from "@/utils";
|
||||
|
||||
export default {
|
||||
name: "Clusters",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 角色表格数据
|
||||
roleList: [],
|
||||
menuIdsChecked: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否显示弹出层(数据权限)
|
||||
openDataScope: false,
|
||||
isEdit: false,
|
||||
// 日期范围
|
||||
dateRange: [],
|
||||
// 状态数据字典
|
||||
statusOptions: [],
|
||||
// 数据范围选项
|
||||
dataScopeOptions: [
|
||||
{
|
||||
value: "1",
|
||||
label: "全部数据权限",
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "自定数据权限",
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "本部门数据权限",
|
||||
},
|
||||
{
|
||||
value: "4",
|
||||
label: "本部门及以下数据权限",
|
||||
},
|
||||
{
|
||||
value: "5",
|
||||
label: "仅本人数据权限",
|
||||
},
|
||||
],
|
||||
// 菜单列表
|
||||
menuOptions: [],
|
||||
menuList: [],
|
||||
// 部门列表
|
||||
deptOptions: [],
|
||||
menuOptionsAlert: "加载中,请稍后",
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
sysMenu: [],
|
||||
},
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label",
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
roleName: [
|
||||
{ required: true, message: "角色名称不能为空", trigger: "blur" },
|
||||
],
|
||||
roleKey: [
|
||||
{ required: true, message: "权限字符不能为空", trigger: "blur" },
|
||||
],
|
||||
roleSort: [
|
||||
{ required: true, message: "角色顺序不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.getDicts("sys_normal_disable").then((response) => {
|
||||
this.statusOptions = response.data;
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
/** 查询角色列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listClusters().then((response) => {
|
||||
this.roleList = response.data.list;
|
||||
this.total = response.data.count;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
|
||||
// 所有菜单节点数据
|
||||
getMenuAllCheckedKeys() {
|
||||
// 目前被选中的菜单节点
|
||||
const checkedKeys = this.$refs.menuTree.getHalfCheckedKeys();
|
||||
console.log("目前被选中的菜单节点", checkedKeys);
|
||||
// 半选中的菜单节点
|
||||
const halfCheckedKeys = this.$refs.menuTree.getCheckedKeys();
|
||||
console.log("半选中的菜单节点", halfCheckedKeys);
|
||||
// checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
|
||||
return halfCheckedKeys;
|
||||
},
|
||||
// 所有部门节点数据
|
||||
getDeptAllCheckedKeys() {
|
||||
// 目前被选中的部门节点
|
||||
const checkedKeys = this.$refs.dept.getCheckedKeys();
|
||||
// 半选中的部门节点
|
||||
// const halfCheckedKeys = this.$refs.dept.getCheckedKeys()
|
||||
// checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
|
||||
return checkedKeys;
|
||||
},
|
||||
/** 根据角色ID查询菜单树结构 */
|
||||
getRoleMenuTreeselect(row, checkedKeys) {
|
||||
if (row.roleKey === "admin") {
|
||||
this.menuOptionsAlert = "系统超级管理员无需此操作";
|
||||
this.menuOptions = [];
|
||||
} else {
|
||||
this.$nextTick(() => {
|
||||
this.$refs.menuTree.setCheckedKeys(checkedKeys);
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 根据角色ID查询部门树结构 */
|
||||
getRoleDeptTreeselect(roleId) {
|
||||
roleDeptTreeselect(roleId).then((response) => {
|
||||
this.deptOptions = response.data.depts;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.dept.setCheckedKeys(response.data.checkedKeys);
|
||||
});
|
||||
});
|
||||
},
|
||||
// 角色状态修改
|
||||
handleStatusChange(row) {
|
||||
const text = row.status === "2" ? "启用" : "停用";
|
||||
this.$confirm(
|
||||
'确认要"' + text + '""' + row.roleName + '"角色吗?',
|
||||
"警告",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return changeRoleStatus(row.roleId, row.status);
|
||||
})
|
||||
.then((res) => {
|
||||
console.log("res", res);
|
||||
this.msgSuccess(res.msg);
|
||||
})
|
||||
.catch(function () {
|
||||
row.status = row.status === "2" ? "1" : "2";
|
||||
});
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
// 取消按钮(数据权限)
|
||||
cancelDataScope() {
|
||||
this.openDataScope = false;
|
||||
this.reset();
|
||||
},
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.menuOptions = this.menuList;
|
||||
if (this.$refs.menuTree !== undefined) {
|
||||
this.$refs.menuTree.setCheckedKeys([]);
|
||||
}
|
||||
this.form = {
|
||||
roleId: undefined,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
roleSort: 0,
|
||||
status: "2",
|
||||
menuIds: [],
|
||||
deptIds: [],
|
||||
sysMenu: [],
|
||||
remark: undefined,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageIndex = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.roleId);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
// this.getMenuTreeselect(0)
|
||||
this.open = true;
|
||||
this.title = "添加角色";
|
||||
this.isEdit = false;
|
||||
},
|
||||
handleSortChang(column, prop, order) {
|
||||
prop = column.prop;
|
||||
order = column.order;
|
||||
if (order === "descending") {
|
||||
this.queryParams[prop + "Order"] = "desc";
|
||||
} else if (order === "ascending") {
|
||||
this.queryParams[prop + "Order"] = "asc";
|
||||
} else {
|
||||
this.queryParams[prop + "Order"] = undefined;
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
this.menuIdsChecked = [];
|
||||
this.reset();
|
||||
const roleId = row.roleId || this.ids;
|
||||
getRole(roleId).then((response) => {
|
||||
this.form = response.data;
|
||||
this.menuIdsChecked = response.data.menuIds;
|
||||
this.title = "修改角色";
|
||||
this.isEdit = true;
|
||||
this.open = true;
|
||||
this.getRoleMenuTreeselect(row, response.data.menuIds);
|
||||
});
|
||||
},
|
||||
/** 分配数据权限操作 */
|
||||
handleDataScope(row) {
|
||||
this.reset();
|
||||
getRole(row.roleId).then((response) => {
|
||||
this.form = response.data;
|
||||
this.openDataScope = true;
|
||||
this.title = "分配数据权限";
|
||||
this.getRoleDeptTreeselect(row.roleId);
|
||||
});
|
||||
},
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.roleId !== undefined) {
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys();
|
||||
updateRole(this.form, this.form.roleId).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys();
|
||||
addRole(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
/** 提交按钮(数据权限) */
|
||||
submitDataScope: function () {
|
||||
if (this.form.roleId !== undefined) {
|
||||
this.form.deptIds = this.getDeptAllCheckedKeys();
|
||||
console.log(this.getDeptAllCheckedKeys());
|
||||
dataScope(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.openDataScope = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const roleIds = (row.roleId && [row.roleId]) || this.ids;
|
||||
this.$confirm(
|
||||
'是否确认删除角色编号为"' + roleIds + '"的数据项?',
|
||||
"警告",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return delRole({ ids: roleIds });
|
||||
})
|
||||
.then((response) => {
|
||||
this.getList();
|
||||
this.msgSuccess(response.msg);
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
this.$confirm("是否确认导出所有角色数据项?", "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
this.downloadLoading = true;
|
||||
import("@/vendor/Export2Excel").then((excel) => {
|
||||
const tHeader = [
|
||||
"角色编号",
|
||||
"角色名称",
|
||||
"权限字符",
|
||||
"显示顺序",
|
||||
"状态",
|
||||
"创建时间",
|
||||
];
|
||||
const filterVal = [
|
||||
"roleId",
|
||||
"roleName",
|
||||
"roleKey",
|
||||
"roleSort",
|
||||
"status",
|
||||
"createdAt",
|
||||
];
|
||||
const list = this.roleList;
|
||||
const data = formatJson(filterVal, list);
|
||||
excel.export_json_to_excel({
|
||||
header: tHeader,
|
||||
data,
|
||||
filename: "角色管理",
|
||||
autoWidth: true, // Optional
|
||||
bookType: "xlsx", // Optional
|
||||
});
|
||||
this.downloadLoading = false;
|
||||
});
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,353 +0,0 @@
|
||||
<template>
|
||||
<BasicLayout>
|
||||
<template #wrapper>
|
||||
<el-card class="box-card">
|
||||
<el-form ref="queryForm" :model="queryParams" :inline="true">
|
||||
<el-form-item label="集群ID" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="集群ID"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 260px"
|
||||
@change="selectChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="roleList"
|
||||
border
|
||||
@selection-change="handleSelectionChange"
|
||||
@sort-change="handleSortChang"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
label="命名空间名称"
|
||||
sortable="custom"
|
||||
prop="EnvironmentId"
|
||||
width="200"
|
||||
/>
|
||||
<el-table-column
|
||||
label="说明"
|
||||
sortable="custom"
|
||||
prop="Remark"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="命名空间ID"
|
||||
sortable="custom"
|
||||
prop="NamespaceId"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
|
||||
<el-table-column
|
||||
label="命名空间名称"
|
||||
sortable="custom"
|
||||
prop="NamespaceName"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="Topic数量"
|
||||
sortable="custom"
|
||||
prop="TopicNum"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
sortable="custom"
|
||||
prop="CreateTime"
|
||||
width="160"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.CreateTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="left"
|
||||
class-name="small-padding fixed-width"
|
||||
width="80"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
v-if="scope.row.roleKey !== 'admin'"
|
||||
v-permisaction="['admin:sysRole:remove']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageIndex"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</el-card>
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
listRole,
|
||||
getRole,
|
||||
delRole,
|
||||
addRole,
|
||||
updateRole,
|
||||
dataScope,
|
||||
changeRoleStatus,
|
||||
} from "@/api/admin/sys-role";
|
||||
import { listEnvironments } from "@/api/tdmq/environments";
|
||||
import { describeSelectClusters } from "@/api/tdmq/clusters";
|
||||
import {
|
||||
treeselect as deptTreeselect,
|
||||
roleDeptTreeselect,
|
||||
} from "@/api/admin/sys-dept";
|
||||
import { formatJson } from "@/utils";
|
||||
|
||||
export default {
|
||||
name: "Environment",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 角色表格数据
|
||||
roleList: [],
|
||||
menuIdsChecked: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否显示弹出层(数据权限)
|
||||
openDataScope: false,
|
||||
isEdit: false,
|
||||
// 日期范围
|
||||
dateRange: [],
|
||||
// 状态数据字典
|
||||
statusOptions: [],
|
||||
// 数据范围选项
|
||||
dataScopeOptions: [
|
||||
{
|
||||
value: "1",
|
||||
label: "全部数据权限",
|
||||
},
|
||||
{
|
||||
value: "2",
|
||||
label: "自定数据权限",
|
||||
},
|
||||
{
|
||||
value: "3",
|
||||
label: "本部门数据权限",
|
||||
},
|
||||
{
|
||||
value: "4",
|
||||
label: "本部门及以下数据权限",
|
||||
},
|
||||
{
|
||||
value: "5",
|
||||
label: "仅本人数据权限",
|
||||
},
|
||||
],
|
||||
// 菜单列表
|
||||
menuOptions: [],
|
||||
menuList: [],
|
||||
// 部门列表
|
||||
deptOptions: [],
|
||||
menuOptionsAlert: "加载中,请稍后",
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
// 表单参数
|
||||
form: {
|
||||
sysMenu: [],
|
||||
},
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label",
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
roleName: [
|
||||
{ required: true, message: "角色名称不能为空", trigger: "blur" },
|
||||
],
|
||||
roleKey: [
|
||||
{ required: true, message: "权限字符不能为空", trigger: "blur" },
|
||||
],
|
||||
roleSort: [
|
||||
{ required: true, message: "角色顺序不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList("pulsar-44or73egbj4g");
|
||||
this.describeSelectClusters();
|
||||
},
|
||||
methods: {
|
||||
/** 查询角色列表 */
|
||||
getList(clustersId) {
|
||||
this.loading = true;
|
||||
listEnvironments(clustersId).then((response) => {
|
||||
this.roleList = response.data.list;
|
||||
this.total = response.data.count;
|
||||
this.loading = false;
|
||||
});
|
||||
},
|
||||
describeSelectClusters() {
|
||||
describeSelectClusters().then((res) => {
|
||||
this.statusOptions = res.data;
|
||||
});
|
||||
},
|
||||
//selectChange
|
||||
selectChange(e) {
|
||||
this.getList(e);
|
||||
},
|
||||
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.menuOptions = this.menuList;
|
||||
if (this.$refs.menuTree !== undefined) {
|
||||
this.$refs.menuTree.setCheckedKeys([]);
|
||||
}
|
||||
this.form = {
|
||||
roleId: undefined,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
roleSort: 0,
|
||||
status: "2",
|
||||
menuIds: [],
|
||||
deptIds: [],
|
||||
sysMenu: [],
|
||||
remark: undefined,
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageIndex = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.roleId);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
|
||||
this.open = true;
|
||||
this.title = "添加角色";
|
||||
this.isEdit = false;
|
||||
},
|
||||
handleSortChang(column, prop, order) {
|
||||
prop = column.prop;
|
||||
order = column.order;
|
||||
if (order === "descending") {
|
||||
this.queryParams[prop + "Order"] = "desc";
|
||||
} else if (order === "ascending") {
|
||||
this.queryParams[prop + "Order"] = "asc";
|
||||
} else {
|
||||
this.queryParams[prop + "Order"] = undefined;
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
if (this.form.roleId !== undefined) {
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys();
|
||||
updateRole(this.form, this.form.roleId).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.form.menuIds = this.getMenuAllCheckedKeys();
|
||||
addRole(this.form).then((response) => {
|
||||
if (response.code === 200) {
|
||||
this.msgSuccess(response.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(response.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
const roleIds = (row.roleId && [row.roleId]) || this.ids;
|
||||
this.$confirm(
|
||||
'是否确认删除角色编号为"' + roleIds + '"的数据项?',
|
||||
"警告",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return delRole({ ids: roleIds });
|
||||
})
|
||||
.then((response) => {
|
||||
this.getList();
|
||||
this.msgSuccess(response.msg);
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
@@ -1,437 +0,0 @@
|
||||
<template>
|
||||
<BasicLayout>
|
||||
<template #wrapper>
|
||||
<el-card class="box-card">
|
||||
<el-form ref="queryForm" :model="queryParams" :inline="true">
|
||||
<el-form-item label="集群ID" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="集群ID"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 260px"
|
||||
@change="selectChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in statusOptions"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="命名空间ID" prop="status">
|
||||
<el-select
|
||||
v-model="selectedEnvironments"
|
||||
placeholder="命名空间ID"
|
||||
clearable
|
||||
size="small"
|
||||
style="width: 260px"
|
||||
@change="selectChangeEnvironments"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in environmentsOptions"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
size="mini"
|
||||
@click="handleAdd"
|
||||
>新增</el-button
|
||||
>
|
||||
</el-col>
|
||||
</el-row>
|
||||
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="roleList"
|
||||
border
|
||||
@selection-change="handleSelectionChange"
|
||||
@sort-change="handleSortChang"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column
|
||||
label="队列名称"
|
||||
sortable="custom"
|
||||
prop="TopicName"
|
||||
width="200"
|
||||
/>
|
||||
<el-table-column
|
||||
label="说明"
|
||||
sortable="custom"
|
||||
prop="Remark"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="命名空间ID"
|
||||
sortable="custom"
|
||||
prop="EnvironmentId"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="队列类型"
|
||||
sortable="custom"
|
||||
prop="TopicType"
|
||||
:show-overflow-tooltip="true"
|
||||
width="80"
|
||||
/>
|
||||
<el-table-column
|
||||
label="消费者数量"
|
||||
sortable="custom"
|
||||
prop="ConsumerCount"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="生产者数量"
|
||||
sortable="custom"
|
||||
prop="ProducerCount"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
sortable="custom"
|
||||
prop="CreateTime"
|
||||
width="160"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ parseTime(scope.row.CreateTime) }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="操作"
|
||||
align="left"
|
||||
class-name="small-padding fixed-width"
|
||||
width="80"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button
|
||||
v-if="scope.row.roleKey !== 'admin'"
|
||||
v-permisaction="['admin:sysRole:remove']"
|
||||
size="mini"
|
||||
type="text"
|
||||
icon="el-icon-delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>删除</el-button
|
||||
>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
v-show="total > 0"
|
||||
:total="total"
|
||||
:page.sync="queryParams.pageIndex"
|
||||
:limit.sync="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
|
||||
<!-- 添加或修改角色配置对话框 -->
|
||||
<el-dialog
|
||||
v-if="open"
|
||||
:title="title"
|
||||
:visible.sync="open"
|
||||
width="600px"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
|
||||
<el-form-item label="集群ID">
|
||||
<el-select
|
||||
v-model="form.clusterId"
|
||||
placeholder="请选择"
|
||||
@change="selectChange"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in statusOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
:disabled="item.status == 1"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="命名空间">
|
||||
<el-select v-model="form.environmentId" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in environmentsOptions"
|
||||
:key="item.value"
|
||||
:label="item.label"
|
||||
:value="item.value"
|
||||
:disabled="item.status == 1"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="Topic名称" prop="topicName">
|
||||
<el-input
|
||||
v-model="form.topicName"
|
||||
placeholder="请输入Topic名称"
|
||||
:disabled="isEdit"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注">
|
||||
<el-input
|
||||
v-model="form.remark"
|
||||
:disabled="isEdit"
|
||||
placeholder="请输入内容"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="form.topicType" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="item in topicTypeOptions"
|
||||
:key="item.id"
|
||||
:label="item.value"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="分区数量" prop="partitions">
|
||||
<el-input-number
|
||||
v-model="form.partitions"
|
||||
controls-position="right"
|
||||
:min="0"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</el-card>
|
||||
</template>
|
||||
</BasicLayout>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { selectEnvironments } from "@/api/tdmq/environments";
|
||||
import { describeSelectClusters } from "@/api/tdmq/clusters";
|
||||
import { listTopic, addTopic, delTopic } from "@/api/tdmq/topic";
|
||||
|
||||
export default {
|
||||
name: "Topic",
|
||||
components: {},
|
||||
data() {
|
||||
return {
|
||||
// 遮罩层
|
||||
loading: true,
|
||||
// 选中数组
|
||||
ids: [],
|
||||
// 非单个禁用
|
||||
single: true,
|
||||
// 非多个禁用
|
||||
multiple: true,
|
||||
// 总条数
|
||||
total: 0,
|
||||
// 角色表格数据
|
||||
roleList: [],
|
||||
menuIdsChecked: [],
|
||||
// 弹出层标题
|
||||
title: "",
|
||||
// 是否显示弹出层
|
||||
open: false,
|
||||
// 是否显示弹出层(数据权限)
|
||||
openDataScope: false,
|
||||
isEdit: false,
|
||||
// 日期范围
|
||||
dateRange: [],
|
||||
// 状态数据字典
|
||||
statusOptions: [],
|
||||
//命名空间选择
|
||||
environmentsOptions: [],
|
||||
//topic类型
|
||||
topicTypeOptions: [
|
||||
{ id: 0, value: "普通消息" },
|
||||
{ id: 1, value: "全局顺序消息" },
|
||||
{ id: 2, value: "局部顺序消息" },
|
||||
{ id: 3, value: "重试队列" },
|
||||
{ id: 4, value: "死信队列" },
|
||||
],
|
||||
menuOptionsAlert: "加载中,请稍后",
|
||||
selectedClustersId: "",
|
||||
selectedEnvironments: "",
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
roleName: undefined,
|
||||
roleKey: undefined,
|
||||
status: undefined,
|
||||
},
|
||||
|
||||
// 表单参数
|
||||
form: {
|
||||
clusterId: "",
|
||||
environmentId: "",
|
||||
topicName: "",
|
||||
remark: "",
|
||||
topicType: "",
|
||||
partitions: 1,
|
||||
},
|
||||
defaultProps: {
|
||||
children: "children",
|
||||
label: "label",
|
||||
},
|
||||
// 表单校验
|
||||
rules: {
|
||||
topicName: [
|
||||
{ required: true, message: "队列名称不能为空", trigger: "blur" },
|
||||
],
|
||||
clusterId: [
|
||||
{ required: true, message: "集群ID不能为空", trigger: "blur" },
|
||||
],
|
||||
environmentId: [
|
||||
{ required: true, message: "命名空间不能为空", trigger: "blur" },
|
||||
],
|
||||
topicType: [
|
||||
{ required: true, message: "队列类型不能为空", trigger: "blur" },
|
||||
],
|
||||
},
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.getList();
|
||||
this.selectEnvironments("pulsar-44or73egbj4g");
|
||||
this.describeSelectClusters();
|
||||
},
|
||||
methods: {
|
||||
/** 查询角色列表 */
|
||||
getList() {
|
||||
this.loading = true;
|
||||
listTopic({
|
||||
environmentId: this.selectedEnvironments,
|
||||
clusterId: this.selectedClustersId,
|
||||
}).then((response) => {
|
||||
this.loading = false;
|
||||
this.roleList = response.data.list;
|
||||
this.total = response.data.count;
|
||||
});
|
||||
},
|
||||
describeSelectClusters() {
|
||||
describeSelectClusters().then((res) => {
|
||||
this.statusOptions = res.data;
|
||||
});
|
||||
},
|
||||
selectEnvironments(clustersId) {
|
||||
selectEnvironments(clustersId).then((res) => {
|
||||
this.environmentsOptions = res.data;
|
||||
});
|
||||
},
|
||||
//selectChange集群ID
|
||||
selectChange(e) {
|
||||
this.selectedClustersId = e;
|
||||
this.selectEnvironments(e);
|
||||
},
|
||||
//change命名空间
|
||||
selectChangeEnvironments(e) {
|
||||
this.selectedEnvironments = e;
|
||||
this.getList();
|
||||
},
|
||||
// 取消按钮
|
||||
cancel() {
|
||||
this.open = false;
|
||||
this.reset();
|
||||
},
|
||||
|
||||
// 表单重置
|
||||
reset() {
|
||||
this.menuOptions = this.menuList;
|
||||
if (this.$refs.menuTree !== undefined) {
|
||||
this.$refs.menuTree.setCheckedKeys([]);
|
||||
}
|
||||
this.form = {
|
||||
partitions: 0,
|
||||
remark: "",
|
||||
};
|
||||
this.resetForm("form");
|
||||
},
|
||||
/** 搜索按钮操作 */
|
||||
handleQuery() {
|
||||
this.queryParams.pageIndex = 1;
|
||||
this.getList();
|
||||
},
|
||||
/** 重置按钮操作 */
|
||||
resetQuery() {
|
||||
this.dateRange = [];
|
||||
this.resetForm("queryForm");
|
||||
this.handleQuery();
|
||||
},
|
||||
// 多选框选中数据
|
||||
handleSelectionChange(selection) {
|
||||
this.ids = selection.map((item) => item.roleId);
|
||||
this.single = selection.length !== 1;
|
||||
this.multiple = !selection.length;
|
||||
},
|
||||
/** 新增按钮操作 */
|
||||
handleAdd() {
|
||||
this.reset();
|
||||
this.open = true;
|
||||
this.title = "添加Topic";
|
||||
this.isEdit = false;
|
||||
},
|
||||
handleSortChang(column, prop, order) {
|
||||
prop = column.prop;
|
||||
order = column.order;
|
||||
if (order === "descending") {
|
||||
this.queryParams[prop + "Order"] = "desc";
|
||||
} else if (order === "ascending") {
|
||||
this.queryParams[prop + "Order"] = "asc";
|
||||
} else {
|
||||
this.queryParams[prop + "Order"] = undefined;
|
||||
}
|
||||
this.getList();
|
||||
},
|
||||
|
||||
/** 提交按钮 */
|
||||
submitForm: function () {
|
||||
this.$refs["form"].validate((valid) => {
|
||||
if (valid) {
|
||||
addTopic(this.form).then((res) => {
|
||||
if (res.code === 200) {
|
||||
this.msgSuccess(res.msg);
|
||||
this.open = false;
|
||||
this.getList();
|
||||
} else {
|
||||
this.msgError(res.msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/** 删除按钮操作 */
|
||||
handleDelete(row) {
|
||||
row.ClustersId = this.selectedClustersId;
|
||||
this.$confirm(
|
||||
'是否确认删除Topic为"' + row.TopicName + '"的数据项?',
|
||||
"警告",
|
||||
{
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}
|
||||
)
|
||||
.then(function () {
|
||||
return delTopic({
|
||||
topicName: row.TopicName,
|
||||
environmentId: row.EnvironmentId,
|
||||
clusterId: row.ClustersId,
|
||||
});
|
||||
})
|
||||
.then((response) => {
|
||||
this.getList();
|
||||
this.msgSuccess(response.msg);
|
||||
})
|
||||
.catch(function () {});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
Reference in New Issue
Block a user