Files
zzp-server/app/api/logic/LanguageLogic.php
2026-01-19 14:19:22 +08:00

100 lines
3.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?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\api\logic;
use app\common\enum\YesNoEnum;
use app\common\logic\BaseLogic;
use app\common\model\setting\Language;
use app\common\model\setting\LanguagePag;
/**
* 文章逻辑
* Class LanguageLogic
* @package app\api\logic
*/
class LanguageLogic extends BaseLogic
{
/**
* @notes 语言详情
* @param $params
* @return array
* @author 段誉
* @date 2022/9/20 17:09
*/
public static function detail($params)
{
// 语言详情
$field = ['id','name_loc as name','symbol','precision'];
$where = ['symbol' => $params['name']];
$language = Language::field($field)
->where($where)
->findOrEmpty()
->toArray();
return $language;
}
/**
* @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()
{
$field = ['id','name_loc as name','symbol','precision','time_format'];
$langs = Language::field($field)
->where(['is_show' => YesNoEnum::YES])
->order(['sort' => 'desc', 'id' => 'desc'])
->select()
->toArray();
return $langs;
}
/**
* @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 getPagAllData($params)
{
//查询语言
$language = Language::where(['symbol' => $params['lang']])->findOrEmpty();
if ($language->isEmpty()) {
throw new \Exception('network.parameterAbnormality');//参数异常
}
$field = ['type','name','value'];
$pags = LanguagePag::field($field)
->where(['lang' => $params['lang']])
->order(['type' => 'asc','name' => 'asc', 'value' => 'asc'])
->select()
->toArray();
return $pags;
}
}