Commit 6304c8c2 by rongkailun

【新增】图片资讯功能新增

parent f9f826b1
...@@ -43,7 +43,8 @@ public class NewsController extends AbstractController { ...@@ -43,7 +43,8 @@ public class NewsController extends AbstractController {
public R list(@RequestBody NewsParams newsParams) { public R list(@RequestBody NewsParams newsParams) {
Page<NewsEntity> page = this.newsService.selectNewsList(newsParams, Page<NewsEntity> page = this.newsService.selectNewsList(newsParams,
new Page(newsParams.getPage(),newsParams.getLimit())); new Page(newsParams.getPage(),newsParams.getLimit()));
return R.ok().put("page", page); PageUtils pageUtils = new PageUtils(page);
return R.ok().put("page", pageUtils);
} }
......
...@@ -4,10 +4,12 @@ import java.util.Arrays; ...@@ -4,10 +4,12 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.utils.PageUtils; import io.office.common.utils.PageUtils;
import io.office.common.utils.R; import io.office.common.utils.R;
import io.office.modules.manage.entity.NewsEntity; import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.manage.entity.PictureEntity; import io.office.modules.manage.entity.PictureEntity;
import io.office.modules.manage.entity.dto.PictureParams;
import io.office.modules.manage.service.PictureService; import io.office.modules.manage.service.PictureService;
import io.office.modules.sys.controller.AbstractController; import io.office.modules.sys.controller.AbstractController;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
...@@ -34,9 +36,11 @@ public class PictureController extends AbstractController { ...@@ -34,9 +36,11 @@ public class PictureController extends AbstractController {
*/ */
@RequestMapping("/list") @RequestMapping("/list")
// @RequiresPermissions("generator:picture:list") // @RequiresPermissions("generator:picture:list")
public R list(@RequestParam Map<String, Object> params){ public R list(@RequestBody PictureParams params){
PageUtils page = pictureService.queryPage(params); Page<PictureEntity> page = this.pictureService.selectPictureList(params,
return R.ok().put("page", page); new Page(params.getPage(),params.getLimit()));
PageUtils pageUtils = new PageUtils(page);
return R.ok().put("page", pageUtils);
} }
...@@ -86,7 +90,7 @@ public class PictureController extends AbstractController { ...@@ -86,7 +90,7 @@ public class PictureController extends AbstractController {
*/ */
@RequestMapping("/delete") @RequestMapping("/delete")
// @RequiresPermissions("generator:picture:delete") // @RequiresPermissions("generator:picture:delete")
public R delete(@RequestBody List ids){ public R delete(@RequestBody List<Long> ids){
try { try {
R r = this.pictureService.deletePicture(ids, getUser()); R r = this.pictureService.deletePicture(ids, getUser());
return r; return r;
......
package io.office.modules.manage.dao; package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.PictureEntity; import io.office.modules.manage.entity.PictureEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.office.modules.manage.entity.dto.PictureParams;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* ${comments} * ${comments}
...@@ -13,5 +18,6 @@ import org.apache.ibatis.annotations.Mapper; ...@@ -13,5 +18,6 @@ import org.apache.ibatis.annotations.Mapper;
*/ */
@Mapper @Mapper
public interface PictureDao extends BaseMapper<PictureEntity> { public interface PictureDao extends BaseMapper<PictureEntity> {
List<PictureEntity> selectPictureList(@Param("params") PictureParams params, Page page);
} }
package io.office.modules.manage.entity.dto; package io.office.modules.manage.entity.dto;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import io.office.modules.manage.entity.page.PageParams;
import lombok.Data; import lombok.Data;
import java.util.*; import java.util.*;
...@@ -11,9 +12,7 @@ import java.util.*; ...@@ -11,9 +12,7 @@ import java.util.*;
* @date 2021/10/14 * @date 2021/10/14
*/ */
@Data @Data
public class NewsParams { public class NewsParams extends PageParams {
private int page;
private int limit;
private String title; private String title;
private int levels; private int levels;
private String author; private String author;
......
package io.office.modules.manage.entity.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.office.modules.manage.entity.page.PageParams;
import lombok.Data;
import java.util.Date;
/**
* @author rkl
* @description 图片资讯入参
* @date 2021/10/18
*/
@Data
public class PictureParams extends PageParams {
private String title;
private String status;
private String pictureType;
private String pictureLevel;
private String editor;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date inputDateStart;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date inputDateEnd;
private String keyword;
}
package io.office.modules.manage.entity.page;
import lombok.Data;
/**
* @author rkl
* @description
* @date 2021/10/18
*/
@Data
public class PageParams {
private int page;
private int limit;
}
package io.office.modules.manage.service; package io.office.modules.manage.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils; import io.office.common.utils.PageUtils;
import io.office.common.utils.R; import io.office.common.utils.R;
import io.office.modules.manage.entity.PictureEntity; import io.office.modules.manage.entity.PictureEntity;
import io.office.modules.manage.entity.dto.PictureParams;
import io.office.modules.sys.entity.SysUserEntity; import io.office.modules.sys.entity.SysUserEntity;
import java.util.List; import java.util.List;
...@@ -27,5 +29,7 @@ public interface PictureService extends IService<PictureEntity> { ...@@ -27,5 +29,7 @@ public interface PictureService extends IService<PictureEntity> {
R deletePicture(List ids, SysUserEntity user); R deletePicture(List ids, SysUserEntity user);
R verifyPicture(PictureEntity picture, SysUserEntity user); R verifyPicture(PictureEntity picture, SysUserEntity user);
Page<PictureEntity> selectPictureList(PictureParams params, Page page);
} }
package io.office.modules.manage.service.impl; package io.office.modules.manage.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.utils.PageUtils; import io.office.common.utils.PageUtils;
import io.office.common.utils.Query; import io.office.common.utils.Query;
import io.office.common.utils.R; import io.office.common.utils.R;
import io.office.modules.manage.dao.PictureDao; import io.office.modules.manage.dao.PictureDao;
import io.office.modules.manage.entity.NewsEntity; import io.office.modules.manage.entity.NewsEntity;
import io.office.modules.manage.entity.PictureEntity; import io.office.modules.manage.entity.PictureEntity;
import io.office.modules.manage.entity.dto.PictureParams;
import io.office.modules.manage.service.PictureService; import io.office.modules.manage.service.PictureService;
import io.office.modules.sys.entity.SysUserEntity; import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
...@@ -21,6 +24,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; ...@@ -21,6 +24,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service("pictureService") @Service("pictureService")
public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> implements PictureService { public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> implements PictureService {
@Autowired
PictureDao pictureDao;
@Override @Override
public PageUtils queryPage(Map<String, Object> params) { public PageUtils queryPage(Map<String, Object> params) {
IPage<PictureEntity> page = this.page( IPage<PictureEntity> page = this.page(
...@@ -35,6 +42,8 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i ...@@ -35,6 +42,8 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
public R insertPicture(PictureEntity picture, SysUserEntity user) { public R insertPicture(PictureEntity picture, SysUserEntity user) {
picture.setEditor(user.getUsername()); picture.setEditor(user.getUsername());
picture.setLasteditor(user.getUsername()); picture.setLasteditor(user.getUsername());
picture.setInputdate(new Date());
picture.setStatus(0);
int insert = baseMapper.insert(picture); int insert = baseMapper.insert(picture);
if (insert>0){ if (insert>0){
return R.ok("新增成功!"); return R.ok("新增成功!");
...@@ -49,7 +58,7 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i ...@@ -49,7 +58,7 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
return R.error("id不能为空!"); return R.error("id不能为空!");
} }
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>(); QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",picture.getPictureid()); newsEntityQueryWrapper.eq("pictureid",picture.getPictureid());
picture.setEditor(user.getUsername()); picture.setEditor(user.getUsername());
picture.setLasteditor(user.getUsername()); picture.setLasteditor(user.getUsername());
int update = baseMapper.update(picture, newsEntityQueryWrapper); int update = baseMapper.update(picture, newsEntityQueryWrapper);
...@@ -64,8 +73,10 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i ...@@ -64,8 +73,10 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
public R deletePicture(List ids, SysUserEntity user) { public R deletePicture(List ids, SysUserEntity user) {
PictureEntity pictureEntity = new PictureEntity(); PictureEntity pictureEntity = new PictureEntity();
pictureEntity.setPiclevel(0); pictureEntity.setPiclevel(0);
pictureEntity.setLasteditor(user.getUsername());
pictureEntity.setEditor(user.getUsername());
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>(); QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.in("id",ids); newsEntityQueryWrapper.in("pictureid",ids);
int delete = baseMapper.update(pictureEntity, newsEntityQueryWrapper); int delete = baseMapper.update(pictureEntity, newsEntityQueryWrapper);
if (delete>0){ if (delete>0){
return R.ok("删除成功!"); return R.ok("删除成功!");
...@@ -80,7 +91,7 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i ...@@ -80,7 +91,7 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
picture.setInputdate(new Date()); picture.setInputdate(new Date());
picture.setLasteditor(user.getUsername()); picture.setLasteditor(user.getUsername());
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>(); QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",picture.getPictureid()); newsEntityQueryWrapper.eq("pictureid",picture.getPictureid());
int verify = baseMapper.update(picture, newsEntityQueryWrapper); int verify = baseMapper.update(picture, newsEntityQueryWrapper);
if (verify>0){ if (verify>0){
return R.ok("审核成功!"); return R.ok("审核成功!");
...@@ -89,4 +100,11 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i ...@@ -89,4 +100,11 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
} }
} }
@Override
public Page<PictureEntity> selectPictureList(PictureParams params, Page page) {
List<PictureEntity> newsList = this.pictureDao.selectPictureList(params, page);
page.setRecords(newsList);
return page;
}
} }
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="io.office.modules.manage.dao.PictureDao">
<!-- 可根据自己的需求,是否要使用 -->
<resultMap type="io.office.modules.manage.entity.PictureEntity" id="pictureMap">
<result property="pictureid" column="pictureID"/>
<result property="title" column="Title"/>
<result property="pictureType" column="Picture_type"/>
<result property="picFile" column="Pic_file"/>
<result property="minPicFile" column="Min_Pic_file"/>
<result property="editor" column="Editor"/>
<result property="inputdate" column="inputDate"/>
<result property="piclevel" column="PicLevel"/>
<result property="status" column="Status"/>
<result property="keyword" column="keyword"/>
<result property="jumppath" column="JumpPath"/>
<result property="content" column="content"/>
<result property="articleId" column="article_id"/>
<result property="showtime" column="showtime"/>
<result property="auditor" column="auditor"/>
<result property="lasteditor" column="lasteditor"/>
</resultMap>
<select id="selectPictureList" resultMap="pictureMap" parameterType="io.office.modules.manage.entity.dto.PictureParams">
SELECT
t.title,
t.Picture_type,
t.showtime,
t.inputDate,
t.keyword,
t.Editor,
t.lasteditor,
t.auditor,
t.Status,
t.PicLevel
FROM
picture t
where 1=1
<if test="params.title !='' and params.title !=null">
and t.title like concat('%',#{params.title},'%')
</if>
<if test="params.editor !='' and params.editor !=null">
and t.Editor like concat('%',#{params.editor},'%')
</if>
<if test="params.keyword !='' and params.keyword !=null">
and t.keyword like concat('%',#{params.keyword},'%')
</if>
<if test="params.status !=''">
and t.Status =#{params.status}
</if>
<if test="params.pictureType !='' and params.pictureType !=null">
and t.Picture_type =#{params.pictureType}
</if>
<choose>
<when test="params.pictureLevel != 0">
AND PicLevel = #{params.pictureLevel}
</when>
<otherwise>
AND PicLevel = 0
</otherwise>
</choose>
ORDER BY
pictureID DESC
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment