|
|
@@ -2,20 +2,20 @@
|
|
|
|
|
|
namespace App\Service;
|
|
|
|
|
|
-use App\Model\Priority;
|
|
|
+use App\Model\Tag;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
|
|
-class PriorityService extends Service
|
|
|
+class TagService extends Service
|
|
|
{
|
|
|
- public function priorityEdit($data, $user){
|
|
|
- list($status,$msg) = $this->priorityRule($data,$user,false);
|
|
|
+ public function tagEdit($data, $user){
|
|
|
+ list($status,$msg) = $this->tagRule($data,$user,false);
|
|
|
if(!$status) return [$status, $msg];
|
|
|
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
$update = $msg['data'][0];
|
|
|
- $model = new Priority();
|
|
|
+ $model = new Tag();
|
|
|
$model->where('id',$data['id'])->update($update);
|
|
|
|
|
|
DB::commit();
|
|
|
@@ -27,15 +27,15 @@ class PriorityService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
- public function priorityAdd($data,$user){
|
|
|
- list($status,$msg) = $this->priorityRule($data,$user);
|
|
|
+ public function tagAdd($data,$user){
|
|
|
+ list($status,$msg) = $this->tagRule($data,$user);
|
|
|
if(!$status) return [$status,$msg];
|
|
|
|
|
|
try {
|
|
|
DB::beginTransaction();
|
|
|
|
|
|
foreach ($msg['data'] as $value){
|
|
|
- $model = new Priority();
|
|
|
+ $model = new Tag();
|
|
|
$model->title = $value['title'];
|
|
|
$model->code = $value['code'];
|
|
|
$model->type = $value['type'];
|
|
|
@@ -54,20 +54,20 @@ class PriorityService extends Service
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
- public function priorityDel($data, $user){
|
|
|
+ public function tagDel($data, $user){
|
|
|
if(empty($data['id'])) return [false, 'ID不能为空'];
|
|
|
|
|
|
- Priority::whereIn('id',$data['id'])->update([
|
|
|
+ Tag::whereIn('id',$data['id'])->update([
|
|
|
'del_time'=>time()
|
|
|
]);
|
|
|
|
|
|
return [true,''];
|
|
|
}
|
|
|
|
|
|
- public function priorityCommon($data,$user, $field = []){
|
|
|
- if(empty($field)) $field = Priority::$field;
|
|
|
+ public function tagCommon($data,$user, $field = []){
|
|
|
+ if(empty($field)) $field = Tag::$field;
|
|
|
|
|
|
- $model = Priority::TopClear($user,$data);
|
|
|
+ $model = Tag::TopClear($user,$data);
|
|
|
$model = $model->where('del_time',0)
|
|
|
->select($field)
|
|
|
->orderby('id', 'asc');
|
|
|
@@ -76,21 +76,22 @@ class PriorityService extends Service
|
|
|
if(! empty($data['code'])) $model->where('code', 'LIKE', '%'.$data['code'].'%');
|
|
|
if(isset($data['is_use'])) $model->where('is_use', $data['is_use']);
|
|
|
if(! empty($data['id'])) $model->whereIn('id', $data['id']);
|
|
|
+ if(! empty($data['type'])) $model->where('type', $data['type']);
|
|
|
|
|
|
return $model;
|
|
|
}
|
|
|
|
|
|
- public function priorityList($data, $user){
|
|
|
- $model = $this->priorityCommon($data, $user);
|
|
|
+ public function tagList($data, $user){
|
|
|
+ $model = $this->tagCommon($data, $user);
|
|
|
$list = $this->limit($model,'',$data);
|
|
|
$list = $this->fillPriorityList($list, $user);
|
|
|
|
|
|
return [true, $list];
|
|
|
}
|
|
|
|
|
|
- public function priorityDetail($data, $user){
|
|
|
+ public function tagDetail($data, $user){
|
|
|
if(empty($data['id'])) return [false,'id不能为空'];
|
|
|
- list($status, $return) = $this->priorityList(['id' => [$data['id']]], $user);
|
|
|
+ list($status, $return) = $this->tagList(['id' => [$data['id']]], $user);
|
|
|
$return = $return['data'][0] ?? [];
|
|
|
|
|
|
return [true, $return];
|
|
|
@@ -100,14 +101,14 @@ class PriorityService extends Service
|
|
|
if(empty($list)) return $list;
|
|
|
|
|
|
foreach ($list['data'] as $key => $value){
|
|
|
- $list['data'][$key]['type_title'] = Priority::TYPE_TITLE[$value['type']] ?? "";
|
|
|
- $list['data'][$key]['is_use_title'] = Priority::IS_USE[$value['is_use']] ?? "";
|
|
|
+ $list['data'][$key]['type_title'] = Tag::TYPE_TITLE[$value['type']] ?? "";
|
|
|
+ $list['data'][$key]['is_use_title'] = Tag::IS_USE[$value['is_use']] ?? "";
|
|
|
}
|
|
|
|
|
|
return $list;
|
|
|
}
|
|
|
|
|
|
- public function priorityRule($data,$user, $is_check = true){
|
|
|
+ public function tagRule($data,$user, $is_check = true){
|
|
|
if(empty($data['data'])) return [false,'数据不能为空!'];
|
|
|
|
|
|
$code = array_column($data['data'],'code');
|
|
|
@@ -138,16 +139,16 @@ class PriorityService extends Service
|
|
|
if(! isset($value['sort'])) return [false, '排序字段sort不存在'];
|
|
|
if (filter_var($value['sort'], FILTER_VALIDATE_INT) === false) return [false, '排序字段sort必须是整数且不能含有小数点'];
|
|
|
|
|
|
- if(! isset(Priority::TYPE_TITLE[$value['type']])) return [false, 'type错误'];
|
|
|
+ if(! isset(Tag::TYPE_TITLE[$value['type']])) return [false, 'type错误'];
|
|
|
if($is_check){
|
|
|
$data['data'][$key]['crt_time'] = time();
|
|
|
- $bool = Priority::whereRaw("binary code = '{$value['code']}'")
|
|
|
+ $bool = Tag::whereRaw("binary code = '{$value['code']}'")
|
|
|
->where('top_depart_id', $top_depart_id)
|
|
|
->where('del_time',0)
|
|
|
->exists();
|
|
|
}else{
|
|
|
if($this->isEmpty($data,'id')) return [false,'id不能为空!'];
|
|
|
- $bool = Priority::whereRaw("binary code = '{$value['code']}'")
|
|
|
+ $bool = Tag::whereRaw("binary code = '{$value['code']}'")
|
|
|
->where('top_depart_id', $top_depart_id)
|
|
|
->where('id','<>',$data['id'])
|
|
|
->where('del_time',0)
|