123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118 |
- <?php
- /**
- * CardBatchController.php
- * User: ZhouBenXu
- * Date: 2024/6/27
- * Time: 上午9:36
- * Notes: 卡批次管理
- */
- namespace app\admin\controller\card;
- use support\Request;
- use support\Response;
- use app\admin\validate\card\CardBatchValidate;
- use app\admin\service\card\CardBatchService;
- use Tinywan\Jwt\JwtToken;
- class CardBatchController
- {
- /**
- * Notes: 添加卡批次
- * User: ZhouBenXu
- * DateTime: 2024/6/27 上午9:44
- */
- public function insert(Request $request)
- {
- $params = $request->post();
- $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
- // 验证器
- $validate = new CardBatchValidate();
- if (!$validate->scene('add')->check($params)) {
- return json_fail($validate->getError());
- }
- return CardBatchService::insert($params);
- }
- /**
- * Notes: 修改卡批次 仅修改名称 状态 有效期
- * User: ZhouBenXu
- * DateTime: 2024/6/27 上午9:44
- */
- public function save(Request $request)
- {
- $params = $request->post();
- $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
- // 验证器
- $validate = new CardBatchValidate();
- if (!$validate->scene('save')->check($params)) {
- return json_fail($validate->getError());
- }
- // 校验有效期 0 永久 1增加 2 减少
- return CardBatchService::save($params);
- }
- /**
- * Notes: 删除 支持批量
- * User: ZhouBenXu
- * DateTime: 2024/6/27 下午5:41
- * @param Request $request
- * @return Response
- */
- public function delete(Request $request)
- {
- // 验证器
- $validate = new CardBatchValidate();
- if (!$validate->scene('delete')->check($request->post())) {
- return json_fail($validate->getError());
- }
- $card_batch_ids = $request->post('card_batch_ids');
- return CardBatchService::delete($card_batch_ids);
- }
- /**
- * Notes: 批次列表
- * User: ZhouBenXu
- * DateTime: 2024/6/28 上午9:51
- * @param Request $request
- * @return Response
- */
- public function list(Request $request)
- {
- $params = $request->get();
- $params['page'] = $params['page'] ?? 1;
- $params['pageSize'] = $params['pageSize'] ?? 20;
- $params['join_card_batch_user_id'] = JwtToken::getCurrentId();
- // 验证器
- $validate = new CardBatchValidate();
- if (!$validate->scene('list')->check($params)) {
- return json_fail($validate->getError());
- }
- return CardBatchService::getList($params);
- }
- /**
- * Notes: 卡批次详情
- * User: ZhouBenXu
- * DateTime: 2024/6/28 上午10:51
- * @param Request $request
- * @return Response
- */
- public function info(Request $request)
- {
- $params = $request->get();
- // 验证器
- $validate = new CardBatchValidate();
- if (!$validate->scene('info')->check($params)) {
- return json_fail($validate->getError());
- }
- return CardBatchService::getInfo($params['card_batch_id']);
- }
- }
|