first commit

This commit is contained in:
Your Name
2026-01-19 14:19:22 +08:00
commit fe2d9c1868
4777 changed files with 665503 additions and 0 deletions

View File

@@ -0,0 +1,157 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic\setting;
use app\common\enum\YesNoEnum;
use app\common\model\setting\Language;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* 语言包逻辑
* Class LanguageLogic
* @package app\adminapi\logic\setting
*/
class LanguageLogic extends BaseLogic
{
/**
* @notes 添加语言包
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/30 13:59
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
Language::create([
'name' => $params['name'],
'name_loc' => $params['name_loc'],
'symbol' => $params['symbol'],
'trans_symbol' => $params['trans_symbol'],
'logo' => $params['logo'],
'precision' => $params['precision'],
'time_format' => $params['time_format'],
'is_show' => $params['is_show'],
'sort' => $params['sort']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑语言包
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/30 13:59
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
Language::where('id', $params['id'])->update([
'name' => $params['name'],
'name_loc' => $params['name_loc'],
'symbol' => $params['symbol'],
'trans_symbol' => $params['trans_symbol'],
'logo' => $params['logo'],
'precision' => $params['precision'],
'time_format' => $params['time_format'],
'is_show' => $params['is_show'],
'sort' => $params['sort']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除语言包
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/30 13:59
*/
public static function delete(array $params): bool
{
return Language::destroy($params['id']);
}
/**
* @notes 获取语言包详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/11/30 13:59
*/
public static function detail($params): array
{
return Language::findOrEmpty($params['id'])->toArray();
}
/**
* @notes 更改状态
* @param array $params
* @return bool
* @author heshihu
* @date 2022/2/22 10:18
*/
public static function updateStatus(array $params)
{
Language::update([
'id' => $params['id'],
'is_show' => $params['is_show']
]);
return true;
}
/**
* @notes 语言包数据
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author 段誉
* @date 2022/10/13 10:53
*/
public static function getAllData()
{
return Language::where(['is_show' => YesNoEnum::YES])
->order(['sort' => 'desc', 'id' => 'desc'])
->select()
->toArray();
}
}