style: 错误提示英文内容
This commit is contained in:
@@ -12,20 +12,20 @@ func MMLSendMsg(ip, msg string) (string, error) {
|
||||
// 创建MMLClient实例
|
||||
client, err := NewMMLClient(ip)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("创建MMLClient实例失败:%v", err)
|
||||
return "", fmt.Errorf("failed to create MMLClient instance: %v", err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
// 发送数据
|
||||
err = client.Send(msg)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("发送数据失败:%v", err)
|
||||
return "", fmt.Errorf("sending data failed: %v", err)
|
||||
}
|
||||
|
||||
// 接收数据
|
||||
data, err := client.Receive()
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("接收数据失败:%v", err)
|
||||
return "", fmt.Errorf("failed to receive data: %v", err)
|
||||
}
|
||||
|
||||
return data, nil
|
||||
@@ -41,15 +41,16 @@ func MMLSendMsgToString(ip, msg string) (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
str = strings.ToLower(str)
|
||||
|
||||
// 截断
|
||||
index := strings.Index(str, "\n")
|
||||
if index != -1 {
|
||||
str = str[:index]
|
||||
str = strings.ToLower(str)
|
||||
}
|
||||
|
||||
// 命令成功
|
||||
if strings.Contains(str, "ok") || strings.Contains(str, "OK") {
|
||||
if strings.Contains(str, "ok") || strings.Contains(str, "success") {
|
||||
return str, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ func ReadSheet(filePath, sheetName string) ([]map[string]string, error) {
|
||||
}
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
logger.Errorf("工作表文件关闭失败 : %v", err)
|
||||
logger.Errorf("ReadSheet to close worksheet file : %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -60,7 +60,7 @@ func ReadSheet(filePath, sheetName string) ([]map[string]string, error) {
|
||||
sheetName = "Sheet1"
|
||||
}
|
||||
if visible, _ := f.GetSheetVisible(sheetName); !visible {
|
||||
return data, fmt.Errorf("读取工作簿 %s 失败", sheetName)
|
||||
return data, fmt.Errorf("failed to read workbook %s", sheetName)
|
||||
}
|
||||
|
||||
// 获取工作簿记录
|
||||
@@ -99,7 +99,7 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
||||
f := excelize.NewFile()
|
||||
defer func() {
|
||||
if err := f.Close(); err != nil {
|
||||
logger.Errorf("工作表文件关闭失败 : %v", err)
|
||||
logger.Errorf("WriteSheet to close worksheet file: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -109,7 +109,7 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
||||
}
|
||||
index, err := f.NewSheet(sheetName)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("创建工作表失败 %v", err)
|
||||
return "", fmt.Errorf("failed to create worksheet %v", err)
|
||||
}
|
||||
// 设置工作簿的默认工作表
|
||||
f.SetActiveSheet(index)
|
||||
@@ -143,12 +143,12 @@ func WriteSheet(headerCells map[string]string, dataCells []map[string]any, fileN
|
||||
|
||||
// 创建文件目录
|
||||
if err := os.MkdirAll(filepath.Dir(saveFilePath), 0750); err != nil {
|
||||
return "", fmt.Errorf("创建保存文件失败 %v", err)
|
||||
return "", fmt.Errorf("failed to create save file %v", err)
|
||||
}
|
||||
|
||||
// 根据指定路径保存文件
|
||||
if err := f.SaveAs(saveFilePath); err != nil {
|
||||
return "", fmt.Errorf("保存工作表失败 %v", err)
|
||||
return "", fmt.Errorf("failed to save worksheet %v", err)
|
||||
}
|
||||
return saveFilePath, nil
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"mime/multipart"
|
||||
"path"
|
||||
@@ -74,13 +73,13 @@ func generateFileName(fileName string) string {
|
||||
func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
||||
// 判断上传文件名称长度
|
||||
if len(fileName) > DEFAULT_FILE_NAME_LENGTH {
|
||||
return fmt.Errorf("上传文件名称长度限制最长为 %d", DEFAULT_FILE_NAME_LENGTH)
|
||||
return fmt.Errorf("The maximum length limit for uploading file names is %d", DEFAULT_FILE_NAME_LENGTH)
|
||||
}
|
||||
|
||||
// 最大上传文件大小
|
||||
maxFileSize := uploadFileSize()
|
||||
if fileSize > maxFileSize {
|
||||
return fmt.Errorf("最大上传文件大小 %s", parse.Bit(float64(maxFileSize)))
|
||||
return fmt.Errorf("Maximum upload file size %s", parse.Bit(float64(maxFileSize)))
|
||||
}
|
||||
|
||||
// 判断文件拓展是否为允许的拓展类型
|
||||
@@ -96,7 +95,7 @@ func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
||||
}
|
||||
}
|
||||
if !hasExt {
|
||||
return fmt.Errorf("上传文件类型不支持,仅支持以下类型:%s", strings.Join(allowExts, "、"))
|
||||
return fmt.Errorf("The upload file type is not supported, only the following types are supported:%s", strings.Join(allowExts, ","))
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -108,7 +107,7 @@ func isAllowWrite(fileName string, allowExts []string, fileSize int64) error {
|
||||
func isAllowRead(filePath string) error {
|
||||
// 禁止目录上跳级别
|
||||
if strings.Contains(filePath, "..") {
|
||||
return fmt.Errorf("禁止目录上跳级别")
|
||||
return fmt.Errorf("Prohibit jumping levels on the directory")
|
||||
}
|
||||
|
||||
// 检查允许下载的文件规则
|
||||
@@ -121,7 +120,7 @@ func isAllowRead(filePath string) error {
|
||||
}
|
||||
}
|
||||
if !hasExt {
|
||||
return fmt.Errorf("非法下载的文件规则:%s", fileExt)
|
||||
return fmt.Errorf("Rules for illegally downloaded files: %s", fileExt)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -203,7 +202,7 @@ func ReadUploadFileStream(filePath, headerRange string) (map[string]any, error)
|
||||
result["chunkSize"] = end - start + 1
|
||||
byteArr, err := getFileStream(fileAsbPath, start, end)
|
||||
if err != nil {
|
||||
return map[string]any{}, errors.New("读取文件失败")
|
||||
return map[string]any{}, fmt.Errorf("fail to read file")
|
||||
}
|
||||
result["data"] = byteArr
|
||||
return result, nil
|
||||
@@ -211,7 +210,7 @@ func ReadUploadFileStream(filePath, headerRange string) (map[string]any, error)
|
||||
|
||||
byteArr, err := getFileStream(fileAsbPath, 0, fileSize)
|
||||
if err != nil {
|
||||
return map[string]any{}, errors.New("读取文件失败")
|
||||
return map[string]any{}, fmt.Errorf("fail to read file")
|
||||
}
|
||||
result["data"] = byteArr
|
||||
return result, nil
|
||||
@@ -261,7 +260,7 @@ func ChunkCheckFile(identifier, originalFileName string) ([]string, error) {
|
||||
readPath := path.Join(dir, dirPath)
|
||||
fileList, err := getDirFileNameList(readPath)
|
||||
if err != nil {
|
||||
return []string{}, errors.New("读取文件失败")
|
||||
return []string{}, fmt.Errorf("fail to read file")
|
||||
}
|
||||
return fileList, nil
|
||||
}
|
||||
|
||||
@@ -51,10 +51,10 @@ func mergeToNewFile(dirPath string, writePath string, fileName string) error {
|
||||
// 读取目录下所有文件并排序,注意文件名称是否数值
|
||||
fileNameList, err := getDirFileNameList(dirPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("读取合并目标文件失败: %v", err)
|
||||
return fmt.Errorf("failed to read merge target file: %v", err)
|
||||
}
|
||||
if len(fileNameList) <= 0 {
|
||||
return fmt.Errorf("读取合并目标文件失败")
|
||||
return fmt.Errorf("failed to read merge target file")
|
||||
}
|
||||
|
||||
// 排序
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"ems.agt/src/framework/constants/cachekey"
|
||||
@@ -37,16 +36,16 @@ func (s *RegisterImpl) ValidateCaptcha(code, uuid string) error {
|
||||
return nil
|
||||
}
|
||||
if code == "" || uuid == "" {
|
||||
return errors.New("验证码信息错误")
|
||||
return fmt.Errorf("verification code information error")
|
||||
}
|
||||
verifyKey := cachekey.CAPTCHA_CODE_KEY + uuid
|
||||
captcha, err := redis.Get("", verifyKey)
|
||||
if err != nil {
|
||||
return errors.New("验证码已失效")
|
||||
return fmt.Errorf("the verification code has expired")
|
||||
}
|
||||
redis.Del("", verifyKey)
|
||||
if captcha != code {
|
||||
return errors.New("验证码错误")
|
||||
return fmt.Errorf("verification code error")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -57,13 +56,13 @@ func (s *RegisterImpl) ByUserName(username, password, userType string) (string,
|
||||
registerUserStr := s.sysConfigService.SelectConfigValueByKey("sys.account.registerUser")
|
||||
captchaEnabled := parse.Boolean(registerUserStr)
|
||||
if !captchaEnabled {
|
||||
return "", fmt.Errorf("注册用户【%s】失败,很抱歉,系统已关闭外部用户注册通道", username)
|
||||
return "", fmt.Errorf("failed to register user [%s]. Sorry, the system has closed the external user registration channel", username)
|
||||
}
|
||||
|
||||
// 检查用户登录账号是否唯一
|
||||
uniqueUserName := s.sysUserService.CheckUniqueUserName(username, "")
|
||||
if !uniqueUserName {
|
||||
return "", fmt.Errorf("注册用户【%s】失败,注册账号已存在", username)
|
||||
return "", fmt.Errorf("failed to register user [%s], registered account already exists", username)
|
||||
}
|
||||
|
||||
sysUser := systemModel.SysUser{
|
||||
@@ -72,7 +71,7 @@ func (s *RegisterImpl) ByUserName(username, password, userType string) (string,
|
||||
Password: password, // 原始密码
|
||||
Status: common.STATUS_YES, // 账号状态激活
|
||||
DeptID: "100", // 归属部门为根节点
|
||||
CreateBy: "注册", // 创建来源
|
||||
CreateBy: "register", // 创建来源
|
||||
}
|
||||
// 标记用户类型
|
||||
if userType == "" {
|
||||
@@ -87,7 +86,7 @@ func (s *RegisterImpl) ByUserName(username, password, userType string) (string,
|
||||
if insertId != "" {
|
||||
return insertId, nil
|
||||
}
|
||||
return "", fmt.Errorf("注册用户【%s】失败,请联系系统管理人员", username)
|
||||
return "", fmt.Errorf("failed to register user [%s]. Please contact the system administrator", username)
|
||||
}
|
||||
|
||||
// registerRoleInit 注册初始角色
|
||||
|
||||
Reference in New Issue
Block a user