Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ufo
/
yohoufo-fore
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
mali
6 years ago
Commit
11059660d6f23ad73ad22aaf5a82e47c5a617cea
1 parent
3547b935
资源位商品池配置
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
176 additions
and
2 deletions
dal/src/main/java/com/yohoufo/dal/resource/ResourcesGoodsPoolMapper.java
dal/src/main/java/com/yohoufo/dal/resource/model/ResourcesGoodsPool.java
dal/src/main/resources/META-INF/mybatis/resource/ResourcesGoodsPoolMapper.xml
product/src/main/java/com/yohoufo/product/controller/ProductSearchController.java
resource/src/main/java/com/yohoufo/resource/controller/ResourcesGoodsPoolController.java
resource/src/main/java/com/yohoufo/resource/service/impl/ResourcesGoodsPoolService.java
web/src/main/resources/databases.yml
web/src/main/webapp/META-INF/autoconf/databases.yml
dal/src/main/java/com/yohoufo/dal/resource/ResourcesGoodsPoolMapper.java
0 → 100644
View file @
1105966
package
com
.
yohoufo
.
dal
.
resource
;
import
com.yohoufo.dal.resource.model.ResourcesGoodsPool
;
import
java.util.List
;
/**
* Created by li.ma on 2018/11/17.
*/
public
interface
ResourcesGoodsPoolMapper
{
/**
* 查询所有的首页商品池配置
* @return
*/
List
<
ResourcesGoodsPool
>
selectAll
();
}
...
...
dal/src/main/java/com/yohoufo/dal/resource/model/ResourcesGoodsPool.java
0 → 100644
View file @
1105966
package
com
.
yohoufo
.
dal
.
resource
.
model
;
import
com.alibaba.fastjson.JSONObject
;
/**
* 首页资源位商品池配置
* Created by li.ma on 2018/11/17.
*/
public
class
ResourcesGoodsPool
{
private
int
id
;
private
int
poolId
;
public
int
getPoolId
()
{
return
poolId
;
}
public
void
setPoolId
(
int
poolId
)
{
this
.
poolId
=
poolId
;
}
public
int
getId
()
{
return
id
;
}
public
void
setId
(
int
id
)
{
this
.
id
=
id
;
}
@Override
public
String
toString
()
{
return
JSONObject
.
toJSONString
(
this
);
}
}
...
...
dal/src/main/resources/META-INF/mybatis/resource/ResourcesGoodsPoolMapper.xml
0 → 100644
View file @
1105966
<?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.yohoufo.dal.resource.ResourcesGoodsPoolMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.yohoufo.dal.resource.model.ResourcesGoodsPool"
>
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"pool_id"
jdbcType=
"INTEGER"
property=
"poolId"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id, pool_id
</sql>
<select
id=
"selectAll"
resultMap=
"BaseResultMap"
>
select
<include
refid=
"Base_Column_List"
/>
from resources_goods_pool limit 100
</select>
</mapper>
\ No newline at end of file
...
...
product/src/main/java/com/yohoufo/product/controller/ProductSearchController.java
View file @
1105966
...
...
@@ -3,6 +3,7 @@ package com.yohoufo.product.controller;
import
com.alibaba.fastjson.JSONObject
;
import
com.yoho.tools.docs.ApiOperation
;
import
com.yohoufo.common.annotation.IgnoreSignature
;
import
com.yohoufo.common.caller.UfoServiceCaller
;
import
com.yohoufo.product.helper.SearchHelpService
;
import
com.yohoufo.product.request.ProductSearchReq
;
import
com.yohoufo.product.request.SortIdLevel
;
...
...
@@ -21,6 +22,8 @@ import com.yohoufo.common.annotation.IgnoreSession;
import
com.yohoufo.common.cache.Cachable
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Map
;
@RestController
public
class
ProductSearchController
{
...
...
@@ -30,6 +33,8 @@ public class ProductSearchController {
private
ProductSearchService
productSearchService
;
@Autowired
private
SearchHelpService
searchHelpService
;
@Autowired
private
UfoServiceCaller
ufoServiceCaller
;
@ApiOperation
(
name
=
"ufo.product.search.list"
,
desc
=
"首页商品推荐"
)
@RequestMapping
(
params
=
"method=ufo.product.search.list"
)
...
...
@@ -51,12 +56,13 @@ public class ProductSearchController {
@RequestParam
(
value
=
"page"
,
required
=
false
)
Integer
page
)
{
if
(
type
!=
null
)
{
Map
<
Integer
,
Integer
>
poolConfig
=
ufoServiceCaller
.
call
(
"ufo.resource.goodsPool"
,
Map
.
class
);
if
(
type
==
0
)
{
productPool
=
"2"
;
productPool
=
String
.
valueOf
(
poolConfig
.
get
(
2
))
;
order
=
"pools.id:asc"
;
}
if
(
type
==
1
)
{
productPool
=
"4"
;
productPool
=
String
.
valueOf
(
poolConfig
.
get
(
4
))
;
order
=
"pools.id:asc"
;
}
if
(
type
==
2
)
{
...
...
resource/src/main/java/com/yohoufo/resource/controller/ResourcesGoodsPoolController.java
0 → 100644
View file @
1105966
package
com
.
yohoufo
.
resource
.
controller
;
import
com.yoho.tools.docs.ApiOperation
;
import
com.yohoufo.common.ApiResponse
;
import
com.yohoufo.common.annotation.IgnoreSession
;
import
com.yohoufo.resource.service.IConfigTypeService
;
import
com.yohoufo.resource.service.impl.ResourcesGoodsPoolService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.util.Map
;
/**
* Created by li.ma on 2018/11/17.
*/
@RestController
public
class
ResourcesGoodsPoolController
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
ResourcesGoodsPoolController
.
class
);
@Autowired
private
ResourcesGoodsPoolService
resourcesGoodsPoolService
;
/**
* <p>获取配置列表,返回map</p>
*
*/
@ApiOperation
(
name
=
"ufo.resource.goodsPool"
,
desc
=
"获取首页资源位商品池"
)
@RequestMapping
(
params
=
"method=ufo.resource.goodsPool"
)
@ResponseBody
@IgnoreSession
public
Map
<
Integer
,
Integer
>
goodsPoolList
()
{
logger
.
info
(
"goodsPool begin."
);
Map
<
Integer
,
Integer
>
data
=
resourcesGoodsPoolService
.
configTypeList
();
logger
.
info
(
"goodsPool success. result is "
,
data
);
return
data
;
}
}
...
...
resource/src/main/java/com/yohoufo/resource/service/impl/ResourcesGoodsPoolService.java
0 → 100644
View file @
1105966
package
com
.
yohoufo
.
resource
.
service
.
impl
;
import
com.yoho.core.cache.LocalCache
;
import
com.yohoufo.dal.resource.ResourcesGoodsPoolMapper
;
import
com.yohoufo.dal.resource.model.ConfigType
;
import
com.yohoufo.dal.resource.model.ResourcesGoodsPool
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
/**
* Created by li.ma on 2018/11/17.
*/
@Service
public
class
ResourcesGoodsPoolService
{
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
ResourcesGoodsPoolService
.
class
);
private
LocalCache
localCache
=
new
LocalCache
();
@Autowired
private
ResourcesGoodsPoolMapper
resourcesGoodsPoolMapper
;
private
final
String
NormalResourcesGoodsPool_CACHE_KEY
=
"ResourcesGoodsPoolList"
;
@PostConstruct
private
void
init
()
{
localCache
.
init
(
NormalResourcesGoodsPool_CACHE_KEY
,
10
,
TimeUnit
.
MINUTES
,
(
String
s
,
Object
o
)
->
{
LOGGER
.
info
(
"ResourcesGoodsPoolList init s = {}, o = {}"
,
s
,
o
);
List
<
ResourcesGoodsPool
>
resourcesGoodsPoolList
=
resourcesGoodsPoolMapper
.
selectAll
();
return
resourcesGoodsPoolList
.
stream
().
collect
(
Collectors
.
toMap
(
ResourcesGoodsPool:
:
getId
,
ResourcesGoodsPool:
:
getPoolId
));
});
}
/**
* 获取所有状态正常的配置项
* @return
*/
public
Map
<
Integer
,
Integer
>
configTypeList
(){
Map
<
Integer
,
Integer
>
map
=
(
Map
<
Integer
,
Integer
>)
localCache
.
get
(
NormalResourcesGoodsPool_CACHE_KEY
);
if
(
map
!=
null
&&
map
.
size
()
>
0
)
{
return
map
;
}
return
new
HashMap
<
Integer
,
Integer
>()
{
{
map
.
put
(
2
,
2
);
map
.
put
(
4
,
4
);
}
};
}
}
...
...
web/src/main/resources/databases.yml
View file @
1105966
...
...
@@ -61,4 +61,5 @@ datasources:
-
com.yohoufo.dal.resource.ResourcesContentMapper
-
com.yohoufo.dal.resource.ResourcesMapper
-
com.yohoufo.dal.resource.ConfigTypeMapper
-
com.yohoufo.dal.resource.ResourcesGoodsPoolMapper
readOnlyInSlave
:
true
\ No newline at end of file
...
...
web/src/main/webapp/META-INF/autoconf/databases.yml
View file @
1105966
...
...
@@ -61,4 +61,5 @@ datasources:
-
com.yohoufo.dal.resource.ResourcesContentMapper
-
com.yohoufo.dal.resource.ResourcesMapper
-
com.yohoufo.dal.resource.ConfigTypeMapper
-
com.yohoufo.dal.resource.ResourcesGoodsPoolMapper
readOnlyInSlave
:
true
\ No newline at end of file
...
...
Please
register
or
login
to post a comment