This commit is contained in:
wangchengming 2024-12-10 16:35:03 +08:00
commit 2ee0d0aefd
16 changed files with 1143 additions and 0 deletions

View File

@ -0,0 +1,93 @@
package com.ruoyi.official.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.official.domain.bo.GwCompanyMessageBo;
import com.ruoyi.official.domain.vo.GwCompanyMessageVo;
import com.ruoyi.official.service.IGwCompanyMessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
/**
* 留言信息
*
* @author ruoyi
* @date 2024-06-19
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/official/companymessage")
public class GwCompanyMessageController extends BaseController {
private final IGwCompanyMessageService iGwCompanyMessageService;
/**
* 查询新闻信息列表
*/
//@SaCheckPermission("official:companymessage:list")
@GetMapping("/list")
public TableDataInfo<GwCompanyMessageVo> list(GwCompanyMessageBo bo, PageQuery pageQuery) {
return iGwCompanyMessageService.queryPageList(bo, pageQuery);
}
/**
* 获取新闻信息详细信息
*
* @param id 主键
*/
/*@SaCheckPermission("official:slideshow:query")*/
@GetMapping("/{id}")
public R<GwCompanyMessageVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
return R.ok(iGwCompanyMessageService.queryById(id));
}
/**
* 新增新闻信息
*/
//@SaCheckPermission("official:companymessage:add")
@Log(title = "留言信息 ", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/add")
public R<Void> add(@Validated(AddGroup.class) @RequestBody GwCompanyMessageBo bo) {
return toAjax(iGwCompanyMessageService.insertByBo(bo));
}
/**
* 修改新闻信息
*/
//@SaCheckPermission("official:companymessage:edit")
@Log(title = "留言信息 ", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping("/edit")
public R<Void> edit(@Validated(EditGroup.class) @RequestBody GwCompanyMessageBo bo) {
return toAjax(iGwCompanyMessageService.updateByBo(bo));
}
/**
* 删除留言信息
*
* @param ids 主键串
*/
//@SaCheckPermission("official:companymessage:remove")
@Log(title = "留言信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(iGwCompanyMessageService.deleteWithValidByIds(Arrays.asList(ids), true));
}
}

View File

@ -0,0 +1,113 @@
package com.ruoyi.official.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.annotation.RepeatSubmit;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.official.domain.bo.GwMessageBo;
import com.ruoyi.official.domain.bo.GwSlideshowBo;
import com.ruoyi.official.domain.vo.GwMessageVo;
import com.ruoyi.official.domain.vo.GwSlideshowVo;
import com.ruoyi.official.service.IGwMessageService;
import com.ruoyi.official.service.IGwSlideshowService;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
/**
* 留言信息
*
* @author ruoyi
* @date 2024-06-19
*/
@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/official/message")
public class GwMessageController extends BaseController {
private final IGwMessageService iGwMessageService;
/**
* 查询新闻信息列表
*/
//@SaCheckPermission("official:message:list")
@GetMapping("/list")
public TableDataInfo<GwMessageVo> list(GwMessageBo bo, PageQuery pageQuery) {
return iGwMessageService.queryPageList(bo, pageQuery);
}
/**
* 导出新闻信息列表
*/
@SaCheckPermission("official:message:export")
@Log(title = "留言信息 ", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(GwMessageBo bo, HttpServletResponse response) {
List<GwMessageVo> list = iGwMessageService.queryList(bo);
ExcelUtil.exportExcel(list, "新闻信息", GwMessageVo.class, response);
}
/**
* 获取新闻信息详细信息
*
* @param id 主键
*/
/*@SaCheckPermission("official:slideshow:query")*/
@GetMapping("/{id}")
public R<GwMessageVo> getInfo(@NotNull(message = "主键不能为空") @PathVariable Long id) {
return R.ok(iGwMessageService.queryById(id));
}
/**
* 新增新闻信息
*/
//@SaCheckPermission("official:message:add")
@Log(title = "留言信息 ", businessType = BusinessType.INSERT)
@RepeatSubmit()
@PostMapping("/add")
public R<Void> add(@Validated(AddGroup.class) @RequestBody GwMessageBo bo) {
return toAjax(iGwMessageService.insertByBo(bo));
}
/**
* 修改新闻信息
*/
//@SaCheckPermission("official:message:edit")
@Log(title = "留言信息 ", businessType = BusinessType.UPDATE)
@RepeatSubmit()
@PutMapping()
public R<Void> edit(@Validated(EditGroup.class) @RequestBody GwMessageBo bo) {
return toAjax(iGwMessageService.updateByBo(bo));
}
/**
* 删除留言信息
*
* @param ids 主键串
*/
//@SaCheckPermission("official:message:remove")
@Log(title = "留言信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public R<Void> remove(@NotEmpty(message = "主键不能为空")
@PathVariable Long[] ids) {
return toAjax(iGwMessageService.deleteWithValidByIds(Arrays.asList(ids), true));
}
}

View File

@ -0,0 +1,135 @@
package com.ruoyi.official.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author wh.g
* @date 2024-11-29 11:05
*/
@Data
@TableName("gw_company_message")
public class GwCompanyMessage extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键id
*/
@TableId(value = "id")
private Long id;
/**
* 类型 1.合作伙伴 2.供应商
*/
private String propertiesType;
/**
* 公司名称
*/
private String companyName;
/**
* 联系地址
*/
private String address;
/**
* 联系电话
*/
private String phoneNumber;
/**
* 电子邮箱
*/
private String email;
/**
* 擅长方向 1.项目合作 2.人脉资源 3.创新技术 4.法律咨询 5.投融资 6.行业经验 7.产品 8.资质优势
*/
private String fieldType;
/**
* 统一社会信用代码
*/
private String identifierCode;
/**
* 企业性质 1.国营 2.私营 3.合资 4.其他
*/
private String businessNature;
/**
* 行业领域
*/
private String fieldIndustry;
/**
* 主要产品
*/
private String mainProducts;
/**
* 网址
*/
private String webAddress;
/**
* 设计开发能力 1.自主设计开发 2.来料加工 3.贸易代理
*/
private String developmentCapability;
/**
* 遵守标准 1.国际标准 2.国家标准 3.行业标准 4.企业标准
*/
private String complianceStandards;
/**
* 产品已获得的认证 1.3C 2.ROHS 3.其他说明
*/
private String productCertification;
/**
* 其他说明
*/
private String otherNotes;
/**
* 质量体系情况 1.ISO9001 2.ISO14001 3.ISO27001 4.QS9000 5.TS16849
*/
private String qualitySystem;
/**
* 是否具备相关资质 1.专利 2.软件著作权 3.食品生产许可证 4.食品经营许可证 5.其他证书
*/
private String relevantQualifications;
/**
* 优势概念
*/
private String advantageConcept;
/**
* 合作意向
*/
private String cooperationIntention;
/**
* 图片上传地址
*/
private String imageurl;
/**
* 文件类型 0图片 1视频
*/
private String fileType;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -0,0 +1,41 @@
package com.ruoyi.official.domain;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author wh.g
* @date 2024-11-29 11:05
*/
@Data
@TableName("gw_message")
public class GwMessage extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键id
*/
@TableId(value = "id")
private Long id;
/**
* 标题名称
*/
private String captionName;
/**
* 反馈人
*/
private String userName;
/**
* 联系方式
*/
private String phoneNumber;
/**
* 反馈内容
*/
private String abstracts;
}

View File

@ -0,0 +1,135 @@
package com.ruoyi.official.domain.bo;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author wh.g
* @date 2024-11-29 11:05
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class GwCompanyMessageBo extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键id
*/
@TableId(value = "id")
private Long id;
/**
* 类型 1.合作伙伴 2.供应商
*/
private String propertiesType;
/**
* 公司名称
*/
private String companyName;
/**
* 联系地址
*/
private String address;
/**
* 联系电话
*/
private String phoneNumber;
/**
* 电子邮箱
*/
private String email;
/**
* 擅长方向 1.项目合作 2.人脉资源 3.创新技术 4.法律咨询 5.投融资 6.行业经验 7.产品 8.资质优势
*/
private String fieldType;
/**
* 统一社会信用代码
*/
private String identifierCode;
/**
* 企业性质 1.国营 2.私营 3.合资 4.其他
*/
private String businessNature;
/**
* 行业领域
*/
private String fieldIndustry;
/**
* 主要产品
*/
private String mainProducts;
/**
* 网址
*/
private String webAddress;
/**
* 设计开发能力 1.自主设计开发 2.来料加工 3.贸易代理
*/
private String developmentCapability;
/**
* 遵守标准 1.国际标准 2.国家标准 3.行业标准 4.企业标准
*/
private String complianceStandards;
/**
* 产品已获得的认证 1.3C 2.ROHS 3.其他说明
*/
private String productCertification;
/**
* 其他说明
*/
private String otherNotes;
/**
* 质量体系情况 1.ISO9001 2.ISO14001 3.ISO27001 4.QS9000 5.TS16849
*/
private String qualitySystem;
/**
* 是否具备相关资质 1.专利 2.软件著作权 3.食品生产许可证 4.食品经营许可证 5.其他证书
*/
private String relevantQualifications;
/**
* 优势概念
*/
private String advantageConcept;
/**
* 合作意向
*/
private String cooperationIntention;
/**
* 图片上传地址
*/
private String imageurl;
/**
* 文件类型 0图片 1视频
*/
private String fileType;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -0,0 +1,53 @@
package com.ruoyi.official.domain.bo;
import com.ruoyi.common.core.domain.BaseEntity;
import com.ruoyi.common.core.validate.AddGroup;
import com.ruoyi.common.core.validate.EditGroup;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
/**
* 新闻信息
业务对象 gw_slideshow
*
* @author ruoyi
* @date 2024-06-19
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class GwMessageBo extends BaseEntity {
/**
* 主键id
*/
@NotNull(message = "主键id不能为空", groups = { EditGroup.class })
private Long id;
/**
* 标题名称
*/
private String captionName;
/**
* 反馈人
*/
private String userName;
/**
* 联系方式
*/
private String phoneNumber;
/**
* 反馈内容
*/
private String abstracts;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -0,0 +1,135 @@
package com.ruoyi.official.domain.vo;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
/**
* @author wh.g
* @date 2024-11-29 11:05
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class GwCompanyMessageVo extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 主键id
*/
@TableId(value = "id")
private Long id;
/**
* 类型 1.合作伙伴 2.供应商
*/
private String propertiesType;
/**
* 公司名称
*/
private String companyName;
/**
* 联系地址
*/
private String address;
/**
* 联系电话
*/
private String phoneNumber;
/**
* 电子邮箱
*/
private String email;
/**
* 擅长方向 1.项目合作 2.人脉资源 3.创新技术 4.法律咨询 5.投融资 6.行业经验 7.产品 8.资质优势
*/
private String fieldType;
/**
* 统一社会信用代码
*/
private String identifierCode;
/**
* 企业性质 1.国营 2.私营 3.合资 4.其他
*/
private String businessNature;
/**
* 行业领域
*/
private String fieldIndustry;
/**
* 主要产品
*/
private String mainProducts;
/**
* 网址
*/
private String webAddress;
/**
* 设计开发能力 1.自主设计开发 2.来料加工 3.贸易代理
*/
private String developmentCapability;
/**
* 遵守标准 1.国际标准 2.国家标准 3.行业标准 4.企业标准
*/
private String complianceStandards;
/**
* 产品已获得的认证 1.3C 2.ROHS 3.其他说明
*/
private String productCertification;
/**
* 其他说明
*/
private String otherNotes;
/**
* 质量体系情况 1.ISO9001 2.ISO14001 3.ISO27001 4.QS9000 5.TS16849
*/
private String qualitySystem;
/**
* 是否具备相关资质 1.专利 2.软件著作权 3.食品生产许可证 4.食品经营许可证 5.其他证书
*/
private String relevantQualifications;
/**
* 优势概念
*/
private String advantageConcept;
/**
* 合作意向
*/
private String cooperationIntention;
/**
* 图片上传地址
*/
private String imageurl;
/**
* 文件类型 0图片 1视频
*/
private String fileType;
/**
* 创建时间
*/
private Date createTime;
}

View File

@ -0,0 +1,57 @@
package com.ruoyi.official.domain.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import java.util.Date;
import java.util.Map;
/**
* 新闻信息
视图对象 gw_slideshow
*
* @author ruoyi
* @date 2024-06-19
*/
@Data
@ExcelIgnoreUnannotated
public class GwMessageVo {
private static final long serialVersionUID=1L;
/**
* 主键id
*/
@ExcelProperty(value = "主键id")
private Long id;
/**
* 标题名称
*/
@ExcelProperty(value = "标题名称")
private String captionName;
/**
* 反馈人
*/
@ExcelProperty(value = "反馈人")
private String userName;
/**
* 联系方式
*/
@ExcelProperty(value = "联系方式")
private String phoneNumber;
/**
* 反馈内容
*/
@ExcelProperty(value = "反馈内容")
private String abstracts;
/**
* 反馈时间
*/
@ExcelProperty(value = "反馈时间")
private Date createTime;
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.official.mapper;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.official.domain.GwCompanyMessage;
import com.ruoyi.official.domain.GwMessage;
import com.ruoyi.official.domain.vo.GwCompanyMessageVo;
import com.ruoyi.official.domain.vo.GwMessageVo;
/**
* 新闻信息
Mapper接口
*
* @author ruoyi
* @date 2024-06-19
*/
public interface GwCompanyMessageMapper extends BaseMapperPlus<GwCompanyMessageMapper, GwCompanyMessage, GwCompanyMessageVo> {
}

View File

@ -0,0 +1,18 @@
package com.ruoyi.official.mapper;
import com.ruoyi.common.core.mapper.BaseMapperPlus;
import com.ruoyi.official.domain.GwMessage;
import com.ruoyi.official.domain.GwSlideshow;
import com.ruoyi.official.domain.vo.GwMessageVo;
import com.ruoyi.official.domain.vo.GwSlideshowVo;
/**
* 新闻信息
Mapper接口
*
* @author ruoyi
* @date 2024-06-19
*/
public interface GwMessageMapper extends BaseMapperPlus<GwMessageMapper, GwMessage, GwMessageVo> {
}

View File

@ -0,0 +1,26 @@
package com.ruoyi.official.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.official.domain.bo.GwCompanyMessageBo;
import com.ruoyi.official.domain.vo.GwCompanyMessageVo;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author wh.g
* @date 2024-12-03 9:57
*/
public interface IGwCompanyMessageService {
TableDataInfo<GwCompanyMessageVo> queryPageList(GwCompanyMessageBo bo, PageQuery pageQuery);
GwCompanyMessageVo queryById(@NotNull(message = "主键不能为空") Long id);
Boolean insertByBo(GwCompanyMessageBo bo);
Boolean updateByBo(GwCompanyMessageBo bo);
Boolean deleteWithValidByIds(List<Long> list, boolean b);
}

View File

@ -0,0 +1,28 @@
package com.ruoyi.official.service;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.official.domain.bo.GwMessageBo;
import com.ruoyi.official.domain.vo.GwMessageVo;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.List;
/**
* @author wh.g
* @date 2024-11-29 11:04
*/
public interface IGwMessageService {
TableDataInfo<GwMessageVo> queryPageList(GwMessageBo bo, PageQuery pageQuery);
List<GwMessageVo> queryList(GwMessageBo bo);
GwMessageVo queryById(@NotNull(message = "主键不能为空") Long id);
Boolean insertByBo(GwMessageBo bo);
Boolean updateByBo(GwMessageBo bo);
Boolean deleteWithValidByIds(List<Long> list, boolean b);
}

View File

@ -0,0 +1,96 @@
package com.ruoyi.official.service.impl;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.official.domain.GwCompanyMessage;
import com.ruoyi.official.domain.bo.GwCompanyMessageBo;
import com.ruoyi.official.domain.vo.GwCompanyMessageVo;
import com.ruoyi.official.mapper.GwCompanyMessageMapper;
import com.ruoyi.official.service.IGwCompanyMessageService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* 留言信息
* Service业务层处理
*
* @author ruoyi
* @date 2024-06-19
*/
@RequiredArgsConstructor
@Service
public class GwCompanyMessageServiceImpl implements IGwCompanyMessageService {
private final GwCompanyMessageMapper baseMapper;
/**
* 查询留言信息
*/
@Override
public GwCompanyMessageVo queryById(Long id) {
GwCompanyMessageVo gwCompanyMessageVo = baseMapper.selectVoById(id);
return gwCompanyMessageVo;
}
/**
* 查询留言信息列表
*/
@Override
public TableDataInfo<GwCompanyMessageVo> queryPageList(GwCompanyMessageBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<GwCompanyMessage> lqw = buildQueryWrapper(bo);
Page<GwCompanyMessageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
private LambdaQueryWrapper<GwCompanyMessage> buildQueryWrapper(GwCompanyMessageBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<GwCompanyMessage> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getCompanyName()), GwCompanyMessage::getCompanyName, bo.getCompanyName());
lqw.eq(StringUtils.isNotBlank(bo.getPropertiesType()), GwCompanyMessage::getPropertiesType, bo.getPropertiesType());
return lqw;
}
/**
* 新增留言信息
*/
@Override
public Boolean insertByBo(GwCompanyMessageBo bo) {
bo.setCreateTime(new Date());
GwCompanyMessage add = BeanUtil.toBean(bo, GwCompanyMessage.class);
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改留言信息
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateByBo(GwCompanyMessageBo bo) {
GwCompanyMessage update = BeanUtil.toBean(bo, GwCompanyMessage.class);
return baseMapper.updateById(update) > 0;
}
/**
* 批量删除留言信息
*/
@Override
public Boolean deleteWithValidByIds(List<Long> ids, boolean isValid) {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@ -0,0 +1,140 @@
package com.ruoyi.official.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.official.domain.GwMessage;
import com.ruoyi.official.domain.bo.GwMessageBo;
import com.ruoyi.official.domain.vo.GwMessageVo;
import com.ruoyi.official.mapper.GwMessageMapper;
import com.ruoyi.official.service.IGwMessageService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
/**
* 留言信息
* Service业务层处理
*
* @author ruoyi
* @date 2024-06-19
*/
@Slf4j
@RequiredArgsConstructor
@Service
public class GwMessageServiceImpl implements IGwMessageService {
private final GwMessageMapper baseMapper;
/**
* 查询留言信息
*/
@Override
public GwMessageVo queryById(Long id) {
GwMessageVo gwMessageVo = baseMapper.selectVoById(id);
return gwMessageVo;
}
/**
* 查询留言信息列表
*/
@Override
public TableDataInfo<GwMessageVo> queryPageList(GwMessageBo bo, PageQuery pageQuery) {
LambdaQueryWrapper<GwMessage> lqw = buildQueryWrapper(bo);
Page<GwMessageVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw);
return TableDataInfo.build(result);
}
/**
* 查询留言信息列表
*/
@Override
public List<GwMessageVo> queryList(GwMessageBo bo) {
LambdaQueryWrapper<GwMessage> lqw = buildQueryWrapper(bo);
return baseMapper.selectVoList(lqw);
}
private LambdaQueryWrapper<GwMessage> buildQueryWrapper(GwMessageBo bo) {
Map<String, Object> params = bo.getParams();
LambdaQueryWrapper<GwMessage> lqw = Wrappers.lambdaQuery();
lqw.like(StringUtils.isNotBlank(bo.getCaptionName()), GwMessage::getCaptionName, bo.getCaptionName());
return lqw;
}
/**
* 新增留言信息
*/
@Override
public Boolean insertByBo(GwMessageBo bo) {
log.info("BBBBBBBBB-------------------"+bo.toString());
bo.setCreateTime(new Date());
GwMessage add = BeanUtil.toBean(bo, GwMessage.class);
log.info("AAAAAAAAa-------------------"+add.toString());
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
bo.setId(add.getId());
}
return flag;
}
/**
* 修改留言信息
*/
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean updateByBo(GwMessageBo bo) {
GwMessage update = BeanUtil.toBean(bo, GwMessage.class);
validEntityBeforeSave(update);
return baseMapper.updateById(update) > 0;
}
/**
* 保存前的数据校验
*/
private void validEntityBeforeSave(GwMessage entity) {
//TODO 做一些数据校验,如唯一约束
//存在已置顶的数据不允许添加编辑
/* if (ObjectUtil.isNotEmpty(entity.getId())) {
//编辑
GwSlideshowVo slideshowVo = baseMapper.selectVoOne(Wrappers.<GwSlideshow>lambdaQuery().eq(GwSlideshow::getIsTop, "1"));
if (!(ObjectUtil.equal(slideshowVo.getId(),entity.getId()))) throw new RuntimeException("已存在置顶的图片信息!");
} else {
//新增
boolean exists = baseMapper.exists(Wrappers.<GwSlideshow>lambdaQuery().eq(GwSlideshow::getIsTop, "1"));
if (exists && entity.getIsTop().equals("1")) throw new RuntimeException("已存在置顶的图片信息!");
}*/
//存在想置顶得数据将原来得数据修改为非置顶
List<GwMessageVo> vos = baseMapper.selectVoList(Wrappers.<GwMessage>lambdaQuery().eq(GwMessage::getCaptionName, "1"));
if ( CollUtil.isEmpty(vos)) return;
UpdateWrapper<GwMessage> updateWrapper = new UpdateWrapper<>();
vos.stream().forEach(ixt->{
// updateWrapper.("id", list).set("is_top", "0");
updateWrapper.eq("id",ixt.getId()).set("is_top", "0");
baseMapper.update(BeanUtil.toBean(ixt,GwMessage.class),updateWrapper);
});
}
/**
* 批量删除留言信息
*/
@Override
public Boolean deleteWithValidByIds(List<Long> ids, boolean isValid) {
if (isValid) {
//TODO 做一些业务上的校验,判断是否需要校验
}
return baseMapper.deleteBatchIds(ids) > 0;
}
}

View File

@ -0,0 +1,35 @@
<?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.ruoyi.official.mapper.GwCompanyMessageMapper">
<resultMap type="com.ruoyi.official.domain.GwCompanyMessage" id="GwCompanyMessageResult">
<result property="id" column="id"/>
<result property="propertiesType" column="properties_type"/>
<result property="companyName" column="company_name"/>
<result property="address" column="address"/>
<result property="phoneNumber" column="phone_number"/>
<result property="email" column="email"/>
<result property="fieldType" column="field_type"/>
<result property="identifierCode" column="identifier_code"/>
<result property="businessNature" column="business_nature"/>
<result property="fieldIndustry" column="field_industry"/>
<result property="mainProducts" column="main_products"/>
<result property="webAddress" column="web_address"/>
<result property="developmentCapability" column="development_capability"/>
<result property="complianceStandards" column="compliance_standards"/>
<result property="productCertification" column="product_certification"/>
<result property="otherNotes" column="other_notes"/>
<result property="qualitySystem" column="quality_system"/>
<result property="relevantQualifications" column="relevant_qualifications"/>
<result property="advantageConcept" column="advantage_concept"/>
<result property="cooperationIntention" column="cooperation_intention"/>
<result property="imageurl" column="imageurl"/>
<result property="fileType" column="file_type"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>

View File

@ -0,0 +1,20 @@
<?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.ruoyi.official.mapper.GwMessageMapper">
<resultMap type="com.ruoyi.official.domain.GwMessage" id="GwMessageResult">
<result property="id" column="id"/>
<result property="captionName" column="caption_name"/>
<result property="userName" column="user_name"/>
<result property="phoneNumber" column="phone_number"/>
<result property="abstracts" column="abstracts"/>
<result property="createTime" column="create_time"/>
<result property="createBy" column="create_by"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
</mapper>