| | |
| | | package com.jilongda.manage.controller; |
| | | |
| | | |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.jilongda.common.Ticket.TicketUtil; |
| | | import com.jilongda.common.basic.ApiResult; |
| | | import com.jilongda.common.basic.PageInfo; |
| | | import com.jilongda.manage.model.TStore; |
| | | import com.jilongda.manage.model.TTicket; |
| | | import com.jilongda.manage.query.TicketQuery; |
| | | import com.jilongda.manage.service.TStoreService; |
| | | import com.jilongda.manage.service.TTicketService; |
| | | import com.jilongda.manage.vo.TTicketVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | * @author 无关风月 |
| | | * @since 2024-12-09 |
| | | */ |
| | | @Api(tags = "小票机") |
| | | @RestController |
| | | @RequestMapping("/t-ticket") |
| | | public class TTicketController { |
| | | |
| | | |
| | | |
| | | @Autowired |
| | | private TTicketService tTicketService; |
| | | @Autowired |
| | | private TStoreService storeService; |
| | | |
| | | @ApiOperation(value = "小票机列表") |
| | | @PostMapping(value = "/pageList") |
| | | public ApiResult<PageInfo<TTicketVO>> pageList(@RequestBody TicketQuery query) { |
| | | PageInfo<TTicketVO> ticketVOPageInfo = tTicketService.pageList(query); |
| | | return ApiResult.success(ticketVOPageInfo); |
| | | } |
| | | |
| | | @ApiOperation(value = "小票机添加") |
| | | @PostMapping(value = "/add") |
| | | public ApiResult<String> add(@RequestBody TTicket dto) { |
| | | TStore store = storeService.getById(dto.getStoreId()); |
| | | String res = TicketUtil.addprinter(dto.getCloudId() + "#" + dto.getSecret() + "#" + store.getName()); |
| | | JSONObject result = JSONObject.parseObject(res); |
| | | if (!result.getString("msg").equals("ok")){ |
| | | return ApiResult.failed(result.getString("msg")); |
| | | } |
| | | tTicketService.save(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | @ApiOperation(value = "小票机详情") |
| | | @GetMapping(value = "/detail") |
| | | public ApiResult<TTicket> detail(Integer id) { |
| | | return ApiResult.success(tTicketService.getById(id)); |
| | | } |
| | | @ApiOperation(value = "小票机编辑") |
| | | @PostMapping(value = "/update") |
| | | public ApiResult<String> update(@RequestBody TTicket dto) { |
| | | TStore store = storeService.getById(dto.getStoreId()); |
| | | String res = TicketUtil.editprinter(dto.getCloudId()+"",store.getName()); |
| | | JSONObject result = JSONObject.parseObject(res); |
| | | if (!result.getString("msg").equals("ok")){ |
| | | return ApiResult.failed(result.getString("msg")); |
| | | } |
| | | tTicketService.updateById(dto); |
| | | return ApiResult.success(); |
| | | } |
| | | |
| | | @ApiOperation(value = "小票机上下架") |
| | | @GetMapping(value = "/upAndDown") |
| | | public ApiResult<Boolean> upAndDown(@RequestParam Integer id, |
| | | @RequestParam Integer status) { |
| | | return ApiResult.success(tTicketService.upAndDown(id,status)); |
| | | } |
| | | |
| | | } |
| | | |