@ -1,5 +1,7 @@
package com.ruoyi.base.controller ;
import cn.hutool.json.JSONArray ;
import cn.hutool.json.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper ;
import com.baomidou.mybatisplus.core.metadata.IPage ;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page ;
@ -27,6 +29,7 @@ import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.enums.BusinessType ;
import com.ruoyi.common.utils.StringUtils ;
import com.ruoyi.common.utils.poi.ExcelUtil ;
import com.ruoyi.webSocket.Message ;
import io.swagger.annotations.Api ;
import io.swagger.annotations.ApiImplicitParam ;
import io.swagger.annotations.ApiImplicitParams ;
@ -75,14 +78,15 @@ public class WebController extends BaseController {
/ * *
* 导航栏接口 - - 所有分类
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 获取站点分类树--所有分类 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /category " )
public R < List < BusiCategoryVO > > categoryList ( @RequestParam ( required = true ) String tenantId ) {
public R < List < BusiCategoryVO > > categoryList ( @RequestParam ( required = true ) String tenantId ) {
BusiCategory category = new BusiCategory ( ) ;
category . setTenantId ( tenantId ) ;
List < BusiCategoryVO > busiCategoryVOList = categoryService . treeCategory ( category ) ;
@ -91,9 +95,10 @@ public class WebController extends BaseController {
/ * *
* 获取站点产品分类树 - - 产品分类
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 获取站点分类树--根据一级分类ID查询所有子级分类树 " )
@ApiImplicitParams ( value = {
@ -101,12 +106,12 @@ public class WebController extends BaseController {
@ApiImplicitParam ( name = " catgId " , value = " 一级分类ID " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
} )
@GetMapping ( " /prodCategory " )
public R < List < BusiCategoryVO > > prodCategoryList ( @RequestParam ( required = true ) String tenantId , @RequestParam ( required = true ) String catgId ) {
public R < List < BusiCategoryVO > > prodCategoryList ( @RequestParam ( required = true ) String tenantId , @RequestParam ( required = true ) String catgId ) {
BusiCategory category = new BusiCategory ( ) ;
category . setTenantId ( tenantId ) ;
List < BusiCategoryVO > busiCategoryVOList = categoryService . treeCategory ( category ) ;
for ( BusiCategoryVO categoryVO : busiCategoryVOList ) {
if ( catgId . equals ( categoryVO . getId ( ) ) ) {
for ( BusiCategoryVO categoryVO : busiCategoryVOList ) {
if ( catgId . equals ( categoryVO . getId ( ) ) ) {
return R . ok ( categoryVO . getChildren ( ) ) ;
}
}
@ -115,107 +120,113 @@ public class WebController extends BaseController {
}
/ * *
*
* @author vinjor - M
* @date 15 : 44 2025 / 7 / 8
* @param id 查询单个分类栏目详情 - - 单页面栏目和询盘栏目使用
* @return com . ruoyi . common . core . domain . R < com . ruoyi . busi . domain . BusiCategory >
* @author vinjor - M
* @date 15 : 44 2025 / 7 / 8
* * /
@ApiOperation ( " 查询单个分类栏目详情--单页面栏目和询盘栏目使用 " )
@ApiImplicitParam ( name = " id " , value = " 主键ID " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /categoryInfo " )
public R < BusiCategory > categoryInfo ( @RequestParam ( required = true ) String id ) {
public R < BusiCategory > categoryInfo ( @RequestParam ( required = true ) String id ) {
return R . ok ( categoryService . getById ( id ) ) ;
}
/ * *
* 轮播图
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 轮播图 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /pic " )
public R < List < BasePic > > picList ( @RequestParam ( required = true ) String tenantId ) {
public R < List < BasePic > > picList ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( basePicService . list ( tenantId ) ) ;
}
/ * *
* 公司介绍 - 富文本 - 首页展示区域
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 公司介绍-富文本-首页展示区域 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /indexCompanyInfo " )
public R < String > indexCompanyInfo ( @RequestParam ( required = true ) String tenantId ) {
public R < String > indexCompanyInfo ( @RequestParam ( required = true ) String tenantId ) {
BaseSiteInfo baseSiteInfo = siteInfoService . getSiteInfo ( tenantId ) ;
return R . ok ( baseSiteInfo . getCompanyInfo ( ) ) ;
}
/ * *
* 热门产品 - 前10
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 热门产品-前10 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /hotProduct " )
public R < List < BusiProdNew > > hotProduct ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( prodNewService . hotProdOrNews ( tenantId , DATA_TYPE_PRODUCT , true ) ) ;
public R < List < BusiProdNew > > hotProduct ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( prodNewService . hotProdOrNews ( tenantId , DATA_TYPE_PRODUCT , true ) ) ;
}
/ * *
* 普通产品 - 前10
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 普通产品-前10 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /product " )
public R < List < BusiProdNew > > product ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( prodNewService . hotProdOrNews ( tenantId , DATA_TYPE_PRODUCT , false ) ) ;
public R < List < BusiProdNew > > product ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( prodNewService . hotProdOrNews ( tenantId , DATA_TYPE_PRODUCT , false ) ) ;
}
/ * *
* 热门新闻 - 前10
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 热门新闻-前10 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /hotNews " )
public R < List < BusiProdNew > > hotNews ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( prodNewService . hotProdOrNews ( tenantId , DATA_TYPE_NEWS , true ) ) ;
public R < List < BusiProdNew > > hotNews ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( prodNewService . hotProdOrNews ( tenantId , DATA_TYPE_NEWS , true ) ) ;
}
/ * *
* 页面底部
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 页面底部 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /footerInfo " )
public R < BaseSiteInfo > footerInfo ( @RequestParam ( required = true ) String tenantId ) {
public R < BaseSiteInfo > footerInfo ( @RequestParam ( required = true ) String tenantId ) {
return R . ok ( siteInfoService . getSiteInfo ( tenantId ) ) ;
}
/ * *
* 产品列表分页
* @author vinjor - M
* @date 15 : 17 2025 / 7 / 8
*
* @param tenantId 租户id
* @param catgId 分类ID
* @param pageNum
* @param pageSize
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 15 : 17 2025 / 7 / 8
* * /
@ApiOperation ( " 产品列表分页 " )
@ApiImplicitParams ( value = {
@ -225,19 +236,19 @@ public class WebController extends BaseController {
@ApiImplicitParam ( name = " catgId " , value = " 分类id " , required = false , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
} )
@GetMapping ( " /prodPageList " )
public R < IPage < BusiProdNew > > prodPageList ( String tenantId , String catgId ,
public R < IPage < BusiProdNew > > prodPageList ( String tenantId , String catgId ,
@RequestParam ( name = " pageNum " , defaultValue = " 1 " ) Integer pageNum ,
@RequestParam ( name = " pageSize " , defaultValue = " 10 " ) Integer pageSize ) {
Page < BusiProdNew > page = new Page < > ( pageNum , pageSize ) ;
LambdaQueryWrapper < BusiProdNew > queryWrapper = new LambdaQueryWrapper < BusiProdNew > ( )
. eq ( BusiProdNew : : getDataType , DATA_TYPE_PRODUCT )
. eq ( BusiProdNew : : getIfPublic , true )
. eq ( BusiProdNew : : getTenantId , tenantId ) ;
if ( StringUtils . isNotEmpty ( catgId ) ) {
List < String > catgIdList = new ArrayList < > ( ) ;
. eq ( BusiProdNew : : getDataType , DATA_TYPE_PRODUCT )
. eq ( BusiProdNew : : getIfPublic , true )
. eq ( BusiProdNew : : getTenantId , tenantId ) ;
if ( StringUtils . isNotEmpty ( catgId ) ) {
List < String > catgIdList = new ArrayList < > ( ) ;
catgIdList . add ( catgId ) ;
catgIdList . addAll ( categoryService . getAllChildrenId ( catgId ) ) ;
queryWrapper . in ( BusiProdNew : : getCatgId , catgIdList ) ;
queryWrapper . in ( BusiProdNew : : getCatgId , catgIdList ) ;
}
queryWrapper . orderByDesc ( BusiProdNew : : getSort ) ;
/ / 查所有栏目
@ -254,13 +265,14 @@ public class WebController extends BaseController {
/ * *
* 新闻列表分页
* @author vinjor - M
* @date 15 : 17 2025 / 7 / 8
*
* @param tenantId 租户id
* @param catgId 分类ID
* @param pageNum
* @param pageSize
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 15 : 17 2025 / 7 / 8
* * /
@ApiOperation ( " 新闻列表分页 " )
@ApiImplicitParams ( value = {
@ -270,19 +282,19 @@ public class WebController extends BaseController {
@ApiImplicitParam ( name = " catgId " , value = " 分类id " , required = false , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
} )
@GetMapping ( " /newsPageList " )
public R < IPage < BusiProdNew > > newsPageList ( String tenantId , String catgId ,
public R < IPage < BusiProdNew > > newsPageList ( String tenantId , String catgId ,
@RequestParam ( name = " pageNum " , defaultValue = " 1 " ) Integer pageNum ,
@RequestParam ( name = " pageSize " , defaultValue = " 10 " ) Integer pageSize ) {
Page < BusiProdNew > page = new Page < > ( pageNum , pageSize ) ;
LambdaQueryWrapper < BusiProdNew > queryWrapper = new LambdaQueryWrapper < BusiProdNew > ( )
. eq ( BusiProdNew : : getDataType , DATA_TYPE_NEWS )
. eq ( BusiProdNew : : getIfPublic , true )
. eq ( BusiProdNew : : getTenantId , tenantId ) ;
if ( StringUtils . isNotEmpty ( catgId ) ) {
List < String > catgIdList = new ArrayList < > ( ) ;
. eq ( BusiProdNew : : getDataType , DATA_TYPE_NEWS )
. eq ( BusiProdNew : : getIfPublic , true )
. eq ( BusiProdNew : : getTenantId , tenantId ) ;
if ( StringUtils . isNotEmpty ( catgId ) ) {
List < String > catgIdList = new ArrayList < > ( ) ;
catgIdList . add ( catgId ) ;
catgIdList . addAll ( categoryService . getAllChildrenId ( catgId ) ) ;
queryWrapper . in ( BusiProdNew : : getCatgId , catgIdList ) ;
queryWrapper . in ( BusiProdNew : : getCatgId , catgIdList ) ;
}
queryWrapper . orderByDesc ( BusiProdNew : : getSort ) ;
/ / 查所有栏目
@ -292,29 +304,31 @@ public class WebController extends BaseController {
List < BusiCategoryVO > busiCategoryVOList = categoryService . treeCategory ( category ) ;
/ / 转map
Map < String , String > catgMap = categoryService . dealFirstIdRtnMap ( busiCategoryVOList ) ;
IPage < BusiProdNew > rtnPage = prodNewService . page ( page , queryWrapper ) ;
IPage < BusiProdNew > rtnPage = prodNewService . page ( page , queryWrapper ) ;
rtnPage . getRecords ( ) . forEach ( item - > item . setMaxCatgId ( catgMap . getOrDefault ( item . getCatgId ( ) , " " ) ) ) ;
return R . ok ( rtnPage ) ;
}
/ * *
* 产品或新闻详情
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 产品或新闻详情 " )
@ApiImplicitParam ( name = " id " , value = " 产品或新闻ID " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /prodNewsInfo " )
public R < WebDetailVO > prodNewsInfo ( @RequestParam ( required = true ) String id ) {
public R < WebDetailVO > prodNewsInfo ( @RequestParam ( required = true ) String id ) {
return R . ok ( prodNewService . getProdNewInfo ( id ) ) ;
}
/ * *
* 全站搜索
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 全站搜索 " )
@ApiImplicitParams ( value = {
@ -324,23 +338,24 @@ public class WebController extends BaseController {
@ApiImplicitParam ( name = " text " , value = " 搜索内容 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
} )
@GetMapping ( " /searchText " )
public R < IPage < BusiProdNew > > searchText ( String tenantId , String text ,
public R < IPage < BusiProdNew > > searchText ( String tenantId , String text ,
@RequestParam ( name = " pageNum " , defaultValue = " 1 " ) Integer pageNum ,
@RequestParam ( name = " pageSize " , defaultValue = " 10 " ) Integer pageSize ) {
Page < BusiProdNew > page = new Page < > ( pageNum , pageSize ) ;
return R . ok ( prodNewService . searchTextAll ( tenantId , text , page ) ) ;
@RequestParam ( name = " pageSize " , defaultValue = " 10 " ) Integer pageSize ) {
Page < BusiProdNew > page = new Page < > ( pageNum , pageSize ) ;
return R . ok ( prodNewService . searchTextAll ( tenantId , text , page ) ) ;
}
/ * *
* 查询盘设置 - 都有哪些字段需要填写 , 是否必填
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 查询盘设置-都有哪些字段需要填写,是否必填 " )
@ApiImplicitParam ( name = " tenantId " , value = " 站点唯一码 " , required = true , dataType = " string " , paramType = " query " , dataTypeClass = String . class )
@GetMapping ( " /inquirySet " )
public R < BaseInquiry > inquirySet ( @RequestParam ( required = true ) String tenantId , HttpServletRequest request ) {
public R < BaseInquiry > inquirySet ( @RequestParam ( required = true ) String tenantId , HttpServletRequest request ) {
String ip = CommonUtils . getIpAddr ( request ) ;
System . out . println ( ip ) ;
System . out . println ( CommonUtils . getAddr ( ip ) ) ;
@ -349,10 +364,11 @@ public class WebController extends BaseController {
/ * *
* 保存在线聊天内容
* @author PQZ
* @date 15 : 24 2025 / 7 / 17
*
* @param busiChatMain { @link BusiChatMain }
* @return com . ruoyi . common . core . domain . AjaxResult
* @author PQZ
* @date 15 : 24 2025 / 7 / 17
* * /
@PostMapping ( " /chatMain " )
public AjaxResult saveChatMain ( @RequestBody BusiChatMain busiChatMain , HttpServletRequest request ) {
@ -361,20 +377,24 @@ public class WebController extends BaseController {
try {
ip = CommonUtils . getIpAddr ( request ) ;
nationalStr = CommonUtils . getAddr ( ip ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( " 识别所属国家失败 " ) ;
}
ip = StringUtils . isNotEmpty ( ip ) ? ip : " 未知 " ;
BusiChatMain result = busiChatMainService . queryByIpAndCusCode ( ip , busiChatMain . getCusCode ( ) ) ;
if ( result ! = null ) {
ip = StringUtils . isNotEmpty ( ip ) ? ip : " 未知 " ;
BusiChatMain result = busiChatMainService . queryByIpAndCusCode ( ip , busiChatMain . getCusCode ( ) , busiChatMain . getProdId ( ) ) ;
if ( result ! = null ) {
if ( StringUtils . isNotEmpty ( result . getItemJson ( ) ) ) {
JSONArray array = new JSONArray ( result . getItemJson ( ) ) ;
result . setJsonArray ( array ) ;
}
return success ( result ) ;
} else {
nationalStr = StringUtils . isNotEmpty ( nationalStr ) ? nationalStr : " 未知 " ;
nationalStr = StringUtils . isNotEmpty ( nationalStr ) ? nationalStr : " 未知 " ;
String national = nationalStr . split ( " \\ | " ) [ 0 ] ;
System . out . println ( ip + " ----- " + nationalStr ) ;
System . out . println ( ip + " ----- " + nationalStr ) ;
String oceania = " 未知 " ;
Map < String , String > nationalMap = nationalService . getNationalMap ( ) ;
if ( nationalMap . containsKey ( national ) ) {
Map < String , String > nationalMap = nationalService . getNationalMap ( ) ;
if ( nationalMap . containsKey ( national ) ) {
oceania = nationalMap . get ( national ) ;
}
busiChatMain . setIp ( ip ) ;
@ -386,11 +406,27 @@ public class WebController extends BaseController {
}
}
/ * *
* 保存用户消息
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author PQZ
* @date 14 : 12 2025 / 8 / 4
* * /
@PostMapping ( " /saveMessage " )
public AjaxResult saveMessage ( @RequestBody BusiChatMain busiChatMain ) {
busiChatMain . setItemJson ( busiChatMain . getJsonArray ( ) . toString ( ) ) ;
busiChatMainService . updateById ( busiChatMain ) ;
return success ( ) ;
}
/ * *
* 提交在线询盘表单
*
* @return com . ruoyi . common . core . domain . AjaxResult
* @author vinjor - M
* @date 10 : 04 2025 / 7 / 8
* @return com . ruoyi . common . core . domain . AjaxResult
* * /
@ApiOperation ( " 提交在线询盘表单 " )
@ApiImplicitParams ( value = {
@ -404,22 +440,22 @@ public class WebController extends BaseController {
@ApiImplicitParam ( name = " equipment " , value = " 设备类型(移动端|电脑端) " , required = true , paramType = " body " )
} )
@PostMapping ( " /inquirySave " )
public R < String > inquirySave ( @ApiIgnore @RequestBody BusiInquiryItem inquiryItem , HttpServletRequest request ) {
public R < String > inquirySave ( @ApiIgnore @RequestBody BusiInquiryItem inquiryItem , HttpServletRequest request ) {
String ip = " " ;
String nationalStr = " " ;
try {
ip = CommonUtils . getIpAddr ( request ) ;
nationalStr = CommonUtils . getAddr ( ip ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
logger . error ( " 识别所属国家失败 " ) ;
}
ip = StringUtils . isNotEmpty ( ip ) ? ip : " 未知 " ;
nationalStr = StringUtils . isNotEmpty ( nationalStr ) ? nationalStr : " 未知 " ;
ip = StringUtils . isNotEmpty ( ip ) ? ip : " 未知 " ;
nationalStr = StringUtils . isNotEmpty ( nationalStr ) ? nationalStr : " 未知 " ;
String national = nationalStr . split ( " \\ | " ) [ 0 ] ;
System . out . println ( ip + " ----- " + nationalStr ) ;
System . out . println ( ip + " ----- " + nationalStr ) ;
String oceania = " 未知 " ;
Map < String , String > nationalMap = nationalService . getNationalMap ( ) ;
if ( nationalMap . containsKey ( national ) ) {
Map < String , String > nationalMap = nationalService . getNationalMap ( ) ;
if ( nationalMap . containsKey ( national ) ) {
oceania = nationalMap . get ( national ) ;
}
inquiryItem . setIp ( ip ) ;
@ -430,7 +466,7 @@ public class WebController extends BaseController {
}
@GetMapping ( " /test " )
public R < ? > test ( ) {
public R < ? > test ( ) {
googleKeywordService . test ( ) ;
return R . ok ( ) ;
}