资讯管理 资讯信息和资讯分类实现 add by gqk 2024/04/16 15:29
This commit is contained in:
parent
be597c2af3
commit
e00a55efad
@ -26,6 +26,8 @@ xinelu:
|
|||||||
script-file-url: /scriptFileUrl
|
script-file-url: /scriptFileUrl
|
||||||
# 获取管理端富文本的上传路径
|
# 获取管理端富文本的上传路径
|
||||||
rich-text-picture-url: /richTextPictureUrl
|
rich-text-picture-url: /richTextPictureUrl
|
||||||
|
# 资讯富文本的上传路径
|
||||||
|
info-rich-text-picture-url: /infoRichTextPictureUrl
|
||||||
|
|
||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
server:
|
server:
|
||||||
@ -80,7 +82,7 @@ spring:
|
|||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 6
|
database: 6
|
||||||
# 密码
|
# 密码
|
||||||
password: xinelu@6990
|
password: 123456
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
timeout: 10s
|
timeout: 10s
|
||||||
lettuce:
|
lettuce:
|
||||||
@ -103,8 +105,7 @@ token:
|
|||||||
# 令牌有效期(默认30分钟)
|
# 令牌有效期(默认30分钟)
|
||||||
expireTime: 30
|
expireTime: 30
|
||||||
# 请求拦截白名单
|
# 请求拦截白名单
|
||||||
ant-matchers: /postDischarge/**,/testMobile/**
|
ant-matchers: /postDischarge/**,/testMobile/**,/mobile/**
|
||||||
|
|
||||||
## MyBatis-Plus配置
|
## MyBatis-Plus配置
|
||||||
mybatis-plus:
|
mybatis-plus:
|
||||||
# 实体扫描,多个package用逗号或者分号分隔
|
# 实体扫描,多个package用逗号或者分号分隔
|
||||||
|
|||||||
@ -71,6 +71,11 @@ public class SystemBusinessConfig {
|
|||||||
*/
|
*/
|
||||||
private String scriptFileUrl;
|
private String scriptFileUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯图片地址
|
||||||
|
*/
|
||||||
|
private String infoRichTextPictureUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取管理端富文本的上传路径
|
* 获取管理端富文本的上传路径
|
||||||
*/
|
*/
|
||||||
@ -206,4 +211,12 @@ public class SystemBusinessConfig {
|
|||||||
public void setRichTextPictureUrl(String richTextPictureUrl) {
|
public void setRichTextPictureUrl(String richTextPictureUrl) {
|
||||||
this.richTextPictureUrl = richTextPictureUrl;
|
this.richTextPictureUrl = richTextPictureUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInfoRichTextPictureUrl() {
|
||||||
|
return infoRichTextPictureUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInfoRichTextPictureUrl(String infoRichTextPictureUrl) {
|
||||||
|
this.infoRichTextPictureUrl = infoRichTextPictureUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -283,4 +283,19 @@ public class Constants {
|
|||||||
* 成功
|
* 成功
|
||||||
*/
|
*/
|
||||||
public static final int SUCCESS_ERROR_CODE = 0;
|
public static final int SUCCESS_ERROR_CODE = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类编码前缀
|
||||||
|
*/
|
||||||
|
public static final String INFO_CATEGORY_CODE = "ICC";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯编码前缀
|
||||||
|
*/
|
||||||
|
public static final String INFO_CODE = "IC";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 科室编码前缀
|
||||||
|
*/
|
||||||
|
public static final String DEPARTMENT_CODE = "HDC";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import com.xinelu.common.config.SystemBusinessConfig;
|
|||||||
import com.xinelu.common.utils.DateUtils;
|
import com.xinelu.common.utils.DateUtils;
|
||||||
import com.xinelu.common.utils.StringUtils;
|
import com.xinelu.common.utils.StringUtils;
|
||||||
import com.xinelu.common.utils.uuid.IdUtils;
|
import com.xinelu.common.utils.uuid.IdUtils;
|
||||||
|
import org.apache.commons.compress.utils.Lists;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
@ -13,6 +14,10 @@ import javax.servlet.http.HttpServletResponse;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件处理工具类
|
* 文件处理工具类
|
||||||
@ -22,6 +27,16 @@ import java.nio.charset.StandardCharsets;
|
|||||||
public class FileUtils {
|
public class FileUtils {
|
||||||
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匹配content中的<img />标签
|
||||||
|
**/
|
||||||
|
private static final String PATTEN_IMG = "<(img|IMG)(.*?)(/>|></img>|>)";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 匹配<img />标签中的src
|
||||||
|
**/
|
||||||
|
private static final String PATTEN_SRC = "(src|SRC)=(\"|\')(.*?)(\"|\')";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 输出指定文件的byte数组
|
* 输出指定文件的byte数组
|
||||||
*
|
*
|
||||||
@ -243,4 +258,39 @@ public class FileUtils {
|
|||||||
return baseName;
|
return baseName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取img标签中的src值
|
||||||
|
*
|
||||||
|
* @param content img的内容
|
||||||
|
* @return List<String>
|
||||||
|
*/
|
||||||
|
public static List<String> getImgSrc(String content) {
|
||||||
|
if (StringUtils.isBlank(content)) {
|
||||||
|
return Lists.newArrayList();
|
||||||
|
}
|
||||||
|
List<String> list = new ArrayList<>();
|
||||||
|
//开始匹配content中的<img />标签
|
||||||
|
Pattern pImg = Pattern.compile(PATTEN_IMG);
|
||||||
|
Matcher mImg = pImg.matcher(content);
|
||||||
|
boolean resultImg = mImg.find();
|
||||||
|
if (resultImg) {
|
||||||
|
while (resultImg) {
|
||||||
|
//获取到匹配的<img />标签中的内容
|
||||||
|
String strImg = mImg.group(2);
|
||||||
|
//开始匹配<img />标签中的src
|
||||||
|
Pattern pSrc = Pattern.compile(PATTEN_SRC);
|
||||||
|
Matcher mSrc = pSrc.matcher(strImg);
|
||||||
|
if (mSrc.find()) {
|
||||||
|
String strSrc = mSrc.group(3);
|
||||||
|
if (StringUtils.isNotBlank(strSrc)) {
|
||||||
|
list.add(strSrc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//匹配content中是否存在下一个<img />标签,有则继续以上步骤匹配<img />标签中的src
|
||||||
|
resultImg = mImg.find();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,113 @@
|
|||||||
|
package com.xinelu.manage.controller.info;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.xinelu.manage.service.infocategory.IInfoCategoryService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.xinelu.common.annotation.Log;
|
||||||
|
import com.xinelu.common.core.controller.BaseController;
|
||||||
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
|
import com.xinelu.common.enums.BusinessType;
|
||||||
|
import com.xinelu.manage.domain.info.Info;
|
||||||
|
import com.xinelu.manage.service.info.IInfoService;
|
||||||
|
import com.xinelu.common.utils.poi.ExcelUtil;
|
||||||
|
import com.xinelu.common.core.page.TableDataInfo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯信息Controller
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manage/info")
|
||||||
|
public class InfoController extends BaseController {
|
||||||
|
@Resource
|
||||||
|
private IInfoService infoService;
|
||||||
|
@Resource
|
||||||
|
private IInfoCategoryService infoCategoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯信息列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:info:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(Info info) {
|
||||||
|
startPage();
|
||||||
|
List<Info> list = infoService.selectInfoList(info);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出资讯信息列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:info:export')")
|
||||||
|
@Log(title = "资讯信息", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, Info info) {
|
||||||
|
List<Info> list = infoService.selectInfoList(info);
|
||||||
|
ExcelUtil<Info> util = new ExcelUtil<>(Info.class);
|
||||||
|
util.exportExcel(response, list, "资讯信息数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资讯信息详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:info:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
|
return AjaxResult.success(infoService.selectInfoById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:info:add')")
|
||||||
|
@Log(title = "资讯信息", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("/add")
|
||||||
|
public AjaxResult add(@RequestBody Info info) {
|
||||||
|
return toAjax(infoService.insertInfo(info));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:info:edit')")
|
||||||
|
@Log(title = "资讯信息", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/edit")
|
||||||
|
public AjaxResult edit(@RequestBody Info info) {
|
||||||
|
return infoService.updateInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:info:remove')")
|
||||||
|
@Log(title = "资讯信息", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
return infoService.deleteInfoByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Log(title = "图片文件上传", businessType = BusinessType.OTHER)
|
||||||
|
@PostMapping("/picUpload")
|
||||||
|
public AjaxResult picUpload(@RequestBody MultipartFile file) {
|
||||||
|
|
||||||
|
return infoService.picUpload(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,104 @@
|
|||||||
|
package com.xinelu.manage.controller.infocategory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.xinelu.common.custominterface.Insert;
|
||||||
|
import com.xinelu.manage.dto.infocategory.InfoCategoryDTO;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import com.xinelu.common.annotation.Log;
|
||||||
|
import com.xinelu.common.core.controller.BaseController;
|
||||||
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
|
import com.xinelu.common.enums.BusinessType;
|
||||||
|
import com.xinelu.manage.domain.infocategory.InfoCategory;
|
||||||
|
import com.xinelu.manage.service.infocategory.IInfoCategoryService;
|
||||||
|
import com.xinelu.common.utils.poi.ExcelUtil;
|
||||||
|
import com.xinelu.common.core.page.TableDataInfo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类Controller
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/manage/category")
|
||||||
|
public class InfoCategoryController extends BaseController {
|
||||||
|
@Resource
|
||||||
|
private IInfoCategoryService infoCategoryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯分类列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:category:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(InfoCategory infoCategory) {
|
||||||
|
startPage();
|
||||||
|
List<InfoCategory> list = infoCategoryService.selectInfoCategoryList(infoCategory);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 导出资讯分类列表
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:category:export')")
|
||||||
|
@Log(title = "资讯分类", businessType = BusinessType.EXPORT)
|
||||||
|
@PostMapping("/export")
|
||||||
|
public void export(HttpServletResponse response, InfoCategory infoCategory) {
|
||||||
|
List<InfoCategory> list = infoCategoryService.selectInfoCategoryList(infoCategory);
|
||||||
|
ExcelUtil<InfoCategory> util = new ExcelUtil<>(InfoCategory.class);
|
||||||
|
util.exportExcel(response, list, "资讯分类数据");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取资讯分类详细信息
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:category:query')")
|
||||||
|
@GetMapping(value = "/{id}")
|
||||||
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||||
|
return AjaxResult.success(infoCategoryService.selectInfoCategoryById(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯分类
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:category:add')")
|
||||||
|
@Log(title = "资讯分类", businessType = BusinessType.INSERT)
|
||||||
|
@PostMapping("/add")
|
||||||
|
public AjaxResult add(@RequestBody @Validated(Insert.class) InfoCategoryDTO infoCategoryDTO) {
|
||||||
|
|
||||||
|
return infoCategoryService.insertInfoCategory(infoCategoryDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯分类
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:category:edit')")
|
||||||
|
@Log(title = "资讯分类", businessType = BusinessType.UPDATE)
|
||||||
|
@PutMapping("/edit")
|
||||||
|
public AjaxResult edit(@RequestBody InfoCategory infoCategory) {
|
||||||
|
return infoCategoryService.updateInfoCategory(infoCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯分类
|
||||||
|
*/
|
||||||
|
@PreAuthorize("@ss.hasPermi('manage:category:remove')")
|
||||||
|
@Log(title = "资讯分类", businessType = BusinessType.DELETE)
|
||||||
|
@DeleteMapping("/{ids}")
|
||||||
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||||
|
return toAjax(infoCategoryService.deleteInfoCategoryByIds(ids));
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,152 @@
|
|||||||
|
package com.xinelu.manage.domain.info;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
import com.xinelu.common.annotation.Excel;
|
||||||
|
import com.xinelu.common.core.domain.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯信息对象 info
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "资讯信息对象", description = "info")
|
||||||
|
public class Info extends BaseEntity {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键id
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯所属分类id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯所属分类id")
|
||||||
|
@Excel(name = "资讯所属分类id")
|
||||||
|
private Long infoCategoryId;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯所属分类id
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯列别名称")
|
||||||
|
@Excel(name = "资讯类别名称")
|
||||||
|
private String infoCategoryName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯标题
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯标题")
|
||||||
|
@Excel(name = "资讯标题")
|
||||||
|
private String infoTitle;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯编码
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯编码")
|
||||||
|
@Excel(name = "资讯编码")
|
||||||
|
private String infoCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯图文内容,富文本
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯图文内容,富文本")
|
||||||
|
@Excel(name = "资讯图文内容,富文本")
|
||||||
|
private String infoContent;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 咨询点击次数
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯点击次数")
|
||||||
|
@Excel(name = "咨询点击次数")
|
||||||
|
private Long infoClickCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯跳转路径
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯跳转路径")
|
||||||
|
@Excel(name = "资讯跳转路径")
|
||||||
|
private String infoJumpLink;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯大图地址
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯大图地址")
|
||||||
|
@Excel(name = "资讯大图地址")
|
||||||
|
private String infoLargePictureUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯排序
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯排序")
|
||||||
|
@Excel(name = "资讯排序")
|
||||||
|
private Long infoSort;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯创建人
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯创建人")
|
||||||
|
@Excel(name = "资讯创建人")
|
||||||
|
private String infoCreator;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯创建时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯创建时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "资讯创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime infoCreateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯修改人
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯修改人")
|
||||||
|
@Excel(name = "资讯修改人")
|
||||||
|
private String infoReviser;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯修改时间
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "资讯修改时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "资讯修改时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime infoModifyTime;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id", getId())
|
||||||
|
.append("infoCategoryId", getInfoCategoryId())
|
||||||
|
.append("infoCategoryName", getInfoCategoryName())
|
||||||
|
.append("infoTitle", getInfoTitle())
|
||||||
|
.append("infoCode", getInfoCode())
|
||||||
|
.append("infoContent", getInfoContent())
|
||||||
|
.append("infoClickCount", getInfoClickCount())
|
||||||
|
.append("infoJumpLink", getInfoJumpLink())
|
||||||
|
.append("infoLargePictureUrl", getInfoLargePictureUrl())
|
||||||
|
.append("infoSort", getInfoSort())
|
||||||
|
.append("infoCreator", getInfoCreator())
|
||||||
|
.append("infoCreateTime", getInfoCreateTime())
|
||||||
|
.append("infoReviser", getInfoReviser())
|
||||||
|
.append("infoModifyTime", getInfoModifyTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,81 @@
|
|||||||
|
package com.xinelu.manage.domain.infocategory;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.xinelu.common.annotation.Excel;
|
||||||
|
import com.xinelu.common.core.domain.BaseEntity;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类对象 info_category
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ApiModel(value = "资讯分类对象", description = "info_category")
|
||||||
|
public class InfoCategory extends BaseEntity
|
||||||
|
{
|
||||||
|
private static final long serialVersionUID=1L;
|
||||||
|
|
||||||
|
/** 主键id */
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 资讯分类编码 */
|
||||||
|
@ApiModelProperty(value = "资讯分类编码")
|
||||||
|
@Excel(name = "资讯分类编码")
|
||||||
|
private String infoCategoryCode;
|
||||||
|
|
||||||
|
/** 资讯分类名称 */
|
||||||
|
@ApiModelProperty(value = "资讯分类名称")
|
||||||
|
@Excel(name = "资讯分类名称")
|
||||||
|
private String infoCategoryName;
|
||||||
|
|
||||||
|
/** 资讯分类类型 */
|
||||||
|
@ApiModelProperty(value = "资讯分类类型")
|
||||||
|
@Excel(name = "资讯分类类型")
|
||||||
|
private String infoCategoryType;
|
||||||
|
|
||||||
|
/** 资讯分类排序 */
|
||||||
|
@ApiModelProperty(value = "资讯分类排序")
|
||||||
|
@Excel(name = "资讯分类排序")
|
||||||
|
private Long infoCategorySort;
|
||||||
|
|
||||||
|
/** 资讯创建人 */
|
||||||
|
@ApiModelProperty(value = "资讯创建人")
|
||||||
|
@Excel(name = "资讯创建人")
|
||||||
|
private String infoCategoryCreator;
|
||||||
|
|
||||||
|
/** 资讯创建时间 */
|
||||||
|
@ApiModelProperty(value = "资讯创建时间")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@Excel(name = "资讯创建时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
private LocalDateTime infoCategoryCreateTime;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
|
||||||
|
.append("id",getId())
|
||||||
|
.append("infoCategoryCode",getInfoCategoryCode())
|
||||||
|
.append("infoCategoryName",getInfoCategoryName())
|
||||||
|
.append("infoCategoryType",getInfoCategoryType())
|
||||||
|
.append("infoCategorySort",getInfoCategorySort())
|
||||||
|
.append("infoCategoryCreator",getInfoCategoryCreator())
|
||||||
|
.append("infoCategoryCreateTime",getInfoCategoryCreateTime())
|
||||||
|
.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,17 @@
|
|||||||
|
package com.xinelu.manage.dto.infocategory;
|
||||||
|
|
||||||
|
import com.xinelu.manage.domain.infocategory.InfoCategory;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class InfoCategoryDTO implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类对象传入集合
|
||||||
|
*/
|
||||||
|
private List<InfoCategory> infoCategoryList;
|
||||||
|
}
|
||||||
@ -0,0 +1,72 @@
|
|||||||
|
package com.xinelu.manage.mapper.info;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xinelu.manage.domain.info.Info;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯信息Mapper接口
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
public interface InfoMapper {
|
||||||
|
/**
|
||||||
|
* 查询资讯信息
|
||||||
|
*
|
||||||
|
* @param id 资讯信息主键
|
||||||
|
* @return 资讯信息
|
||||||
|
*/
|
||||||
|
Info selectInfoById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯信息列表
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 资讯信息集合
|
||||||
|
*/
|
||||||
|
List<Info> selectInfoList(Info info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯信息
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertInfo(Info info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯信息
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateInfo(Info info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯信息
|
||||||
|
*
|
||||||
|
* @param id 资讯信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资讯信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoByIds(Long[] ids);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id数组查询资讯信息
|
||||||
|
*
|
||||||
|
* @param ids 数组
|
||||||
|
* @return List<Info>
|
||||||
|
*/
|
||||||
|
|
||||||
|
List<Info> selectInfoByIds(Long[] ids);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,94 @@
|
|||||||
|
package com.xinelu.manage.mapper.infocategory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xinelu.manage.domain.infocategory.InfoCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类Mapper接口
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
public interface InfoCategoryMapper {
|
||||||
|
/**
|
||||||
|
* 查询资讯分类
|
||||||
|
*
|
||||||
|
* @param id 资讯分类主键
|
||||||
|
* @return 资讯分类
|
||||||
|
*/
|
||||||
|
InfoCategory selectInfoCategoryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据名称查询是否存在类型
|
||||||
|
* @param name
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
InfoCategory selectInfoCategoryByName(String name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯分类列表
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 资讯分类集合
|
||||||
|
*/
|
||||||
|
List<InfoCategory> selectInfoCategoryList(InfoCategory infoCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertInfoCategory(InfoCategory infoCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int updateInfoCategory(InfoCategory infoCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯分类
|
||||||
|
*
|
||||||
|
* @param id 资讯分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoCategoryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资讯分类
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的数据主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoCategoryByIds(Long[] ids);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类名称查询重复分类名称
|
||||||
|
*
|
||||||
|
* @param categoryNameList 资讯分类名称集合
|
||||||
|
* @return List<String>
|
||||||
|
*/
|
||||||
|
List<String> selectInfoCategoryName(List<String> categoryNameList);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量新增资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategoryList 资讯分类集合
|
||||||
|
* @return 数量
|
||||||
|
*/
|
||||||
|
int insertInfoCategoryList(List<InfoCategory> infoCategoryList);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据分类名称查询重复分类名称
|
||||||
|
*
|
||||||
|
* @param infoCategoryName 资讯分类名称
|
||||||
|
* @return int
|
||||||
|
**/
|
||||||
|
int selectInfoCategoryCount(String infoCategoryName);
|
||||||
|
}
|
||||||
@ -0,0 +1,70 @@
|
|||||||
|
package com.xinelu.manage.service.info;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
|
import com.xinelu.manage.domain.info.Info;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯信息Service接口
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
public interface IInfoService {
|
||||||
|
/**
|
||||||
|
* 查询资讯信息
|
||||||
|
*
|
||||||
|
* @param id 资讯信息主键
|
||||||
|
* @return 资讯信息
|
||||||
|
*/
|
||||||
|
Info selectInfoById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯信息列表
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 资讯信息集合
|
||||||
|
*/
|
||||||
|
List<Info> selectInfoList(Info info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯信息
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int insertInfo(Info info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯信息
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
AjaxResult updateInfo(Info info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资讯信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的资讯信息主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
AjaxResult deleteInfoByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯信息信息
|
||||||
|
*
|
||||||
|
* @param id 资讯信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片文件上传
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
AjaxResult picUpload(MultipartFile file);
|
||||||
|
}
|
||||||
@ -0,0 +1,225 @@
|
|||||||
|
package com.xinelu.manage.service.info.impl;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.xinelu.common.config.SystemBusinessConfig;
|
||||||
|
import com.xinelu.common.constant.Constants;
|
||||||
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
|
import com.xinelu.common.exception.ServiceException;
|
||||||
|
import com.xinelu.common.utils.SecurityUtils;
|
||||||
|
import com.xinelu.common.utils.codes.GenerateSystemCodeUtil;
|
||||||
|
import com.xinelu.common.utils.file.FileUploadUtils;
|
||||||
|
import com.xinelu.common.utils.file.FileUtils;
|
||||||
|
import io.netty.util.internal.ObjectUtil;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.xinelu.manage.mapper.info.InfoMapper;
|
||||||
|
import com.xinelu.manage.domain.info.Info;
|
||||||
|
import com.xinelu.manage.service.info.IInfoService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯信息Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InfoServiceImpl implements IInfoService {
|
||||||
|
@Resource
|
||||||
|
private InfoMapper infoMapper;
|
||||||
|
@Resource
|
||||||
|
private GenerateSystemCodeUtil generateSystemCodeUtil;
|
||||||
|
@Resource
|
||||||
|
private SystemBusinessConfig systemBusinessConfig;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯信息
|
||||||
|
*
|
||||||
|
* @param id 资讯信息主键
|
||||||
|
* @return 资讯信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Info selectInfoById(Long id) {
|
||||||
|
return infoMapper.selectInfoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯信息列表
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 资讯信息
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Info> selectInfoList(Info info) {
|
||||||
|
return infoMapper.selectInfoList(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯信息
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int insertInfo(Info info) {
|
||||||
|
info.setInfoCreateTime(LocalDateTime.now());
|
||||||
|
info.setInfoCreator(SecurityUtils.getUsername());
|
||||||
|
info.setInfoCode(Constants.INFO_CODE + generateSystemCodeUtil.generateSystemCode(Constants.INFO_CODE));
|
||||||
|
return infoMapper.insertInfo(info);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯信息
|
||||||
|
*
|
||||||
|
* @param info 资讯信息
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult updateInfo(Info info) {
|
||||||
|
//根据id查询之前的数据
|
||||||
|
Info infoByID = infoMapper.selectInfoById(info.getId());
|
||||||
|
if (Objects.isNull(infoByID)) {
|
||||||
|
return AjaxResult.error("当前资讯信息不存在,无法修改,请联系管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加修改人 修改时间
|
||||||
|
info.setInfoReviser(SecurityUtils.getUsername());
|
||||||
|
info.setInfoModifyTime(LocalDateTime.now());
|
||||||
|
int count = infoMapper.updateInfo(info);
|
||||||
|
if (count <= 0) {
|
||||||
|
throw new ServiceException("修改资讯信息失败,请联系管理员!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//如果两个图片不相等,删除之前的图片
|
||||||
|
if (!info.getInfoLargePictureUrl().equals(infoByID.getInfoLargePictureUrl())) {
|
||||||
|
deletePictureUrl(infoByID.getInfoLargePictureUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
//遍历修改前后内容相不相等,如果不为空且不相等,寻找遍历前后图片的差集,然后删除.
|
||||||
|
if (StringUtils.isNotBlank(info.getInfoContent()) && StringUtils.isNotBlank(infoByID.getInfoContent())
|
||||||
|
&& !info.getInfoContent().equals(infoByID.getInfoContent())) {
|
||||||
|
//获取图片地址
|
||||||
|
List<String> infoImgSrc = FileUtils.getImgSrc(info.getInfoContent());
|
||||||
|
List<String> infoByIDImgSrc = FileUtils.getImgSrc(infoByID.getInfoContent());
|
||||||
|
|
||||||
|
//遍历删除图片
|
||||||
|
List<String> subList = new ArrayList<>(CollectionUtils.subtract(infoImgSrc, infoByIDImgSrc));
|
||||||
|
for (String picUrl : subList) {
|
||||||
|
|
||||||
|
if (StringUtils.isBlank(picUrl)) { //删除富文本图片
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//修改路径
|
||||||
|
String substring = picUrl.substring(picUrl.indexOf("/profile"));
|
||||||
|
//删除富文本图片
|
||||||
|
deletePictureUrl(substring);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资讯信息
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的资讯信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult deleteInfoByIds(Long[] ids) {
|
||||||
|
//查询删除之前数据
|
||||||
|
List<Info> infoList = infoMapper.selectInfoByIds(ids);
|
||||||
|
//删除表信息
|
||||||
|
int count = infoMapper.deleteInfoByIds(ids);
|
||||||
|
if (count <= 0) {
|
||||||
|
return AjaxResult.error("删除资讯信息失败!");
|
||||||
|
}
|
||||||
|
|
||||||
|
//筛选资讯主缩略图
|
||||||
|
List<String> largePicUrlList = infoList.stream().filter(Objects::nonNull).map(Info::getInfoLargePictureUrl).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||||
|
//删除主图
|
||||||
|
for (String picUrl : largePicUrlList) {
|
||||||
|
String substring = picUrl.substring(picUrl.indexOf("/profile"));
|
||||||
|
//删除富文本图片
|
||||||
|
deletePictureUrl(substring);
|
||||||
|
}
|
||||||
|
|
||||||
|
//筛选资讯内容
|
||||||
|
List<String> infoContentList = infoList.stream().filter(Objects::nonNull).map(Info::getInfoLargePictureUrl).filter(StringUtils::isNotBlank).collect(Collectors.toList());
|
||||||
|
//遍历获取富文本内容图片地址
|
||||||
|
for (String infoContent : infoContentList) {
|
||||||
|
List<String> picUrlList = FileUtils.getImgSrc(infoContent);
|
||||||
|
for (String picUrl : picUrlList) {
|
||||||
|
if (StringUtils.isBlank(picUrl)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//修改路径
|
||||||
|
String substring = picUrl.substring(picUrl.indexOf("/profile"));
|
||||||
|
//删除富文本图片
|
||||||
|
deletePictureUrl(substring);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯信息信息
|
||||||
|
*
|
||||||
|
* @param id 资讯信息主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteInfoById(Long id) {
|
||||||
|
return infoMapper.deleteInfoById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 图片文件上传
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public AjaxResult picUpload(MultipartFile file) {
|
||||||
|
try {
|
||||||
|
return AjaxResult.success(FileUploadUtils.upload(
|
||||||
|
systemBusinessConfig.getProfile() + systemBusinessConfig.getInfoRichTextPictureUrl(), file));
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return AjaxResult.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯站图片地址
|
||||||
|
*
|
||||||
|
* @param pictureUrl 资讯站图片地址
|
||||||
|
* @return void 资讯站图片地址
|
||||||
|
**/
|
||||||
|
private void deletePictureUrl(String pictureUrl) {
|
||||||
|
if (StringUtils.isBlank(pictureUrl)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String picture = SystemBusinessConfig.getProfile() + systemBusinessConfig.getInfoRichTextPictureUrl() + pictureUrl.replaceAll("/profile", "");
|
||||||
|
File checkReportNameFile = new File(picture);
|
||||||
|
if (checkReportNameFile.exists()) {
|
||||||
|
boolean delete = checkReportNameFile.delete();
|
||||||
|
if (BooleanUtils.isFalse(delete)) {
|
||||||
|
throw new ServiceException("图片地址删除失败!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,65 @@
|
|||||||
|
package com.xinelu.manage.service.infocategory;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
|
import com.xinelu.manage.domain.infocategory.InfoCategory;
|
||||||
|
import com.xinelu.manage.dto.infocategory.InfoCategoryDTO;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类Service接口
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
public interface IInfoCategoryService {
|
||||||
|
/**
|
||||||
|
* 查询资讯分类
|
||||||
|
*
|
||||||
|
* @param id 资讯分类主键
|
||||||
|
* @return 资讯分类
|
||||||
|
*/
|
||||||
|
InfoCategory selectInfoCategoryById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯分类列表
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 资讯分类集合
|
||||||
|
*/
|
||||||
|
List<InfoCategory> selectInfoCategoryList(InfoCategory infoCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategoryDTO 资讯分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
AjaxResult insertInfoCategory(InfoCategoryDTO infoCategoryDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
AjaxResult updateInfoCategory(InfoCategory infoCategory);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资讯分类
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的资讯分类主键集合
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoCategoryByIds(Long[] ids);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除资讯分类信息
|
||||||
|
*
|
||||||
|
* @param id 资讯分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
int deleteInfoCategoryById(Long id);
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,157 @@
|
|||||||
|
package com.xinelu.manage.service.infocategory.impl;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.xinelu.common.constant.Constants;
|
||||||
|
import com.xinelu.common.core.domain.AjaxResult;
|
||||||
|
import com.xinelu.common.utils.SecurityUtils;
|
||||||
|
import com.xinelu.common.utils.codes.GenerateSystemCodeUtil;
|
||||||
|
import com.xinelu.common.utils.file.FileUploadUtils;
|
||||||
|
import com.xinelu.manage.dto.infocategory.InfoCategoryDTO;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.xinelu.manage.mapper.infocategory.InfoCategoryMapper;
|
||||||
|
import com.xinelu.manage.domain.infocategory.InfoCategory;
|
||||||
|
import com.xinelu.manage.service.infocategory.IInfoCategoryService;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 资讯分类Service业务层处理
|
||||||
|
*
|
||||||
|
* @author xinelu
|
||||||
|
* @date 2024-04-11
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class InfoCategoryServiceImpl implements IInfoCategoryService {
|
||||||
|
@Resource
|
||||||
|
private InfoCategoryMapper infoCategoryMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private GenerateSystemCodeUtil generateSystemCodeUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯分类
|
||||||
|
*
|
||||||
|
* @param id 资讯分类主键
|
||||||
|
* @return 资讯分类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public InfoCategory selectInfoCategoryById(Long id) {
|
||||||
|
return infoCategoryMapper.selectInfoCategoryById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询资讯分类列表
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 资讯分类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<InfoCategory> selectInfoCategoryList(InfoCategory infoCategory) {
|
||||||
|
return infoCategoryMapper.selectInfoCategoryList(infoCategory);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新增资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategoryDTO 资讯分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult insertInfoCategory(InfoCategoryDTO infoCategoryDTO) {
|
||||||
|
//筛选不为空资讯分类名称
|
||||||
|
List<String> categoryNameList = infoCategoryDTO.getInfoCategoryList().stream().filter(Objects::nonNull).map(InfoCategory::getInfoCategoryName).collect(Collectors.toList());
|
||||||
|
//资讯分类名称去重
|
||||||
|
List<String> distinctNameList = infoCategoryDTO.getInfoCategoryList().stream().filter(Objects::nonNull).map(InfoCategory::getInfoCategoryName).distinct().collect(Collectors.toList());
|
||||||
|
|
||||||
|
//集合取差集
|
||||||
|
List<String> subtractNameList = new ArrayList<>(CollectionUtils.subtract(categoryNameList, distinctNameList));
|
||||||
|
if (subtractNameList.size() > 0) {
|
||||||
|
return AjaxResult.error("'" + subtractNameList.get(0) + "'重复,请修改后重新录入!");
|
||||||
|
}
|
||||||
|
//数据库查询资讯分类名称
|
||||||
|
List<String> existCategoryName = infoCategoryMapper.selectInfoCategoryName(categoryNameList);
|
||||||
|
|
||||||
|
List<String> existRetainAllNameList = new ArrayList<>(CollectionUtils.intersection(distinctNameList, existCategoryName));
|
||||||
|
if (existRetainAllNameList.size() > 0) {
|
||||||
|
return AjaxResult.error("'" + existRetainAllNameList.get(0) + "'已存在,请修改后重新录入!");
|
||||||
|
}
|
||||||
|
for (InfoCategory infocategory : infoCategoryDTO.getInfoCategoryList()) {
|
||||||
|
|
||||||
|
infocategory.setCreateTime(LocalDateTime.now());//设置添加时间
|
||||||
|
infocategory.setInfoCategoryCreator(SecurityUtils.getUsername());//设置当前的用户
|
||||||
|
infocategory.setInfoCategoryType(infocategory.getInfoCategoryName());//类型 无用 直接赋值和名称相同
|
||||||
|
infocategory.setInfoCategoryCode(Constants.INFO_CATEGORY_CODE + generateSystemCodeUtil.generateSystemCode(Constants.DEPARTMENT_CODE));
|
||||||
|
}
|
||||||
|
int insertCount = infoCategoryMapper.insertInfoCategoryList(infoCategoryDTO.getInfoCategoryList());
|
||||||
|
if (insertCount < 0) {
|
||||||
|
throw new RuntimeException("新增资讯分类信息失败,请联系管理员!");
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改资讯分类
|
||||||
|
*
|
||||||
|
* @param infoCategory 资讯分类
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public AjaxResult updateInfoCategory(InfoCategory infoCategory) {
|
||||||
|
//根据咨询分类id查询数据库
|
||||||
|
// InfoCategory infoCategoryByName = infoCategoryMapper.selectInfoCategoryByName(infoCategory.getInfoCategoryName());
|
||||||
|
InfoCategory infoCategoryByName = infoCategoryMapper.selectInfoCategoryById(infoCategory.getId());
|
||||||
|
if (Objects.isNull(infoCategoryByName)) {
|
||||||
|
return AjaxResult.error("当前资讯分类信息不存在,无法修改,请联系管理员!");
|
||||||
|
}
|
||||||
|
//两名称都不为空,且不相等
|
||||||
|
if (StringUtils.isNotBlank(infoCategory.getInfoCategoryName()) && StringUtils.isNotBlank(infoCategoryByName.getInfoCategoryName()) && !infoCategory.getInfoCategoryName().equals(infoCategoryByName.getInfoCategoryName())) {
|
||||||
|
int infoCategoryCount = infoCategoryMapper.selectInfoCategoryCount(infoCategory.getInfoCategoryName());//查找要修改的名称是否已经存在了
|
||||||
|
if (infoCategoryCount > 0) {
|
||||||
|
return AjaxResult.error("已有该资讯分类信息名称:" + infoCategory.getInfoCategoryName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
infoCategoryByName.setUpdateTime(LocalDateTime.now());//设置时间
|
||||||
|
infoCategoryByName.setInfoCategoryName(infoCategory.getInfoCategoryName());//设置名称为修改的名称
|
||||||
|
infoCategoryByName.setInfoCategorySort(infoCategory.getInfoCategorySort());//设置排序
|
||||||
|
infoCategoryByName.setUpdateBy(SecurityUtils.getUsername());//设置当前用户
|
||||||
|
infoCategoryByName.setInfoCategoryType(infoCategory.getInfoCategoryName());//类型
|
||||||
|
int updateInfoCategory = infoCategoryMapper.updateInfoCategory(infoCategoryByName);//更新到数据库
|
||||||
|
if (updateInfoCategory < 0) {
|
||||||
|
return AjaxResult.error("修改资讯分类信息失败,请联系管理员!");
|
||||||
|
}
|
||||||
|
return AjaxResult.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量删除资讯分类
|
||||||
|
*
|
||||||
|
* @param ids 需要删除的资讯分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteInfoCategoryByIds(Long[] ids) {
|
||||||
|
return infoCategoryMapper.deleteInfoCategoryByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 删除资讯分类信息
|
||||||
|
*
|
||||||
|
* @param id 资讯分类主键
|
||||||
|
* @return 结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int deleteInfoCategoryById(Long id) {
|
||||||
|
return infoCategoryMapper.deleteInfoCategoryById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,223 @@
|
|||||||
|
<?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="com.xinelu.manage.mapper.info.InfoMapper">
|
||||||
|
|
||||||
|
<resultMap type="Info" id="InfoResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="infoCategoryId" column="info_category_id"/>
|
||||||
|
<result property="infoCategoryName" column="info_category_name"/>
|
||||||
|
<result property="infoTitle" column="info_title"/>
|
||||||
|
<result property="infoCode" column="info_code"/>
|
||||||
|
<result property="infoContent" column="info_content"/>
|
||||||
|
<result property="infoClickCount" column="info_click_count"/>
|
||||||
|
<result property="infoJumpLink" column="info_jump_link"/>
|
||||||
|
<result property="infoLargePictureUrl" column="info_large_picture_url"/>
|
||||||
|
<result property="infoSort" column="info_sort"/>
|
||||||
|
<result property="infoCreator" column="info_creator"/>
|
||||||
|
<result property="infoCreateTime" column="info_create_time"/>
|
||||||
|
<result property="infoReviser" column="info_reviser"/>
|
||||||
|
<result property="infoModifyTime" column="info_modify_time"/>
|
||||||
|
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectInfoVo">
|
||||||
|
select id,
|
||||||
|
info_category_id,
|
||||||
|
info_category_name,
|
||||||
|
info_title,
|
||||||
|
info_code,
|
||||||
|
info_content,
|
||||||
|
info_click_count,
|
||||||
|
info_jump_link,
|
||||||
|
info_large_picture_url,
|
||||||
|
info_sort,
|
||||||
|
info_creator,
|
||||||
|
info_create_time,
|
||||||
|
info_reviser,
|
||||||
|
info_modify_time
|
||||||
|
from info
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectInfoList" parameterType="Info" resultMap="InfoResult">
|
||||||
|
<include refid="selectInfoVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="infoCategoryId != null ">
|
||||||
|
and info_category_id = #{infoCategoryId}
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null ">
|
||||||
|
and info_category_name = #{infoCategoryName}
|
||||||
|
</if>
|
||||||
|
<if test="infoTitle != null and infoTitle != ''">
|
||||||
|
and info_title = #{infoTitle}
|
||||||
|
</if>
|
||||||
|
<if test="infoCode != null and infoCode != ''">
|
||||||
|
and info_code = #{infoCode}
|
||||||
|
</if>
|
||||||
|
<if test="infoContent != null and infoContent != ''">
|
||||||
|
and info_content = #{infoContent}
|
||||||
|
</if>
|
||||||
|
<if test="infoClickCount != null ">
|
||||||
|
and info_click_count = #{infoClickCount}
|
||||||
|
</if>
|
||||||
|
<if test="infoJumpLink != null and infoJumpLink != ''">
|
||||||
|
and info_jump_link = #{infoJumpLink}
|
||||||
|
</if>
|
||||||
|
<if test="infoLargePictureUrl != null and infoLargePictureUrl != ''">
|
||||||
|
and info_large_picture_url = #{infoLargePictureUrl}
|
||||||
|
</if>
|
||||||
|
<if test="infoSort != null ">
|
||||||
|
and info_sort = #{infoSort}
|
||||||
|
</if>
|
||||||
|
<if test="infoCreator != null and infoCreator != ''">
|
||||||
|
and info_creator = #{infoCreator}
|
||||||
|
</if>
|
||||||
|
<if test="infoCreateTime != null ">
|
||||||
|
and info_create_time = #{infoCreateTime}
|
||||||
|
</if>
|
||||||
|
<if test="infoReviser != null and infoReviser != ''">
|
||||||
|
and info_reviser = #{infoReviser}
|
||||||
|
</if>
|
||||||
|
<if test="infoModifyTime != null ">
|
||||||
|
and info_modify_time = #{infoModifyTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by info_sort
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectInfoById" parameterType="Long"
|
||||||
|
resultMap="InfoResult">
|
||||||
|
<include refid="selectInfoVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertInfo" parameterType="Info" useGeneratedKeys="true"
|
||||||
|
keyProperty="id">
|
||||||
|
insert into info
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="infoCategoryId != null">info_category_id,
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null">info_category_name,
|
||||||
|
</if>
|
||||||
|
<if test="infoTitle != null">info_title,
|
||||||
|
</if>
|
||||||
|
<if test="infoCode != null">info_code,
|
||||||
|
</if>
|
||||||
|
<if test="infoContent != null">info_content,
|
||||||
|
</if>
|
||||||
|
<if test="infoClickCount != null">info_click_count,
|
||||||
|
</if>
|
||||||
|
<if test="infoJumpLink != null">info_jump_link,
|
||||||
|
</if>
|
||||||
|
<if test="infoLargePictureUrl != null">info_large_picture_url,
|
||||||
|
</if>
|
||||||
|
<if test="infoSort != null">info_sort,
|
||||||
|
</if>
|
||||||
|
<if test="infoCreator != null">info_creator,
|
||||||
|
</if>
|
||||||
|
<if test="infoCreateTime != null">info_create_time,
|
||||||
|
</if>
|
||||||
|
<if test="infoReviser != null">info_reviser,
|
||||||
|
</if>
|
||||||
|
<if test="infoModifyTime != null">info_modify_time,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="infoCategoryId != null">#{infoCategoryId},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null">#{infoCategoryName},
|
||||||
|
</if>
|
||||||
|
<if test="infoTitle != null">#{infoTitle},
|
||||||
|
</if>
|
||||||
|
<if test="infoCode != null">#{infoCode},
|
||||||
|
</if>
|
||||||
|
<if test="infoContent != null">#{infoContent},
|
||||||
|
</if>
|
||||||
|
<if test="infoClickCount != null">#{infoClickCount},
|
||||||
|
</if>
|
||||||
|
<if test="infoJumpLink != null">#{infoJumpLink},
|
||||||
|
</if>
|
||||||
|
<if test="infoLargePictureUrl != null">#{infoLargePictureUrl},
|
||||||
|
</if>
|
||||||
|
<if test="infoSort != null">#{infoSort},
|
||||||
|
</if>
|
||||||
|
<if test="infoCreator != null">#{infoCreator},
|
||||||
|
</if>
|
||||||
|
<if test="infoCreateTime != null">#{infoCreateTime},
|
||||||
|
</if>
|
||||||
|
<if test="infoReviser != null">#{infoReviser},
|
||||||
|
</if>
|
||||||
|
<if test="infoModifyTime != null">#{infoModifyTime},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateInfo" parameterType="Info">
|
||||||
|
update info
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="infoCategoryId != null">info_category_id =
|
||||||
|
#{infoCategoryId},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null">info_category_name =
|
||||||
|
#{infoCategoryName},
|
||||||
|
</if>
|
||||||
|
<if test="infoTitle != null">info_title =
|
||||||
|
#{infoTitle},
|
||||||
|
</if>
|
||||||
|
<if test="infoCode != null">info_code =
|
||||||
|
#{infoCode},
|
||||||
|
</if>
|
||||||
|
<if test="infoContent != null">info_content =
|
||||||
|
#{infoContent},
|
||||||
|
</if>
|
||||||
|
<if test="infoClickCount != null">info_click_count =
|
||||||
|
#{infoClickCount},
|
||||||
|
</if>
|
||||||
|
<if test="infoJumpLink != null">info_jump_link =
|
||||||
|
#{infoJumpLink},
|
||||||
|
</if>
|
||||||
|
<if test="infoLargePictureUrl != null">info_large_picture_url =
|
||||||
|
#{infoLargePictureUrl},
|
||||||
|
</if>
|
||||||
|
<if test="infoSort != null">info_sort =
|
||||||
|
#{infoSort},
|
||||||
|
</if>
|
||||||
|
<if test="infoCreator != null">info_creator =
|
||||||
|
#{infoCreator},
|
||||||
|
</if>
|
||||||
|
<if test="infoCreateTime != null">info_create_time =
|
||||||
|
#{infoCreateTime},
|
||||||
|
</if>
|
||||||
|
<if test="infoReviser != null">info_reviser =
|
||||||
|
#{infoReviser},
|
||||||
|
</if>
|
||||||
|
<if test="infoModifyTime != null">info_modify_time =
|
||||||
|
#{infoModifyTime},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteInfoById" parameterType="Long">
|
||||||
|
delete
|
||||||
|
from info
|
||||||
|
where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteInfoByIds" parameterType="String">
|
||||||
|
delete from info where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectInfoByIds" resultMap="InfoResult">
|
||||||
|
<include refid="selectInfoVo"/>
|
||||||
|
where id in
|
||||||
|
<foreach item="ids" collection="array" open="(" separator="," close=")">
|
||||||
|
#{ids}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,166 @@
|
|||||||
|
<?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="com.xinelu.manage.mapper.infocategory.InfoCategoryMapper">
|
||||||
|
|
||||||
|
<resultMap type="InfoCategory" id="InfoCategoryResult">
|
||||||
|
<result property="id" column="id"/>
|
||||||
|
<result property="infoCategoryCode" column="info_category_code"/>
|
||||||
|
<result property="infoCategoryName" column="info_category_name"/>
|
||||||
|
<result property="infoCategoryType" column="info_category_type"/>
|
||||||
|
<result property="infoCategorySort" column="info_category_sort"/>
|
||||||
|
<result property="infoCategoryCreator" column="info_category_creator"/>
|
||||||
|
<result property="infoCategoryCreateTime" column="info_category_create_time"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="selectInfoCategoryVo">
|
||||||
|
select id, info_category_code, info_category_name, info_category_type, info_category_sort, info_category_creator, info_category_create_time from info_category
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="selectInfoCategoryList" parameterType="InfoCategory" resultMap="InfoCategoryResult">
|
||||||
|
<include refid="selectInfoCategoryVo"/>
|
||||||
|
<where>
|
||||||
|
<if test="infoCategoryCode != null and infoCategoryCode != ''">
|
||||||
|
and info_category_code = #{infoCategoryCode}
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null and infoCategoryName != ''">
|
||||||
|
and info_category_name like concat('%', #{infoCategoryName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryType != null and infoCategoryType != ''">
|
||||||
|
and info_category_type = #{infoCategoryType}
|
||||||
|
</if>
|
||||||
|
<if test="infoCategorySort != null ">
|
||||||
|
and info_category_sort = #{infoCategorySort}
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreator != null and infoCategoryCreator != ''">
|
||||||
|
and info_category_creator = #{infoCategoryCreator}
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreateTime != null ">
|
||||||
|
and info_category_create_time = #{infoCategoryCreateTime}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by info_category_sort
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectInfoCategoryByName" parameterType="String" resultMap="InfoCategoryResult">
|
||||||
|
<include refid="selectInfoCategoryVo"/>
|
||||||
|
where info_category_name = #{info_category_name}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="selectInfoCategoryById" parameterType="Long" resultMap="InfoCategoryResult">
|
||||||
|
<include refid="selectInfoCategoryVo"/>
|
||||||
|
where id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertInfoCategory" parameterType="InfoCategory" useGeneratedKeys="true"
|
||||||
|
keyProperty="id">
|
||||||
|
insert into info_category
|
||||||
|
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="infoCategoryCode != null">info_category_code,
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null">info_category_name,
|
||||||
|
</if>
|
||||||
|
<if test="e != null">info_category_type,
|
||||||
|
</if>
|
||||||
|
<if test="infoCategorySort != null">info_category_sort,
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreator != null">info_category_creator,
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreateTime != null">info_category_create_time,
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
|
<if test="infoCategoryCode != null">#{infoCategoryCode},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null">#{infoCategoryName},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryType != null">#{infoCategoryType},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategorySort != null">#{infoCategorySort},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreator != null">#{infoCategoryCreator},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreateTime != null">#{infoCategoryCreateTime},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<update id="updateInfoCategory" parameterType="InfoCategory">
|
||||||
|
update info_category
|
||||||
|
<trim prefix="SET" suffixOverrides=",">
|
||||||
|
<if test="infoCategoryCode != null">info_category_code =
|
||||||
|
#{infoCategoryCode},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryName != null">info_category_name =
|
||||||
|
#{infoCategoryName},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryType != null">info_category_type =
|
||||||
|
#{infoCategoryType},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategorySort != null">info_category_sort =
|
||||||
|
#{infoCategorySort},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreator != null">info_category_creator =
|
||||||
|
#{infoCategoryCreator},
|
||||||
|
</if>
|
||||||
|
<if test="infoCategoryCreateTime != null">info_category_create_time =
|
||||||
|
#{infoCategoryCreateTime},
|
||||||
|
</if>
|
||||||
|
</trim>
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteInfoCategoryById" parameterType="Long">
|
||||||
|
delete from info_category where id = #{id}
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<delete id="deleteInfoCategoryByIds" parameterType="String">
|
||||||
|
delete from info_category where id in
|
||||||
|
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<select id="selectInfoCategoryName" resultType="java.lang.String">
|
||||||
|
select info_category_name from info_category where info_category_name in
|
||||||
|
<foreach item="categoryNameList" collection="list" open="(" separator="," close=")">
|
||||||
|
#{categoryNameList}
|
||||||
|
</foreach>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insertInfoCategoryList">
|
||||||
|
insert into info_category(
|
||||||
|
info_category_code,
|
||||||
|
info_category_name,
|
||||||
|
info_category_type,
|
||||||
|
info_category_sort,
|
||||||
|
info_category_creator,
|
||||||
|
info_category_create_time
|
||||||
|
)values
|
||||||
|
<foreach item="infoCategoryList" index="index" collection="list" separator=",">
|
||||||
|
(
|
||||||
|
#{infoCategoryList.infoCategoryCode},
|
||||||
|
#{infoCategoryList.infoCategoryName},
|
||||||
|
#{infoCategoryList.infoCategoryType},
|
||||||
|
#{infoCategoryList.infoCategorySort},
|
||||||
|
#{infoCategoryList.infoCategoryCreator},
|
||||||
|
#{infoCategoryList.infoCategoryCreateTime}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="selectInfoCategoryCount" resultType="int">
|
||||||
|
SELECT
|
||||||
|
count( 1 )
|
||||||
|
FROM
|
||||||
|
info_category
|
||||||
|
<where>
|
||||||
|
<if test="infoCategoryName != null and infoCategoryName != ''">
|
||||||
|
and info_category_name = #{infoCategoryName}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package com.xinelu.mobile.controller.info;
|
||||||
|
|
||||||
|
import com.xinelu.common.core.controller.BaseController;
|
||||||
|
import com.xinelu.common.core.page.TableDataInfo;
|
||||||
|
import com.xinelu.manage.domain.info.Info;
|
||||||
|
import com.xinelu.manage.service.info.IInfoService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.xinelu.common.utils.PageUtils.startPage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信端获取资讯信息
|
||||||
|
* 资讯信息Controller
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/mobile/info")
|
||||||
|
public class MobileInfoController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IInfoService infoService;
|
||||||
|
|
||||||
|
|
||||||
|
//@PreAuthorize("@ss.hasPermi('mobile:info:list')")
|
||||||
|
@GetMapping("/list")
|
||||||
|
public TableDataInfo list(Info info) {
|
||||||
|
startPage();
|
||||||
|
List<Info> list = infoService.selectInfoList(info);
|
||||||
|
return getDataTable(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user