InfoLogic.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\logic\info;
  20. use app\common\enum\DefaultEnum;
  21. use app\common\enum\YesNoEnum;
  22. use app\common\model\GoodsBrand;
  23. use app\common\model\Banner;
  24. use app\common\model\Info;
  25. class InfoLogic
  26. {
  27. /**
  28. * @notes 添加信息
  29. * @param $params
  30. * @return bool
  31. * @author ljj
  32. * @date 2021/7/14 5:00
  33. */
  34. public function add($params)
  35. {
  36. $Info= new Info;
  37. $Info->type = $params['type'];
  38. $Info->cid = $params['cid'] ?? '';
  39. $Info->title = $params['title'] ?? '';
  40. $Info->synopsis = $params['synopsis'] ?? '';
  41. $Info->image = $params['image'] ?? '';
  42. $Info->address = $params['address'] ?? '';
  43. $Info->phone = $params['phone'] ?? '';
  44. $Info->latitude = $params['latitude'] ?? '';
  45. $Info->longitude = $params['longitude'] ?? '';
  46. $Info->content = $params['content'] ?? '';
  47. $Info->sort = (isset($params['sort']) && !empty($params['sort'])) ? $params['sort'] : 1;
  48. $Info->is_show = $params['is_show'] ?? YesNoEnum::YES;
  49. return $Info->save();
  50. }
  51. /**
  52. * @notes 删除信息
  53. * @param $params
  54. * @return bool
  55. * @author ljj
  56. * @date 2021/7/15 10:37
  57. */
  58. public function del($params)
  59. {
  60. return Info::destroy($params['id']);
  61. }
  62. /**
  63. * @notes 编辑信息
  64. * @param $params
  65. * @return bool
  66. * @throws \think\db\exception\DataNotFoundException
  67. * @throws \think\db\exception\DbException
  68. * @throws \think\db\exception\ModelNotFoundException
  69. * @author ljj
  70. * @date 2021/7/15 11:05
  71. */
  72. public function edit($params)
  73. {
  74. $Info = Info::find($params['id']);
  75. $Info->type = $params['type'];
  76. $Info->cid = $params['cid'] ?? '';
  77. $Info->title = $params['title'] ?? '';
  78. $Info->synopsis = $params['synopsis'] ?? '';
  79. $Info->image = $params['image'] ?? '';
  80. $Info->address = $params['address'] ?? '';
  81. $Info->phone = $params['phone'] ?? '';
  82. $Info->latitude = $params['latitude'] ?? '';
  83. $Info->longitude = $params['longitude'] ?? '';
  84. $Info->content = $params['content'] ?? '';
  85. $Info->sort = (isset($params['sort']) && !empty($params['sort'])) ? $params['sort'] : 1;
  86. $Info->is_show = $params['is_show'] ?? YesNoEnum::YES;
  87. return $Info->save();
  88. }
  89. /**
  90. * @notes 修改信息状态
  91. * @param $params
  92. * @return bool
  93. * @throws \think\db\exception\DataNotFoundException
  94. * @throws \think\db\exception\DbException
  95. * @throws \think\db\exception\ModelNotFoundException
  96. * @author ljj
  97. * @date 2021/7/15 11:41
  98. */
  99. public function status($params)
  100. {
  101. $Info = Info::find($params['id']);
  102. $is_show = 1;
  103. if($Info['is_show']==1){
  104. $is_show = 0;
  105. }
  106. $Info->is_show = $is_show;
  107. return $Info->save();
  108. }
  109. /**
  110. * @notes 查看信息详情
  111. * @param $params
  112. * @return array
  113. * @throws \think\db\exception\DataNotFoundException
  114. * @throws \think\db\exception\DbException
  115. * @throws \think\db\exception\ModelNotFoundException
  116. * @author ljj
  117. * @date 2021/7/19 4:45 下午
  118. */
  119. public function detail($params)
  120. {
  121. return Info::find($params['id'])->toArray();
  122. }
  123. }