123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- namespace app\admin\model;
- use think\Db;
- use think\Model;
- class EmailTemplateModel extends Model
- {
- protected $name = 'email_template';
- public function getByWhere($map,$od, $Nowpage, $limits)
- {
- $res = $this
- ->where($map)
- ->page($Nowpage, $limits)
- ->order($od)
- ->select();
- return $res;
- }
- /**
- * [getOneMenu 根据菜单id获取一条信息]
- * @author
- */
- public function getInfo($id)
- {
- return $this->where('id', $id)->find();
- }
- /*
- * 页面总数
- */
- public function getCount($map){
- return $this->alias('a')
- ->where($map)
- ->count();
- }
- public function edit($param)
- {
- $param['update_time']=time();
- $res=$this->allowField(true)->save($param, ['id' => $param['id']]);
- if($res){
- return ['code' => 200, 'data' => '', 'msg' => '编辑成功'];
- }else{
- return ['code' => 100, 'data' => '', 'msg' =>'编辑失败'];
- }
- }
- public function add($param)
- {
- $data['spread_id']=session('uid');
- $data['create_time']=time();
- $data['theme']=$param['theme'];
- $data['type']=isset($param['type'])?$param['type']:1;
- $data['content']=$param['content'];
- if (isset($param['form'])) {
- $data['form'] = $param['form'];
- }
- if (isset($param['to'])) {
- $data['to'] = $param['to'];
- }
- $res=Db::table('think_email_template')->insertGetId($data);
- if($res){
- return ['code' => 200, 'data' => '', 'msg' => '添加成功','id'=>$res];
- }else{
- return ['code' => 100, 'data' => '', 'msg' =>'添加失败'];
- }
- }
- /**
- * batchDelUser 批量删除管理员
- * @param $param
- * @return array
- */
- public function del($param){
- try{
- Db::name('email_template')->where('id','=',$param)->update(['is_deleted'=>time()]);
- return ['code' => 200, 'data' => '', 'msg' => '批量删除成功'];
- }catch( \Exception $e){
- return ['code' => 100, 'data' => '', 'msg' => '批量删除失败'];
- }
- }
- /**
- * batchDelUser 批量删除管理员
- * @param $param
- * @return array
- */
- public function batchDel($param){
- try{
- Db::name('email_template')->where('id','in',$param)->update(['is_deleted'=>time()]);
- return ['code' => 200, 'data' => '', 'msg' => '批量删除成功'];
- }catch( \Exception $e){
- return ['code' => 100, 'data' => '', 'msg' => '批量删除失败'];
- }
- }
- }
|