Commit e670afb3 by 庄欣

测试

parent 237dde85
......@@ -51,7 +51,7 @@ class Article extends \Illuminate\Routing\Controller
$model = ArtModel::newArt($post);
if ($model !== false) {
Event::fire(new ArtAddEvent($model));
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error();
}
......@@ -69,10 +69,17 @@ class Article extends \Illuminate\Routing\Controller
$model = ArtModel::findOrFail($id);
$post = $request->all();
isset($post['content']) && $post['content'] = $this->csrf($post,'content');
$validate_Data = array_merge($model->toArray(),$post);
$validator = new ArtValidator();
$res = $validator->validate($validate_Data);
if ($res == false) {
$messages = $validator->getMessages();
return Response::error($messages,HttpStatus::HttpValidationFailed);
}
$res = $model->uptArt($post);
if ($res !== false) {
Event::fire(new ArtEditedEvent($model));
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error();
}
......
......@@ -7,8 +7,79 @@
*/
namespace App\City\Model;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Cache;
class City extends Model
{
protected $table = "myp_city";
protected $table = "myp_site";
//存储、更新地点缓存
public static function getPlace ($id,$forceUpdate = false) {
$key = base64_encode("place-".$id);
if(!Cache::has($key) || $forceUpdate == true) {
Cache::put($key,self::where('id',$id)->get());
}
return Cache::get($key);
}
public static function getPlaceName ($id,$field = "name") {
if (empty($id)) {
return "";
}
$cache = self::getPlace($id);
if (empty($cache)) {
return $id;
}
return $cache->$field;
}
public static function getPlaceParent($id) {
if (empty($id)) {
return "";
}
return self::getPlaceName(self::getPlaceName($id,"previous"));
}
public static function getPlaceRoot($id) {
if (empty($id)) {
return "";
}
while (self::getPlace($id)->level != 0) {
$id = self::getPlaceRoot(self::getPlace($id)->previous);
}
return $id;
}
public static function getChina()
{
return 1;
}
public static function list_to_tree($list, $pk='id', $pid = 'pid', $child = 'child', $root = 0) {
// 创建Tree
$tree = array();
if(is_array($list)) {
// 创建基于主键的数组引用
$refer = array();
foreach ($list as $key => $data) {
$refer[$data[$pk]] =& $list[$key];
}
foreach ($list as $key => $data) {
// 判断是否存在parent
$parentId = $data[$pid];
if ($root == $parentId) {
$tree[] =& $list[$key];
}else{
if (isset($refer[$parentId])) {
$parent =& $refer[$parentId];
$parent[$child][] =& $list[$key];
}
}
}
}
return $tree;
}
}
\ No newline at end of file
......@@ -22,10 +22,11 @@ class Response
}
//method put,post,head return
public static function ok ($code = HttpStatus::HttpOk)
public static function ok ($data = "",$code = HttpStatus::HttpOk)
{
return [
'code' => $code,
'data' => $data,
'api_ver' => RouteServiceProvider::getVersion()
];
}
......
......@@ -15,6 +15,7 @@ class ValidatorBase extends Validator
public function validate(array $post)
{
self::$_validator = self::make($post,$this->validator,$this->message);
file_put_contents("/var/www/log1.txt",json_encode($post));
if (self::$_validator->passes()) {
if (method_exists($this, "custom_validate")) {
$res = call_user_func_array([$this, "custom_validate"], [$post]);
......
......@@ -9,6 +9,7 @@ class Keywords extends Model
{
use Models;
protected $table = "myp_kw";
public $timestamps = false;
public function __construct(array $attributes = [])
{
......@@ -20,7 +21,6 @@ class Keywords extends Model
{
$this->create_time = date("Y-m-d H:i:s",time());
$this->is_del = 0;
$this->sort = 0;
}
public static function getIdByWords($words,$uid = 0,$auto_add = false)
......@@ -40,6 +40,7 @@ class Keywords extends Model
$model->uid = $uid;
$model->follow_count = 0;
$model->used_count = 1;
$model->recommend = 0;
$model->save();
return $model;
} else {
......
<?php
namespace App\Libraries\ElasticSearch;
use Illuminate\Support\Facades\Log;
class Search {
protected static $server = [];
......@@ -26,7 +27,7 @@ class Search {
protected function __construct($index_name)
{
$this->server_ip = "http://".config("app.ip").":".config("app.port");
$this->server_ip = "http://".config("app.elastic_searcher.ip").":".config("app.elastic_searcher.port");
$this->index_name = $index_name;
}
......@@ -46,7 +47,8 @@ class Search {
$this->type_name = $type;
$this->data_id = $id;
$this->data = $data;
return $this->go();
$res = $this->go();
return $res;
}
......@@ -78,6 +80,7 @@ class Search {
curl_setopt($curl,CURLOPT_URL,$this->buildRequest());
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
$res = curl_exec($curl);
Log::info($res);
$decode = json_decode($res);
if (json_last_error()) {
return false;
......
......@@ -3,18 +3,21 @@
namespace App\Photo\Model;
use \Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use App\Traits\Models;
class Details extends \Illuminate\Database\Eloquent\Model
{
use Models;
const fields = [
"url","file_name","image_width","image_height","hit"
];
public $table = "myp_xp_set_details";
public $timestamps = false;
public $fillable = [
"url","file_name","image_width","image_height"
];
public function __construct(array $attributes = [])
{
......@@ -24,7 +27,6 @@ class Details extends \Illuminate\Database\Eloquent\Model
public function beforeValidationOnCreate()
{
parent::beforeValidationOnCreate();
$this->hit = 0;
$this->is_del = 0;
$this->create_time = date("Y-m-d H:i:s",time());
......
......@@ -4,11 +4,57 @@ namespace App\Photo\v1\Controller;
use App\Http\Response\HttpStatus;
use App\Http\Response\Response;
use App\Traits\Controller;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpFoundation\Request;
use App\Photo\Model\Details as DetailModel;
use App\Photo\Model\Photo as PhotoModel;
use Illuminate\Http\Request;
class Details extends \Illuminate\Routing\Controller
{
use Controller;
protected $query_fields = [
"xp_id","is_del"
];
public function index($id)
{
$query = request()->query();
$where = $this->filter($query);
$where['xp_id'] = $id;
is_null($where) && $where = [];
$row = isset($query["size"])?$query["size"]:config("app.default_perpage");
return Response::success(DetailModel::where($where)->paginate($row)->toArray());
}
public function store($id,Request $request)
{
try {
$model = PhotoModel::findOrFail($id);
$details = DetailModel::add($request->all(),null);
$res = $model->relation_details()->saveMany($details);
if ($res) {
return Response::ok();
} else {
return Response::error();
}
} catch (ModelNotFoundException $e){
return Response::error(HttpStatus::HttpNotFound,"选片未找到");
}
}
public function destory($id,$ids)
{
try {
$model = PhotoModel::findOrFail($id);
$res = $model->relation_details()->whereIn("id",$ids)->delete();
if ($res) {
return Response::ok();
} else {
return Response::error();
}
} catch (ModelNotFoundException $e){
return Response::error(HttpStatus::HttpNotFound,"选片未找到");
}
}
}
\ No newline at end of file
......@@ -25,7 +25,8 @@ class Photo extends \Illuminate\Routing\Controller
$where = $this->filter($query);
is_null($where) && $where = [];
$row = isset($query["size"])?$query["size"]:config("app.default_perpage");
return Response::success(PhotoModel::where($where)->paginate($row)->toArray());
$model = $this->getOrder(PhotoModel::class,$where);
return Response::success($model->paginate($row)->toArray());
}
......@@ -51,7 +52,7 @@ class Photo extends \Illuminate\Routing\Controller
}
$model = PhotoModel::newPhoto($post);
if ($model !== false) {
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error();
}
......@@ -63,12 +64,12 @@ class Photo extends \Illuminate\Routing\Controller
$model = PhotoModel::findOrFail($id);
$res = $model->update($request->all());
if ($res !== false) {
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error();
}
} catch (\Exception $e) {
return Response::error(HttpStatus::HttpNotFound,"选片未找到");
return Response::error("选片未找到",HttpStatus::HttpNotFound);
}
}
......@@ -83,4 +84,15 @@ class Photo extends \Illuminate\Routing\Controller
} catch (ModelNotFoundException $e){}
return Response::ok();
}
public function show($id) {
try {
$model = PhotoModel::findOrFail($id);
return Response::success($model->toArray());
} catch (ModelNotFoundException $e){
return Response::error("选片未找到",HttpStatus::HttpNotFound);
}
}
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Log;
class AppServiceProvider extends ServiceProvider
{
......
<?php
namespace App\Sets\Events;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Event;
use App\Sets\Model\Sets as SetsModel;
class SetsEditedEvent extends Event
{
use SerializesModels;
public $model;
public function __construct(SetsModel $model)
{
$this->model = $model;
}
}
......@@ -6,6 +6,7 @@ use App\Sets\Model\Category;
use \Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\DB;
use App\City\Model\City as CityModel;
class Sets extends Model
{
......@@ -23,6 +24,10 @@ class Sets extends Model
'abroad', 'modeling_count_from_user','is_promotion',"temp_price","type"
];
const fields = [
'id','title','cover','price','type','is_promotion','is_shelf','create_time'
];
public function __construct(array $attributes = [])
{
parent::__construct($attributes);
......@@ -129,31 +134,31 @@ class Sets extends Model
$data['temp_price'] = $data['price'];
$this->update($data);
//促销
if (isset($data['promotion'])) {
if (isset($data['promotion']) && !empty($data['promotion'])) {
$models = Promotion::add($data['promotion']);
$this->relation_promotion()->update(['is_del' => 1]);
$this->relation_promotion()->saveMany($models);
};
//绑定的样片
if (isset($data['works'])) {
if (isset($data['works']) && !empty($data['works'])) {
$models = Works::add($data['works']);
$this->relation_works()->delete();
$this->relation_works()->saveMany($models);
};
//输入的附件
if (isset($data['attachment'])) {
if (isset($data['attachment']) && !empty($data['attachment'])) {
$models = Attachment::add($data['attachment']);
$this->relation_attatchment()->delete();
$this->relation_attatchment()->saveMany($models);
};
//分类
if (isset($data['category'])) {
if (isset($data['category']) && !empty($data['category'])) {
$models = Category::add($data['category']);
$this->relation_category()->delete();
$this->relation_category()->saveMany($models);
};
//关键词
if (isset($data['keywords'])) {
if (isset($data['keywords']) && !empty($data['keywords'])) {
$models = Keywords::add($data['keywords'],$this->uid);
$this->relation_keywords()->delete();
$this->relation_keywords()->saveMany($models);
......
......@@ -89,6 +89,10 @@ class SetsValidator extends Validator
'is_shelf.required' => '上下架状态必填',
'is_promotion.required' => '促销状态必填',
'is_promotion.in' => '促销状态必须为0或1',
'is_shelf.in' => '上下架必须为0或1',
'duration_unit.in' => '时间区间应为小时、天、周',
'start_time.date' => '请输入正确的开始时间',
'end_time.date' => '请输入正确的结束时间'
];
/**
......@@ -100,53 +104,66 @@ class SetsValidator extends Validator
$messages = [];
if (empty($data['works'])) {
$messages[] = "该套系至少应绑定一个样片集";
return $messages;
}
if (empty($data['category'])) {
$messages[] = "该套系必须至少选择一个分类";
return $messages;
}
if ($data['modeling_count'] < $data['modeling_count_from_user']) {
$messages[] = "摄影师最多提供数不可大于造型总数量";
return $messages;
}
if ($data['start_time'] > $data['end_time']) {
$messages[] = "套系开始时间必须小于结束时间";
return $messages;
}
if ($data["is_promotion"] == 1 && empty($data['promotion']['id'])) {
if ($data['promotion']['promotion_start_time'] >= $data['promotion']['promotion_end_time']) {
$messages[] = "特惠开始时间应小于特惠停止时间";
return $messages;
}
if ((int)$data['promotion']['per_user_count'] > $data['promotion']['p_order_count']) {
$messages[] = "特惠的限购额度应小于特惠数量";
return $messages;
}
if ($data['promotion']['p_order_count'] <= 0 ) {
$messages[] = "特惠数量应大于0";
return $messages;
}
if ($data['promotion']['promotion_start_time'] < $data['start_time']) {
$messages[] = "特惠的开始时间应大于套系的起始有效时间";
return $messages;
}
if ($data['promotion']['promotion_end_time'] > $data['end_time']) {
$messages[] = "特惠的结束时间应小于在套系终止有效时间";
return $messages;
}
$startdate=strtotime($data['promotion']['promotion_start_time']);
$enddate=strtotime($data['promotion']['promotion_end_time']);
$days=round(($enddate-$startdate)/3600/24) ;
if ($days > 100) {
$messages[] = "特惠时间长度不应大于100天";
return $messages;
}
if ($data['promotion']['promotion_price'] >= $data['price']) {
$messages[] = "特惠价格应小于套系价格";
return $messages;
}
if ($data['promotion']['promotion_price'] < 5) {
$messages[] = "特惠价格应大于5元";
return $messages;
}
$validator = new PromotionValidator();
$res = $validator->validate($data['promotion']);
if($res->fails()) {
$messages[] = $validator->getMessages();
return $messages;
}
unset($validator);
}
......@@ -155,7 +172,7 @@ class SetsValidator extends Validator
foreach($data["attachment"] as $item) {
if(!empty($item['title'])) {
$res = $validator->validate($item);
if($res->fails()) {
if($res == false) {
$messages[] = $validator->getMessages();
break;
}
......
......@@ -89,7 +89,7 @@ class Sets extends \Illuminate\Routing\Controller
$model = SetsModel::newSets($post);
if ($model !== false) {
Event::fire(new SetsEditedEvent($model));
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error(SetsModel::getError());
}
......@@ -104,10 +104,18 @@ class Sets extends \Illuminate\Routing\Controller
{
try {
$model = SetsModel::findOrFail($id);
$res = $model->fill($request->all())->save();
$data = $request->all();
$validate_Data = array_merge($model->toArray(),$data);
$validator = new SetsValidator();
$res = $validator->validate($validate_Data);
if ($res == false) {
$messages = $validator->getMessages();
return Response::error($messages,HttpStatus::HttpValidationFailed);
}
$res = $model->uptSets($data);
if ($res) {
Event::fire(new SetsEditedEvent($model));
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error();
}
......@@ -116,7 +124,6 @@ class Sets extends \Illuminate\Routing\Controller
}
}
public function destory($id)
{
try {
......@@ -124,7 +131,7 @@ class Sets extends \Illuminate\Routing\Controller
$res = $model->delete();
if ($res) {
Event::fire(new SetsEditedEvent($model));
return Response::ok();
return Response::ok($model->id);
} else {
return Response::error();
}
......@@ -132,4 +139,12 @@ class Sets extends \Illuminate\Routing\Controller
return Response::error(HttpStatus::HttpNotFound,"样片未找到");
}
}
public function all($ids)
{
$where['id'] = explode(",",$ids);
$model = $this->setBlurSearch(SetsModel::class,$where,"id","in");
return Response::success($model->select(SetsModel::fields)->get());
}
}
\ No newline at end of file
......@@ -14,8 +14,6 @@ trait Controller
*/
public function filter($where)
{
$order = isset($where["order"])?$where["order"]:"id-desc";
$where['order'] = $order;
if (is_null($where) || empty($where)) {
return [];
}
......@@ -34,22 +32,39 @@ trait Controller
return $where;
}
public function setBlurSearch($model,$where,$key,$condition = "like")
public function setDefaultOrder($where)
{
$result_model = null;
$order = isset($where["order"])?$where["order"]:"id-desc";
$where['order'] = $order;
return $where;
}
public function getOrder($model,&$where)
{
if (!empty($model->unionOrders)) {
return $model;
}
if (!isset($where['order'])) {
$where = $this->setDefaultOrder($where);
}
list($field,$sort) = explode("-",$where["order"]);
$result_model = $model::orderBy($field,$sort);
try {
unset($where['order']);
unset($where['page']);
unset($where['size']);
} catch (\Exception $e) {
} catch (\Exception $e) {}
return $model::orderBy($field,$sort);
}
}
public function setBlurSearch($model,$where,$key,$condition = "like")
{
$result_model = null;
$result_model = $this->getOrder($model,$where);
if (!in_array($key,array_keys($where))) {
return $result_model->where($where);
}
$where[$key] = trim($where[$key]);
is_string($where[$key]) && $where[$key] = trim($where[$key]);
switch ($condition) {
case "like":
$result_model = $result_model->where($key,"like","%".$where[$key]."%");
......@@ -70,7 +85,7 @@ trait Controller
$result_model = $result_model->where($where);
break;
case "in":
$result_model = $result_model->whereIn($key,"in",$where[$key]);
$result_model = $result_model->whereIn($key,$where[$key]);
break;
}
unset($where[$key]);
......@@ -87,4 +102,7 @@ trait Controller
public function csrf($data,$key) {
return preg_replace("/<script[^>]*>.*<\/script>/i","",$data[$key]);
}
}
\ No newline at end of file
......@@ -27,12 +27,16 @@ Trait Models
return static::get(["id"])->count();
}
public static function add(array $data,$uid)
public static function add(array $data,$uid = null)
{
$items = [];
foreach ($data as $item) {
$item = new static($item,$uid);
array_push($items,$item);
if ($uid != null) {
$model = new static($item, $uid);
} else {
$model = new static($item);
}
array_push($items,$model);
}
return $items;
}
......
......@@ -26,7 +26,7 @@ class WorksSearcherListener
'works_id' => $works->id,
'name' => $works->name,
'kw' => implode(" ",$keyworks),
'photographer_name' => UserModel::getUserInfo($works->uid,['nickname']),
'photographer_name' => UserModel::getUserInfo($works->uid,['nickname'])->nickname,
'lasttime' => date("Y-m-d H:i:s",time())
]);
}
......
......@@ -14,16 +14,20 @@ class Keywords extends Model
protected $fillable = [
"kw_id","kw_name"
];
public $timestamps = false;
public function __construct(array $attributes = [],$uid = null)
{
parent::__construct($attributes);
$model = \App\Kw\Model\Keywords::getIdByWords($attributes['kw_name'] , $uid , true);
$this->kw_id = $model->id;
$this->kw_name = $model->kw_name;
if (!empty($attributes)) {
$model = \App\Kw\Model\Keywords::getIdByWords($attributes['kw_name'], $uid, true);
$this->kw_id = $model->id;
$this->kw_name = $model->kw_name;
}
$this->beforeValidationOnCreate();
}
public function beforeValidationOnCreate()
{
$this->is_del = 0;
$this->create_time = date("Y-m-d H:i:s",time());
}
}
\ No newline at end of file
......@@ -6,5 +6,5 @@ use \Illuminate\Database\Eloquent\Model;
class Sets extends Model
{
protected $table = "myp_works_category";
protected $table = "myp_sets_works";
}
\ No newline at end of file
......@@ -11,6 +11,7 @@ namespace App\Works\Model;
use App\Photo\v1\Controller\Details;
use App\Works\Events\DetailDeleteEvent;
use App\Works\Model\Details as DetailModel;
use App\Sets\Model\Works as SetsModel;
use App\Traits\Models;
use \Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
......@@ -41,6 +42,7 @@ class Works extends Model
$this->count = 0;
$this->create_time = date("Y-m-d H:i:s",time());
$this->is_del = 0;
$this->introduction = " ";
}
public function skipAttributesOnUpdate()
......@@ -49,7 +51,11 @@ class Works extends Model
}
protected $fillable = [
'uid', 'name', 'cover',"is_hidden"
'uid', 'name', 'cover',"is_hidden","introduction"
];
const fields = [
'id','name', 'cover',"is_hidden",'create_time'
];
public function relation_sets()
......@@ -98,9 +104,13 @@ class Works extends Model
}
}
if (isset($data['keywords']) && !empty($data['keywords'])) {
$models = Keywords::add($data['keywords']);
$models = Keywords::add($data['keywords'],$data['uid']);
$model->relation_keywords()->saveMany($models);
}
if (isset($data['sets']) && !empty($data['sets'])) {
$models = SetsModel::add($data['sets']);
$model->relation_sets()->saveMany($models);
}
} catch (\Exception $e) {
self::throwError($e);
DB::rollBack();
......@@ -129,10 +139,19 @@ class Works extends Model
$this->relation_detail()->delete();
$this->relation_detail()->saveMany($details);
}
if (isset($data['keywords']) && !empty($data['keywords'])) {
$models = Keywords::add($data['keywords'],$data['uid']);
$models = Keywords::add($data['keywords'],$this->uid);
$this->relation_keywords()->delete();
$this->relation_keywords()->saveMany($models);
}
if (isset($data['sets']) && !empty($data['sets'])) {
$models = SetsModel::add($data['sets']);
$this->relation_sets()->delete();
$this->relation_sets()->saveMany($models);
}
$this->update($data);
} catch (\Exception $e) {
self::throwError($e);
......
<?php
namespace App\Works\Validation;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use App\Http\Validation\ValidatorBase as Validator;
class WorksValidator extends Validator
{
protected $validator = [
'name' => 'required|chinese_length:2,15',
'details' => 'array_length_min:5,array_length_max:15',
'uid' => 'required',
'cover' => 'required'
];
protected $message = [
'name.required' => '请填写样片名称',
'name.chinese_length' => '样片名称应为2到15字之间',
'details.array_length_min' => '您必须上传5-15张照片',
'details.array_length_max' => '您必须上传5-15张照片',
'uid.required' => 'uid必需',
'cover.required' => '必须设置封面图片'
];
public function custom_validate($post)
{
$message = [];
if (strtoupper(request()->getMethod()) == "POST" ||
(strtoupper(request()->getMethod()) == "PUT" && isset($post['details']))
) {
if (!isset($post['details']) || empty($post['details'])) {
$message[] = "您必须上传5-15张照片";
return $message;
};
$count = count($post['details']);
if ($count < 5 || $count > 15) {
$message[] = "您必须上传5-15张照片";
return $message;
}
}
if (strtoupper(request()->getMethod()) == "POST" ||
(strtoupper(request()->getMethod()) == "PUT" && isset($post['sets']))
) {
if (!isset($post['sets']) || empty($post['sets'])) {
if (!isset($post['FROM_SETS']) || $post['FROM_SETS'] != 1) {
$message[] = "您必须绑定至少一个套系";
return $message;
}
}
}
return $message;
}
}
\ No newline at end of file
......@@ -83,16 +83,16 @@ class Works extends \Illuminate\Routing\Controller
$validator = new WorksValidator();
$post = $request->all();
$res = $validator->validate($post);
if ($res->fails()) {
if ($res == false) {
$messages = $validator->getMessages();
return Response::error($messages,HttpStatus::HttpValidationFailed);
}
$model = WorksModel::newWorks($post);
if ($model !== false) {
Event::fire(new WorksEditedEvent($model));
return Response::ok();
return Response::success($model->id);
} else {
return Response::error();
return Response::error(WorksModel::getError());
}
}
......@@ -105,10 +105,18 @@ class Works extends \Illuminate\Routing\Controller
{
try {
$model = WorksModel::findOrFail($id);
$data = $request->all();
$validate_Data = array_merge($model->toArray(),$data);
$validator = new WorksValidator();
$res = $validator->validate($validate_Data);
if ($res == false) {
$messages = $validator->getMessages();
return Response::error($messages,HttpStatus::HttpValidationFailed);
}
$res = $model->uptWorks($request->all());
if ($res) {
Event::fire(new WorksEditedEvent($model));
return Response::ok();
return Response::success($model->id);
} else {
return Response::error();
}
......@@ -137,4 +145,13 @@ class Works extends \Illuminate\Routing\Controller
return Response::error(HttpStatus::HttpNotFound,"样片未找到");
}
}
public function all($ids)
{
$where['id'] = explode(",",$ids);
$model = $this->setBlurSearch(WorksModel::class,$where,"id","in");
return Response::success($model->select(WorksModel::fields)->get());
}
}
\ No newline at end of file
......@@ -5,7 +5,6 @@ Route::resource ("test" , \App\Test\Controller\TestController::class);
//套系
Route::group(["prefix" => "sets", 'namespace' => Provider::getNamespace("sets")],function(){
//套系列表
Route::get ("/" , "Sets@index");
//套系详情
......@@ -15,10 +14,14 @@ Route::group(["prefix" => "sets", 'namespace' => Provider::getNamespace("sets")]
//新增套系
Route::post("/" , "Sets@store");
//编辑套系
/*Route::put ("/{id}" , "Sets@update");
Route::put ("/{id}" , "Sets@update");
//删除套系
Route::delete("/{id}", "Sets@destory");
/*
Route::delete("/{id}/hard", "Sets@delete");
*/
//获取IDS所含ID的所有套系,使用,隔开
Route::get ("/all/{ids}" , "Sets@all");
});
//分类
......@@ -52,6 +55,8 @@ Route::group(["prefix" => "works", 'namespace' => Provider::getNamespace("works"
Route::delete("/{ids}/image","Details@destory")->where(['ids'=>'\S+']);
//新增样片里的照片
Route::post("/{id}/image","Details@store");
//获取IDS所含ID的所有样片,使用,隔开
Route::get ("/all/{ids}" , "Works@all");
});
......@@ -85,13 +90,18 @@ Route::group(["prefix" => "photo", 'namespace' => Provider::getNamespace("photo"
Route::get("/" , "Photo@index");
Route::post("/" , "Photo@store");
Route::delete("/{id}", "Photo@destory")->where(['id' => '\d+']);
Route::put("/{id}" , "Photo@update")->where(['id' => '\d+']);
Route::put("/{id}" , "Photo@update")->where(['id' => '\d+']);
Route::post("/{id}" , "Details@store")->where(['id' => '\d+']);
Route::delete("/{id}/{ids}" , "Details@destory");
Route::get("/{id}", "Photo@show")->where(['id' => '\d+']);
Route::get("/{id}/list", "Details@index")->where(['id' => '\d+']);
});
//城市
Route::group(["prefix" => "city", 'namespace' => Provider::getNamespace("city")],function(){
Route::get("/" , "City@index");
});
//关键词
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment