From 3837e277dd53a37f134f923374f0c0868aea8851 Mon Sep 17 00:00:00 2001 From: zhanglipeng Date: Fri, 25 Dec 2020 15:17:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E9=97=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/BySchoolNewsController.java | 46 ++++++++----------- .../service/impl/BySchoolNewsServiceImpl.java | 4 +- .../mybatis/benyi/BySchoolNewsMapper.xml | 30 ++++++------ 3 files changed, 37 insertions(+), 43 deletions(-) diff --git a/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/BySchoolNewsController.java b/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/BySchoolNewsController.java index 45a13be71..22e5bb63f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/BySchoolNewsController.java +++ b/ruoyi/src/main/java/com/ruoyi/project/benyi/controller/BySchoolNewsController.java @@ -32,34 +32,30 @@ import com.ruoyi.framework.web.page.TableDataInfo; */ @RestController @RequestMapping("/benyi/news") -public class BySchoolNewsController extends BaseController -{ +public class BySchoolNewsController extends BaseController { @Autowired private IBySchoolNewsService bySchoolNewsService; @Autowired private SchoolCommon schoolCommon; -/** - * 查询新闻中心列表 - */ -@PreAuthorize("@ss.hasPermi('benyi:news:list')") -@GetMapping("/list") - public TableDataInfo list(BySchoolNews bySchoolNews) - { - bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId()); + /** + * 查询新闻中心列表 + */ + @PreAuthorize("@ss.hasPermi('benyi:news:list')") + @GetMapping("/list") + public TableDataInfo list(BySchoolNews bySchoolNews) { startPage(); List list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews); return getDataTable(list); } - + /** * 导出新闻中心列表 */ @PreAuthorize("@ss.hasPermi('benyi:news:export')") @Log(title = "新闻中心", businessType = BusinessType.EXPORT) @GetMapping("/export") - public AjaxResult export(BySchoolNews bySchoolNews) - { + public AjaxResult export(BySchoolNews bySchoolNews) { List list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews); ExcelUtil util = new ExcelUtil(BySchoolNews.class); return util.exportExcel(list, "news"); @@ -70,8 +66,7 @@ public class BySchoolNewsController extends BaseController */ @PreAuthorize("@ss.hasPermi('benyi:news:query')") @GetMapping(value = "/{id}") - public AjaxResult getInfo(@PathVariable("id") Long id) - { + public AjaxResult getInfo(@PathVariable("id") Long id) { return AjaxResult.success(bySchoolNewsService.selectBySchoolNewsById(id)); } @@ -81,15 +76,12 @@ public class BySchoolNewsController extends BaseController @PreAuthorize("@ss.hasPermi('benyi:news:add')") @Log(title = "新闻中心", businessType = BusinessType.INSERT) @PostMapping - public AjaxResult add(@RequestBody BySchoolNews bySchoolNews) - { - bySchoolNews.setIsdel("N"); - bySchoolNews.setCreateTime(new Date()); - bySchoolNews.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId()); - bySchoolNews.setIscheck("N"); - bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId()); - bySchoolNews.setType("1"); - return toAjax(bySchoolNewsService.insertBySchoolNews(bySchoolNews)); + public AjaxResult add(@RequestBody BySchoolNews bySchoolNews) { + bySchoolNews.setCreateTime(new Date()); + bySchoolNews.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId()); + bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId()); + bySchoolNews.setType("1"); + return toAjax(bySchoolNewsService.insertBySchoolNews(bySchoolNews)); } /** @@ -98,8 +90,7 @@ public class BySchoolNewsController extends BaseController @PreAuthorize("@ss.hasPermi('benyi:news:edit')") @Log(title = "新闻中心", businessType = BusinessType.UPDATE) @PutMapping - public AjaxResult edit(@RequestBody BySchoolNews bySchoolNews) - { + public AjaxResult edit(@RequestBody BySchoolNews bySchoolNews) { return toAjax(bySchoolNewsService.updateBySchoolNews(bySchoolNews)); } @@ -109,8 +100,7 @@ public class BySchoolNewsController extends BaseController @PreAuthorize("@ss.hasPermi('benyi:news:remove')") @Log(title = "新闻中心", businessType = BusinessType.DELETE) @DeleteMapping("/{ids}") - public AjaxResult remove(@PathVariable Long[] ids) - { + public AjaxResult remove(@PathVariable Long[] ids) { return toAjax(bySchoolNewsService.deleteBySchoolNewsByIds(ids)); } } diff --git a/ruoyi/src/main/java/com/ruoyi/project/benyi/service/impl/BySchoolNewsServiceImpl.java b/ruoyi/src/main/java/com/ruoyi/project/benyi/service/impl/BySchoolNewsServiceImpl.java index 5ebe64907..ee1cb3c56 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/benyi/service/impl/BySchoolNewsServiceImpl.java +++ b/ruoyi/src/main/java/com/ruoyi/project/benyi/service/impl/BySchoolNewsServiceImpl.java @@ -2,7 +2,8 @@ package com.ruoyi.project.benyi.service.impl; import java.util.List; import com.ruoyi.common.utils.DateUtils; - import org.springframework.beans.factory.annotation.Autowired; +import com.ruoyi.framework.aspectj.lang.annotation.DataScope; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.project.benyi.mapper.BySchoolNewsMapper; import com.ruoyi.project.benyi.domain.BySchoolNews; @@ -39,6 +40,7 @@ public class BySchoolNewsServiceImpl implements IBySchoolNewsService * @return 新闻中心 */ @Override + @DataScope(deptAlias = "d") public List selectBySchoolNewsList(BySchoolNews bySchoolNews) { return bySchoolNewsMapper.selectBySchoolNewsList(bySchoolNews); diff --git a/ruoyi/src/main/resources/mybatis/benyi/BySchoolNewsMapper.xml b/ruoyi/src/main/resources/mybatis/benyi/BySchoolNewsMapper.xml index f518fc995..52d9e99df 100644 --- a/ruoyi/src/main/resources/mybatis/benyi/BySchoolNewsMapper.xml +++ b/ruoyi/src/main/resources/mybatis/benyi/BySchoolNewsMapper.xml @@ -22,30 +22,32 @@ - select id, title, imgurl, abstractcontent, type, content, isdel, createuserid, create_time, dept_id, istop, ischeck, checkuserid, check_time from by_school_news + select d.id, d.title, d.imgurl, d.abstractcontent, d.type, d.content, d.isdel, d.createuserid, d.create_time, d.dept_id, d.istop, d.ischeck, d.checkuserid, d.check_time from by_school_news d