fix: 改sys_i18n表结构

This commit is contained in:
TsMask
2025-03-18 16:27:50 +08:00
parent 8c1a73e9b3
commit c5e5fe105b
5 changed files with 1349 additions and 1380 deletions

View File

@@ -3,11 +3,6 @@ package model
// SysI18n 系统_多语言 sys_i18n
type SysI18n struct {
ID int64 `json:"id" gorm:"column:id;primaryKey;autoIncrement"` // ID
DelFlag string `json:"delFlag" gorm:"column:del_flag"` // 删除标记0存在 1删除
CreateBy string `json:"createBy" gorm:"column:create_by"` // 创建者
CreateTime int64 `json:"createTime" gorm:"column:create_time"` // 创建时间
UpdateBy string `json:"updateBy" gorm:"column:update_by"` // 更新者
UpdateTime int64 `json:"updateTime" gorm:"column:update_time"` // 更新时间
KeyLable string `json:"key" gorm:"column:key_lable"` // 多语言属性名
ValueZh string `json:"valueZh" gorm:"column:value_zh"` // 中文
ValueEn string `json:"valueEn" gorm:"column:value_en"` // 英文

View File

@@ -1,8 +1,6 @@
package repository
import (
"time"
"be.ems/src/framework/database/db"
"be.ems/src/framework/logger"
"be.ems/src/modules/system/model"
@@ -17,7 +15,6 @@ type SysI18n struct{}
// Select 查询集合
func (r SysI18n) Select(param model.SysI18n) []model.SysI18n {
tx := db.DB("").Model(&model.SysI18n{})
tx = tx.Where("del_flag = '0'")
// 查询条件拼接
if param.KeyLable != "" {
tx = tx.Where("key_lable = ?", param.KeyLable)
@@ -46,7 +43,7 @@ func (r SysI18n) SelectByIds(ids []int64) []model.SysI18n {
}
tx := db.DB("").Model(&model.SysI18n{})
// 构建查询条件
tx = tx.Where("id in ? and del_flag = '0'", ids)
tx = tx.Where("id in ?", ids)
// 查询数据
if err := tx.Find(&rows).Error; err != nil {
logger.Errorf("query find err => %v", err.Error())
@@ -57,13 +54,6 @@ func (r SysI18n) SelectByIds(ids []int64) []model.SysI18n {
// Insert 新增信息 返回新增数据ID
func (r SysI18n) Insert(param model.SysI18n) int64 {
param.DelFlag = "0"
if param.CreateBy != "" {
ms := time.Now().UnixMilli()
param.UpdateBy = param.CreateBy
param.UpdateTime = ms
param.CreateTime = ms
}
// 执行插入
if err := db.DB("").Create(&param).Error; err != nil {
logger.Errorf("insert err => %v", err.Error())
@@ -77,13 +67,10 @@ func (r SysI18n) Update(param model.SysI18n) int64 {
if param.ID <= 0 {
return 0
}
if param.UpdateBy != "" {
param.UpdateTime = time.Now().UnixMilli()
}
tx := db.DB("").Model(&model.SysI18n{})
// 构建查询条件
tx = tx.Where("id = ?", param.ID)
tx = tx.Omit("id", "del_flag", "create_by", "create_time")
tx = tx.Omit("id")
// 执行更新
if err := tx.Updates(param).Error; err != nil {
logger.Errorf("update err => %v", err.Error())
@@ -97,12 +84,10 @@ func (r SysI18n) DeleteByIds(ids []int64) int64 {
if len(ids) <= 0 {
return 0
}
tx := db.DB("").Model(&model.SysI18n{})
// 构建查询条件
tx = tx.Where("id in ?", ids)
// 执行更新删除标记
if err := tx.Update("del_flag", "1").Error; err != nil {
logger.Errorf("update err => %v", err.Error())
tx := db.DB("").Where("id in ?", ids)
// 执行删除
if err := tx.Delete(&model.SysRoleMenu{}).Error; err != nil {
logger.Errorf("delete err => %v", err.Error())
return 0
}
return tx.RowsAffected
@@ -111,7 +96,7 @@ func (r SysI18n) DeleteByIds(ids []int64) int64 {
// CheckUnique 检查信息是否唯一 返回ID
func (r SysI18n) CheckUnique(key string) int64 {
tx := db.DB("").Model(&model.SysI18n{})
tx = tx.Where("del_flag = 0 and key= ?", key)
tx = tx.Where("key_lable= ?", key)
// 查询数据
var id int64 = 0
if err := tx.Select("id").Limit(1).Find(&id).Error; err != nil {

View File

@@ -106,7 +106,6 @@ func (s SysI18n) UpdateKeyValue(language, key, value string) bool {
// CacheLoad 加载多语言数据 传入*查询全部
func (s SysI18n) CacheLoad(langKey string) {
param := model.SysI18n{
DelFlag: constants.STATUS_NO,
KeyLable: langKey,
}