123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package com.txz.mall.controller.appcontroller;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import com.txz.mall.core.Result;
- import com.txz.mall.core.ResultCode;
- import com.txz.mall.model.Banner;
- import com.txz.mall.service.BannerService;
- import com.txz.mall.web.param.BannerParam;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.web.bind.annotation.*;
- import tk.mybatis.mapper.entity.Condition;
- import tk.mybatis.mapper.entity.Example.Criteria;
- import javax.annotation.Resource;
- import java.util.Date;
- import java.util.List;
- /**
- * Created by CodeGenerator on 2025/08/05.
- */
- @Api(tags = "app轮播图管理")
- @RestController
- @RequestMapping("/app/banner")
- public class AppBannerController {
- private static Logger log = LoggerFactory.getLogger(AppBannerController.class);
- @Resource
- private BannerService bannerService;
- // @PostMapping("/add")
- // @ApiOperation(value = "轮播图新增")
- // public Result add(@RequestBody Banner banner) {
- // if (banner == null) {
- // return Result.fail(ResultCode.OBJECT_IS_NULL);
- // }
- // try {
- // banner.setCreateTime(new Date());
- //// banner.setCreateUserId(userId);
- // bannerService.save(banner);
- // } catch (Exception e) {
- // log.error("新增对象操作异常e:{}", e);
- // return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- // }
- // return Result.success();
- // }
- //
- // @DeleteMapping("/delete")
- // @ApiOperation(value = "轮播图删除")
- // public Result delete(@RequestParam Long id) {
- // if (id == null) {
- // return Result.fail(ResultCode.ID_IS_NULL);
- // }
- // try {
- // Banner banner = new Banner();
- // banner.setId(id);
- // banner.setIsDelete(1);
- // bannerService.update(banner);
- // } catch (Exception e) {
- // log.error("删除对象操作异常e:{}", e);
- // return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- // }
- // return Result.success();
- // }
- //
- // @PutMapping("/update")
- // @ApiOperation(value = "轮播图更新")
- // public Result update(@RequestBody Banner banner) {
- // if (banner == null) {
- // return Result.fail(ResultCode.OBJECT_IS_NULL);
- // }
- // if (banner.getId() == null) {
- // return Result.fail(ResultCode.ID_IS_NULL);
- // }
- // try {
- // banner.setUpdateTime(new Date());
- //// banner.setUpdateUserId(userId);
- // bannerService.update(banner);
- // } catch (Exception e) {
- // log.error("更新对象操作异常e:{}", e);
- // return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- // }
- // return Result.success();
- // }
- @GetMapping("/detail")
- @ApiOperation(value = "轮播图获取详情")
- public Result<Banner> detail(@RequestParam Long id) {
- if (id == null) {
- return Result.fail(ResultCode.ID_IS_NULL);
- }
- Banner banner = null;
- try {
- banner = bannerService.findById(id);
- } catch (Exception e) {
- log.error("查询对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success(banner);
- }
- @PostMapping("/list")
- @ApiOperation(value = "轮播图获取列表")
- public Result<List<Banner>> list(@RequestBody BannerParam banner) {
- PageHelper.startPage(banner.getPage(), banner.getSize());
- Condition condition = new Condition(Banner.class);
- Criteria criteria = condition.createCriteria();
- criteria.andEqualTo("isDelete", 0);
- condition.setOrderByClause("create_time DESC");
- PageInfo pageInfo = null;
- try {
- List<Banner> list = bannerService.findByCondition(condition);
- pageInfo = new PageInfo(list);
- } catch (Exception e) {
- log.error("查询对象操作异常e:{}", e);
- return Result.fail(ResultCode.INTERNAL_SERVER_ERROR);
- }
- return Result.success(pageInfo);
- }
- }
|