| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- package com.ylx.web.controller.massage;
- import com.alibaba.fastjson.JSON;
- import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
- import com.ylx.common.annotation.Log;
- import com.ylx.common.core.domain.R;
- import com.ylx.common.enums.BusinessType;
- import com.ylx.common.exception.ServiceException;
- import com.ylx.massage.domain.TLbt;
- import com.ylx.massage.service.TLbtService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.web.bind.annotation.RequestBody;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import javax.annotation.Resource;
- import java.util.List;
- /**
- * 轮播图 前端控制器
- */
- @RestController
- @RequestMapping("/api/lbt/v1")
- @Slf4j
- @Api(tags = {"轮播图管理"})
- public class TLbtController {
- @Resource
- private TLbtService lbtService;
- /**
- * 获取轮播图
- *
- * @return R<List<TLbt>>
- */
- @ApiOperation("获取轮播图")
- @RequestMapping(value = "/getAll", method = RequestMethod.GET)
- public R<List<TLbt>> getAll() {
- try {
- QueryWrapper<TLbt> wrapper = new QueryWrapper<>();
- wrapper.lambda().orderByAsc(TLbt::getCSort);
- List<TLbt> list = lbtService.list(wrapper);
- return R.ok(list);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 添加或者更新轮播图
- *
- * @param lbt
- * @return R
- */
- @Log(title = "轮播图管理", businessType = BusinessType.INSERT)
- @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST)
- @ApiOperation("添加或者更新轮播图")
- public R addOrUpdate(@RequestBody TLbt lbt) {
- try {
- log.info("请求参数:{}", JSON.toJSONString(lbt));
- return R.ok(lbtService.addOrUpdate(lbt));
- } catch (ServiceException s) {
- log.error(s.toString());
- return R.fail(s.getMessage());
- } catch (Exception e) {
- log.error(e.toString());
- return R.fail("系统异常");
- }
- }
- /**
- * 分页查询轮播图数据
- * @param page
- * @param lbt
- * @return R<Page<TLbt>>
- */
- @ApiOperation("分页查询数据")
- @RequestMapping(value = "/select", method = RequestMethod.GET)
- public R<Page<TLbt>> selectSpfl(Page<TLbt> page, TLbt lbt) {
- try {
- LambdaQueryWrapper<TLbt> tLbtLambdaQueryWrapper = new LambdaQueryWrapper<>();
- tLbtLambdaQueryWrapper.like(StringUtils.isNotBlank(lbt.getCDescribe()), TLbt::getCDescribe, lbt.getCDescribe())
- .orderByAsc(TLbt::getCSort);
- // 获取查询返回结果
- Page<TLbt> pageSelect = lbtService.page(page, tLbtLambdaQueryWrapper);
- return R.ok(pageSelect);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException(e);
- }
- }
- /**
- * 删除轮播图
- *
- * @param tLbt
- * @return R
- */
- @Log(title = "轮播图管理", businessType = BusinessType.DELETE)
- @RequestMapping(value = "/del", method = RequestMethod.POST)
- @ApiOperation("删除轮播图")
- public R del(@RequestBody TLbt tLbt) {
- try {
- return R.ok(lbtService.del(tLbt));
- } catch (ServiceException s) {
- log.error(s.toString());
- return R.fail(s.getMessage());
- } catch (Exception e) {
- log.error(e.toString());
- return R.fail("系统异常");
- }
- }
- /**
- * 根据id查询轮播图
- *
- * @param tLbt
- * @return R
- */
- @ApiOperation("根据id查询轮播图")
- @RequestMapping(value = "/wx/getByid", method = RequestMethod.POST)
- public R getById(@RequestBody TLbt tLbt) {
- return R.ok(lbtService.getById(tLbt.getCId()));
- }
- }
|