AdminUserModel.class.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Admin\Model;
  15. class AdminUserModel{
  16. /**
  17. *显示分页
  18. */
  19. public function show_admin_user_page(){
  20. $sql="select * from ".C('DB_PREFIX')."admin ";
  21. $count=count(M()->query($sql));
  22. $Page = new \Think\Page($count,C('BACK_PAGE_NUM'));
  23. $show = $Page->show();// 分页显示输出
  24. $sql.=' order by a_id desc LIMIT '.$Page->firstRow.','.$Page->listRows;
  25. $list=M()->query($sql);
  26. return array(
  27. 'empty'=>'<tr><td colspan="20">~~暂无数据</td></tr>',
  28. 'list'=>$list,
  29. 'page'=>$show
  30. );
  31. }
  32. function add_admin_user($data){
  33. if(empty($data['a_uname'])){
  34. $error="用户名不能为空!!";
  35. }elseif(M('Admin')->getByAUname(trim($data['a_uname']))){
  36. $error="用户名已经存在!!";
  37. }elseif(empty($data['a_passwd'])){
  38. $error="密码不能为空!!";
  39. }
  40. if($error){
  41. return array(
  42. 'status'=>'back',
  43. 'message'=>$error
  44. );
  45. }
  46. $data['a_passwd'] =think_ucenter_encrypt($data['a_passwd'],C('PWD_KEY'));
  47. $data['a_create_time'] =time();
  48. $data['a_status'] =1;
  49. if(M('Admin')->add($data)){
  50. return array(
  51. 'status'=>'success',
  52. 'message'=>'新增成功',
  53. 'jump'=>U('AdminUser/index')
  54. );
  55. }else{
  56. return array(
  57. 'status'=>'back',
  58. 'message'=>'新增失败'
  59. );
  60. }
  61. }
  62. function edit_admin_user($d){
  63. $d['a_passwd']=think_ucenter_encrypt($d['a_passwd'],C('PWD_KEY'));
  64. $r=M('Admin')->where(array('a_id'=>$d['a_id']))->save($d);
  65. if($r){
  66. return array(
  67. 'status'=>'success',
  68. 'message'=>'修改成功',
  69. 'jump'=>U('AdminUser/index')
  70. );
  71. }else{
  72. return array(
  73. 'status'=>'fail',
  74. 'message'=>'修改失败',
  75. 'jump'=>U('AdminUser/index')
  76. );
  77. }
  78. }
  79. }
  80. ?>