| | |
| | | package com.oying.modules.message.rest; |
| | | |
| | | import com.oying.annotation.Log; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.oying.modules.message.common.OrderStatusEnum; |
| | | import com.oying.modules.message.common.PlatFormEnum; |
| | | import com.oying.modules.message.domain.MesMsgRecord; |
| | | import com.oying.modules.message.domain.dto.MesShopMsgRespDTO; |
| | | import com.oying.modules.message.domain.dto.MesMsgRecordQueryCriteria; |
| | | import com.oying.modules.message.domain.myDto.MesMsgRecordQueryOrderDto; |
| | | import com.oying.modules.message.domain.myDto.MesMsgRecordQueryPollDto; |
| | | import com.oying.modules.message.domain.myDto.MesMsgRecordQuerySystemDto; |
| | | import com.oying.modules.message.service.MesMsgRecordService; |
| | | import com.oying.modules.message.domain.dto.MesMsgRecordQueryCriteria; |
| | | import com.oying.utils.R; |
| | | import lombok.RequiredArgsConstructor; |
| | | import java.util.List; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.oying.utils.PageResult; |
| | | import com.oying.utils.R; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiParam; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @author 李萌 |
| | |
| | | @Slf4j |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "消息") |
| | | @Api(tags = "消息中心2.0") |
| | | @RequestMapping("/api/mesMsgRecord") |
| | | public class MesMsgRecordController { |
| | | |
| | | private final MesMsgRecordService mesMsgRecordService; |
| | | |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('mesMsgRecord:list')") |
| | | public void exportMesMsgRecord(HttpServletResponse response, MesMsgRecordQueryCriteria criteria) throws IOException { |
| | | mesMsgRecordService.download(mesMsgRecordService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @ApiOperation("查询消息") |
| | | @PreAuthorize("@el.check('mesMsgRecord:list')") |
| | | public ResponseEntity<PageResult<MesMsgRecord>> queryMesMsgRecord(MesMsgRecordQueryCriteria criteria){ |
| | | Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | return new ResponseEntity<>(mesMsgRecordService.queryAll(criteria,page),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增消息") |
| | | @ApiOperation("新增消息") |
| | | @PreAuthorize("@el.check('mesMsgRecord:add')") |
| | | public ResponseEntity<Object> createMesMsgRecord(@Validated @RequestBody MesMsgRecord resources){ |
| | | mesMsgRecordService.create(resources); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改消息") |
| | | @ApiOperation("修改消息") |
| | | @PreAuthorize("@el.check('mesMsgRecord:edit')") |
| | | public ResponseEntity<Object> updateMesMsgRecord(@Validated @RequestBody MesMsgRecord resources){ |
| | | mesMsgRecordService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除消息") |
| | | @ApiOperation("删除消息") |
| | | @PreAuthorize("@el.check('mesMsgRecord:del')") |
| | | public ResponseEntity<Object> deleteMesMsgRecord(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) { |
| | | mesMsgRecordService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | // |
| | | // @ApiOperation("导出数据") |
| | | // @GetMapping(value = "/download") |
| | | // @PreAuthorize("@el.check('mesMsgRecord:list')") |
| | | // public void exportMesMsgRecord(HttpServletResponse response, MesMsgRecordQueryCriteria criteria) throws IOException { |
| | | // mesMsgRecordService.download(mesMsgRecordService.queryAll(criteria), response); |
| | | // } |
| | | // |
| | | // @GetMapping |
| | | // @ApiOperation("查询消息") |
| | | // @PreAuthorize("@el.check('mesMsgRecord:list')") |
| | | // public ResponseEntity<PageResult<MesMsgRecord>> queryMesMsgRecord(MesMsgRecordQueryCriteria criteria) { |
| | | // Page<Object> page = new Page<>(criteria.getPage(), criteria.getSize()); |
| | | // return new ResponseEntity<>(mesMsgRecordService.queryAll(criteria, page), HttpStatus.OK); |
| | | // } |
| | | // |
| | | // @PostMapping |
| | | // @Log("新增消息") |
| | | // @ApiOperation("新增消息") |
| | | // @PreAuthorize("@el.check('mesMsgRecord:add')") |
| | | // public ResponseEntity<Object> createMesMsgRecord(@Validated @RequestBody MesMsgRecord resources) { |
| | | // mesMsgRecordService.create(resources); |
| | | // return new ResponseEntity<>(HttpStatus.CREATED); |
| | | // } |
| | | // |
| | | // @PutMapping |
| | | // @Log("修改消息") |
| | | // @ApiOperation("修改消息") |
| | | // @PreAuthorize("@el.check('mesMsgRecord:edit')") |
| | | // public ResponseEntity<Object> updateMesMsgRecord(@Validated @RequestBody MesMsgRecord resources) { |
| | | // mesMsgRecordService.update(resources); |
| | | // return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | // } |
| | | // |
| | | // @DeleteMapping |
| | | // @Log("删除消息") |
| | | // @ApiOperation("删除消息") |
| | | // @PreAuthorize("@el.check('mesMsgRecord:del')") |
| | | // public ResponseEntity<Object> deleteMesMsgRecord(@ApiParam(value = "传ID数组[]") @RequestBody List<Long> ids) { |
| | | // mesMsgRecordService.deleteAll(ids); |
| | | // return new ResponseEntity<>(HttpStatus.OK); |
| | | // } |
| | | |
| | | |
| | | /* 1. 轮询最新消息(通知栏) */ //todo 轮询啥? |
| | | //只查“未读”消息,不分种类,返回最新 N 条 1=买家 2=商户 3=骑手" |
| | | //只查“未读”消息,不分种类,返回最新 N 条 1=买家 2=商户 3=骑手" 消息类型为系统消息1? |
| | | @GetMapping("/poll") |
| | | @ApiOperation("查询轮询消息 1(买家)、2(商户)、3(骑手)") |
| | | @PreAuthorize("@el.check('mesMsgRecord:list')") |
| | |
| | | |
| | | // 实现业务逻辑,调用服务层获取未读消息 |
| | | try { |
| | | List<MesMsgRecordQueryPollDto> mes=mesMsgRecordService.PollMes(platform); |
| | | // Long system = Long.valueOf(MesTypeEnum.SYSTEM.getKey()); |
| | | // List<MesMsgRecordQueryPollDto> mes = mesMsgRecordService.PollMes(platform, system); |
| | | List<MesMsgRecordQueryPollDto> mes = mesMsgRecordService.PollMesAll(platform); |
| | | |
| | | |
| | | return R.success(mes); |
| | | } catch (Exception e) { |
| | | log.error("查询轮询消息失败:",e); |
| | | return R.fail("查询轮询消息失败"); |
| | | } |
| | | |
| | | |
| | | |
| | | } |
| | |
| | | // @PutMapping("/ack/{msgId}") |
| | | // @ApiOperation("确认收到消息") |
| | | // public R<Void> ack(@PathVariable Long msgId) { |
| | | |
| | | //// mesMsgRecordService.markRead(msgId, null); |
| | | // return R.success(); |
| | | // } |
| | | /* 2. 批量确认收到消息 主键*/ |
| | | @PutMapping("/ack") |
| | | @ApiOperation("批量确认收到消息") |
| | | @ApiOperation("批量确认收到消息 主键ids 1(买家)、2(商户)、3(骑手)") |
| | | public R<Void> batchAck(@ApiParam(value = "消息ID数组") @RequestBody List<Long> msgIds,@RequestParam Long platform) { |
| | | if (msgIds == null || msgIds.isEmpty()) { |
| | | return R.fail("消息ID列表不能为空"); |
| | |
| | | } |
| | | |
| | | /* 4. 用店铺id 查询订单消息 */ |
| | | @GetMapping("/order") |
| | | @ApiOperation("用店铺id 查询订单消息") |
| | | public R<List<MesMsgRecordQueryOrderDto>> order(@PathVariable Long shopId ) { |
| | | // @GetMapping("/order") |
| | | // @ApiOperation("用店铺id 查询订单消息") |
| | | // public R<List<MesMsgRecordQueryOrderDto>> order(@RequestParam Long shopId) { |
| | | // try { |
| | | // List<MesMsgRecordQueryOrderDto> res = mesMsgRecordService.queryorder(shopId); |
| | | // return R.success(res); |
| | | // } catch (Exception e) { |
| | | // log.error("用店铺id 获取订单消息失败,shopId: {}", shopId, e); |
| | | // return R.fail("用店铺id 获取订单消息失败"); |
| | | // |
| | | // } |
| | | // |
| | | // } |
| | | |
| | | //商户端:买家下单提醒 根据商户id 获取买家下单提醒 |
| | | @GetMapping("/order/pending") |
| | | @ApiOperation("商户端:用店铺id 获取下单订单消息") |
| | | public R<List<MesMsgRecordQueryOrderDto>> getPendingOrders(@RequestParam Long shopId) { |
| | | try { |
| | | List<MesMsgRecordQueryOrderDto> res=mesMsgRecordService.queryorder(shopId); |
| | | String content = OrderStatusEnum.MERCHANT_ORDER_SUBMITTED.getValue(); |
| | | List<MesMsgRecordQueryOrderDto> res = mesMsgRecordService.queryorderPending(shopId, content); |
| | | return R.success(res); |
| | | } catch (Exception e) { |
| | | log.error("用店铺id 获取订单消息失败,shopId: {}", shopId, e); |
| | | return R.fail("用店铺id 获取订单消息失败"); |
| | | |
| | | log.error("用店铺id 获取待处理订单消息失败,shopId: {}", shopId, e); |
| | | return R.fail("用店铺id 获取待处理订单消息失败"); |
| | | } |
| | | } |
| | | |
| | | //商户端:订单送达通知 。 根据商户id 获取买家下订单送达 |
| | | @GetMapping("/order/delivered") |
| | | @ApiOperation("商户端:用店铺id 获取订单送达消息") |
| | | public R<List<MesMsgRecordQueryOrderDto>> getDeliveredOrders(@RequestParam Long shopId) { |
| | | try { |
| | | String content = OrderStatusEnum.BUYER_ORDER_STATUS_CHANGED.getValue(); |
| | | List<MesMsgRecordQueryOrderDto> res = mesMsgRecordService.queryorderPending(shopId, content); |
| | | return R.success(res); |
| | | } catch (Exception e) { |
| | | log.error("用店铺id 获取已送达订单消息失败,shopId: {}", shopId, e); |
| | | return R.fail("用店铺id 获取已送达订单消息失败"); |
| | | } |
| | | } |
| | | |
| | | //买家端:订单状态变化通知 |
| | | @GetMapping("/buyer/order/status") |
| | | @ApiOperation("买家端:获取订单状态变化消息") |
| | | public R<List<MesMsgRecordQueryOrderDto>> getBuyerOrderStatus(@RequestParam Long buyerId) { |
| | | try { |
| | | List<MesMsgRecordQueryOrderDto> res = mesMsgRecordService.queryBuyerOrderMessages(buyerId); |
| | | return R.success(res); |
| | | } catch (Exception e) { |
| | | log.error("买家端获取订单状态变化消息失败,buyerId: {}", buyerId, e); |
| | | return R.fail("获取订单状态变化消息失败"); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | //买家端:订单送达通知 |
| | | @GetMapping("/buyer/order/delivered") |
| | | @ApiOperation("买家端:获取订单送达消息") |
| | | public R<List<MesMsgRecordQueryOrderDto>> getBuyerDeliveredOrders(@RequestParam Long buyerId) { |
| | | try { |
| | | List<MesMsgRecordQueryOrderDto> res = mesMsgRecordService.queryBuyerOrderMessagesComplete(buyerId); |
| | | return R.success(res); |
| | | } catch (Exception e) { |
| | | log.error("买家端获取订单送达消息失败,buyerId: {}", buyerId, e); |
| | | return R.fail("获取订单送达消息失败"); |
| | | } |
| | | } |
| | | |
| | | } |