TLbtController.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. package com.ylx.web.controller.massage;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  5. import com.ylx.common.constant.MassageConstants;
  6. import com.ylx.common.core.domain.R;
  7. import com.ylx.common.utils.uuid.IdUtils;
  8. import com.ylx.massage.domain.TLbt;
  9. import com.ylx.massage.service.TLbtService;
  10. import io.swagger.annotations.Api;
  11. import io.swagger.annotations.ApiOperation;
  12. import lombok.extern.slf4j.Slf4j;
  13. import org.apache.commons.lang3.StringUtils;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RequestMethod;
  17. import org.springframework.web.bind.annotation.RestController;
  18. import javax.annotation.Resource;
  19. import java.util.List;
  20. /**
  21. * 轮播图 前端控制器
  22. */
  23. @RestController
  24. @RequestMapping("/api/lbt/v1")
  25. @Slf4j
  26. @Api(tags = {"轮播图管理"})
  27. public class TLbtController {
  28. @Resource
  29. private TLbtService lbtService;
  30. /**
  31. * 获取轮播图
  32. *
  33. * @return
  34. */
  35. @ApiOperation("获取轮播图")
  36. @RequestMapping(value = "/getAll", method = RequestMethod.POST)
  37. public R<List<TLbt>> getAll() {
  38. QueryWrapper<TLbt> wrapper = new QueryWrapper<>();
  39. wrapper.lambda().eq(TLbt::getnDel, MassageConstants.INTEGER_ZERO);
  40. List<TLbt> list = lbtService.list(wrapper);
  41. return R.ok(list);
  42. }
  43. /**
  44. * 添加或者更新轮播图
  45. *
  46. * @param lbt
  47. * @return
  48. */
  49. @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST)
  50. @ApiOperation("添加或者更新轮播图")
  51. public R addOrUpdate(@RequestBody TLbt lbt) {
  52. try {
  53. if (StringUtils.isBlank(lbt.getcId())) {
  54. lbt.setcId(IdUtils.fastSimpleUUID());
  55. }
  56. return R.ok(lbtService.saveOrUpdate(lbt));
  57. } catch (Exception e) {
  58. log.error("addOrUpdate出现异常", e);
  59. return R.fail();
  60. }
  61. }
  62. /**
  63. * 分页查询数据
  64. */
  65. @ApiOperation("分页查询数据")
  66. @RequestMapping(value = "/select", method = RequestMethod.GET)
  67. public R<Page<TLbt>> selectSpfl(Page<TLbt> page, TLbt lbt) {
  68. LambdaQueryWrapper<TLbt> tLbtLambdaQueryWrapper = new LambdaQueryWrapper<>();
  69. tLbtLambdaQueryWrapper.eq(TLbt::getnDel, MassageConstants.INTEGER_ZERO).
  70. like(StringUtils.isNotBlank(lbt.getcDescribe()), TLbt::getcDescribe, lbt.getcDescribe());
  71. // 获取查询返回结果
  72. Page<TLbt> pageSelect = lbtService.page(page, tLbtLambdaQueryWrapper);
  73. return R.ok(pageSelect);
  74. }
  75. @RequestMapping(value = "/del", method = RequestMethod.POST)
  76. @ApiOperation("删除轮播图")
  77. public R del(@RequestBody TLbt tLbt) {
  78. TLbt tSpflNew = new TLbt();
  79. tSpflNew.setcId(tLbt.getcId());
  80. tSpflNew.setnDel(MassageConstants.INTEGER_ONE);
  81. return R.ok(lbtService.updateById(tSpflNew));
  82. }
  83. @ApiOperation("根据id查询轮播图")
  84. @RequestMapping(value = "/wx/getByid", method = RequestMethod.POST)
  85. public R getById(@RequestBody TLbt tLbt) {
  86. return R.ok(lbtService.getById(tLbt.getcId()));
  87. }
  88. }