Browse Source

金蝶更新

pull/269/head
yehongyang 3 years ago
parent
commit
407795f06c
5 changed files with 32 additions and 5 deletions
  1. +11
    -0
      utils/log/log.go
  2. +12
    -0
      web/controllers/common/CommonUploadPic.rest.go
  3. +3
    -0
      web/controllers/common/common.go
  4. +1
    -1
      web/middleware/middleware.go
  5. +5
    -4
      web/supports/simple_response.go

+ 11
- 0
utils/log/log.go View File

@ -2,6 +2,7 @@ package log
import (
"github.com/spf13/viper"
"io/ioutil"
"leit.com/LAPP_CHEERSSON_BACKEND/utils"
"os"
"strings"
@ -39,6 +40,16 @@ func folder(model outputDriver) error {
return err
}
func Read(model string, _fileName string) []byte {
fileName := _fileName + "." + loggerConfig.Config[model].Filetype
path := loggerConfig.Config[model].Filename + "/" + fileName
bytes, err := ioutil.ReadFile(path)
if err != nil {
return nil
}
return bytes
}
/**
写入文件
*/


+ 12
- 0
web/controllers/common/CommonUploadPic.rest.go View File

@ -9,6 +9,7 @@ import (
"leit.com/LAPP_CHEERSSON_BACKEND/global"
"leit.com/LAPP_CHEERSSON_BACKEND/task"
"leit.com/LAPP_CHEERSSON_BACKEND/utils"
logUtils "leit.com/LAPP_CHEERSSON_BACKEND/utils/log"
"leit.com/LAPP_CHEERSSON_BACKEND/web/middleware/jwts"
"leit.com/LAPP_CHEERSSON_BACKEND/web/supports"
"strings"
@ -37,6 +38,17 @@ func RegisterEmpinfo(party router.Party, path string) {
})
}
//读取日志
func RegisterReadLog(party router.Party, path string) {
party.Get(path+"/{model:string}"+"/{fileName:string}", func(ctx iris.Context) {
model := ctx.Params().GetString("model")
fileName := ctx.Params().GetString("fileName")
data := logUtils.Read(model, fileName)
ctx.Write(data)
})
}
/******************************************************************************
*
* @Function Name : RegisterUploadMustPic


+ 3
- 0
web/controllers/common/common.go View File

@ -32,7 +32,10 @@ func RegisterRoutes() {
RegisterOrg(org, "/list")
empinfo := party.Party("/empinfo")
RegisterEmpinfo(empinfo, "/list")
log := party.Party("/log")
RegisterReadLog(log, "/read")
})
}
/******************************************************************************


+ 1
- 1
web/middleware/middleware.go View File

@ -14,7 +14,7 @@ type Middleware struct {
func ServeHTTP(ctx iris.Context) {
path := ctx.Path()
// 过滤静态资源、login接口、首页等...不需要验证
if checkURL(path) || strings.Contains(path, "/public") {
if checkURL(path) || strings.Contains(path, "/public") || strings.Contains(path, "/admin/common/log/read") {
ctx.Next()
return
}


+ 5
- 4
web/supports/simple_response.go View File

@ -64,11 +64,12 @@ func Ok(ctx iris.Context, msg string, data interface{}) {
}
type SJ struct {
CODE interface{} `json:"code"`
MSG interface{} `json:"msg"`
DATA interface{} `json:"data"`
CODE interface{} `json:"code"`
MSG interface{} `json:"msg"`
DATA interface{} `json:"data"`
}
func OkString(ctx iris.Context, msg string, data interface{}){
func OkString(ctx iris.Context, msg string, data interface{}) {
ctx.StatusCode(iris.StatusOK)
s := SJ{
CODE: iris.StatusOK,


Loading…
Cancel
Save