zj
2024-03-27 2c9a5fa4b53955033b1bd2ac637dea0728808551
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package org.example.controller;
 
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.example.common.ServerResponse;
import org.example.dao.JournalismMapper;
import org.example.pojo.Journalism;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
/**
 * @program: webSocketProject
 * @description: 新闻
 * @create: 2024-03-27 14:03
 **/
@RestController
@RequestMapping("/api/news/")
public class JournalismController {
 
    @Autowired
    JournalismMapper journalismMapper;
 
    @GetMapping("getNewsListAll.do")
    public ServerResponse JournalismAll(){
        LambdaQueryWrapper<Journalism> queryWrapper = new LambdaQueryWrapper<>();
        return ServerResponse.createBySuccess(journalismMapper.selectList(queryWrapper));
    }
 
    @GetMapping("getNewsList.do")
    public ServerResponse JournalismNumber(){
        LambdaQueryWrapper<Journalism>  queryWrapper  =  new  LambdaQueryWrapper<>();
        queryWrapper.orderByDesc(Journalism::getTime).last("limit  20");
        return ServerResponse.createBySuccess(journalismMapper.selectList(queryWrapper));
    }
 
}