package com.ylx.web.controller.massage; 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.constant.MassageConstants; import com.ylx.common.core.domain.R; import com.ylx.common.utils.uuid.IdUtils; 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 */ @ApiOperation("获取轮播图") @RequestMapping(value = "/getAll", method = RequestMethod.POST) public R> getAll() { QueryWrapper wrapper = new QueryWrapper<>(); wrapper.lambda().eq(TLbt::getnDel, MassageConstants.INTEGER_ZERO); List list = lbtService.list(wrapper); return R.ok(list); } /** * 添加或者更新轮播图 * * @param lbt * @return */ @RequestMapping(value = "/addOrUpdate", method = RequestMethod.POST) @ApiOperation("添加或者更新轮播图") public R addOrUpdate(@RequestBody TLbt lbt) { try { if (StringUtils.isBlank(lbt.getcId())) { lbt.setcId(IdUtils.fastSimpleUUID()); } return R.ok(lbtService.saveOrUpdate(lbt)); } catch (Exception e) { log.error("addOrUpdate出现异常", e); return R.fail(); } } /** * 分页查询数据 */ @ApiOperation("分页查询数据") @RequestMapping(value = "/select", method = RequestMethod.GET) public R> selectSpfl(Page page, TLbt lbt) { LambdaQueryWrapper tLbtLambdaQueryWrapper = new LambdaQueryWrapper<>(); tLbtLambdaQueryWrapper.eq(TLbt::getnDel, MassageConstants.INTEGER_ZERO). like(StringUtils.isNotBlank(lbt.getcDescribe()), TLbt::getcDescribe, lbt.getcDescribe()); // 获取查询返回结果 Page pageSelect = lbtService.page(page, tLbtLambdaQueryWrapper); return R.ok(pageSelect); } @RequestMapping(value = "/del", method = RequestMethod.POST) @ApiOperation("删除轮播图") public R del(@RequestBody TLbt tLbt) { TLbt tSpflNew = new TLbt(); tSpflNew.setcId(tLbt.getcId()); tSpflNew.setnDel(MassageConstants.INTEGER_ONE); return R.ok(lbtService.updateById(tSpflNew)); } @ApiOperation("根据id查询轮播图") @RequestMapping(value = "/wx/getByid", method = RequestMethod.POST) public R getById(@RequestBody TLbt tLbt) { return R.ok(lbtService.getById(tLbt.getcId())); } }