|
| 1 | +package com.github.cadecode.uniboot.framework.base.plugin.controller; |
| 2 | + |
| 3 | +import cn.hutool.core.util.ObjUtil; |
| 4 | +import com.github.cadecode.uniboot.common.core.web.response.PageResult; |
| 5 | +import com.github.cadecode.uniboot.framework.base.annotation.ApiFormat; |
| 6 | +import com.github.cadecode.uniboot.framework.base.plugin.bean.po.PlgMqMsg; |
| 7 | +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgPageReqVo; |
| 8 | +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgPageResVo; |
| 9 | +import com.github.cadecode.uniboot.framework.base.plugin.bean.vo.PlgMqMsgVo.PlgMqMsgUpdateReqVo; |
| 10 | +import com.github.cadecode.uniboot.framework.base.plugin.convert.PlgMqMsgConvert; |
| 11 | +import com.github.cadecode.uniboot.framework.base.plugin.service.PlgMqMsgService; |
| 12 | +import com.github.pagehelper.PageHelper; |
| 13 | +import com.github.pagehelper.PageInfo; |
| 14 | +import io.swagger.annotations.Api; |
| 15 | +import io.swagger.annotations.ApiOperation; |
| 16 | +import lombok.RequiredArgsConstructor; |
| 17 | +import lombok.extern.slf4j.Slf4j; |
| 18 | +import org.springframework.validation.annotation.Validated; |
| 19 | +import org.springframework.web.bind.annotation.PostMapping; |
| 20 | +import org.springframework.web.bind.annotation.RequestBody; |
| 21 | +import org.springframework.web.bind.annotation.RequestMapping; |
| 22 | +import org.springframework.web.bind.annotation.RestController; |
| 23 | + |
| 24 | +import javax.validation.Valid; |
| 25 | +import javax.validation.constraints.NotEmpty; |
| 26 | +import java.util.List; |
| 27 | + |
| 28 | +/** |
| 29 | + * MQ 消息管理 |
| 30 | + * |
| 31 | + * @author Cade Li |
| 32 | + * @since 2023/8/19 |
| 33 | + */ |
| 34 | +@ApiFormat |
| 35 | +@Slf4j |
| 36 | +@RequiredArgsConstructor |
| 37 | +@Api(tags = "MQ 管理") |
| 38 | +@RequestMapping("plugin/mq_msg") |
| 39 | +@RestController |
| 40 | +@Validated |
| 41 | +public class PlgMqMsgController { |
| 42 | + |
| 43 | + private final PlgMqMsgService mqMsgService; |
| 44 | + |
| 45 | + @ApiOperation("查询列表") |
| 46 | + @PostMapping("page") |
| 47 | + public PageResult<PlgMqMsgPageResVo> page(@RequestBody @Valid PlgMqMsgPageReqVo reqVo) { |
| 48 | + PageInfo<PlgMqMsg> pageInfo = PageHelper.startPage(reqVo.getPageNumber(), reqVo.getPageSize()) |
| 49 | + .doSelectPageInfo(() -> mqMsgService.lambdaQuery() |
| 50 | + .ge(ObjUtil.isNotEmpty(reqVo.getStartCreateTime()), PlgMqMsg::getCreateTime, reqVo.getStartCreateTime()) |
| 51 | + .le(ObjUtil.isNotEmpty(reqVo.getEndCreateTime()), PlgMqMsg::getCreateTime, reqVo.getEndCreateTime()) |
| 52 | + .eq(ObjUtil.isNotEmpty(reqVo.getBizType()), PlgMqMsg::getBizType, reqVo.getBizType()) |
| 53 | + .in(ObjUtil.isNotEmpty(reqVo.getSendStateList()), PlgMqMsg::getSendState, reqVo.getSendStateList()) |
| 54 | + .orderByDesc(PlgMqMsg::getCreateTime) |
| 55 | + .list()); |
| 56 | + List<PlgMqMsgPageResVo> voList = PlgMqMsgConvert.INSTANCE.poToPageResVo(pageInfo.getList()); |
| 57 | + return new PageResult<>((int) pageInfo.getTotal(), voList); |
| 58 | + } |
| 59 | + |
| 60 | + @ApiOperation("更新") |
| 61 | + @PostMapping("update") |
| 62 | + public boolean update(@RequestBody @Valid PlgMqMsgUpdateReqVo reqVo) { |
| 63 | + PlgMqMsg po = PlgMqMsgConvert.INSTANCE.voToPo(reqVo); |
| 64 | + return mqMsgService.updateById(po); |
| 65 | + } |
| 66 | + |
| 67 | + @ApiOperation("查询-byIdList") |
| 68 | + @PostMapping("list_by_id_list") |
| 69 | + public List<PlgMqMsgPageResVo> listByIdList(@RequestBody @NotEmpty List<String> idList) { |
| 70 | + List<PlgMqMsg> poList = mqMsgService.listByIds(idList); |
| 71 | + return PlgMqMsgConvert.INSTANCE.poToPageResVo(poList); |
| 72 | + } |
| 73 | +} |
0 commit comments