123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- /**
- * 系统模版
- * Created by PhpStorm.
- * User: XiaoMing
- * Date: 2019/11/29
- * Time: 15:22
- */
- namespace JinDouYun\Model\System;
- use Mall\Framework\Core\ErrorCode;
- use Mall\Framework\Core\ResultWrapper;
- use JinDouYun\Dao\System\DSystemTemplate;
- use Mall\Framework\Core\StatusCode;
- class MSystemTemplate
- {
- private $objDSystemTemplate;
- private $onlineUserId;
- private $onlineEnterpriseId;
- public function __construct($onlineUserId, $enterpriseId)
- {
- $this->onlineUserId = $onlineUserId;
- $this->onlineEnterpriseId = $enterpriseId;
- $this->objDSystemTemplate = new DSystemTemplate('default');
- }
- /**
- * 添加系统模版
- * @param $params
- * @return ResultWrapper
- */
- public function add($params)
- {
- $dbResult = $this->objDSystemTemplate->insert($params);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
- }
- return ResultWrapper::success($dbResult);
- }
- /**
- * 系统模版启用/停用
- * @param $params
- * @return ResultWrapper
- */
- public function updateEnableStatus($params)
- {
- $dbResult = $this->objDSystemTemplate->update(['enableStatus' => $params['enableStatus']], $params['id']);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
- }
- return ResultWrapper::success($dbResult);
- }
- /**
- * 获取模版列表
- * @param $selectParams
- * @return array|bool|ResultWrapper
- */
- public function getAll($selectParams)
- {
- $limit = $selectParams['limit'];
- unset($selectParams['limit']);
- $offset = $selectParams['offset'];
- unset($selectParams['offset']);
- $selectParams['deleteStatus'] = StatusCode::$standard;
- $dbResult = $this->objDSystemTemplate->select($selectParams, '*', 'createTime desc', $limit, $offset);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
- }
- $total = $this->objDSystemTemplate->count($selectParams);
- $return = [
- 'data' => $dbResult,
- 'total' => ($total) ? intval($total) : 0,
- ];
- return ResultWrapper::success($return);
- }
- /**
- * 编辑系统模版
- * @param $params
- * @return ResultWrapper
- */
- public function edit($params)
- {
- $id = $params['id'];
- unset($params['id']);
- $dbResult = $this->objDSystemTemplate->update($params, $id);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
- }
- return ResultWrapper::success($dbResult);
- }
- /**
- * 删除系统模版
- * @param $ids
- * @return ResultWrapper
- */
- public function del($ids)
- {
- $dbResult = $this->objDSystemTemplate->update(['deleteStatus' => StatusCode::$delete],$ids);
- if ($dbResult === false) {
- return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
- }
- return ResultWrapper::success($dbResult);
- }
- }
|