This commit is contained in:
zhanglipeng 2020-12-25 15:17:46 +08:00
parent 8650200345
commit 3837e277dd
3 changed files with 37 additions and 43 deletions

View File

@ -32,8 +32,7 @@ import com.ruoyi.framework.web.page.TableDataInfo;
*/ */
@RestController @RestController
@RequestMapping("/benyi/news") @RequestMapping("/benyi/news")
public class BySchoolNewsController extends BaseController public class BySchoolNewsController extends BaseController {
{
@Autowired @Autowired
private IBySchoolNewsService bySchoolNewsService; private IBySchoolNewsService bySchoolNewsService;
@Autowired @Autowired
@ -44,9 +43,7 @@ public class BySchoolNewsController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('benyi:news:list')") @PreAuthorize("@ss.hasPermi('benyi:news:list')")
@GetMapping("/list") @GetMapping("/list")
public TableDataInfo list(BySchoolNews bySchoolNews) public TableDataInfo list(BySchoolNews bySchoolNews) {
{
bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
startPage(); startPage();
List<BySchoolNews> list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews); List<BySchoolNews> list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews);
return getDataTable(list); return getDataTable(list);
@ -58,8 +55,7 @@ public class BySchoolNewsController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:news:export')") @PreAuthorize("@ss.hasPermi('benyi:news:export')")
@Log(title = "新闻中心", businessType = BusinessType.EXPORT) @Log(title = "新闻中心", businessType = BusinessType.EXPORT)
@GetMapping("/export") @GetMapping("/export")
public AjaxResult export(BySchoolNews bySchoolNews) public AjaxResult export(BySchoolNews bySchoolNews) {
{
List<BySchoolNews> list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews); List<BySchoolNews> list = bySchoolNewsService.selectBySchoolNewsList(bySchoolNews);
ExcelUtil<BySchoolNews> util = new ExcelUtil<BySchoolNews>(BySchoolNews.class); ExcelUtil<BySchoolNews> util = new ExcelUtil<BySchoolNews>(BySchoolNews.class);
return util.exportExcel(list, "news"); return util.exportExcel(list, "news");
@ -70,8 +66,7 @@ public class BySchoolNewsController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('benyi:news:query')") @PreAuthorize("@ss.hasPermi('benyi:news:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) public AjaxResult getInfo(@PathVariable("id") Long id) {
{
return AjaxResult.success(bySchoolNewsService.selectBySchoolNewsById(id)); return AjaxResult.success(bySchoolNewsService.selectBySchoolNewsById(id));
} }
@ -81,12 +76,9 @@ public class BySchoolNewsController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:news:add')") @PreAuthorize("@ss.hasPermi('benyi:news:add')")
@Log(title = "新闻中心", businessType = BusinessType.INSERT) @Log(title = "新闻中心", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public AjaxResult add(@RequestBody BySchoolNews bySchoolNews) public AjaxResult add(@RequestBody BySchoolNews bySchoolNews) {
{
bySchoolNews.setIsdel("N");
bySchoolNews.setCreateTime(new Date()); bySchoolNews.setCreateTime(new Date());
bySchoolNews.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId()); bySchoolNews.setCreateuserid(SecurityUtils.getLoginUser().getUser().getUserId());
bySchoolNews.setIscheck("N");
bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId()); bySchoolNews.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
bySchoolNews.setType("1"); bySchoolNews.setType("1");
return toAjax(bySchoolNewsService.insertBySchoolNews(bySchoolNews)); return toAjax(bySchoolNewsService.insertBySchoolNews(bySchoolNews));
@ -98,8 +90,7 @@ public class BySchoolNewsController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:news:edit')") @PreAuthorize("@ss.hasPermi('benyi:news:edit')")
@Log(title = "新闻中心", businessType = BusinessType.UPDATE) @Log(title = "新闻中心", businessType = BusinessType.UPDATE)
@PutMapping @PutMapping
public AjaxResult edit(@RequestBody BySchoolNews bySchoolNews) public AjaxResult edit(@RequestBody BySchoolNews bySchoolNews) {
{
return toAjax(bySchoolNewsService.updateBySchoolNews(bySchoolNews)); return toAjax(bySchoolNewsService.updateBySchoolNews(bySchoolNews));
} }
@ -109,8 +100,7 @@ public class BySchoolNewsController extends BaseController
@PreAuthorize("@ss.hasPermi('benyi:news:remove')") @PreAuthorize("@ss.hasPermi('benyi:news:remove')")
@Log(title = "新闻中心", businessType = BusinessType.DELETE) @Log(title = "新闻中心", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) public AjaxResult remove(@PathVariable Long[] ids) {
{
return toAjax(bySchoolNewsService.deleteBySchoolNewsByIds(ids)); return toAjax(bySchoolNewsService.deleteBySchoolNewsByIds(ids));
} }
} }

View File

@ -2,6 +2,7 @@ package com.ruoyi.project.benyi.service.impl;
import java.util.List; import java.util.List;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.project.benyi.mapper.BySchoolNewsMapper; import com.ruoyi.project.benyi.mapper.BySchoolNewsMapper;
@ -39,6 +40,7 @@ public class BySchoolNewsServiceImpl implements IBySchoolNewsService
* @return 新闻中心 * @return 新闻中心
*/ */
@Override @Override
@DataScope(deptAlias = "d")
public List<BySchoolNews> selectBySchoolNewsList(BySchoolNews bySchoolNews) public List<BySchoolNews> selectBySchoolNewsList(BySchoolNews bySchoolNews)
{ {
return bySchoolNewsMapper.selectBySchoolNewsList(bySchoolNews); return bySchoolNewsMapper.selectBySchoolNewsList(bySchoolNews);

View File

@ -22,30 +22,32 @@
</resultMap> </resultMap>
<sql id="selectBySchoolNewsVo"> <sql id="selectBySchoolNewsVo">
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
</sql> </sql>
<select id="selectBySchoolNewsList" parameterType="BySchoolNews" resultMap="BySchoolNewsResult"> <select id="selectBySchoolNewsList" parameterType="BySchoolNews" resultMap="BySchoolNewsResult">
<include refid="selectBySchoolNewsVo"/> <include refid="selectBySchoolNewsVo"/>
<where> <where>
<if test="title != null and title != ''">and title = #{title}</if> d.isdel = 'N'
<if test="imgurl != null and imgurl != ''">and imgurl = #{imgurl}</if> <if test="title != null and title != ''">and d.title = #{title}</if>
<if test="abstractcontent != null and abstractcontent != ''">and abstractcontent = #{abstractcontent}</if> <if test="imgurl != null and imgurl != ''">and d.imgurl = #{imgurl}</if>
<if test="type != null and type != ''">and type = #{type}</if> <if test="abstractcontent != null and abstractcontent != ''">and d.abstractcontent = #{abstractcontent}</if>
<if test="content != null and content != ''">and content = #{content}</if> <if test="type != null and type != ''">and d.type = #{type}</if>
<if test="isdel != null and isdel != ''">and isdel = #{isdel}</if> <if test="content != null and content != ''">and d.content = #{content}</if>
<if test="createuserid != null ">and createuserid = #{createuserid}</if> <if test="createuserid != null ">and d.createuserid = #{createuserid}</if>
<if test="deptId != null ">and dept_id = #{deptId}</if> <if test="deptId != null ">and d.dept_id = #{deptId}</if>
<if test="istop != null and istop != ''">and istop = #{istop}</if> <if test="istop != null and istop != ''">and d.istop = #{istop}</if>
<if test="ischeck != null and ischeck != ''">and ischeck = #{ischeck}</if> <if test="ischeck != null and ischeck != ''">and d.ischeck = #{ischeck}</if>
<if test="checkuserid != null ">and checkuserid = #{checkuserid}</if> <if test="checkuserid != null ">and d.checkuserid = #{checkuserid}</if>
<if test="checkTime != null ">and check_time = #{checkTime}</if> <if test="checkTime != null ">and d.check_time = #{checkTime}</if>
</where> </where>
<!-- 数据范围过滤 -->
${dataScope}
</select> </select>
<select id="selectBySchoolNewsById" parameterType="Long" resultMap="BySchoolNewsResult"> <select id="selectBySchoolNewsById" parameterType="Long" resultMap="BySchoolNewsResult">
<include refid="selectBySchoolNewsVo"/> <include refid="selectBySchoolNewsVo"/>
where id = #{id} where d.id = #{id}
</select> </select>
<insert id="insertBySchoolNews" parameterType="BySchoolNews" useGeneratedKeys="true" keyProperty="id"> <insert id="insertBySchoolNews" parameterType="BySchoolNews" useGeneratedKeys="true" keyProperty="id">