You've already forked qlg.tsgz.moe
Init Repo
This commit is contained in:
150
hyhproject/admin/model/Express.php
Executable file
150
hyhproject/admin/model/Express.php
Executable file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
|
||||
namespace wstmart\admin\model;
|
||||
|
||||
use think\Db;
|
||||
|
||||
/**
|
||||
|
||||
* ============================================================================
|
||||
|
||||
* 快递业务处理
|
||||
|
||||
*/
|
||||
|
||||
class Express extends Base{
|
||||
|
||||
/**
|
||||
|
||||
* 分页
|
||||
|
||||
*/
|
||||
|
||||
public function pageQuery(){
|
||||
|
||||
return $this->where('dataFlag',1)->field('expressId,expressName,expressCode,expressImg')->order('expressId desc')->paginate(input('limit/d'));
|
||||
|
||||
}
|
||||
|
||||
public function getById($id){
|
||||
|
||||
return $this->get(['expressId'=>$id,'dataFlag'=>1]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 新增
|
||||
|
||||
*/
|
||||
|
||||
public function add(){
|
||||
|
||||
// $data = ['expressName'=>input('post.expressName'),'expressCode'=>input('post.expressCode')];
|
||||
|
||||
$data = input('post.');
|
||||
|
||||
WSTUnset($data,'expressId');
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
try{
|
||||
|
||||
$result = $this->validate('Express.add')->allowField(true)->save($data);
|
||||
|
||||
if (false !==$result){
|
||||
|
||||
$id = $this->expressId;
|
||||
|
||||
//启用文件上传
|
||||
|
||||
WSTUseImages(1,$id,$data['expressImg']);
|
||||
|
||||
if(false !==$result){
|
||||
|
||||
Db::commit();
|
||||
|
||||
return WSTReturn("新增成功",1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}catch(\Exception $e){
|
||||
|
||||
Db::rollback();errLog($e);
|
||||
|
||||
}
|
||||
|
||||
return WSTReturn('新增失败',-1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 编辑
|
||||
|
||||
*/
|
||||
|
||||
public function edit(){
|
||||
|
||||
$data = input('post.');
|
||||
|
||||
Db::startTrans();
|
||||
|
||||
try{
|
||||
|
||||
WSTUseImages(1, (int)$data['expressId'], $data['expressImg'], 'express', 'expressImg');
|
||||
|
||||
$result = $this->validate('Express.edit')->allowField(true)->save($data,['expressId'=>(int)$data['expressId']]);
|
||||
|
||||
if(false !== $result){
|
||||
|
||||
Db::commit();
|
||||
|
||||
return WSTReturn("编辑成功", 1);
|
||||
|
||||
}
|
||||
|
||||
}catch (\Exception $e) {
|
||||
|
||||
Db::rollback();errLog($e);
|
||||
|
||||
}
|
||||
|
||||
return WSTReturn('编辑失败',-1);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* 删除
|
||||
|
||||
*/
|
||||
|
||||
public function del(){
|
||||
|
||||
$id = (int)input('post.id/d',0);
|
||||
|
||||
$data = [];
|
||||
|
||||
$data['dataFlag'] = -1;
|
||||
|
||||
$result = $this->update($data,['expressId'=>$id]);
|
||||
|
||||
if(false !== $result){
|
||||
|
||||
return WSTReturn("删除成功", 1);
|
||||
|
||||
}else{
|
||||
|
||||
return WSTReturn($this->getError(),-1);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user