mirror of
https://gitee.com/xiangheng/x_admin.git
synced 2025-12-24 08:12:55 +08:00
完善service导入
This commit is contained in:
@@ -3,6 +3,8 @@ package commonController
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
"x_admin/core/response"
|
||||
"x_admin/service/commonService"
|
||||
|
||||
@@ -43,15 +45,73 @@ func (uh uploadChunkHandler) getChunkPath(fileMd5 string, chunkSize string, inde
|
||||
|
||||
func (uh uploadChunkHandler) CheckFileExist(c *gin.Context) {
|
||||
var fileMd5 = c.Query("fileMd5")
|
||||
var fileName = c.Query("fileName")
|
||||
if fileMd5 == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件hash错误")
|
||||
return
|
||||
}
|
||||
if fileName == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件名错误")
|
||||
return
|
||||
}
|
||||
//文件类型白名单
|
||||
var whiteList = []string{
|
||||
".jpg",
|
||||
".jpeg",
|
||||
".png",
|
||||
".gif",
|
||||
".bmp",
|
||||
".svg",
|
||||
".webp",
|
||||
".avif",
|
||||
".txt",
|
||||
".mp4",
|
||||
".avi",
|
||||
".mov",
|
||||
".wmv",
|
||||
".flv",
|
||||
".mkv",
|
||||
".mp3",
|
||||
".wav",
|
||||
".aac",
|
||||
".flac",
|
||||
".ogg",
|
||||
".m4a",
|
||||
".pdf",
|
||||
".doc",
|
||||
".docx",
|
||||
".xls",
|
||||
".xlsx",
|
||||
".ppt",
|
||||
".pptx",
|
||||
".zip",
|
||||
".rar",
|
||||
".7z",
|
||||
".tar",
|
||||
".gz",
|
||||
".bz2",
|
||||
".xz",
|
||||
}
|
||||
var fileExt = ""
|
||||
for _, ext := range whiteList {
|
||||
if strings.HasSuffix(fileName, ext) {
|
||||
fileExt = ext
|
||||
break
|
||||
}
|
||||
}
|
||||
if fileExt == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件类型错误")
|
||||
return
|
||||
}
|
||||
|
||||
// var fileName = url.QueryEscape(c.Query("fileName"))
|
||||
// 正则检查MD5
|
||||
// reg := regexp.MustCompile(`^[a-fA-F0-9_]{32+}$`)
|
||||
// if !reg.MatchString(fileMd5) {
|
||||
// response.FailWithMsg(c, response.SystemError, "文件hash错误")
|
||||
// return
|
||||
// }
|
||||
var filePath = fmt.Sprintf("%s/%s", uh.uploadPath, fileMd5)
|
||||
reg := regexp.MustCompile(`^[a-zA-Z0-9_]+$`)
|
||||
if !reg.MatchString(fileMd5) {
|
||||
response.FailWithMsg(c, response.SystemError, "文件hash错误")
|
||||
return
|
||||
}
|
||||
var filePath = uh.getFilePath(fileMd5)
|
||||
// 检查文件是否存在
|
||||
if commonService.UploadChunkService.CheckFileExist(filePath) {
|
||||
response.OkWithData(c, filePath)
|
||||
@@ -62,6 +122,14 @@ func (uh uploadChunkHandler) CheckFileExist(c *gin.Context) {
|
||||
func (uh uploadChunkHandler) HasChunk(c *gin.Context) {
|
||||
var fileMd5 = c.Query("fileMd5")
|
||||
var chunkSize = c.Query("chunkSize")
|
||||
if fileMd5 == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件hash错误")
|
||||
return
|
||||
}
|
||||
if chunkSize == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "分片大小错误")
|
||||
return
|
||||
}
|
||||
var chunkDir = uh.getChunkDir(fileMd5, chunkSize)
|
||||
var HasChunk = commonService.UploadChunkService.HasChunk(chunkDir)
|
||||
response.OkWithData(c, HasChunk)
|
||||
@@ -87,6 +155,22 @@ func (uh uploadChunkHandler) UploadChunk(c *gin.Context) {
|
||||
chunkSize := c.PostForm("chunkSize") // 分片分割的大小
|
||||
index := c.PostForm("index") // 分片序号
|
||||
fileMd5 := c.PostForm("fileMd5") // 上传文件的md5
|
||||
if fileMd5 == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件hash错误")
|
||||
return
|
||||
}
|
||||
if chunkSize == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "分片大小错误")
|
||||
return
|
||||
}
|
||||
if index == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "分片序号错误")
|
||||
return
|
||||
}
|
||||
if chunk == nil {
|
||||
response.FailWithMsg(c, response.SystemError, "分片文件错误")
|
||||
return
|
||||
}
|
||||
|
||||
chunkDir := uh.getChunkDir(fileMd5, chunkSize)
|
||||
chunkPath := uh.getChunkPath(fileMd5, chunkSize, index)
|
||||
@@ -109,6 +193,22 @@ func (uh uploadChunkHandler) MergeChunk(c *gin.Context) {
|
||||
response.FailWithMsg(c, response.SystemError, bindErr.Error())
|
||||
return
|
||||
}
|
||||
if MergeChunk.FileMd5 == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件hash错误")
|
||||
return
|
||||
}
|
||||
if MergeChunk.FileName == "" {
|
||||
response.FailWithMsg(c, response.SystemError, "文件名错误")
|
||||
return
|
||||
}
|
||||
if MergeChunk.ChunkCount <= 0 {
|
||||
response.FailWithMsg(c, response.SystemError, "分片数量错误")
|
||||
return
|
||||
}
|
||||
if MergeChunk.ChunkSize <= 0 {
|
||||
response.FailWithMsg(c, response.SystemError, "分片大小错误")
|
||||
return
|
||||
}
|
||||
var filePath = uh.getFilePath(MergeChunk.FileMd5)
|
||||
var chunkDir = uh.getChunkDir(MergeChunk.FileMd5, fmt.Sprintf("%d", MergeChunk.ChunkSize))
|
||||
err := commonService.UploadChunkService.MergeChunk(chunkDir, filePath, MergeChunk.ChunkCount)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"x_admin/config"
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/service/settingService"
|
||||
"x_admin/util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -26,7 +27,7 @@ type indexService struct {
|
||||
// Console 控制台数据
|
||||
func (iSrv indexService) Console() (res map[string]interface{}, e error) {
|
||||
// 版本信息
|
||||
name, err := util.ConfigUtil.GetVal(iSrv.db, "website", "name", "x_admin-Go")
|
||||
name, err := settingService.SystemConfigService.GetVal(iSrv.db, "website", "name", "x_admin-Go")
|
||||
if e = response.CheckErr(err, "Console Get err"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -71,11 +72,11 @@ func (iSrv indexService) Console() (res map[string]interface{}, e error) {
|
||||
|
||||
// Config 公共配置
|
||||
func (iSrv indexService) Config() (res map[string]interface{}, e error) {
|
||||
website, err := util.ConfigUtil.Get(iSrv.db, "website")
|
||||
website, err := settingService.SystemConfigService.Get(iSrv.db, "website")
|
||||
if e = response.CheckErr(err, "Config Get err"); e != nil {
|
||||
return
|
||||
}
|
||||
copyrightStr, err := util.ConfigUtil.GetVal(iSrv.db, "website", "copyright", "")
|
||||
copyrightStr, err := settingService.SystemConfigService.GetVal(iSrv.db, "website", "copyright", "")
|
||||
if e = response.CheckErr(err, "Config GetVal err"); e != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
. "x_admin/schema/flowSchema"
|
||||
"x_admin/schema/flowSchema"
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
@@ -28,7 +28,7 @@ type flowApplyService struct {
|
||||
}
|
||||
|
||||
// List 申请流程列表
|
||||
func (service flowApplyService) List(page request.PageReq, listReq FlowApplyListReq) (res response.PageResp, e error) {
|
||||
func (service flowApplyService) List(page request.PageReq, listReq flowSchema.FlowApplyListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -74,7 +74,7 @@ func (service flowApplyService) List(page request.PageReq, listReq FlowApplyList
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []FlowApplyResp{}
|
||||
result := []flowSchema.FlowApplyResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -85,7 +85,7 @@ func (service flowApplyService) List(page request.PageReq, listReq FlowApplyList
|
||||
}
|
||||
|
||||
// Detail 申请流程详情
|
||||
func (service flowApplyService) Detail(id int) (res FlowApplyResp, e error) {
|
||||
func (service flowApplyService) Detail(id int) (res flowSchema.FlowApplyResp, e error) {
|
||||
var obj model.FlowApply
|
||||
err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
@@ -99,7 +99,7 @@ func (service flowApplyService) Detail(id int) (res FlowApplyResp, e error) {
|
||||
}
|
||||
|
||||
// Add 申请流程新增
|
||||
func (service flowApplyService) Add(addReq FlowApplyAddReq) (e error) {
|
||||
func (service flowApplyService) Add(addReq flowSchema.FlowApplyAddReq) (e error) {
|
||||
var obj model.FlowApply
|
||||
var flow_template_resp, err = TemplateService.Detail(addReq.TemplateId)
|
||||
if e = response.CheckErrDBNotRecord(err, "模板不存在!"); e != nil {
|
||||
@@ -119,7 +119,7 @@ func (service flowApplyService) Add(addReq FlowApplyAddReq) (e error) {
|
||||
}
|
||||
|
||||
// Edit 申请流程编辑
|
||||
func (service flowApplyService) Edit(editReq FlowApplyEditReq) (e error) {
|
||||
func (service flowApplyService) Edit(editReq flowSchema.FlowApplyEditReq) (e error) {
|
||||
var obj model.FlowApply
|
||||
err := service.db.Where("id = ? AND is_delete = ?", editReq.Id, 0).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/flowSchema"
|
||||
"x_admin/schema/flowSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
"x_admin/service/systemService"
|
||||
"x_admin/util"
|
||||
@@ -34,7 +34,7 @@ type flowHistoryService struct {
|
||||
}
|
||||
|
||||
// List 流程历史列表
|
||||
func (service flowHistoryService) List(page request.PageReq, listReq FlowHistoryListReq) (res response.PageResp, e error) {
|
||||
func (service flowHistoryService) List(page request.PageReq, listReq flowSchema.FlowHistoryListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -82,7 +82,7 @@ func (service flowHistoryService) List(page request.PageReq, listReq FlowHistory
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
list := []FlowHistoryResp{}
|
||||
list := []flowSchema.FlowHistoryResp{}
|
||||
convert_util.Copy(&list, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -93,7 +93,7 @@ func (service flowHistoryService) List(page request.PageReq, listReq FlowHistory
|
||||
}
|
||||
|
||||
// ListAll 流程历史列表
|
||||
func (service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []FlowHistoryResp, e error) {
|
||||
func (service flowHistoryService) ListAll(listReq flowSchema.FlowHistoryListReq) (res []flowSchema.FlowHistoryResp, e error) {
|
||||
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.FlowHistory{})
|
||||
@@ -117,7 +117,7 @@ func (service flowHistoryService) ListAll(listReq FlowHistoryListReq) (res []Flo
|
||||
}
|
||||
|
||||
// Detail 流程历史详情
|
||||
func (service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error) {
|
||||
func (service flowHistoryService) Detail(id int) (res flowSchema.FlowHistoryResp, e error) {
|
||||
var obj model.FlowHistory
|
||||
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
@@ -131,7 +131,7 @@ func (service flowHistoryService) Detail(id int) (res FlowHistoryResp, e error)
|
||||
}
|
||||
|
||||
// Add 流程历史新增
|
||||
func (service flowHistoryService) Add(addReq FlowHistoryAddReq) (e error) {
|
||||
func (service flowHistoryService) Add(addReq flowSchema.FlowHistoryAddReq) (e error) {
|
||||
var obj model.FlowHistory
|
||||
convert_util.Copy(&obj, addReq)
|
||||
err := service.db.Create(&obj).Error
|
||||
@@ -140,7 +140,7 @@ func (service flowHistoryService) Add(addReq FlowHistoryAddReq) (e error) {
|
||||
}
|
||||
|
||||
// Edit 流程历史编辑
|
||||
func (service flowHistoryService) Edit(editReq FlowHistoryEditReq) (e error) {
|
||||
func (service flowHistoryService) Edit(editReq flowSchema.FlowHistoryEditReq) (e error) {
|
||||
var obj model.FlowHistory
|
||||
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
@@ -182,7 +182,7 @@ func (service flowHistoryService) GetApprover(ApplyId int) (res []systemSchema.S
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var userTask FlowTree
|
||||
var userTask flowSchema.FlowTree
|
||||
for n := 0; n < len(nextNodes); n++ {
|
||||
if nextNodes[n].Type == "bpmn:userTask" {
|
||||
userTask = nextNodes[n]
|
||||
@@ -260,7 +260,7 @@ func (service flowHistoryService) GetApprover(ApplyId int) (res []systemSchema.S
|
||||
}
|
||||
|
||||
// 通过审批
|
||||
func (service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
func (service flowHistoryService) Pass(pass flowSchema.PassReq) (e error) {
|
||||
nextNodes, applyDetail, LastHistory, err := service.GetNextNode(pass.ApplyId)
|
||||
|
||||
if err != nil {
|
||||
@@ -363,7 +363,7 @@ func (service flowHistoryService) Pass(pass PassReq) (e error) {
|
||||
}
|
||||
|
||||
// 驳回
|
||||
func (service flowHistoryService) Back(back BackReq) (e error) {
|
||||
func (service flowHistoryService) Back(back flowSchema.BackReq) (e error) {
|
||||
// 得判断一下驳回的人权限
|
||||
// 获取最后一条历史记录
|
||||
var LastHistory model.FlowHistory
|
||||
@@ -466,7 +466,7 @@ func (service flowHistoryService) Back(back BackReq) (e error) {
|
||||
/**
|
||||
* 获取下一批流程,直到审批或结束节点
|
||||
*/
|
||||
func (service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, apply FlowApplyResp, LastHistory model.FlowHistory, e error) {
|
||||
func (service flowHistoryService) GetNextNode(ApplyId int) (res []flowSchema.FlowTree, apply flowSchema.FlowApplyResp, LastHistory model.FlowHistory, e error) {
|
||||
var applyDetail, err = ApplyService.Detail(ApplyId)
|
||||
|
||||
if e = response.CheckErr(err, "获取审批申请失败"); e != nil {
|
||||
@@ -479,7 +479,7 @@ func (service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, appl
|
||||
}).Limit(1).Last(&LastHistory)
|
||||
|
||||
// start
|
||||
var flowTree []FlowTree
|
||||
var flowTree []flowSchema.FlowTree
|
||||
json.Unmarshal([]byte(applyDetail.FlowProcessDataList), &flowTree)
|
||||
var formValue map[string]interface{}
|
||||
|
||||
@@ -490,11 +490,11 @@ func (service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, appl
|
||||
json.Unmarshal([]byte(applyDetail.FormValue), &formValue)
|
||||
}
|
||||
|
||||
var next []FlowTree
|
||||
var next []flowSchema.FlowTree
|
||||
if result.RowsAffected == 0 {
|
||||
for _, v := range flowTree {
|
||||
if v.Type == "bpmn:startEvent" {
|
||||
next = []FlowTree{v}
|
||||
next = []flowSchema.FlowTree{v}
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -515,8 +515,8 @@ func (service flowHistoryService) GetNextNode(ApplyId int) (res []FlowTree, appl
|
||||
}
|
||||
|
||||
// 返回节点数组,最后一个节点为用户或结束节点
|
||||
func DeepNextNode(flowTree *[]FlowTree, formValue map[string]interface{}) []FlowTree {
|
||||
var nextNodes []FlowTree
|
||||
func DeepNextNode(flowTree *[]flowSchema.FlowTree, formValue map[string]interface{}) []flowSchema.FlowTree {
|
||||
var nextNodes []flowSchema.FlowTree
|
||||
for _, v := range *flowTree {
|
||||
if v.Type == "bpmn:startEvent" {
|
||||
nextNodes = append(nextNodes, v)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
. "x_admin/schema/flowSchema"
|
||||
"x_admin/schema/flowSchema"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -25,7 +25,7 @@ type flowTemplateService struct {
|
||||
}
|
||||
|
||||
// List 流程模板列表
|
||||
func (service flowTemplateService) List(page request.PageReq, listReq FlowTemplateListReq) (res response.PageResp, e error) {
|
||||
func (service flowTemplateService) List(page request.PageReq, listReq flowSchema.FlowTemplateListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -58,7 +58,7 @@ func (service flowTemplateService) List(page request.PageReq, listReq FlowTempla
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []FlowTemplateResp{}
|
||||
result := []flowSchema.FlowTemplateResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -69,7 +69,7 @@ func (service flowTemplateService) List(page request.PageReq, listReq FlowTempla
|
||||
}
|
||||
|
||||
// ListAll 流程模板列表
|
||||
func (service flowTemplateService) ListAll() (res []FlowTemplateResp, e error) {
|
||||
func (service flowTemplateService) ListAll() (res []flowSchema.FlowTemplateResp, e error) {
|
||||
var modelList []model.FlowTemplate
|
||||
err := service.db.Find(&modelList).Error
|
||||
if e = response.CheckErr(err, "获取列表失败"); e != nil {
|
||||
@@ -80,7 +80,7 @@ func (service flowTemplateService) ListAll() (res []FlowTemplateResp, e error) {
|
||||
}
|
||||
|
||||
// Detail 流程模板详情
|
||||
func (service flowTemplateService) Detail(id int) (res FlowTemplateResp, e error) {
|
||||
func (service flowTemplateService) Detail(id int) (res flowSchema.FlowTemplateResp, e error) {
|
||||
var obj model.FlowTemplate
|
||||
err := service.db.Where("id = ?", id).Limit(1).First(&obj).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "数据不存在!"); e != nil {
|
||||
@@ -94,7 +94,7 @@ func (service flowTemplateService) Detail(id int) (res FlowTemplateResp, e error
|
||||
}
|
||||
|
||||
// Add 流程模板新增
|
||||
func (service flowTemplateService) Add(addReq FlowTemplateAddReq) (e error) {
|
||||
func (service flowTemplateService) Add(addReq flowSchema.FlowTemplateAddReq) (e error) {
|
||||
var obj model.FlowTemplate
|
||||
convert_util.Copy(&obj, addReq)
|
||||
err := service.db.Create(&obj).Error
|
||||
@@ -103,7 +103,7 @@ func (service flowTemplateService) Add(addReq FlowTemplateAddReq) (e error) {
|
||||
}
|
||||
|
||||
// Edit 流程模板编辑
|
||||
func (service flowTemplateService) Edit(editReq FlowTemplateEditReq) (e error) {
|
||||
func (service flowTemplateService) Edit(editReq flowSchema.FlowTemplateEditReq) (e error) {
|
||||
var obj model.FlowTemplate
|
||||
err := service.db.Where("id = ?", editReq.Id).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
. "x_admin/schema/monitorSchema"
|
||||
"x_admin/schema/monitorSchema"
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
"x_admin/util/excel2"
|
||||
@@ -33,7 +33,7 @@ type monitorClientService struct {
|
||||
}
|
||||
|
||||
// List 监控-客户端信息列表
|
||||
func (service monitorClientService) GetModel(listReq MonitorClientListReq) *gorm.DB {
|
||||
func (service monitorClientService) GetModel(listReq monitorSchema.MonitorClientListReq) *gorm.DB {
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.MonitorClient{})
|
||||
if listReq.ProjectKey != nil {
|
||||
@@ -81,7 +81,7 @@ func (service monitorClientService) GetModel(listReq MonitorClientListReq) *gorm
|
||||
}
|
||||
|
||||
// List 监控-客户端信息列表
|
||||
func (service monitorClientService) List(page request.PageReq, listReq MonitorClientListReq) (res response.PageResp, e error) {
|
||||
func (service monitorClientService) List(page request.PageReq, listReq monitorSchema.MonitorClientListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -98,7 +98,7 @@ func (service monitorClientService) List(page request.PageReq, listReq MonitorCl
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorClientResp{}
|
||||
result := []monitorSchema.MonitorClientResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -109,7 +109,7 @@ func (service monitorClientService) List(page request.PageReq, listReq MonitorCl
|
||||
}
|
||||
|
||||
// ListAll 监控-客户端信息列表
|
||||
func (service monitorClientService) ListAll(listReq MonitorClientListReq) (res []MonitorClientResp, e error) {
|
||||
func (service monitorClientService) ListAll(listReq monitorSchema.MonitorClientListReq) (res []monitorSchema.MonitorClientResp, e error) {
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
var modelList []model.MonitorClient
|
||||
@@ -122,7 +122,7 @@ func (service monitorClientService) ListAll(listReq MonitorClientListReq) (res [
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (service monitorClientService) DetailByClientId(ClientId string) (res MonitorClientResp, e error) {
|
||||
func (service monitorClientService) DetailByClientId(ClientId string) (res monitorSchema.MonitorClientResp, e error) {
|
||||
if ClientId == "" {
|
||||
return res, errors.New("ClientId不能为空")
|
||||
}
|
||||
@@ -145,7 +145,7 @@ func (service monitorClientService) DetailByClientId(ClientId string) (res Monit
|
||||
}
|
||||
|
||||
// Detail 监控-客户端信息详情
|
||||
func (service monitorClientService) Detail(Id int) (res MonitorClientResp, e error) {
|
||||
func (service monitorClientService) Detail(Id int) (res monitorSchema.MonitorClientResp, e error) {
|
||||
var obj = model.MonitorClient{}
|
||||
err := service.CacheUtil.GetCache(Id, &obj)
|
||||
if err != nil {
|
||||
@@ -164,8 +164,8 @@ func (service monitorClientService) Detail(Id int) (res MonitorClientResp, e err
|
||||
}
|
||||
|
||||
// ErrorUser 监控-客户端信息详情
|
||||
func (service monitorClientService) ErrorUsers(error_id int) (res []MonitorClientResp, e error) {
|
||||
var obj = []MonitorClientResp{}
|
||||
func (service monitorClientService) ErrorUsers(error_id int) (res []monitorSchema.MonitorClientResp, e error) {
|
||||
var obj = []monitorSchema.MonitorClientResp{}
|
||||
service.db.Raw("SELECT client.*,list.width,list.height,list.create_time AS create_time from x_monitor_error_list as list right join x_monitor_client as client on client.id = list.cid where list.eid = ? Order by list.id DESC LIMIT 0,20", error_id).Scan(&obj)
|
||||
|
||||
convert_util.Copy(&res, obj)
|
||||
@@ -173,7 +173,7 @@ func (service monitorClientService) ErrorUsers(error_id int) (res []MonitorClien
|
||||
}
|
||||
|
||||
// Add 监控-客户端信息新增
|
||||
func (service monitorClientService) Add(addReq MonitorClientAddReq) (createId int, e error) {
|
||||
func (service monitorClientService) Add(addReq monitorSchema.MonitorClientAddReq) (createId int, e error) {
|
||||
var obj model.MonitorClient
|
||||
convert_util.StructToStruct(addReq, &obj)
|
||||
err := service.db.Create(&obj).Error
|
||||
@@ -252,7 +252,7 @@ func (service monitorClientService) GetExcelCol() []excel2.Col {
|
||||
}
|
||||
|
||||
// ExportFile 监控-客户端信息导出
|
||||
func (service monitorClientService) ExportFile(listReq MonitorClientListReq) (res []MonitorClientResp, e error) {
|
||||
func (service monitorClientService) ExportFile(listReq monitorSchema.MonitorClientListReq) (res []monitorSchema.MonitorClientResp, e error) {
|
||||
// 查询
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
@@ -262,13 +262,13 @@ func (service monitorClientService) ExportFile(listReq MonitorClientListReq) (re
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorClientResp{}
|
||||
result := []monitorSchema.MonitorClientResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 导入
|
||||
func (service monitorClientService) ImportFile(importReq []MonitorClientResp) (e error) {
|
||||
func (service monitorClientService) ImportFile(importReq []monitorSchema.MonitorClientResp) (e error) {
|
||||
var importData []model.MonitorClient
|
||||
convert_util.Copy(&importData, importReq)
|
||||
err := service.db.Create(&importData).Error
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
. "x_admin/schema/monitorSchema"
|
||||
"x_admin/schema/monitorSchema"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -27,7 +27,7 @@ type monitorErrorListService struct {
|
||||
}
|
||||
|
||||
// Add 错误对应的用户记录新增
|
||||
func (service monitorErrorListService) Add(addReq MonitorErrorListAddReq) (createId int, e error) {
|
||||
func (service monitorErrorListService) Add(addReq monitorSchema.MonitorErrorListAddReq) (createId int, e error) {
|
||||
var obj model.MonitorErrorList
|
||||
convert_util.StructToStruct(addReq, &obj)
|
||||
err := service.db.Create(&obj).Error
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
. "x_admin/schema/monitorSchema"
|
||||
"x_admin/schema/monitorSchema"
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
"x_admin/util/excel2"
|
||||
@@ -35,7 +35,7 @@ type monitorErrorService struct {
|
||||
}
|
||||
|
||||
// List 监控-错误列列表
|
||||
func (service monitorErrorService) GetModel(listReq MonitorErrorListReq) *gorm.DB {
|
||||
func (service monitorErrorService) GetModel(listReq monitorSchema.MonitorErrorListReq) *gorm.DB {
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.MonitorError{})
|
||||
if listReq.ProjectKey != nil {
|
||||
@@ -67,7 +67,7 @@ func (service monitorErrorService) GetModel(listReq MonitorErrorListReq) *gorm.D
|
||||
}
|
||||
|
||||
// List 监控-错误列列表
|
||||
func (service monitorErrorService) List(page request.PageReq, listReq MonitorErrorListReq) (res response.PageResp, e error) {
|
||||
func (service monitorErrorService) List(page request.PageReq, listReq monitorSchema.MonitorErrorListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -84,7 +84,7 @@ func (service monitorErrorService) List(page request.PageReq, listReq MonitorErr
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorErrorResp{}
|
||||
result := []monitorSchema.MonitorErrorResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -95,7 +95,7 @@ func (service monitorErrorService) List(page request.PageReq, listReq MonitorErr
|
||||
}
|
||||
|
||||
// ListAll 监控-错误列列表
|
||||
func (service monitorErrorService) ListAll(listReq MonitorErrorListReq) (res []MonitorErrorResp, e error) {
|
||||
func (service monitorErrorService) ListAll(listReq monitorSchema.MonitorErrorListReq) (res []monitorSchema.MonitorErrorResp, e error) {
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
var modelList []model.MonitorError
|
||||
@@ -109,7 +109,7 @@ func (service monitorErrorService) ListAll(listReq MonitorErrorListReq) (res []M
|
||||
}
|
||||
|
||||
// Detail 监控-错误列详情
|
||||
func (service monitorErrorService) Detail(Id int) (res MonitorErrorResp, e error) {
|
||||
func (service monitorErrorService) Detail(Id int) (res monitorSchema.MonitorErrorResp, e error) {
|
||||
var obj = model.MonitorError{}
|
||||
|
||||
err := service.db.Where("id = ?", Id).Limit(1).First(&obj).Error
|
||||
@@ -125,7 +125,7 @@ func (service monitorErrorService) Detail(Id int) (res MonitorErrorResp, e error
|
||||
}
|
||||
|
||||
// DetailByMD5 监控-错误列详情
|
||||
func (service monitorErrorService) DetailByMD5(md5 string) (res MonitorErrorResp, e error) {
|
||||
func (service monitorErrorService) DetailByMD5(md5 string) (res monitorSchema.MonitorErrorResp, e error) {
|
||||
var obj = model.MonitorError{}
|
||||
err := service.CacheUtil.GetCache("md5:"+md5, &obj)
|
||||
if err != nil {
|
||||
@@ -144,7 +144,7 @@ func (service monitorErrorService) DetailByMD5(md5 string) (res MonitorErrorResp
|
||||
}
|
||||
|
||||
// Add 监控-错误列新增
|
||||
func (service monitorErrorService) Add(addReq MonitorErrorAddReq) (createId int, err error) {
|
||||
func (service monitorErrorService) Add(addReq monitorSchema.MonitorErrorAddReq) (createId int, err error) {
|
||||
|
||||
var obj model.MonitorError
|
||||
convert_util.StructToStruct(addReq, &obj)
|
||||
@@ -172,7 +172,7 @@ func (service monitorErrorService) Add(addReq MonitorErrorAddReq) (createId int,
|
||||
return 0, err
|
||||
}
|
||||
|
||||
_, err = MonitorErrorListService.Add(MonitorErrorListAddReq{
|
||||
_, err = MonitorErrorListService.Add(monitorSchema.MonitorErrorListAddReq{
|
||||
Eid: strconv.Itoa(createId),
|
||||
Cid: strconv.Itoa(client.Id),
|
||||
Width: addReq.Width,
|
||||
@@ -246,7 +246,7 @@ func (service monitorErrorService) GetExcelCol() []excel2.Col {
|
||||
}
|
||||
|
||||
// ExportFile 监控-错误列导出
|
||||
func (service monitorErrorService) ExportFile(listReq MonitorErrorListReq) (res []MonitorErrorResp, e error) {
|
||||
func (service monitorErrorService) ExportFile(listReq monitorSchema.MonitorErrorListReq) (res []monitorSchema.MonitorErrorResp, e error) {
|
||||
// 查询
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
@@ -256,13 +256,13 @@ func (service monitorErrorService) ExportFile(listReq MonitorErrorListReq) (res
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorErrorResp{}
|
||||
result := []monitorSchema.MonitorErrorResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 导入
|
||||
func (service monitorErrorService) ImportFile(importReq []MonitorErrorResp) (e error) {
|
||||
func (service monitorErrorService) ImportFile(importReq []monitorSchema.MonitorErrorResp) (e error) {
|
||||
var importData []model.MonitorError
|
||||
convert_util.Copy(&importData, importReq)
|
||||
err := service.db.Create(&importData).Error
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model"
|
||||
. "x_admin/schema/monitorSchema"
|
||||
"x_admin/schema/monitorSchema"
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
"x_admin/util/excel2"
|
||||
@@ -32,7 +32,7 @@ type monitorProjectService struct {
|
||||
}
|
||||
|
||||
// List 监控项目列表
|
||||
func (service monitorProjectService) GetModel(listReq MonitorProjectListReq) *gorm.DB {
|
||||
func (service monitorProjectService) GetModel(listReq monitorSchema.MonitorProjectListReq) *gorm.DB {
|
||||
// 查询
|
||||
dbModel := service.db.Model(&model.MonitorProject{})
|
||||
if listReq.ProjectKey != nil {
|
||||
@@ -64,7 +64,7 @@ func (service monitorProjectService) GetModel(listReq MonitorProjectListReq) *go
|
||||
}
|
||||
|
||||
// List 监控项目列表
|
||||
func (service monitorProjectService) List(page request.PageReq, listReq MonitorProjectListReq) (res response.PageResp, e error) {
|
||||
func (service monitorProjectService) List(page request.PageReq, listReq monitorSchema.MonitorProjectListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -81,7 +81,7 @@ func (service monitorProjectService) List(page request.PageReq, listReq MonitorP
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorProjectResp{}
|
||||
result := []monitorSchema.MonitorProjectResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -92,7 +92,7 @@ func (service monitorProjectService) List(page request.PageReq, listReq MonitorP
|
||||
}
|
||||
|
||||
// ListAll 监控项目列表
|
||||
func (service monitorProjectService) ListAll(listReq MonitorProjectListReq) (res []MonitorProjectResp, e error) {
|
||||
func (service monitorProjectService) ListAll(listReq monitorSchema.MonitorProjectListReq) (res []monitorSchema.MonitorProjectResp, e error) {
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
var modelList []model.MonitorProject
|
||||
@@ -106,7 +106,7 @@ func (service monitorProjectService) ListAll(listReq MonitorProjectListReq) (res
|
||||
}
|
||||
|
||||
// Detail 监控项目详情
|
||||
func (service monitorProjectService) Detail(Id int) (res MonitorProjectResp, e error) {
|
||||
func (service monitorProjectService) Detail(Id int) (res monitorSchema.MonitorProjectResp, e error) {
|
||||
var obj = model.MonitorProject{}
|
||||
err := service.CacheUtil.GetCache(Id, &obj)
|
||||
if err != nil {
|
||||
@@ -125,7 +125,7 @@ func (service monitorProjectService) Detail(Id int) (res MonitorProjectResp, e e
|
||||
}
|
||||
|
||||
// Add 监控项目新增
|
||||
func (service monitorProjectService) Add(addReq MonitorProjectAddReq) (createId int, e error) {
|
||||
func (service monitorProjectService) Add(addReq monitorSchema.MonitorProjectAddReq) (createId int, e error) {
|
||||
var obj model.MonitorProject
|
||||
convert_util.StructToStruct(addReq, &obj)
|
||||
obj.ProjectKey = util.ToolsUtil.MakeUuid()
|
||||
@@ -140,7 +140,7 @@ func (service monitorProjectService) Add(addReq MonitorProjectAddReq) (createId
|
||||
}
|
||||
|
||||
// Edit 监控项目编辑
|
||||
func (service monitorProjectService) Edit(editReq MonitorProjectEditReq) (e error) {
|
||||
func (service monitorProjectService) Edit(editReq monitorSchema.MonitorProjectEditReq) (e error) {
|
||||
var obj model.MonitorProject
|
||||
err := service.db.Where("id = ? AND is_delete = ?", editReq.Id, 0).Limit(1).First(&obj).Error
|
||||
// 校验
|
||||
@@ -208,7 +208,7 @@ func (service monitorProjectService) GetExcelCol() []excel2.Col {
|
||||
}
|
||||
|
||||
// ExportFile 监控项目导出
|
||||
func (service monitorProjectService) ExportFile(listReq MonitorProjectListReq) (res []MonitorProjectResp, e error) {
|
||||
func (service monitorProjectService) ExportFile(listReq monitorSchema.MonitorProjectListReq) (res []monitorSchema.MonitorProjectResp, e error) {
|
||||
// 查询
|
||||
dbModel := service.GetModel(listReq)
|
||||
|
||||
@@ -218,13 +218,13 @@ func (service monitorProjectService) ExportFile(listReq MonitorProjectListReq) (
|
||||
if e = response.CheckErr(err, "查询失败"); e != nil {
|
||||
return
|
||||
}
|
||||
result := []MonitorProjectResp{}
|
||||
result := []monitorSchema.MonitorProjectResp{}
|
||||
convert_util.Copy(&result, modelList)
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 导入
|
||||
func (service monitorProjectService) ImportFile(importReq []MonitorProjectResp) (e error) {
|
||||
func (service monitorProjectService) ImportFile(importReq []monitorSchema.MonitorProjectResp) (e error) {
|
||||
var importData []model.MonitorProject
|
||||
convert_util.Copy(&importData, importReq)
|
||||
err := service.db.Create(&importData).Error
|
||||
|
||||
@@ -3,7 +3,8 @@ package settingService
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
. "x_admin/schema/settingSchema"
|
||||
"x_admin/schema/settingSchema"
|
||||
|
||||
"x_admin/util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
|
||||
type ISettingCopyrightService interface {
|
||||
Detail() (res []map[string]interface{}, e error)
|
||||
Save(cReqs []SettingCopyrightItemReq) (e error)
|
||||
Save(cReqs []settingSchema.SettingCopyrightItemReq) (e error)
|
||||
}
|
||||
|
||||
var CopyrightService = NewSettingCopyrightService()
|
||||
@@ -29,7 +30,7 @@ type settingCopyrightService struct {
|
||||
|
||||
// Detail 获取网站备案信息
|
||||
func (cSrv settingCopyrightService) Detail() (res []map[string]interface{}, e error) {
|
||||
data, err := util.ConfigUtil.GetVal(cSrv.db, "website", "copyright", "[]")
|
||||
data, err := SystemConfigService.GetVal(cSrv.db, "website", "copyright", "[]")
|
||||
if e = response.CheckErr(err, "Detail GetVal err"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -38,12 +39,12 @@ func (cSrv settingCopyrightService) Detail() (res []map[string]interface{}, e er
|
||||
}
|
||||
|
||||
// Save 保存网站备案信息
|
||||
func (cSrv settingCopyrightService) Save(cReqs []SettingCopyrightItemReq) (e error) {
|
||||
func (cSrv settingCopyrightService) Save(cReqs []settingSchema.SettingCopyrightItemReq) (e error) {
|
||||
json, err := util.ToolsUtil.ObjToJson(cReqs)
|
||||
if e = response.CheckErr(err, "Save ObjToJson err"); e != nil {
|
||||
return
|
||||
}
|
||||
err = util.ConfigUtil.Set(cSrv.db, "website", "copyright", json)
|
||||
err = SystemConfigService.Set(cSrv.db, "website", "copyright", json)
|
||||
e = response.CheckErr(err, "保存失败")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,7 +4,8 @@ import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/setting_model"
|
||||
. "x_admin/schema/settingSchema"
|
||||
"x_admin/schema/settingSchema"
|
||||
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
@@ -12,12 +13,12 @@ import (
|
||||
)
|
||||
|
||||
type ISettingDictDataService interface {
|
||||
All(allReq SettingDictDataListReq) (res []SettingDictDataResp, e error)
|
||||
All(allReq settingSchema.SettingDictDataListReq) (res []settingSchema.SettingDictDataResp, e error)
|
||||
// List(page request.PageReq, listReq SettingDictDataListReq) (res response.PageResp, e error)
|
||||
Detail(id uint) (res SettingDictDataResp, e error)
|
||||
Add(addReq SettingDictDataAddReq) (e error)
|
||||
Edit(editReq SettingDictDataEditReq) (e error)
|
||||
Del(delReq SettingDictDataDelReq) (e error)
|
||||
Detail(id uint) (res settingSchema.SettingDictDataResp, e error)
|
||||
Add(addReq settingSchema.SettingDictDataAddReq) (e error)
|
||||
Edit(editReq settingSchema.SettingDictDataEditReq) (e error)
|
||||
Del(delReq settingSchema.SettingDictDataDelReq) (e error)
|
||||
}
|
||||
|
||||
var DictDataService = NewSettingDictDataService()
|
||||
@@ -34,7 +35,7 @@ type settingDictDataService struct {
|
||||
}
|
||||
|
||||
// All 字典数据所有
|
||||
func (ddSrv settingDictDataService) All(allReq SettingDictDataListReq) (res []SettingDictDataResp, e error) {
|
||||
func (ddSrv settingDictDataService) All(allReq settingSchema.SettingDictDataListReq) (res []settingSchema.SettingDictDataResp, e error) {
|
||||
var dictType setting_model.DictType
|
||||
err := ddSrv.db.Where("dict_type = ? AND is_delete = ?", allReq.DictType, 0).Limit(1).First(&dictType).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "该字典类型不存在!"); e != nil {
|
||||
@@ -58,13 +59,13 @@ func (ddSrv settingDictDataService) All(allReq SettingDictDataListReq) (res []Se
|
||||
if e = response.CheckErr(err, "All Find err"); e != nil {
|
||||
return
|
||||
}
|
||||
res = []SettingDictDataResp{}
|
||||
res = []settingSchema.SettingDictDataResp{}
|
||||
convert_util.Copy(&res, dictDatas)
|
||||
return
|
||||
}
|
||||
|
||||
// Detail 字典数据详情
|
||||
func (ddSrv settingDictDataService) Detail(id uint) (res SettingDictDataResp, e error) {
|
||||
func (ddSrv settingDictDataService) Detail(id uint) (res settingSchema.SettingDictDataResp, e error) {
|
||||
var dd setting_model.DictData
|
||||
err := ddSrv.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dd).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "字典数据不存在!"); e != nil {
|
||||
@@ -78,7 +79,7 @@ func (ddSrv settingDictDataService) Detail(id uint) (res SettingDictDataResp, e
|
||||
}
|
||||
|
||||
// Add 字典数据新增
|
||||
func (ddSrv settingDictDataService) Add(addReq SettingDictDataAddReq) (e error) {
|
||||
func (ddSrv settingDictDataService) Add(addReq settingSchema.SettingDictDataAddReq) (e error) {
|
||||
if r := ddSrv.db.Where("name = ? AND is_delete = ?", addReq.Name, 0).Limit(1).First(&setting_model.DictData{}); r.RowsAffected > 0 {
|
||||
return response.AssertArgumentError.SetMessage("字典数据已存在!")
|
||||
}
|
||||
@@ -90,7 +91,7 @@ func (ddSrv settingDictDataService) Add(addReq SettingDictDataAddReq) (e error)
|
||||
}
|
||||
|
||||
// Edit 字典数据编辑
|
||||
func (ddSrv settingDictDataService) Edit(editReq SettingDictDataEditReq) (e error) {
|
||||
func (ddSrv settingDictDataService) Edit(editReq settingSchema.SettingDictDataEditReq) (e error) {
|
||||
var dd setting_model.DictData
|
||||
err := ddSrv.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&dd).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "字典数据不存在!"); e != nil {
|
||||
@@ -110,7 +111,7 @@ func (ddSrv settingDictDataService) Edit(editReq SettingDictDataEditReq) (e erro
|
||||
}
|
||||
|
||||
// Del 字典数据删除
|
||||
func (ddSrv settingDictDataService) Del(delReq SettingDictDataDelReq) (e error) {
|
||||
func (ddSrv settingDictDataService) Del(delReq settingSchema.SettingDictDataDelReq) (e error) {
|
||||
err := ddSrv.db.Model(&setting_model.DictData{}).Where("id IN ?", delReq.Ids).Updates(
|
||||
setting_model.DictData{IsDelete: 1, DeleteTime: util.NullTimeUtil.Now()}).Error
|
||||
return response.CheckErr(err, "Del Update err")
|
||||
|
||||
@@ -5,7 +5,8 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/setting_model"
|
||||
. "x_admin/schema/settingSchema"
|
||||
"x_admin/schema/settingSchema"
|
||||
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
@@ -13,12 +14,12 @@ import (
|
||||
)
|
||||
|
||||
type ISettingDictTypeService interface {
|
||||
All() (res []SettingDictTypeResp, e error)
|
||||
List(page request.PageReq, listReq SettingDictTypeListReq) (res response.PageResp, e error)
|
||||
Detail(id uint) (res SettingDictTypeResp, e error)
|
||||
Add(addReq SettingDictTypeAddReq) (e error)
|
||||
Edit(editReq SettingDictTypeEditReq) (e error)
|
||||
Del(delReq SettingDictTypeDelReq) (e error)
|
||||
All() (res []settingSchema.SettingDictTypeResp, e error)
|
||||
List(page request.PageReq, listReq settingSchema.SettingDictTypeListReq) (res response.PageResp, e error)
|
||||
Detail(id uint) (res settingSchema.SettingDictTypeResp, e error)
|
||||
Add(addReq settingSchema.SettingDictTypeAddReq) (e error)
|
||||
Edit(editReq settingSchema.SettingDictTypeEditReq) (e error)
|
||||
Del(delReq settingSchema.SettingDictTypeDelReq) (e error)
|
||||
}
|
||||
|
||||
var DictTypeService = NewSettingDictTypeService()
|
||||
@@ -35,19 +36,19 @@ type settingDictTypeService struct {
|
||||
}
|
||||
|
||||
// All 字典类型所有
|
||||
func (dtSrv settingDictTypeService) All() (res []SettingDictTypeResp, e error) {
|
||||
func (dtSrv settingDictTypeService) All() (res []settingSchema.SettingDictTypeResp, e error) {
|
||||
var dictTypes []setting_model.DictType
|
||||
err := dtSrv.db.Where("is_delete = ?", 0).Order("id desc").Find(&dictTypes).Error
|
||||
if e = response.CheckErr(err, "All Find err"); e != nil {
|
||||
return
|
||||
}
|
||||
res = []SettingDictTypeResp{}
|
||||
res = []settingSchema.SettingDictTypeResp{}
|
||||
convert_util.Copy(&res, dictTypes)
|
||||
return
|
||||
}
|
||||
|
||||
// List 字典类型列表
|
||||
func (dtSrv settingDictTypeService) List(page request.PageReq, listReq SettingDictTypeListReq) (res response.PageResp, e error) {
|
||||
func (dtSrv settingDictTypeService) List(page request.PageReq, listReq settingSchema.SettingDictTypeListReq) (res response.PageResp, e error) {
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
dtModel := dtSrv.db.Model(&setting_model.DictType{}).Where("is_delete = ?", 0)
|
||||
@@ -70,7 +71,7 @@ func (dtSrv settingDictTypeService) List(page request.PageReq, listReq SettingDi
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
dtResp := []SettingDictTypeResp{}
|
||||
dtResp := []settingSchema.SettingDictTypeResp{}
|
||||
convert_util.Copy(&dtResp, dts)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -81,7 +82,7 @@ func (dtSrv settingDictTypeService) List(page request.PageReq, listReq SettingDi
|
||||
}
|
||||
|
||||
// Detail 字典类型详情
|
||||
func (dtSrv settingDictTypeService) Detail(id uint) (res SettingDictTypeResp, e error) {
|
||||
func (dtSrv settingDictTypeService) Detail(id uint) (res settingSchema.SettingDictTypeResp, e error) {
|
||||
var dt setting_model.DictType
|
||||
err := dtSrv.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dt).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "字典类型不存在!"); e != nil {
|
||||
@@ -95,7 +96,7 @@ func (dtSrv settingDictTypeService) Detail(id uint) (res SettingDictTypeResp, e
|
||||
}
|
||||
|
||||
// Add 字典类型新增
|
||||
func (dtSrv settingDictTypeService) Add(addReq SettingDictTypeAddReq) (e error) {
|
||||
func (dtSrv settingDictTypeService) Add(addReq settingSchema.SettingDictTypeAddReq) (e error) {
|
||||
if r := dtSrv.db.Where("dict_name = ? AND is_delete = ?", addReq.DictName, 0).Limit(1).First(&setting_model.DictType{}); r.RowsAffected > 0 {
|
||||
return response.AssertArgumentError.SetMessage("字典名称已存在!")
|
||||
}
|
||||
@@ -110,7 +111,7 @@ func (dtSrv settingDictTypeService) Add(addReq SettingDictTypeAddReq) (e error)
|
||||
}
|
||||
|
||||
// Edit 字典类型编辑
|
||||
func (dtSrv settingDictTypeService) Edit(editReq SettingDictTypeEditReq) (e error) {
|
||||
func (dtSrv settingDictTypeService) Edit(editReq settingSchema.SettingDictTypeEditReq) (e error) {
|
||||
var dt setting_model.DictType
|
||||
err := dtSrv.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&dt).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "字典类型不存在!"); e != nil {
|
||||
@@ -134,7 +135,7 @@ func (dtSrv settingDictTypeService) Edit(editReq SettingDictTypeEditReq) (e erro
|
||||
}
|
||||
|
||||
// Del 字典类型删除
|
||||
func (dtSrv settingDictTypeService) Del(delReq SettingDictTypeDelReq) (e error) {
|
||||
func (dtSrv settingDictTypeService) Del(delReq settingSchema.SettingDictTypeDelReq) (e error) {
|
||||
err := dtSrv.db.Model(&setting_model.DictType{}).Where("id IN ?", delReq.Ids).Updates(
|
||||
setting_model.DictType{IsDelete: 1, DeleteTime: util.NullTimeUtil.Now()}).Error
|
||||
return response.CheckErr(err, "Del Update err")
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package util
|
||||
package settingService
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"x_admin/model/system_model"
|
||||
"x_admin/util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
var ConfigUtil = configUtil{}
|
||||
var SystemConfigService = systemConfigService{}
|
||||
|
||||
// 数据库配置操作工具
|
||||
type configUtil struct{}
|
||||
type systemConfigService struct{}
|
||||
|
||||
// Get 根据类型和名称获取配置字典
|
||||
func (cu configUtil) Get(db *gorm.DB, cnfType string, names ...string) (data map[string]string, err error) {
|
||||
func (cu systemConfigService) Get(db *gorm.DB, cnfType string, names ...string) (data map[string]string, err error) {
|
||||
chain := db.Where("type = ?", cnfType)
|
||||
if len(names) > 0 {
|
||||
chain.Where("name = ?", names[0])
|
||||
@@ -32,7 +33,7 @@ func (cu configUtil) Get(db *gorm.DB, cnfType string, names ...string) (data map
|
||||
}
|
||||
|
||||
// GetVal 根据类型和名称获取配置值
|
||||
func (cu configUtil) GetVal(db *gorm.DB, cnfType string, name string, defaultVal string) (data string, err error) {
|
||||
func (cu systemConfigService) GetVal(db *gorm.DB, cnfType string, name string, defaultVal string) (data string, err error) {
|
||||
config, err := cu.Get(db, cnfType, name)
|
||||
if err != nil {
|
||||
return data, err
|
||||
@@ -45,7 +46,7 @@ func (cu configUtil) GetVal(db *gorm.DB, cnfType string, name string, defaultVal
|
||||
}
|
||||
|
||||
// GetMap 根据类型和名称获取配置值(Json字符串转dict)
|
||||
func (cu configUtil) GetMap(db *gorm.DB, cnfType string, name string) (data map[string]string, err error) {
|
||||
func (cu systemConfigService) GetMap(db *gorm.DB, cnfType string, name string) (data map[string]string, err error) {
|
||||
val, err := cu.GetVal(db, cnfType, name, "")
|
||||
if err != nil {
|
||||
return data, err
|
||||
@@ -53,7 +54,7 @@ func (cu configUtil) GetMap(db *gorm.DB, cnfType string, name string) (data map[
|
||||
if val == "" {
|
||||
return map[string]string{}, nil
|
||||
}
|
||||
err = ToolsUtil.JsonToObj(val, &data)
|
||||
err = util.ToolsUtil.JsonToObj(val, &data)
|
||||
return data, err
|
||||
}
|
||||
|
||||
@@ -62,7 +63,7 @@ func (cu configUtil) GetMap(db *gorm.DB, cnfType string, name string) (data map[
|
||||
// @Param cnfType string 配置的类型
|
||||
// @Param name string 配置的名称
|
||||
// @Param val string 要设置的配置值
|
||||
func (cu configUtil) Set(db *gorm.DB, cnfType string, name string, val string) (err error) {
|
||||
func (cu systemConfigService) Set(db *gorm.DB, cnfType string, name string, val string) (err error) {
|
||||
var config system_model.SystemConfig
|
||||
err = db.Where("type = ? AND name = ?", cnfType, name).First(&config).Error
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
@@ -3,7 +3,8 @@ package settingService
|
||||
import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
. "x_admin/schema/settingSchema"
|
||||
"x_admin/schema/settingSchema"
|
||||
|
||||
"x_admin/util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -11,7 +12,7 @@ import (
|
||||
|
||||
type ISettingWebsiteService interface {
|
||||
Detail() (res map[string]string, e error)
|
||||
Save(wsReq SettingWebsiteReq) (e error)
|
||||
Save(wsReq settingSchema.SettingWebsiteReq) (e error)
|
||||
}
|
||||
|
||||
var WebsiteService = NewSettingWebsiteService()
|
||||
@@ -29,7 +30,7 @@ type settingWebsiteService struct {
|
||||
|
||||
// Detail 获取网站信息
|
||||
func (wSrv settingWebsiteService) Detail() (res map[string]string, e error) {
|
||||
data, err := util.ConfigUtil.Get(wSrv.db, "website")
|
||||
data, err := SystemConfigService.Get(wSrv.db, "website")
|
||||
if e = response.CheckErr(err, "Detail Get err"); e != nil {
|
||||
return
|
||||
}
|
||||
@@ -44,28 +45,28 @@ func (wSrv settingWebsiteService) Detail() (res map[string]string, e error) {
|
||||
}
|
||||
|
||||
// Save 保存网站信息
|
||||
func (wSrv settingWebsiteService) Save(wsReq SettingWebsiteReq) (e error) {
|
||||
err := util.ConfigUtil.Set(wSrv.db, "website", "name", wsReq.Name)
|
||||
func (wSrv settingWebsiteService) Save(wsReq settingSchema.SettingWebsiteReq) (e error) {
|
||||
err := SystemConfigService.Set(wSrv.db, "website", "name", wsReq.Name)
|
||||
if e = response.CheckErr(err, "Save Set name err"); e != nil {
|
||||
return
|
||||
}
|
||||
err = util.ConfigUtil.Set(wSrv.db, "website", "logo", util.UrlUtil.ToRelativeUrl(wsReq.Logo))
|
||||
err = SystemConfigService.Set(wSrv.db, "website", "logo", util.UrlUtil.ToRelativeUrl(wsReq.Logo))
|
||||
if e = response.CheckErr(err, "Save Set logo err"); e != nil {
|
||||
return
|
||||
}
|
||||
err = util.ConfigUtil.Set(wSrv.db, "website", "favicon", util.UrlUtil.ToRelativeUrl(wsReq.Favicon))
|
||||
err = SystemConfigService.Set(wSrv.db, "website", "favicon", util.UrlUtil.ToRelativeUrl(wsReq.Favicon))
|
||||
if e = response.CheckErr(err, "Save Set favicon err"); e != nil {
|
||||
return
|
||||
}
|
||||
err = util.ConfigUtil.Set(wSrv.db, "website", "backdrop", util.UrlUtil.ToRelativeUrl(wsReq.Backdrop))
|
||||
err = SystemConfigService.Set(wSrv.db, "website", "backdrop", util.UrlUtil.ToRelativeUrl(wsReq.Backdrop))
|
||||
if e = response.CheckErr(err, "Save Set backdrop err"); e != nil {
|
||||
return
|
||||
}
|
||||
err = util.ConfigUtil.Set(wSrv.db, "website", "shopName", wsReq.ShopName)
|
||||
err = SystemConfigService.Set(wSrv.db, "website", "shopName", wsReq.ShopName)
|
||||
if e = response.CheckErr(err, "Save Set shopName err"); e != nil {
|
||||
return
|
||||
}
|
||||
err = util.ConfigUtil.Set(wSrv.db, "website", "shopLogo", util.UrlUtil.ToRelativeUrl(wsReq.ShopLogo))
|
||||
err = SystemConfigService.Set(wSrv.db, "website", "shopLogo", util.UrlUtil.ToRelativeUrl(wsReq.ShopLogo))
|
||||
e = response.CheckErr(err, "Save Set shopLogo err")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,16 +4,17 @@ import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/systemSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// type ISystemAuthDeptService interface {
|
||||
// All() (res []SystemAuthDeptResp, e error)
|
||||
// All() (res []systemSchema.SystemAuthDeptResp, e error)
|
||||
// List(listReq SystemAuthDeptListReq) (mapList []interface{}, e error)
|
||||
// Detail(id uint) (res SystemAuthDeptResp, e error)
|
||||
// Detail(id uint) (res systemSchema.SystemAuthDeptResp, e error)
|
||||
// Add(addReq SystemAuthDeptAddReq) (e error)
|
||||
// Edit(editReq SystemAuthDeptEditReq) (e error)
|
||||
// Del(id uint) (e error)
|
||||
@@ -33,19 +34,19 @@ type systemAuthDeptService struct {
|
||||
}
|
||||
|
||||
// All 部门所有
|
||||
func (service systemAuthDeptService) All() (res []SystemAuthDeptResp, e error) {
|
||||
func (service systemAuthDeptService) All() (res []systemSchema.SystemAuthDeptResp, e error) {
|
||||
var depts []system_model.SystemAuthDept
|
||||
err := service.db.Where("is_delete = ?", 0).Order("sort desc, id desc").Find(&depts).Error
|
||||
if e = response.CheckErr(err, "All Find err"); e != nil {
|
||||
return
|
||||
}
|
||||
res = []SystemAuthDeptResp{}
|
||||
res = []systemSchema.SystemAuthDeptResp{}
|
||||
convert_util.Copy(&res, depts)
|
||||
return
|
||||
}
|
||||
|
||||
// List 部门列表
|
||||
func (service systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptResps []SystemAuthDeptResp, e error) {
|
||||
func (service systemAuthDeptService) List(listReq systemSchema.SystemAuthDeptListReq) (deptResps []systemSchema.SystemAuthDeptResp, e error) {
|
||||
deptModel := service.db.Where("is_delete = ?", 0)
|
||||
if listReq.Name != "" {
|
||||
deptModel = deptModel.Where("name like ?", "%"+listReq.Name+"%")
|
||||
@@ -63,7 +64,7 @@ func (service systemAuthDeptService) List(listReq SystemAuthDeptListReq) (deptRe
|
||||
}
|
||||
|
||||
// Detail 部门详情
|
||||
func (service systemAuthDeptService) Detail(id uint) (res SystemAuthDeptResp, e error) {
|
||||
func (service systemAuthDeptService) Detail(id uint) (res systemSchema.SystemAuthDeptResp, e error) {
|
||||
var dept system_model.SystemAuthDept
|
||||
err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&dept).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "部门已不存在!"); e != nil {
|
||||
@@ -77,7 +78,7 @@ func (service systemAuthDeptService) Detail(id uint) (res SystemAuthDeptResp, e
|
||||
}
|
||||
|
||||
// Add 部门新增
|
||||
func (service systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error) {
|
||||
func (service systemAuthDeptService) Add(addReq systemSchema.SystemAuthDeptAddReq) (e error) {
|
||||
if addReq.Pid == 0 {
|
||||
r := service.db.Where("pid = ? AND is_delete = ?", 0, 0).Limit(1).Find(&system_model.SystemAuthDept{})
|
||||
if e = response.CheckErr(r.Error, "Add Find err"); e != nil {
|
||||
@@ -95,7 +96,7 @@ func (service systemAuthDeptService) Add(addReq SystemAuthDeptAddReq) (e error)
|
||||
}
|
||||
|
||||
// Edit 部门编辑
|
||||
func (service systemAuthDeptService) Edit(editReq SystemAuthDeptEditReq) (e error) {
|
||||
func (service systemAuthDeptService) Edit(editReq systemSchema.SystemAuthDeptEditReq) (e error) {
|
||||
var dept system_model.SystemAuthDept
|
||||
err := service.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&dept).Error
|
||||
// 校验
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/systemSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
@@ -25,7 +25,7 @@ type systemLogsServer struct {
|
||||
}
|
||||
|
||||
// Operate 系统操作日志
|
||||
func (logSrv systemLogsServer) Operate(page request.PageReq, logReq SystemLogOperateReq) (res response.PageResp, e error) {
|
||||
func (logSrv systemLogsServer) Operate(page request.PageReq, logReq systemSchema.SystemLogOperateReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -67,7 +67,7 @@ func (logSrv systemLogsServer) Operate(page request.PageReq, logReq SystemLogOpe
|
||||
return
|
||||
}
|
||||
// 数据
|
||||
var logResp []SystemLogOperateResp
|
||||
var logResp []systemSchema.SystemLogOperateResp
|
||||
err = logModel.Limit(limit).Offset(offset).Order("id desc").Find(&logResp).Error
|
||||
if e = response.CheckErr(err, "Operate Find err"); e != nil {
|
||||
return
|
||||
@@ -81,7 +81,7 @@ func (logSrv systemLogsServer) Operate(page request.PageReq, logReq SystemLogOpe
|
||||
}
|
||||
|
||||
// Login 系统登录日志
|
||||
func (logSrv systemLogsServer) Login(page request.PageReq, logReq SystemLogLoginReq) (res response.PageResp, e error) {
|
||||
func (logSrv systemLogsServer) Login(page request.PageReq, logReq systemSchema.SystemLogLoginReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -108,7 +108,7 @@ func (logSrv systemLogsServer) Login(page request.PageReq, logReq SystemLogLogin
|
||||
return
|
||||
}
|
||||
// 数据
|
||||
var logResp []SystemLogLoginResp
|
||||
var logResp []systemSchema.SystemLogLoginResp
|
||||
err = logModel.Limit(limit).Offset(offset).Order("id desc").Find(&logResp).Error
|
||||
if e = response.CheckErr(err, "Login Find err"); e != nil {
|
||||
return
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/systemSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
|
||||
"x_admin/util"
|
||||
|
||||
@@ -31,7 +31,7 @@ type systemLoginService struct {
|
||||
}
|
||||
|
||||
// Login 登录
|
||||
func (loginSrv systemLoginService) Login(c *gin.Context, req *SystemLoginReq) (res SystemLoginResp, e error) {
|
||||
func (loginSrv systemLoginService) Login(c *gin.Context, req *systemSchema.SystemLoginReq) (res systemSchema.SystemLoginResp, e error) {
|
||||
sysAdmin, err := AdminService.FindByUsername(req.Username)
|
||||
if err != nil && errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
if e = loginSrv.RecordLoginLog(c, 0, req.Username, response.LoginAccountError.Msg()); e != nil {
|
||||
@@ -106,11 +106,11 @@ func (loginSrv systemLoginService) Login(c *gin.Context, req *SystemLoginReq) (r
|
||||
return
|
||||
}
|
||||
// 返回登录信息
|
||||
return SystemLoginResp{Token: token}, nil
|
||||
return systemSchema.SystemLoginResp{Token: token}, nil
|
||||
}
|
||||
|
||||
// Logout 退出
|
||||
func (loginSrv systemLoginService) Logout(req *SystemLogoutReq) (e error) {
|
||||
func (loginSrv systemLoginService) Logout(req *systemSchema.SystemLogoutReq) (e error) {
|
||||
util.RedisUtil.Del(config.AdminConfig.BackstageTokenKey + req.Token)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"x_admin/core"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/systemSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
@@ -57,7 +57,7 @@ func (menuSrv systemAuthMenuService) SelectMenuByRoleId(c *gin.Context, roleId u
|
||||
if e = response.CheckErr(err, "SelectMenuByRoleId Find err"); e != nil {
|
||||
return
|
||||
}
|
||||
var menuResps []SystemAuthMenuResp
|
||||
var menuResps []systemSchema.SystemAuthMenuResp
|
||||
convert_util.Copy(&menuResps, menus)
|
||||
mapList = util.ArrayUtil.ListToTree(
|
||||
convert_util.StructsToMaps(menuResps), "id", "pid", "children")
|
||||
@@ -71,13 +71,13 @@ func (menuSrv systemAuthMenuService) List() (res interface{}, e error) {
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
var menuResps []SystemAuthMenuResp
|
||||
var menuResps []systemSchema.SystemAuthMenuResp
|
||||
convert_util.Copy(&menuResps, menus)
|
||||
return menuResps, nil
|
||||
}
|
||||
|
||||
// Detail 菜单详情
|
||||
func (menuSrv systemAuthMenuService) Detail(id uint) (res SystemAuthMenuResp, e error) {
|
||||
func (menuSrv systemAuthMenuService) Detail(id uint) (res systemSchema.SystemAuthMenuResp, e error) {
|
||||
var menu system_model.SystemAuthMenu
|
||||
err := menuSrv.db.Where("id = ?", id).Limit(1).First(&menu).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "菜单已不存在!"); e != nil {
|
||||
@@ -90,7 +90,7 @@ func (menuSrv systemAuthMenuService) Detail(id uint) (res SystemAuthMenuResp, e
|
||||
return
|
||||
}
|
||||
|
||||
func (menuSrv systemAuthMenuService) Add(addReq SystemAuthMenuAddReq) (e error) {
|
||||
func (menuSrv systemAuthMenuService) Add(addReq systemSchema.SystemAuthMenuAddReq) (e error) {
|
||||
var menu system_model.SystemAuthMenu
|
||||
convert_util.Copy(&menu, addReq)
|
||||
err := menuSrv.db.Create(&menu).Error
|
||||
@@ -101,7 +101,7 @@ func (menuSrv systemAuthMenuService) Add(addReq SystemAuthMenuAddReq) (e error)
|
||||
return
|
||||
}
|
||||
|
||||
func (menuSrv systemAuthMenuService) Edit(editReq SystemAuthMenuEditReq) (e error) {
|
||||
func (menuSrv systemAuthMenuService) Edit(editReq systemSchema.SystemAuthMenuEditReq) (e error) {
|
||||
var menu system_model.SystemAuthMenu
|
||||
err := menuSrv.db.Where("id = ?", editReq.ID).Limit(1).Find(&menu).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "菜单已不存在!"); e != nil {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/systemSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
"gorm.io/gorm"
|
||||
@@ -34,19 +34,19 @@ type systemAuthPostService struct {
|
||||
}
|
||||
|
||||
// All 岗位所有
|
||||
func (service systemAuthPostService) All() (res []SystemAuthPostResp, e error) {
|
||||
func (service systemAuthPostService) All() (res []systemSchema.SystemAuthPostResp, e error) {
|
||||
var posts []system_model.SystemAuthPost
|
||||
err := service.db.Order("sort desc, id desc").Find(&posts).Error
|
||||
if e = response.CheckErr(err, "All Find err"); e != nil {
|
||||
return
|
||||
}
|
||||
res = []SystemAuthPostResp{}
|
||||
res = []systemSchema.SystemAuthPostResp{}
|
||||
convert_util.Copy(&res, posts)
|
||||
return
|
||||
}
|
||||
|
||||
// List 岗位列表
|
||||
func (service systemAuthPostService) List(page request.PageReq, listReq SystemAuthPostListReq) (res response.PageResp, e error) {
|
||||
func (service systemAuthPostService) List(page request.PageReq, listReq systemSchema.SystemAuthPostListReq) (res response.PageResp, e error) {
|
||||
// 分页信息
|
||||
limit := page.PageSize
|
||||
offset := page.PageSize * (page.PageNo - 1)
|
||||
@@ -73,7 +73,7 @@ func (service systemAuthPostService) List(page request.PageReq, listReq SystemAu
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
postResps := []SystemAuthPostResp{}
|
||||
postResps := []systemSchema.SystemAuthPostResp{}
|
||||
convert_util.Copy(&postResps, posts)
|
||||
return response.PageResp{
|
||||
PageNo: page.PageNo,
|
||||
@@ -84,7 +84,7 @@ func (service systemAuthPostService) List(page request.PageReq, listReq SystemAu
|
||||
}
|
||||
|
||||
// Detail 部门详情
|
||||
func (service systemAuthPostService) Detail(id uint) (res SystemAuthPostResp, e error) {
|
||||
func (service systemAuthPostService) Detail(id uint) (res systemSchema.SystemAuthPostResp, e error) {
|
||||
var post system_model.SystemAuthPost
|
||||
err := service.db.Where("id = ? AND is_delete = ?", id, 0).Limit(1).First(&post).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "岗位不存在!"); e != nil {
|
||||
@@ -98,7 +98,7 @@ func (service systemAuthPostService) Detail(id uint) (res SystemAuthPostResp, e
|
||||
}
|
||||
|
||||
// Add 部门新增
|
||||
func (service systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error) {
|
||||
func (service systemAuthPostService) Add(addReq systemSchema.SystemAuthPostAddReq) (e error) {
|
||||
r := service.db.Where("(code = ? OR name = ?) AND is_delete = ?", addReq.Code, addReq.Name, 0).Limit(1).Find(&system_model.SystemAuthPost{})
|
||||
if e = response.CheckErr(r.Error, "Add Find err"); e != nil {
|
||||
return
|
||||
@@ -114,7 +114,7 @@ func (service systemAuthPostService) Add(addReq SystemAuthPostAddReq) (e error)
|
||||
}
|
||||
|
||||
// Edit 部门编辑
|
||||
func (service systemAuthPostService) Edit(editReq SystemAuthPostEditReq) (e error) {
|
||||
func (service systemAuthPostService) Edit(editReq systemSchema.SystemAuthPostEditReq) (e error) {
|
||||
var post system_model.SystemAuthPost
|
||||
err := service.db.Where("id = ? AND is_delete = ?", editReq.ID, 0).Limit(1).First(&post).Error
|
||||
// 校验
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"x_admin/core/request"
|
||||
"x_admin/core/response"
|
||||
"x_admin/model/system_model"
|
||||
. "x_admin/schema/systemSchema"
|
||||
"x_admin/schema/systemSchema"
|
||||
"x_admin/util"
|
||||
"x_admin/util/convert_util"
|
||||
|
||||
@@ -30,7 +30,7 @@ type systemAuthRoleService struct {
|
||||
}
|
||||
|
||||
// All 角色所有
|
||||
func (roleSrv systemAuthRoleService) All() (res []SystemAuthRoleSimpleResp, e error) {
|
||||
func (roleSrv systemAuthRoleService) All() (res []systemSchema.SystemAuthRoleSimpleResp, e error) {
|
||||
var roles []system_model.SystemAuthRole
|
||||
err := roleSrv.db.Order("sort desc, id desc").Find(&roles).Error
|
||||
if e = response.CheckErr(err, "All Find err"); e != nil {
|
||||
@@ -55,7 +55,7 @@ func (roleSrv systemAuthRoleService) List(page request.PageReq) (res response.Pa
|
||||
if e = response.CheckErr(err, "列表获取失败"); e != nil {
|
||||
return
|
||||
}
|
||||
var roleResp []SystemAuthRoleResp
|
||||
var roleResp []systemSchema.SystemAuthRoleResp
|
||||
convert_util.Copy(&roleResp, roles)
|
||||
for i := 0; i < len(roleResp); i++ {
|
||||
roleResp[i].Menus = []uint{}
|
||||
@@ -70,7 +70,7 @@ func (roleSrv systemAuthRoleService) List(page request.PageReq) (res response.Pa
|
||||
}
|
||||
|
||||
// Detail 角色详情
|
||||
func (roleSrv systemAuthRoleService) Detail(id uint) (res SystemAuthRoleResp, e error) {
|
||||
func (roleSrv systemAuthRoleService) Detail(id uint) (res systemSchema.SystemAuthRoleResp, e error) {
|
||||
var role system_model.SystemAuthRole
|
||||
err := roleSrv.db.Where("id = ?", id).Limit(1).First(&role).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "角色已不存在!"); e != nil {
|
||||
@@ -93,7 +93,7 @@ func (roleSrv systemAuthRoleService) getMemberCnt(roleId uint) (count int64) {
|
||||
}
|
||||
|
||||
// Add 新增角色
|
||||
func (roleSrv systemAuthRoleService) Add(addReq SystemAuthRoleAddReq) (e error) {
|
||||
func (roleSrv systemAuthRoleService) Add(addReq systemSchema.SystemAuthRoleAddReq) (e error) {
|
||||
var role system_model.SystemAuthRole
|
||||
if r := roleSrv.db.Where("name = ?", strings.Trim(addReq.Name, " ")).Limit(1).First(&role); r.RowsAffected > 0 {
|
||||
return response.AssertArgumentError.SetMessage("角色名称已存在!")
|
||||
@@ -115,7 +115,7 @@ func (roleSrv systemAuthRoleService) Add(addReq SystemAuthRoleAddReq) (e error)
|
||||
}
|
||||
|
||||
// Edit 编辑角色
|
||||
func (roleSrv systemAuthRoleService) Edit(editReq SystemAuthRoleEditReq) (e error) {
|
||||
func (roleSrv systemAuthRoleService) Edit(editReq systemSchema.SystemAuthRoleEditReq) (e error) {
|
||||
err := roleSrv.db.Where("id = ?", editReq.ID).Limit(1).First(&system_model.SystemAuthRole{}).Error
|
||||
if e = response.CheckErrDBNotRecord(err, "角色已不存在!"); e != nil {
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user