You've already forked qlg.tsgz.moe
addons
app_download_files
extend
hyhproject
admin
behavior
common
conf
controller
model
Accreds.php
AdPositions.php
Addons.php
Adgoods.php
Ads.php
Alipays.php
Areas.php
ArticleCats.php
Articles.php
Attributes.php
Banks.php
Base.php
Brands.php
Carts.php
CashDraws.php
ChargeItems.php
CronJobs.php
DataCats.php
Datas.php
EctDay.php
EctDeal.php
EctTarget.php
Express.php
Friendlinks.php
Goods.php
GoodsAppraises.php
GoodsCats.php
GoodsClassify.php
GoodsConsult.php
HomeMenus.php
Hooks.php
Images.php
Index.php
Informs.php
LogMoneys.php
LogOperates.php
LogSms.php
LogStaffLogins.php
LogSysData.php
Member.php
Menus.php
Messages.php
MobileBtns.php
Navs.php
OrderComplains.php
OrderRefunds.php
Orders.php
Payments.php
Privileges.php
Recommends.php
Reports.php
Roles.php
Settlements.php
Shops.php
SpecCats.php
Staffs.php
Styles.php
SysConfigs.php
TemplateMsgs.php
TradeRule.php
UserRanks.php
UserScores.php
Users.php
Weixinpays.php
WeixinpaysApp.php
WxPassiveReplys.php
WxTemplateParams.php
Wxmenus.php
Wxusers.php
validate
view
app
common
home
home2
mobile2
wechat2
.htaccess
command.php
mobile
oss
static
thinkphp
upload
vendor
wxtmp
.gitignore
.htaccess
.user.ini
404.html
H5436787D.wgt
admin.php
app-release.apk
app_download.html
cash.lock
demo.php
get_startup.php
get_version.php
get_version_new.php
index.html
index.php
reg.lock
robots.txt
167 lines
2.3 KiB
PHP
Executable File
167 lines
2.3 KiB
PHP
Executable File
<?php
|
|
|
|
namespace wstmart\admin\model;
|
|
|
|
/**
|
|
|
|
* ============================================================================
|
|
|
|
* 系统数据分类业务处理
|
|
|
|
*/
|
|
|
|
use think\Db;
|
|
|
|
class DataCats extends Base{
|
|
|
|
protected $insert = ['dataFlag'=>1];
|
|
|
|
/**
|
|
|
|
* 获取数据分类列表
|
|
|
|
*/
|
|
|
|
public function listQuery($catId = -1){
|
|
|
|
if($catId==-1)return ['id'=>0,'name'=>'系统数据','isParent'=>true,'open'=>true];
|
|
|
|
$rs = Db::name('data_cats')->where(['dataFlag'=>1])->field('catId id,catName name')->select();
|
|
|
|
return $rs;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 获取数据分类
|
|
|
|
*/
|
|
|
|
public function getById($id){
|
|
|
|
return $this->get(['dataFlag'=>1,'catId'=>$id]);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 新增数据分类
|
|
|
|
*/
|
|
|
|
public function add(){
|
|
|
|
// 验证数据代码
|
|
|
|
$catCode = input('catCode');
|
|
|
|
$hasCode = $this->where(['catCode'=>$catCode,'dataFlag'=>1])->find();
|
|
|
|
if(!empty($hasCode))return WSTReturn('数据分类代码已存在');
|
|
|
|
// 执行新增
|
|
|
|
$result = $this->validate('DataCats.add')->save(input('post.'));
|
|
|
|
if(false !== $result){
|
|
|
|
return WSTReturn("新增成功", 1);
|
|
|
|
}else{
|
|
|
|
return WSTReturn($this->getError(),-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 编辑数据分类
|
|
|
|
*/
|
|
|
|
public function edit(){
|
|
|
|
$id = input('post.catId/d');
|
|
|
|
|
|
|
|
// 验证数据代码
|
|
|
|
$catCode = input('catCode');
|
|
|
|
$hasCode = $this->where(['catCode'=>$catCode,'dataFlag'=>1,'catId'=>['<>',$id]])->find();
|
|
|
|
if(!empty($hasCode))return WSTReturn('数据分类代码已存在');
|
|
|
|
|
|
|
|
|
|
|
|
$result = $this->validate('DataCats.edit')->allowField(['catName','catCode'])->save(input('post.'),['catId'=>$id]);
|
|
|
|
if(false !== $result){
|
|
|
|
return WSTReturn("编辑成功", 1);
|
|
|
|
}else{
|
|
|
|
return WSTReturn($this->getError(),-1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* 删除数据分类
|
|
|
|
*/
|
|
|
|
public function del(){
|
|
|
|
$id = input('post.id/d');
|
|
|
|
$data = [];
|
|
|
|
$data['dataFlag'] = -1;
|
|
|
|
Db::startTrans();
|
|
|
|
try{
|
|
|
|
$result = $this->update($data,['catId'=>$id]);// 删除该数据分类
|
|
|
|
if(false !== $result){
|
|
|
|
// 删除该数据分类下所有子数据
|
|
|
|
Db::name('datas')->where(['catId'=>$id])->setField('dataFlag',-1);
|
|
|
|
Db::commit();
|
|
|
|
return WSTReturn("删除成功", 1);
|
|
|
|
}
|
|
|
|
}catch(\Exception $e){
|
|
|
|
Db::rollback();errLog($e);
|
|
|
|
return WSTReturn("删除失败",-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|