ArticleCategoryLogic.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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;
  20. use app\common\enum\ArticleEnum;
  21. use app\common\logic\BaseLogic;
  22. use app\common\model\ArticleCategory;
  23. class ArticleCategoryLogic extends BaseLogic
  24. {
  25. /**
  26. * @notes 添加文章分类
  27. * @param $params
  28. * @author Tab
  29. * @date 2021/7/13 14:23
  30. */
  31. public static function add($params)
  32. {
  33. $params['create_time'] = time();
  34. ArticleCategory::create($params);
  35. }
  36. /**
  37. * @notes 查看文章/帮助详情
  38. * @param $params
  39. * @return array
  40. * @throws \think\db\exception\DataNotFoundException
  41. * @throws \think\db\exception\DbException
  42. * @throws \think\db\exception\ModelNotFoundException
  43. * @author Tab
  44. * @date 2021/7/13 14:24
  45. */
  46. public static function detail($params)
  47. {
  48. return ArticleCategory::field('name,is_show,sort')->find($params['id'])->toArray();
  49. }
  50. /**
  51. * @notes 编辑文章分类
  52. * @param $params
  53. * @author Tab
  54. * @date 2021/7/13 14:25
  55. */
  56. public static function edit($params)
  57. {
  58. ArticleCategory::update($params);
  59. }
  60. /**
  61. * @notes 删除文章分类
  62. * @param $params
  63. * @author Tab
  64. * @date 2021/7/13 14:25
  65. */
  66. public static function delete($params)
  67. {
  68. ArticleCategory::destroy($params['id']);
  69. }
  70. /**
  71. * @notes 修改是否显示状态
  72. * @param $params
  73. * @throws \think\db\exception\DataNotFoundException
  74. * @throws \think\db\exception\DbException
  75. * @throws \think\db\exception\ModelNotFoundException
  76. * @author Tab
  77. * @date 2021/7/14 11:36
  78. */
  79. public static function isShow($params)
  80. {
  81. $articleCategory = ArticleCategory::find($params['id']);
  82. $articleCategory->is_show = $articleCategory->getData('is_show') ? 0: 1;
  83. $articleCategory->save();
  84. }
  85. }