news demo

This commit is contained in:
王洪庆 2023-03-31 18:33:24 +08:00
parent d634e1037c
commit a10b8497da
5 changed files with 24 additions and 3 deletions

View File

@ -41,9 +41,8 @@ public class NewsController {
public R<List<News>> getNews(String content) { public R<List<News>> getNews(String content) {
// LambdaQueryWrapper<News> qr = new LambdaQueryWrapper<>(); // LambdaQueryWrapper<News> qr = new LambdaQueryWrapper<>();
// qr.like(News::getContent, content); // qr.like(News::getContent, content);
//List<News> list = newsService.list(Wrappers.<News>lambdaQuery().like(News::getContent, content)); List<News> list = newsService.list(Wrappers.<News>lambdaQuery().like(News::getContent, content));
return R.data(list);
return R.data(newsService.getNewsInfo());
} }
@ApiOperationSupport(order = 2) @ApiOperationSupport(order = 2)
@ApiOperation(value = "列表", notes = "传入news") @ApiOperation(value = "列表", notes = "传入news")

View File

@ -2,7 +2,11 @@ package com.kening.vordm.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kening.vordm.entity.News; import com.kening.vordm.entity.News;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* @author G1393 * @author G1393
@ -12,5 +16,6 @@ import com.kening.vordm.entity.News;
*/ */
public interface NewsMapper extends BaseMapper<News> { public interface NewsMapper extends BaseMapper<News> {
List<News> selectNewsPage(IPage<News> page, @Param("title") String title);
} }

View File

@ -23,4 +23,9 @@
create_time,status,manager_id, create_time,status,manager_id,
review_time review_time
</sql> </sql>
<select id="selectNewsPage" resultMap="BaseResultMap">
select * from news where title like CONCAT(CONCAT('%', #{title}), '%')
</select>
</mapper> </mapper>

View File

@ -1,5 +1,6 @@
package com.kening.vordm.service; package com.kening.vordm.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.kening.vordm.entity.News; import com.kening.vordm.entity.News;
@ -10,4 +11,6 @@ import com.kening.vordm.entity.News;
*/ */
public interface NewsService extends IService<News> { public interface NewsService extends IService<News> {
IPage<News> selectNewsPage(IPage<News> page, String title);
} }

View File

@ -1,11 +1,14 @@
package com.kening.vordm.service.impl; package com.kening.vordm.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kening.vordm.entity.News; import com.kening.vordm.entity.News;
import com.kening.vordm.mapper.NewsMapper; import com.kening.vordm.mapper.NewsMapper;
import com.kening.vordm.service.NewsService; import com.kening.vordm.service.NewsService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* @author G1393 * @author G1393
* @description 针对表news(新闻咨询数据表)的数据库操作Service实现 * @description 针对表news(新闻咨询数据表)的数据库操作Service实现
@ -15,4 +18,10 @@ import org.springframework.stereotype.Service;
public class NewsServiceImpl extends ServiceImpl<NewsMapper, News> public class NewsServiceImpl extends ServiceImpl<NewsMapper, News>
implements NewsService { implements NewsService {
@Override
public IPage<News> selectNewsPage(IPage<News> page, String title) {
List<News> news = this.baseMapper.selectNewsPage(page, title);
return page.setRecords(news);
}
} }