Commit 6304c8c2 by rongkailun

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

parent f9f826b1
......@@ -43,7 +43,8 @@ public class NewsController extends AbstractController {
public R list(@RequestBody NewsParams newsParams) {
Page<NewsEntity> page = this.newsService.selectNewsList(newsParams,
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;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.modules.manage.entity.NewsEntity;
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.sys.controller.AbstractController;
import lombok.extern.slf4j.Slf4j;
......@@ -34,9 +36,11 @@ public class PictureController extends AbstractController {
*/
@RequestMapping("/list")
// @RequiresPermissions("generator:picture:list")
public R list(@RequestParam Map<String, Object> params){
PageUtils page = pictureService.queryPage(params);
return R.ok().put("page", page);
public R list(@RequestBody PictureParams params){
Page<PictureEntity> page = this.pictureService.selectPictureList(params,
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 {
*/
@RequestMapping("/delete")
// @RequiresPermissions("generator:picture:delete")
public R delete(@RequestBody List ids){
public R delete(@RequestBody List<Long> ids){
try {
R r = this.pictureService.deletePicture(ids, getUser());
return r;
......
package io.office.modules.manage.dao;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.office.modules.manage.entity.PictureEntity;
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.Param;
import java.util.List;
/**
* ${comments}
......@@ -14,4 +19,5 @@ import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface PictureDao extends BaseMapper<PictureEntity> {
List<PictureEntity> selectPictureList(@Param("params") PictureParams params, Page page);
}
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.*;
......@@ -11,9 +12,7 @@ import java.util.*;
* @date 2021/10/14
*/
@Data
public class NewsParams {
private int page;
private int limit;
public class NewsParams extends PageParams {
private String title;
private int levels;
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;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import io.office.common.utils.PageUtils;
import io.office.common.utils.R;
import io.office.modules.manage.entity.PictureEntity;
import io.office.modules.manage.entity.dto.PictureParams;
import io.office.modules.sys.entity.SysUserEntity;
import java.util.List;
......@@ -27,5 +29,7 @@ public interface PictureService extends IService<PictureEntity> {
R deletePicture(List ids, SysUserEntity user);
R verifyPicture(PictureEntity picture, SysUserEntity user);
Page<PictureEntity> selectPictureList(PictureParams params, Page page);
}
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.Query;
import io.office.common.utils.R;
import io.office.modules.manage.dao.PictureDao;
import io.office.modules.manage.entity.NewsEntity;
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.sys.entity.SysUserEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
......@@ -21,6 +24,10 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service("pictureService")
public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> implements PictureService {
@Autowired
PictureDao pictureDao;
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<PictureEntity> page = this.page(
......@@ -35,6 +42,8 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
public R insertPicture(PictureEntity picture, SysUserEntity user) {
picture.setEditor(user.getUsername());
picture.setLasteditor(user.getUsername());
picture.setInputdate(new Date());
picture.setStatus(0);
int insert = baseMapper.insert(picture);
if (insert>0){
return R.ok("新增成功!");
......@@ -49,7 +58,7 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
return R.error("id不能为空!");
}
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",picture.getPictureid());
newsEntityQueryWrapper.eq("pictureid",picture.getPictureid());
picture.setEditor(user.getUsername());
picture.setLasteditor(user.getUsername());
int update = baseMapper.update(picture, newsEntityQueryWrapper);
......@@ -64,8 +73,10 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
public R deletePicture(List ids, SysUserEntity user) {
PictureEntity pictureEntity = new PictureEntity();
pictureEntity.setPiclevel(0);
pictureEntity.setLasteditor(user.getUsername());
pictureEntity.setEditor(user.getUsername());
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.in("id",ids);
newsEntityQueryWrapper.in("pictureid",ids);
int delete = baseMapper.update(pictureEntity, newsEntityQueryWrapper);
if (delete>0){
return R.ok("删除成功!");
......@@ -80,7 +91,7 @@ public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> i
picture.setInputdate(new Date());
picture.setLasteditor(user.getUsername());
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",picture.getPictureid());
newsEntityQueryWrapper.eq("pictureid",picture.getPictureid());
int verify = baseMapper.update(picture, newsEntityQueryWrapper);
if (verify>0){
return R.ok("审核成功!");
......@@ -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