123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242 |
- <?php
- namespace App\Http\Controllers\Api;
- use App\Service\PortraitService;
- use App\Service\TagService;
- use Illuminate\Http\Request;
- use App\Http\Controllers\Controller;
- class PortraitController extends Controller
- {
- /**
- * 画像配置列表
- * @param Request $request
- * @return array
- */
- public function confList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $res = PortraitService::confList($corpid);
- return self::returnValue($res);
- }
- /**
- * 画像配置操作
- * @param Request $request
- * @return array
- */
- public function confOperate(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'conf_json' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $confJson = $request->input('conf_json');
- list($res, $code) = PortraitService::confOperate($corpid, $confJson);
- return self::returnValue($res, $code);
- }
- /**
- * 画像配置添加属性
- * @param Request $request
- * @return array
- */
- public function confAdd(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'name' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $name = $request->input('name');
- list($res, $code) = PortraitService::confAdd($corpid, $name);
- return self::returnValue($res, $code);
- }
- /**
- * 画像属性编辑
- * @param Request $request
- * @return array
- */
- public function confEdit(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'fid' => 'required|string',
- 'name' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $fid = $request->input('fid');
- $name = $request->input('name');
- list($res, $code) = PortraitService::confEdit($corpid, $fid, $name);
- return self::returnValue($res, $code);
- }
- /**
- * 客户画像编辑
- * @param Request $request
- * @return array
- */
- public function edit(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required|string',
- 'user_id' => 'required|string',
- 'external_userid' => 'required|string',
- 'attrs_json' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $userId = $request->input('user_id');
- $externalUserid = $request->input('external_userid');
- $attrsJson = $request->input('attrs_json');
- list($res, $code) = PortraitService::edit($corpid, $userId, $externalUserid, $attrsJson);
- return self::returnValue($res, $code);
- }
- public function h5CustomerDetail(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'external_userid' => 'required|string',
- 'user_id' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $external_userid = $request->input('external_userid');
- $userId = $request->input('user_id');
- list($data, $code) = PortraitService::h5CustomerDetail($corpid, $external_userid, $userId);
- return self::returnValue($data, $code);
- }
- public function h5CustomerDynamicList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'external_userid' => 'required|string',
- 'user_id' => 'required|string'
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $external_userid = $request->input('external_userid');
- $userId = $request->input('user_id');
- $data = PortraitService::h5CustomerDynamicList($corpid, $external_userid);
- return self::returnValue($data);
- }
- public function h5CustomerOrderList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'external_userid' => 'required|string',
- 'user_id' => 'required|string',
- 'page' => 'required|int',
- 'pagesize' => 'nullable|int',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $external_userid = $request->input('external_userid');
- $userId = $request->input('user_id');
- $page = $request->input('page', 1);
- $pagesize = $request->input('page_size', 20);
- list($data, $total) = PortraitService::h5CustomerOrderList($corpid, $external_userid, $page, $pagesize);
- return self::returnPageValue($data, $total, $pagesize, $page);
- }
- // 客户详情标签编辑
- public function h5CustomerTagUpdate(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- 'external_userid' => 'required|string',
- 'user_id' => 'required|string',
- 'selected_tag_id_list' => 'required|array',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $externalUserId = $request->input('external_userid');
- $userId = $request->input('user_id');
- $selectedTagIdList = $request->input('selected_tag_id_list');
- list($res, $code) = PortraitService::h5CustomerDetailTagUpdate($corpid, $externalUserId, $userId, $selectedTagIdList);
- return self::returnValue($res, $code);
- }
- //标签列表(按标签组分组返回)
- public function h5TagList(Request $request)
- {
- $validator = \Validator::make($request->all(),[
- 'corpid' => 'required',
- ]);
- if ($validator->fails()) {
- return self::returnValue($validator->getMessageBag(), 1102);
- }
- $corpid = $request->input('corpid');
- $keyword = $request->input('keyword');
- $data = TagService::tagList($corpid, $keyword);
- return self::returnValue($data);
- }
- }
|