updates
This commit is contained in:
parent
519852741f
commit
fa33f8a3d2
|
|
@ -1,18 +1,23 @@
|
||||||
package org.jeecg.modules.yx.controller;
|
package org.jeecg.modules.yx.controller;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.util.*;
|
||||||
import java.net.URLDecoder;
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.apache.shiro.SecurityUtils;
|
||||||
import org.jeecg.common.api.vo.Result;
|
import org.jeecg.common.api.vo.Result;
|
||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.common.util.oConvertUtils;
|
import org.jeecg.common.system.vo.LoginUser;
|
||||||
|
import org.jeecg.common.util.AssertUtils;
|
||||||
|
import org.jeecg.modules.yx.dto.YxArticleDTO;
|
||||||
import org.jeecg.modules.yx.entity.YxArticle;
|
import org.jeecg.modules.yx.entity.YxArticle;
|
||||||
|
import org.jeecg.modules.yx.entity.YxArticleContent;
|
||||||
|
import org.jeecg.modules.yx.service.IYxArticleContentService;
|
||||||
import org.jeecg.modules.yx.service.IYxArticleService;
|
import org.jeecg.modules.yx.service.IYxArticleService;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
|
@ -20,18 +25,18 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.jeecg.modules.yx.vo.ArticleEditVO;
|
||||||
|
import org.jeecg.common.system.base.controller.JeecgController;
|
||||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||||
import org.jeecg.common.system.base.controller.JeecgController;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
import org.springframework.web.servlet.ModelAndView;
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||||
|
|
@ -50,7 +55,9 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||||
public class YxArticleController extends JeecgController<YxArticle, IYxArticleService> {
|
public class YxArticleController extends JeecgController<YxArticle, IYxArticleService> {
|
||||||
@Autowired
|
@Autowired
|
||||||
private IYxArticleService yxArticleService;
|
private IYxArticleService yxArticleService;
|
||||||
|
@Autowired
|
||||||
|
private IYxArticleContentService yxArticleContentService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页列表查询
|
* 分页列表查询
|
||||||
*
|
*
|
||||||
|
|
@ -72,37 +79,37 @@ public class YxArticleController extends JeecgController<YxArticle, IYxArticleSe
|
||||||
IPage<YxArticle> pageList = yxArticleService.page(page, queryWrapper);
|
IPage<YxArticle> pageList = yxArticleService.page(page, queryWrapper);
|
||||||
return Result.OK(pageList);
|
return Result.OK(pageList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加
|
* 添加
|
||||||
*
|
*
|
||||||
* @param yxArticle
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@AutoLog(value = "文章表-添加")
|
@AutoLog(value = "文章表-添加")
|
||||||
@ApiOperation(value="文章表-添加", notes="文章表-添加")
|
@ApiOperation(value="文章表-添加", notes="文章表-添加")
|
||||||
@RequiresPermissions("yx:yx_article:add")
|
@RequiresPermissions("yx:yx_article:add")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public Result<String> add(@RequestBody YxArticle yxArticle) {
|
public Result<String> add(@RequestBody ArticleEditVO articleEditVO) {
|
||||||
yxArticleService.save(yxArticle);
|
yxArticleService.save(articleEditVO);
|
||||||
return Result.OK("添加成功!");
|
return Result.OK("添加成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 编辑
|
* 编辑
|
||||||
*
|
*
|
||||||
* @param yxArticle
|
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@AutoLog(value = "文章表-编辑")
|
@AutoLog(value = "文章表-编辑")
|
||||||
@ApiOperation(value="文章表-编辑", notes="文章表-编辑")
|
@ApiOperation(value="文章表-编辑", notes="文章表-编辑")
|
||||||
@RequiresPermissions("yx:yx_article:edit")
|
@RequiresPermissions("yx:yx_article:edit")
|
||||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||||
public Result<String> edit(@RequestBody YxArticle yxArticle) {
|
public Result<String> edit(@RequestBody ArticleEditVO articleEditVO) {
|
||||||
yxArticleService.updateById(yxArticle);
|
yxArticleService.edit(articleEditVO);
|
||||||
return Result.OK("编辑成功!");
|
return Result.OK("编辑成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id删除
|
* 通过id删除
|
||||||
*
|
*
|
||||||
|
|
@ -117,7 +124,7 @@ public class YxArticleController extends JeecgController<YxArticle, IYxArticleSe
|
||||||
yxArticleService.removeById(id);
|
yxArticleService.removeById(id);
|
||||||
return Result.OK("删除成功!");
|
return Result.OK("删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除
|
* 批量删除
|
||||||
*
|
*
|
||||||
|
|
@ -132,7 +139,7 @@ public class YxArticleController extends JeecgController<YxArticle, IYxArticleSe
|
||||||
this.yxArticleService.removeByIds(Arrays.asList(ids.split(",")));
|
this.yxArticleService.removeByIds(Arrays.asList(ids.split(",")));
|
||||||
return Result.OK("批量删除成功!");
|
return Result.OK("批量删除成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过id查询
|
* 通过id查询
|
||||||
*
|
*
|
||||||
|
|
@ -142,12 +149,12 @@ public class YxArticleController extends JeecgController<YxArticle, IYxArticleSe
|
||||||
//@AutoLog(value = "文章表-通过id查询")
|
//@AutoLog(value = "文章表-通过id查询")
|
||||||
@ApiOperation(value="文章表-通过id查询", notes="文章表-通过id查询")
|
@ApiOperation(value="文章表-通过id查询", notes="文章表-通过id查询")
|
||||||
@GetMapping(value = "/queryById")
|
@GetMapping(value = "/queryById")
|
||||||
public Result<YxArticle> queryById(@RequestParam(name="id",required=true) String id) {
|
public Result<YxArticleDTO> queryById(@RequestParam(name="id",required=true) String id) {
|
||||||
YxArticle yxArticle = yxArticleService.getById(id);
|
YxArticleDTO yxArticleDTO = yxArticleService.getArticleDtoById(id);
|
||||||
if(yxArticle==null) {
|
if(yxArticleDTO ==null) {
|
||||||
return Result.error("未找到对应数据");
|
return Result.error("未找到对应数据");
|
||||||
}
|
}
|
||||||
return Result.OK(yxArticle);
|
return Result.OK(yxArticleDTO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -159,7 +166,34 @@ public class YxArticleController extends JeecgController<YxArticle, IYxArticleSe
|
||||||
@RequiresPermissions("yx:yx_article:exportXls")
|
@RequiresPermissions("yx:yx_article:exportXls")
|
||||||
@RequestMapping(value = "/exportXls")
|
@RequestMapping(value = "/exportXls")
|
||||||
public ModelAndView exportXls(HttpServletRequest request, YxArticle yxArticle) {
|
public ModelAndView exportXls(HttpServletRequest request, YxArticle yxArticle) {
|
||||||
return super.exportXls(request, yxArticle, YxArticle.class, "文章表");
|
// Step.1 组装查询条件 QueryGenerator.initQueryWrapper(yxArticle, request.getParameterMap())
|
||||||
|
LambdaQueryWrapper<YxArticle> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
String selections = request.getParameter("selections");
|
||||||
|
if (StringUtils.isNotBlank(selections)) {
|
||||||
|
queryWrapper.in(YxArticle::getId,Arrays.asList(selections.split(",")));
|
||||||
|
}
|
||||||
|
// Step.2 AutoPoi 导出Excel
|
||||||
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||||
|
List<YxArticle> pageList = service.list(queryWrapper);
|
||||||
|
if (CollectionUtils.isNotEmpty(pageList)) {
|
||||||
|
Set<String> articleIdList = pageList.stream().map(YxArticle::getId).collect(Collectors.toSet());
|
||||||
|
List<YxArticleContent> yxArticleContentList = yxArticleContentService.list(new LambdaQueryWrapper<YxArticleContent>().in(YxArticleContent::getArticleId, articleIdList));
|
||||||
|
Map<String, String> stringMap = yxArticleContentList.stream().collect(Collectors.toMap(YxArticleContent::getArticleId, YxArticleContent::getContent));
|
||||||
|
for (YxArticle article : pageList) {
|
||||||
|
article.setContent(stringMap.get(article.getId()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 导出文件名称
|
||||||
|
mv.addObject(NormalExcelConstants.FILE_NAME, "文章数据");
|
||||||
|
mv.addObject(NormalExcelConstants.CLASS, YxArticle.class);
|
||||||
|
//获取当前登录用户
|
||||||
|
//update-begin---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------
|
||||||
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||||
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("文章数据列表数据", "导出人:"+user.getRealname(), "导出信息"));
|
||||||
|
//update-end---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------
|
||||||
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
||||||
|
return mv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -172,7 +206,62 @@ public class YxArticleController extends JeecgController<YxArticle, IYxArticleSe
|
||||||
@RequiresPermissions("yx:yx_article:importExcel")
|
@RequiresPermissions("yx:yx_article:importExcel")
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
return super.importExcel(request, response, YxArticle.class);
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||||
|
// 获取上传文件对象
|
||||||
|
MultipartFile file = entity.getValue();
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(2);
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
try {
|
||||||
|
List<YxArticle> list = ExcelImportUtil.importExcel(file.getInputStream(), YxArticle.class, params);
|
||||||
|
|
||||||
|
if (CollectionUtils.isNotEmpty(list)) {
|
||||||
|
for (YxArticle yxArticle : list) {
|
||||||
|
AssertUtils.notNull(yxArticle.getTitle(),"标题不可为空");
|
||||||
|
AssertUtils.notNull(yxArticle.getSchoolName(),"学校名称不可为空");
|
||||||
|
long count = service.count(new LambdaQueryWrapper<YxArticle>().eq(YxArticle::getTitle, yxArticle.getTitle()));
|
||||||
|
if (count > 0) {
|
||||||
|
return Result.error(String.format("文件导入失败:标题-%s-已存在!", yxArticle.getTitle()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//update-begin-author:taoyan date:20190528 for:批量插入数据
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
service.saveOrUpdateBatch(list);
|
||||||
|
YxArticleContent yxArticleContent = null;
|
||||||
|
List<YxArticleContent> yxArticleContents = new ArrayList<>();
|
||||||
|
for (YxArticle yxArticle : list) {
|
||||||
|
yxArticleContent = new YxArticleContent();
|
||||||
|
yxArticleContent.setContentType("1");
|
||||||
|
yxArticleContent.setArticleId(yxArticle.getId());
|
||||||
|
yxArticleContent.setContent(yxArticle.getContent());
|
||||||
|
yxArticleContents.add(yxArticleContent);
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isNotEmpty(yxArticleContents)) {
|
||||||
|
yxArticleContentService.saveBatch(yxArticleContents);
|
||||||
|
}
|
||||||
|
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
||||||
|
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
log.error(msg, e);
|
||||||
|
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
||||||
|
return Result.error("文件导入失败:有重复数据!");
|
||||||
|
} else {
|
||||||
|
return Result.error("文件导入失败:" + e.getMessage());
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.error("文件导入失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
package org.jeecg.modules.yx.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description
|
||||||
|
* @Author ZhouWenTao
|
||||||
|
* @Date 2024/3/10 21:08
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class YxArticleDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**文章id*/
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private java.lang.String id;
|
||||||
|
/**标题*/
|
||||||
|
@Excel(name = "标题", width = 15)
|
||||||
|
@ApiModelProperty(value = "标题")
|
||||||
|
private java.lang.String title;
|
||||||
|
/**文章内容*/
|
||||||
|
@Excel(name = "文章内容", width = 15)
|
||||||
|
@ApiModelProperty(value = "文章内容")
|
||||||
|
private java.lang.String content;
|
||||||
|
/**内容类型(1.纯文本,2.富文本)*/
|
||||||
|
@Excel(name = "内容类型(1.纯文本,2.富文本)", width = 15)
|
||||||
|
@ApiModelProperty(value = "内容类型(1.纯文本,2.富文本)")
|
||||||
|
private java.lang.String contentType;
|
||||||
|
/**院校id*/
|
||||||
|
@Excel(name = "院校id", width = 15)
|
||||||
|
@ApiModelProperty(value = "院校id")
|
||||||
|
private java.lang.String schoolId;
|
||||||
|
/**院校名称*/
|
||||||
|
@Excel(name = "院校名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "院校名称")
|
||||||
|
private java.lang.String schoolName;
|
||||||
|
/**发布者*/
|
||||||
|
@Excel(name = "发布者", width = 15)
|
||||||
|
@ApiModelProperty(value = "发布者")
|
||||||
|
private java.lang.String author;
|
||||||
|
/**类型(1.招生章程)*/
|
||||||
|
@Excel(name = "类型(1.招生章程)", width = 15)
|
||||||
|
@ApiModelProperty(value = "类型(1.招生章程)")
|
||||||
|
private java.lang.String type;
|
||||||
|
/**发布日期*/
|
||||||
|
@Excel(name = "发布日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "发布日期")
|
||||||
|
private java.util.Date releaseTime;
|
||||||
|
/**阅读量*/
|
||||||
|
@Excel(name = "阅读量", width = 15)
|
||||||
|
@ApiModelProperty(value = "阅读量")
|
||||||
|
private java.lang.Integer viewCount;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
||||||
|
package org.jeecg.modules.yx.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 后台-院校对象
|
||||||
|
* @Author ZhouWenTao
|
||||||
|
* @Date 2024/3/10 21:17
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "后台-院校对象")
|
||||||
|
public class YxSchoolDTO implements Serializable {
|
||||||
|
private String id;
|
||||||
|
private String schoolName;
|
||||||
|
private String schoolCode;
|
||||||
|
}
|
||||||
|
|
@ -4,10 +4,8 @@ import java.io.Serializable;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.*;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
@ -52,6 +50,11 @@ public class YxArticle implements Serializable {
|
||||||
@Excel(name = "发布者", width = 15)
|
@Excel(name = "发布者", width = 15)
|
||||||
@ApiModelProperty(value = "发布者")
|
@ApiModelProperty(value = "发布者")
|
||||||
private java.lang.String author;
|
private java.lang.String author;
|
||||||
|
/**内容*/
|
||||||
|
@Excel(name = "内容", width = 15)
|
||||||
|
@ApiModelProperty(value = "内容")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private java.lang.String content;
|
||||||
/**类型(1.招生章程)*/
|
/**类型(1.招生章程)*/
|
||||||
@Excel(name = "类型(1.招生章程)", width = 15)
|
@Excel(name = "类型(1.招生章程)", width = 15)
|
||||||
@ApiModelProperty(value = "类型(1.招生章程)")
|
@ApiModelProperty(value = "类型(1.招生章程)")
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ public class YxVipCard implements Serializable {
|
||||||
/**对应产品编号*/
|
/**对应产品编号*/
|
||||||
@Excel(name = "对应产品编号", width = 15)
|
@Excel(name = "对应产品编号", width = 15)
|
||||||
@ApiModelProperty(value = "对应产品编号")
|
@ApiModelProperty(value = "对应产品编号")
|
||||||
|
@Dict(dictTable = "yx_vip_sku",dicCode = "sku_code",dicText = "sku_name")
|
||||||
private java.lang.String skuCode;
|
private java.lang.String skuCode;
|
||||||
/**有效日期*/
|
/**有效日期*/
|
||||||
@Excel(name = "有效日期", width = 15, format = "yyyy-MM-dd")
|
@Excel(name = "有效日期", width = 15, format = "yyyy-MM-dd")
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import org.apache.ibatis.annotations.Param;
|
||||||
import org.jeecg.modules.art.dto.ArtSchoolDTO;
|
import org.jeecg.modules.art.dto.ArtSchoolDTO;
|
||||||
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
||||||
import org.jeecg.modules.mini.dto.MiniSchoolDTO;
|
import org.jeecg.modules.mini.dto.MiniSchoolDTO;
|
||||||
|
import org.jeecg.modules.yx.dto.YxSchoolDTO;
|
||||||
import org.jeecg.modules.yx.entity.YxSchool;
|
import org.jeecg.modules.yx.entity.YxSchool;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
|
||||||
|
|
@ -40,4 +41,5 @@ public interface YxSchoolMapper extends BaseMapper<YxSchool> {
|
||||||
|
|
||||||
IPage<MiniSchoolDTO> miniSchoolSearchSm(@Param("page")Page<Object> page, @Param("qvo") QueryRecommendMajorVO queryRecommendMajorVO);
|
IPage<MiniSchoolDTO> miniSchoolSearchSm(@Param("page")Page<Object> page, @Param("qvo") QueryRecommendMajorVO queryRecommendMajorVO);
|
||||||
|
|
||||||
|
YxSchoolDTO getBySchoolName(String schoolName);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,25 @@
|
||||||
package org.jeecg.modules.yx.service;
|
package org.jeecg.modules.yx.service;
|
||||||
|
|
||||||
|
import org.jeecg.modules.yx.dto.YxArticleDTO;
|
||||||
import org.jeecg.modules.yx.entity.YxArticle;
|
import org.jeecg.modules.yx.entity.YxArticle;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import org.jeecg.modules.yx.vo.ArticleEditVO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 文章表
|
* @Description: 文章表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2024-03-06
|
* @Date: 2024-03-06
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface IYxArticleService extends IService<YxArticle> {
|
public interface IYxArticleService extends IService<YxArticle> {
|
||||||
|
public YxArticleDTO getArticleDtoById(String articleId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存文章
|
||||||
|
*/
|
||||||
|
boolean save(ArticleEditVO articleEditVO);
|
||||||
|
/**
|
||||||
|
* 编辑文章
|
||||||
|
*/
|
||||||
|
boolean edit(ArticleEditVO articleEditVO);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import org.jeecg.modules.art.dto.ArtHotSchoolDTO;
|
||||||
import org.jeecg.modules.art.dto.ArtSchoolDTO;
|
import org.jeecg.modules.art.dto.ArtSchoolDTO;
|
||||||
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
||||||
import org.jeecg.modules.mini.dto.MiniSchoolDTO;
|
import org.jeecg.modules.mini.dto.MiniSchoolDTO;
|
||||||
|
import org.jeecg.modules.yx.dto.YxSchoolDTO;
|
||||||
import org.jeecg.modules.yx.entity.YxSchool;
|
import org.jeecg.modules.yx.entity.YxSchool;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
|
@ -17,6 +18,8 @@ import java.util.List;
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
public interface IYxSchoolService extends IService<YxSchool> {
|
public interface IYxSchoolService extends IService<YxSchool> {
|
||||||
|
YxSchoolDTO getBySchoolName(String schoolName);
|
||||||
|
|
||||||
List<YxSchool> oldList();
|
List<YxSchool> oldList();
|
||||||
|
|
||||||
//PC前台端==================================================
|
//PC前台端==================================================
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,18 @@
|
||||||
package org.jeecg.modules.yx.service.impl;
|
package org.jeecg.modules.yx.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
import org.jeecg.common.util.AssertUtils;
|
||||||
|
import org.jeecg.modules.yx.dto.YxArticleDTO;
|
||||||
import org.jeecg.modules.yx.entity.YxArticle;
|
import org.jeecg.modules.yx.entity.YxArticle;
|
||||||
|
import org.jeecg.modules.yx.entity.YxArticleContent;
|
||||||
|
import org.jeecg.modules.yx.mapper.YxArticleContentMapper;
|
||||||
import org.jeecg.modules.yx.mapper.YxArticleMapper;
|
import org.jeecg.modules.yx.mapper.YxArticleMapper;
|
||||||
|
import org.jeecg.modules.yx.service.IYxArticleContentService;
|
||||||
import org.jeecg.modules.yx.service.IYxArticleService;
|
import org.jeecg.modules.yx.service.IYxArticleService;
|
||||||
|
import org.jeecg.modules.yx.service.IYxSchoolService;
|
||||||
|
import org.jeecg.modules.yx.vo.ArticleEditVO;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
|
@ -12,9 +22,74 @@ import javax.annotation.Resource;
|
||||||
/**
|
/**
|
||||||
* @Description: 文章表
|
* @Description: 文章表
|
||||||
* @Author: jeecg-boot
|
* @Author: jeecg-boot
|
||||||
* @Date: 2024-03-06
|
* @Date: 2024-03-06
|
||||||
* @Version: V1.0
|
* @Version: V1.0
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class YxArticleServiceImpl extends ServiceImpl<YxArticleMapper, YxArticle> implements IYxArticleService {
|
public class YxArticleServiceImpl extends ServiceImpl<YxArticleMapper, YxArticle> implements IYxArticleService {
|
||||||
|
@Resource
|
||||||
|
private IYxArticleContentService yxArticleContentService;
|
||||||
|
@Resource
|
||||||
|
private IYxSchoolService yxSchoolService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取详细文章信息
|
||||||
|
*
|
||||||
|
* @param articleId 文章id
|
||||||
|
*/
|
||||||
|
public YxArticleDTO getArticleDtoById(String articleId) {
|
||||||
|
//先获取文章信息
|
||||||
|
YxArticle yxArticle = getById(articleId);
|
||||||
|
if (yxArticle == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
YxArticleDTO miniYxArticleDTO = new YxArticleDTO();
|
||||||
|
BeanUtils.copyProperties(yxArticle, miniYxArticleDTO);
|
||||||
|
LambdaQueryWrapper<YxArticleContent> yxArticleContentLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
yxArticleContentLambdaQueryWrapper.eq(YxArticleContent::getArticleId, articleId);
|
||||||
|
YxArticleContent yxArticleContent = yxArticleContentService.getOne(yxArticleContentLambdaQueryWrapper);
|
||||||
|
if (yxArticleContent != null) {
|
||||||
|
miniYxArticleDTO.setContent(yxArticleContent.getContent());
|
||||||
|
miniYxArticleDTO.setContentType(yxArticleContent.getContentType());
|
||||||
|
}
|
||||||
|
return miniYxArticleDTO;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean save(ArticleEditVO articleEditVO) {
|
||||||
|
YxArticle yxArticle = new YxArticle();
|
||||||
|
AssertUtils.notNull(articleEditVO.getTitle(),"请输入标题");
|
||||||
|
/*AssertUtils.notNull(yxArticle.getSchoolName(),"");*/
|
||||||
|
BeanUtils.copyProperties(articleEditVO,yxArticle);
|
||||||
|
//判断院校id
|
||||||
|
if (yxArticle.getViewCount()==null) {
|
||||||
|
yxArticle.setViewCount(0);
|
||||||
|
}
|
||||||
|
this.saveOrUpdate(yxArticle);
|
||||||
|
YxArticleContent yxArticleContent = new YxArticleContent();
|
||||||
|
yxArticleContent.setArticleId(yxArticle.getId());
|
||||||
|
yxArticleContent.setContent(articleEditVO.getContent());
|
||||||
|
yxArticleContent.setContentType("2");
|
||||||
|
yxArticleContentService.save(yxArticleContent);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean edit(ArticleEditVO articleEditVO) {
|
||||||
|
YxArticle yxArticle = new YxArticle();
|
||||||
|
AssertUtils.notNull(articleEditVO.getTitle(),"请输入标题");
|
||||||
|
/*AssertUtils.notNull(yxArticle.getSchoolName(),"");*/
|
||||||
|
BeanUtils.copyProperties(articleEditVO,yxArticle);
|
||||||
|
yxArticle.setYear(articleEditVO.getYear());
|
||||||
|
//判断院校id
|
||||||
|
if (yxArticle.getViewCount()==null) {
|
||||||
|
yxArticle.setViewCount(0);
|
||||||
|
}
|
||||||
|
this.saveOrUpdate(yxArticle);
|
||||||
|
LambdaUpdateWrapper<YxArticleContent> updateWrapper = new LambdaUpdateWrapper<YxArticleContent>();
|
||||||
|
updateWrapper.eq(YxArticleContent::getArticleId, yxArticle.getId());
|
||||||
|
updateWrapper.set(YxArticleContent::getContent,articleEditVO.getContent());
|
||||||
|
yxArticleContentService.update(updateWrapper);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ import org.jeecg.modules.art.dto.ArtHotSchoolDTO;
|
||||||
import org.jeecg.modules.art.dto.ArtSchoolDTO;
|
import org.jeecg.modules.art.dto.ArtSchoolDTO;
|
||||||
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
import org.jeecg.modules.art.vo.QueryRecommendMajorVO;
|
||||||
import org.jeecg.modules.mini.dto.MiniSchoolDTO;
|
import org.jeecg.modules.mini.dto.MiniSchoolDTO;
|
||||||
|
import org.jeecg.modules.yx.dto.YxSchoolDTO;
|
||||||
import org.jeecg.modules.yx.entity.*;
|
import org.jeecg.modules.yx.entity.*;
|
||||||
import org.jeecg.modules.yx.mapper.YxSchoolMapper;
|
import org.jeecg.modules.yx.mapper.YxSchoolMapper;
|
||||||
import org.jeecg.modules.yx.service.*;
|
import org.jeecg.modules.yx.service.*;
|
||||||
|
|
@ -310,6 +311,11 @@ public class YxSchoolServiceImpl extends ServiceImpl<YxSchoolMapper, YxSchool> i
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public YxSchoolDTO getBySchoolName(String schoolName) {
|
||||||
|
return baseMapper.getBySchoolName(schoolName);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<YxSchool> oldList() {
|
public List<YxSchool> oldList() {
|
||||||
return baseMapper.oldList();
|
return baseMapper.oldList();
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,63 @@
|
||||||
|
package org.jeecg.modules.yx.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Description 文章编辑对象
|
||||||
|
* @Author ZhouWenTao
|
||||||
|
* @Date 2024/3/10 21:12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class ArticleEditVO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**文章id*/
|
||||||
|
@ApiModelProperty(value = "主键")
|
||||||
|
private java.lang.String id;
|
||||||
|
/**标题*/
|
||||||
|
@Excel(name = "标题", width = 15)
|
||||||
|
@ApiModelProperty(value = "标题")
|
||||||
|
private java.lang.String title;
|
||||||
|
/**文章内容*/
|
||||||
|
@Excel(name = "文章内容", width = 15)
|
||||||
|
@ApiModelProperty(value = "文章内容")
|
||||||
|
private java.lang.String content;
|
||||||
|
/**内容类型(1.纯文本,2.富文本)*/
|
||||||
|
@Excel(name = "内容类型(1.纯文本,2.富文本)", width = 15)
|
||||||
|
@ApiModelProperty(value = "内容类型(1.纯文本,2.富文本)")
|
||||||
|
private java.lang.String contentType;
|
||||||
|
/**院校id*/
|
||||||
|
@Excel(name = "院校id", width = 15)
|
||||||
|
@ApiModelProperty(value = "院校id")
|
||||||
|
private java.lang.String schoolId;
|
||||||
|
@ApiModelProperty(value = "年份")
|
||||||
|
private String year;
|
||||||
|
/**院校名称*/
|
||||||
|
@Excel(name = "院校名称", width = 15)
|
||||||
|
@ApiModelProperty(value = "院校名称")
|
||||||
|
private java.lang.String schoolName;
|
||||||
|
/**发布者*/
|
||||||
|
@Excel(name = "发布者", width = 15)
|
||||||
|
@ApiModelProperty(value = "发布者")
|
||||||
|
private java.lang.String author;
|
||||||
|
/**类型(1.招生章程)*/
|
||||||
|
@Excel(name = "类型(1.招生章程)", width = 15)
|
||||||
|
@ApiModelProperty(value = "类型(1.招生章程)")
|
||||||
|
private java.lang.String type;
|
||||||
|
/**发布日期*/
|
||||||
|
@Excel(name = "发布日期", width = 20, format = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "发布日期")
|
||||||
|
private java.util.Date releaseTime;
|
||||||
|
/**阅读量*/
|
||||||
|
@Excel(name = "阅读量", width = 15)
|
||||||
|
@ApiModelProperty(value = "阅读量")
|
||||||
|
private java.lang.Integer viewCount;
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue