Commit 1bffd170 by rongkailun

图片咨询新增修改删除审核

parent acc5c7e5
...@@ -22,7 +22,7 @@ import io.office.common.utils.R; ...@@ -22,7 +22,7 @@ import io.office.common.utils.R;
/** /**
* ${comments} * 文章管理
* *
* @author wudi * @author wudi
* @email * @email
......
package io.office.modules.manage.controller;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
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.service.PictureService;
import io.office.modules.sys.controller.AbstractController;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* 图片咨询管理
*
* @author rkl
* @email
* @date 2021-10-14 15:28:27
*/
@RestController
@RequestMapping("/picture")
@Slf4j
public class PictureController extends AbstractController {
@Autowired
private PictureService pictureService;
/**
* 列表
*/
@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);
}
/**
* 信息
*/
@RequestMapping("/info/{pictureid}")
// @RequiresPermissions("generator:picture:info")
public R info(@PathVariable("pictureid") Integer pictureid){
PictureEntity picture = pictureService.getById(pictureid);
return R.ok().put("picture", picture);
}
/**
* 保存
*/
@RequestMapping("/save")
// @RequiresPermissions("generator:picture:save")
public R save(@RequestBody PictureEntity picture){
try {
R r = this.pictureService.insertPicture(picture,getUser());
return r;
} catch (Exception e) {
log.error("picture save error:", e);
return R.error(e.getMessage());
}
}
/**
* 修改
*/
@RequestMapping("/update")
// @RequiresPermissions("generator:picture:update")
public R update(@RequestBody PictureEntity picture){
try {
R r = this.pictureService.updatePicture(picture, getUser());
return r;
} catch (Exception e) {
log.error("update error:", e);
return R.error(e.getMessage());
}
}
/**
* 删除
*/
@RequestMapping("/delete")
// @RequiresPermissions("generator:picture:delete")
public R delete(@RequestBody List ids){
try {
R r = this.pictureService.deletePicture(ids, getUser());
return r;
} catch (Exception e) {
log.error("delete error:", e);
return R.error(e.getMessage());
}
}
/**
* 审核
*/
@PostMapping("/verifyPicture")
// @RequiresPermissions("manage:news:verify")
public R verify(@RequestBody PictureEntity picture) {
try {
R r = this.pictureService.verifyPicture(picture,getUser());
return r;
} catch (Exception e) {
log.error("delete error:", e);
return R.error(e.getMessage());
}
}
}
package io.office.modules.manage.dao;
import io.office.modules.manage.entity.PictureEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* ${comments}
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-10-14 15:28:27
*/
@Mapper
public interface PictureDao extends BaseMapper<PictureEntity> {
}
package io.office.modules.manage.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.util.Date;
import lombok.Data;
/**
* ${comments}
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-10-14 15:28:27
*/
@Data
@TableName("picture")
public class PictureEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* $column.comments
*/
@TableId
private Integer pictureid;
/**
* $column.comments
*/
private String title;
/**
* $column.comments
*/
private String pictureType;
/**
* $column.comments
*/
private String picFile;
/**
* $column.comments
*/
private String minPicFile;
/**
* $column.comments
*/
private String editor;
/**
* $column.comments
*/
private Date inputdate;
/**
* $column.comments
*/
private Integer piclevel;
/**
* $column.comments
*/
private Integer status;
/**
* $column.comments
*/
private String keyword;
/**
* $column.comments
*/
private String jumppath;
/**
* $column.comments
*/
private String content;
/**
* $column.comments
*/
private Integer articleId;
/**
* $column.comments
*/
private String showtime;
/**
* $column.comments
*/
private String auditor;
/**
* $column.comments
*/
private String lasteditor;
}
package io.office.modules.manage.service;
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.sys.entity.SysUserEntity;
import java.util.List;
import java.util.Map;
/**
* ${comments}
*
* @author chenshun
* @email sunlightcs@gmail.com
* @date 2021-10-14 15:28:27
*/
public interface PictureService extends IService<PictureEntity> {
PageUtils queryPage(Map<String, Object> params);
R insertPicture(PictureEntity picture, SysUserEntity user);
R updatePicture(PictureEntity picture, SysUserEntity user);
R deletePicture(List ids, SysUserEntity user);
R verifyPicture(PictureEntity picture, SysUserEntity user);
}
package io.office.modules.manage.service.impl;
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.service.PictureService;
import io.office.modules.sys.entity.SysUserEntity;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@Service("pictureService")
public class PictureServiceImpl extends ServiceImpl<PictureDao, PictureEntity> implements PictureService {
@Override
public PageUtils queryPage(Map<String, Object> params) {
IPage<PictureEntity> page = this.page(
new Query<PictureEntity>().getPage(params),
new QueryWrapper<PictureEntity>()
);
return new PageUtils(page);
}
@Override
public R insertPicture(PictureEntity picture, SysUserEntity user) {
picture.setEditor(user.getUsername());
picture.setLasteditor(user.getUsername());
int insert = baseMapper.insert(picture);
if (insert>0){
return R.ok("新增成功!");
}else{
return R.error("新增失败!");
}
}
@Override
public R updatePicture(PictureEntity picture, SysUserEntity user) {
if(picture.getPictureid() ==null){
return R.error("id不能为空!");
}
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",picture.getPictureid());
picture.setEditor(user.getUsername());
picture.setLasteditor(user.getUsername());
int update = baseMapper.update(picture, newsEntityQueryWrapper);
if (update>0){
return R.ok("修改成功!");
}else{
return R.error("修改失败!");
}
}
@Override
public R deletePicture(List ids, SysUserEntity user) {
PictureEntity pictureEntity = new PictureEntity();
pictureEntity.setPiclevel(0);
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.in("id",ids);
int delete = baseMapper.update(pictureEntity, newsEntityQueryWrapper);
if (delete>0){
return R.ok("删除成功!");
}else{
return R.error("删除失败!");
}
}
@Override
public R verifyPicture(PictureEntity picture, SysUserEntity user) {
picture.setAuditor(user.getUsername());
picture.setInputdate(new Date());
picture.setLasteditor(user.getUsername());
QueryWrapper<PictureEntity> newsEntityQueryWrapper = new QueryWrapper<>();
newsEntityQueryWrapper.eq("id",picture.getPictureid());
int verify = baseMapper.update(picture, newsEntityQueryWrapper);
if (verify>0){
return R.ok("审核成功!");
}else{
return R.error("审核失败!");
}
}
}
\ 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