EmailsModel.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. namespace app\admin\model;
  3. use think\Db;
  4. use think\Model;
  5. class EmailsModel extends Model
  6. {
  7. protected $name = 'email';
  8. public function getByWhere($map,$od, $Nowpage, $limits)
  9. {
  10. $res = $this
  11. ->where($map)
  12. ->page($Nowpage, $limits)
  13. ->order($od)
  14. ->select();
  15. return $res;
  16. }
  17. /**
  18. * [getOneMenu 根据菜单id获取一条信息]
  19. * @author
  20. */
  21. public function getInfo($id)
  22. {
  23. return $this->where('id', $id)->find();
  24. }
  25. /*
  26. * 页面总数
  27. */
  28. public function getCount($map){
  29. return $this->alias('a')
  30. ->where($map)
  31. ->count();
  32. }
  33. public function edit($param)
  34. {
  35. $param['update_time']=time();
  36. $res=$this->allowField(true)->save($param, ['id' => $param['id']]);
  37. if($res){
  38. return ['code' => 200, 'data' => '', 'msg' => '编辑成功'];
  39. }else{
  40. return ['code' => 100, 'data' => '', 'msg' =>'编辑失败'];
  41. }
  42. }
  43. public function add($param)
  44. {
  45. $param['spread_id']=session('uid');
  46. $param['create_time']=time();
  47. $res=$this->allowField(true)->save($param);
  48. if($res){
  49. return ['code' => 200, 'data' => '', 'msg' => '添加成功'];
  50. }else{
  51. return ['code' => 100, 'data' => '', 'msg' =>'添加失败'];
  52. }
  53. }
  54. /**
  55. * batchDelUser 批量删除管理员
  56. * @param $param
  57. * @return array
  58. */
  59. public function del($param){
  60. try{
  61. Db::name('email')->where('id','=',$param)->update(['is_deleted'=>time()]);
  62. return ['code' => 200, 'data' => '', 'msg' => '批量删除主题收件人成功'];
  63. }catch( \Exception $e){
  64. return ['code' => 100, 'data' => '', 'msg' => '批量删除主题收件人失败'];
  65. }
  66. }
  67. /**
  68. * batchDelUser 批量删除管理员
  69. * @param $param
  70. * @return array
  71. */
  72. public function batchDel($param){
  73. try{
  74. Db::name('email_send')->where('theme_id','in',$param)->update(['is_deleted'=>time()]);
  75. return ['code' => 200, 'data' => '', 'msg' => '批量删除成功'];
  76. }catch( \Exception $e){
  77. return ['code' => 100, 'data' => '', 'msg' => '批量删除失败'];
  78. }
  79. }
  80. }