MSystemTemplate.Class.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. /**
  3. * 系统模版
  4. * Created by PhpStorm.
  5. * User: XiaoMing
  6. * Date: 2019/11/29
  7. * Time: 15:22
  8. */
  9. namespace JinDouYun\Model\System;
  10. use Mall\Framework\Core\ErrorCode;
  11. use Mall\Framework\Core\ResultWrapper;
  12. use JinDouYun\Dao\System\DSystemTemplate;
  13. use Mall\Framework\Core\StatusCode;
  14. class MSystemTemplate
  15. {
  16. private $objDSystemTemplate;
  17. private $onlineUserId;
  18. private $onlineEnterpriseId;
  19. public function __construct($onlineUserId, $enterpriseId)
  20. {
  21. $this->onlineUserId = $onlineUserId;
  22. $this->onlineEnterpriseId = $enterpriseId;
  23. $this->objDSystemTemplate = new DSystemTemplate('default');
  24. }
  25. /**
  26. * 添加系统模版
  27. * @param $params
  28. * @return ResultWrapper
  29. */
  30. public function add($params)
  31. {
  32. $dbResult = $this->objDSystemTemplate->insert($params);
  33. if ($dbResult === false) {
  34. return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
  35. }
  36. return ResultWrapper::success($dbResult);
  37. }
  38. /**
  39. * 系统模版启用/停用
  40. * @param $params
  41. * @return ResultWrapper
  42. */
  43. public function updateEnableStatus($params)
  44. {
  45. $dbResult = $this->objDSystemTemplate->update(['enableStatus' => $params['enableStatus']], $params['id']);
  46. if ($dbResult === false) {
  47. return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
  48. }
  49. return ResultWrapper::success($dbResult);
  50. }
  51. /**
  52. * 获取模版列表
  53. * @param $selectParams
  54. * @return array|bool|ResultWrapper
  55. */
  56. public function getAll($selectParams)
  57. {
  58. $limit = $selectParams['limit'];
  59. unset($selectParams['limit']);
  60. $offset = $selectParams['offset'];
  61. unset($selectParams['offset']);
  62. $selectParams['deleteStatus'] = StatusCode::$standard;
  63. $dbResult = $this->objDSystemTemplate->select($selectParams, '*', 'createTime desc', $limit, $offset);
  64. if ($dbResult === false) {
  65. return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
  66. }
  67. $total = $this->objDSystemTemplate->count($selectParams);
  68. $return = [
  69. 'data' => $dbResult,
  70. 'total' => ($total) ? intval($total) : 0,
  71. ];
  72. return ResultWrapper::success($return);
  73. }
  74. /**
  75. * 编辑系统模版
  76. * @param $params
  77. * @return ResultWrapper
  78. */
  79. public function edit($params)
  80. {
  81. $id = $params['id'];
  82. unset($params['id']);
  83. $dbResult = $this->objDSystemTemplate->update($params, $id);
  84. if ($dbResult === false) {
  85. return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
  86. }
  87. return ResultWrapper::success($dbResult);
  88. }
  89. /**
  90. * 删除系统模版
  91. * @param $ids
  92. * @return ResultWrapper
  93. */
  94. public function del($ids)
  95. {
  96. $dbResult = $this->objDSystemTemplate->update(['deleteStatus' => StatusCode::$delete],$ids);
  97. if ($dbResult === false) {
  98. return ResultWrapper::fail($this->objDSystemTemplate->error(), ErrorCode::$dberror);
  99. }
  100. return ResultWrapper::success($dbResult);
  101. }
  102. }