| | |
| | | package com.ruoyi.web.controller.api; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.system.dto.IdDto; |
| | | import com.ruoyi.system.model.TBanner; |
| | | import com.ruoyi.system.model.TNotice; |
| | | import com.ruoyi.system.service.TBannerService; |
| | | import com.ruoyi.system.service.TNoticeService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.RequiredArgsConstructor; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | |
| | |
| | | @RestController |
| | | @RequestMapping("/index") |
| | | @Api(tags = "首页模块") |
| | | @RequiredArgsConstructor(onConstructor_ = {@Lazy}) |
| | | public class IndexController { |
| | | |
| | | private final TBannerService tBannerService; |
| | | private final TNoticeService tNoticeService; |
| | | |
| | | public IndexController(TBannerService tBannerService, TNoticeService tNoticeService) { |
| | | this.tBannerService = tBannerService; |
| | | this.tNoticeService = tNoticeService; |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "首页模块--轮播图",response = TBanner.class) |
| | |
| | | TBanner tBanner = tBannerService.getById(id); |
| | | return R.ok(tBanner); |
| | | } |
| | | |
| | | |
| | | @ApiOperation(value = "首页模块--公告活动",response = TNotice.class) |
| | | @GetMapping(value = "/getNoticeList") |
| | | public R<List<TNotice>> getNoticeList() { |
| | | List<TNotice> tNoticeList = tNoticeService.list(); |
| | | return R.ok(tNoticeList); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "首页模块--公告活动详情",response = TNotice.class) |
| | | @GetMapping(value = "/getNoticeDetail/{id}") |
| | | public R<TNotice> getNoticeDetail(@PathVariable String id) { |
| | | TNotice notice = tNoticeService.getById(id); |
| | | notice.setReadCount(notice.getReadCount() + 1); |
| | | tNoticeService.updateById(notice); |
| | | return R.ok(notice); |
| | | } |
| | | |
| | | |
| | | } |