1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
- namespace app\admin\controller\goods;
- use app\admin\service\goods\CardService;
- use app\admin\service\goods\GoodsService;
- use app\admin\service\goods\PartnerService;
- use app\admin\validate\goods\GoodsValidate;
- use support\Request;
- use support\Response;
- class CardController
- {
- /**
- * @Desc 商品详情
- * @Author Gorden
- * @Date 2024/3/28 10:25
- *
- * @param Request $request
- * @return Response
- */
- public function info(Request $request)
- {
- $validate = new GoodsValidate();
- if (!$validate->scene('info')->check($request->get())) {
- return json_fail($validate->getError());
- }
- return CardService::info($request->get('goods_id'));
- }
- /**
- * @Desc 添加商品
- * @Author Gorden
- * @Date 2024/3/11 10:21
- *
- * @param Request $request
- * @return Response
- */
- public function insert(Request $request): Response
- {
- $params = $request->post();
- $validate = new GoodsValidate();
- if (!$validate->scene('add')->check($params)) {
- return json_fail($validate->getError());
- }
- $params['goods_classify'] = $params['goods_classify'] ?? 'GOODS';
- return CardService::insert($params);
- }
- /**
- * @Desc 修改商品
- * @Author Gorden
- * @Date 2024/3/28 13:22
- *
- * @param Request $request
- * @return Response
- */
- public function update(Request $request): Response
- {
- $validate = new GoodsValidate();
- if (!$validate->scene('update')->check($request->post())) {
- return json_fail($validate->getError());
- }
- return CardService::update($request->post());
- }
- }
|