Config.php 3.16 KB
<?php

namespace app\api\controller\kuerp\order;

use app\common\controller\Api;
use app\api\model\kuerp\Systems as Systems;
/**
 * 系统配置接口
 */
class Config extends Api
{
    protected $noNeedRight = '*';
    protected $noNeedLogin = '*';

    /**
     * 获取系统配置详情
     * @ApiMethod (POST)
     * @param int $id 系统配置ID
     */
    public function getdetail()
    {
        if ($this->request->isPost()) {
            $name = $this->request->post('name');
            $result = Systems::getDetail($name);
            $this->success('查询成功',$result,200);
        }else{
            $this->error('请求方式错误','',250);
        }
    }

    /**
     * 添加系统配置
     * @ApiMethod (POST)
     * @param array $detail 系统配置数据
     */
    public function adddetail()
    {
        if ($this->request->isPost()) {
            $detail = $this->request->post();
            foreach ($detail as $k=>$v){
                $detail[$k] = is_array($v)?$v:html_entity_decode($v);
            }
            $ret = Systems::addDetail($detail);
            if($ret['status']==200){
                $this->success('添加成功',$ret['msg'],200);
            }else{
                $this->error($ret['msg'],'',$ret['status']);
            }
        }else{
            $this->error('请求方式错误','',250);
        }
    }

    /**
     * 更新系统配置
     * @ApiMethod (POST)
     * @param array $detail 系统配置数据
     */
    public function editdetail()
    {
        if ($this->request->isPost()) {
            $detail = $this->request->post();
            foreach ($detail as $k=>$v){
                $detail[$k] = is_array($v)?$v:html_entity_decode($v);
            }
            $ret = Systems::editDetail($detail);
            if($ret['status']==200){
                $this->success('更新成功','',200);
            }else{
                $this->error($ret['msg'],'',$ret['status']);
            }
        }else{
            $this->error('请求方式错误','',250);
        }
    }

    /**
     * 系统配置
     * @ApiMethod (POST)
     * @param int $name 系统配置name
     */
    public function getSet()
    {
        if ($this->request->isPost()) {
            $name = $this->request->post('name');
            $ret = \think\Db::name('kuerp_user_config')->where(['name'=>$name])->value('value');
            $this->success('查询成功',$ret,200);
        }else{
            $this->error('请求方式错误','',250);
        }
    }

    /**
     * 系统配置
     * @ApiMethod (POST)
     * @param int $name 系统配置name
     */
    public function getConfig()
    {
        if ($this->request->isPost()) {
            $name = $this->request->post('name');
            $ret = \think\Db::name('kuerp_user_sets')->where(['name'=>['in',$name]])->column('value','name');
            if($ret){
                $this->success('查询成功',$ret,200);
            }else{
                $this->error('查询失败','',400);
            }
        }else{
            $this->error('请求方式错误','',250);
        }
    }

}