Sms.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | A3Mall
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2020 http://www.a3-mall.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: xzncit <158373108@qq.com>
  8. // +----------------------------------------------------------------------
  9. namespace app\admin\service\system;
  10. use app\admin\service\Service;
  11. use app\common\models\SmsTemplate as SmsTemplateModel;
  12. class Sms extends Service {
  13. /**
  14. * 获取列表数据
  15. * @param $data
  16. * @return array
  17. * @throws \think\db\exception\DataNotFoundException
  18. * @throws \think\db\exception\DbException
  19. * @throws \think\db\exception\ModelNotFoundException
  20. */
  21. public static function getList($data){
  22. $count = SmsTemplateModel::count();
  23. $list = SmsTemplateModel::page($data["page"]??1,$data["limit"]??10)->order("id","desc")->select()->toArray();
  24. return [ "count"=>$count,"data"=>$list ];
  25. }
  26. /**
  27. * 详情
  28. * @param $id
  29. * @return array[]
  30. * @throws \think\db\exception\DataNotFoundException
  31. * @throws \think\db\exception\DbException
  32. * @throws \think\db\exception\ModelNotFoundException
  33. */
  34. public static function detail($id){
  35. $row = SmsTemplateModel::where("id",$id)->find();
  36. return [ "data"=>$row??[] ];
  37. }
  38. /**
  39. * 保存数据
  40. * @param $data
  41. */
  42. public static function save($data){
  43. if(SmsTemplateModel::where("id",$data["id"])->count()){
  44. SmsTemplateModel::where("id",$data["id"])->save($data);
  45. }else{
  46. SmsTemplateModel::create($data);
  47. }
  48. return true;
  49. }
  50. /**
  51. * 更新字段值
  52. * @return SmsTemplateModel
  53. */
  54. public static function setFields(){
  55. $data = self::getFields();
  56. return SmsTemplateModel::where("id",$data["id"])->update([$data["name"]=>$data["value"]]);
  57. }
  58. }