Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
open-source
/
chejia-smart-service
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 7c8ba50e
authored
Mar 26, 2021
by
tyfanchz
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
调整代码
1 parent
82d51e72
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
52 additions
and
34 deletions
src/main/java/com/glsx/smart/controller/ProductController.java
src/main/java/com/glsx/smart/controller/ProductTypeController.java
src/main/java/com/glsx/smart/service/impl/SmartProductServiceImpl.java
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
src/main/java/com/glsx/smart/utils/DjApiInvoker.java
src/main/java/com/glsx/smart/controller/ProductController.java
View file @
7c8ba50
...
@@ -111,17 +111,17 @@ public class ProductController {
...
@@ -111,17 +111,17 @@ public class ProductController {
return
productService
.
getCommandSetById
(
id
);
return
productService
.
getCommandSetById
(
id
);
}
}
/
//
**
/**
//
* 校验商城商品 id。
* 校验商城商品 id。
//
*
*
//
* @param shopProductId 商品 id
* @param shopProductId 商品 id
//
* @return 商品 id 是否合法
* @return 商品 id 是否合法
//
*/
*/
//
@RequestMapping(value = "/checkShopProductId", method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping
(
value
=
"/checkShopProductId"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
//
public Boolean checkShopProductId(String shopProductId) {
public
Boolean
checkShopProductId
(
String
shopProductId
)
{
//
log.info("$$$$ /product/checkShopProductId param: {}", shopProductId);
log
.
info
(
"$$$$ /product/checkShopProductId param: {}"
,
shopProductId
);
//
return productService.checkShopProductId(shopProductId);
return
productService
.
checkShopProductId
(
shopProductId
);
//
}
}
/**
/**
* 上下架产品。
* 上下架产品。
...
...
src/main/java/com/glsx/smart/controller/ProductTypeController.java
View file @
7c8ba50
...
@@ -73,16 +73,16 @@ public class ProductTypeController {
...
@@ -73,16 +73,16 @@ public class ProductTypeController {
return
productTypeService
.
save
(
productType
);
return
productTypeService
.
save
(
productType
);
}
}
/
//
**
/**
//
* 获取商城标签。
* 获取商城标签。
//
*
*
//
* @return 结果
* @return 结果
//
*/
*/
//
@RequestMapping(value = "/getShopTagList", method = {RequestMethod.GET, RequestMethod.POST})
@RequestMapping
(
value
=
"/getShopTagList"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
POST
})
//
public List<String> getShopTagList() {
public
List
<
String
>
getShopTagList
()
{
//
log.info("$$$$ /productType/getShopTagList ...");
log
.
info
(
"$$$$ /productType/getShopTagList ..."
);
//
return productTypeService.getShopTagList();
return
productTypeService
.
getShopTagList
();
//
}
}
/**
/**
* 根据id列表获取指令执行内容
* 根据id列表获取指令执行内容
...
...
src/main/java/com/glsx/smart/service/impl/SmartProductServiceImpl.java
View file @
7c8ba50
...
@@ -47,9 +47,6 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
...
@@ -47,9 +47,6 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
@Autowired
@Autowired
private
SmartSysCodeMapper
sysCodeMapper
;
private
SmartSysCodeMapper
sysCodeMapper
;
//@Autowired
private
DjApiInvoker
djApiInvoker
;
/**
/**
* 获取产品列表。
* 获取产品列表。
*
*
...
@@ -216,7 +213,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
...
@@ -216,7 +213,7 @@ public class SmartProductServiceImpl extends BaseService implements SmartProduct
public
Boolean
checkShopProductId
(
String
shopProductId
)
{
public
Boolean
checkShopProductId
(
String
shopProductId
)
{
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
Map
<
String
,
Object
>
paramMap
=
new
HashMap
<>();
paramMap
.
put
(
"id"
,
shopProductId
);
paramMap
.
put
(
"id"
,
shopProductId
);
DjApiDTO
djApiDTO
=
djApiInvoker
.
postForResult
(
DjApiDTO
djApiDTO
=
DjApiInvoker
.
of
()
.
postForResult
(
DjApiInvoker
.
DjApiMethod
.
CHECK_SHOP_PRODUCT_ID
,
paramMap
);
DjApiInvoker
.
DjApiMethod
.
CHECK_SHOP_PRODUCT_ID
,
paramMap
);
boolean
valid
=
"0"
.
equals
(
djApiDTO
.
getCode
())
&&
djApiDTO
.
getData
()
!=
null
;
boolean
valid
=
"0"
.
equals
(
djApiDTO
.
getCode
())
&&
djApiDTO
.
getData
()
!=
null
;
return
valid
;
return
valid
;
...
...
src/main/java/com/glsx/smart/service/impl/SmartProductTypeServiceImpl.java
View file @
7c8ba50
...
@@ -34,9 +34,6 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -34,9 +34,6 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Resource
@Resource
private
SmartProductTypeMapper
productTypeMapper
;
private
SmartProductTypeMapper
productTypeMapper
;
//@Autowired
private
DjApiInvoker
djApiInvoker
;
/**
/**
* 分页获取产品类型列表。
* 分页获取产品类型列表。
*
*
...
@@ -128,7 +125,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
...
@@ -128,7 +125,7 @@ public class SmartProductTypeServiceImpl extends BaseService implements SmartPro
@Override
@Override
public
List
<
String
>
getShopTagList
()
{
public
List
<
String
>
getShopTagList
()
{
List
<
String
>
shopTagList
=
new
ArrayList
<>();
List
<
String
>
shopTagList
=
new
ArrayList
<>();
DjApiDTO
djApiDTO
=
djApiInvoker
.
postForResult
(
DjApiDTO
djApiDTO
=
DjApiInvoker
.
of
()
.
postForResult
(
DjApiInvoker
.
DjApiMethod
.
GET_SHOP_TAGS
,
new
HashMap
<>());
DjApiInvoker
.
DjApiMethod
.
GET_SHOP_TAGS
,
new
HashMap
<>());
String
data
=
djApiDTO
.
getData
();
String
data
=
djApiDTO
.
getData
();
if
(
"0"
.
equals
(
djApiDTO
.
getCode
())
&&
data
!=
null
)
{
if
(
"0"
.
equals
(
djApiDTO
.
getCode
())
&&
data
!=
null
)
{
...
...
src/main/java/com/glsx/smart/utils/DjApiInvoker.java
View file @
7c8ba50
...
@@ -8,9 +8,13 @@ import com.glsx.plat.common.utils.HttpUtils;
...
@@ -8,9 +8,13 @@ import com.glsx.plat.common.utils.HttpUtils;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.plat.common.utils.StringUtils
;
import
com.glsx.smart.pojo.DjApiDTO
;
import
com.glsx.smart.pojo.DjApiDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.DisposableBean
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.env.Environment
;
import
org.springframework.stereotype.Component
;
/**
/**
* <p>Description: 嘀加商城 API 调用工具类
* <p>Description: 嘀加商城 API 调用工具类
...
@@ -21,9 +25,9 @@ import org.springframework.core.env.Environment;
...
@@ -21,9 +25,9 @@ import org.springframework.core.env.Environment;
* @date 2021-03-23
* @date 2021-03-23
*/
*/
@Slf4j
@Slf4j
//
@Component
@Component
@Deprecated
@Deprecated
public
class
DjApiInvoker
{
public
class
DjApiInvoker
implements
ApplicationContextAware
,
DisposableBean
{
private
static
final
String
ARG_METHOD
=
"method"
;
private
static
final
String
ARG_METHOD
=
"method"
;
private
static
final
String
ARG_FORMAT
=
"format"
;
private
static
final
String
ARG_FORMAT
=
"format"
;
private
static
final
String
ARG_APP_KEY
=
"appKey"
;
private
static
final
String
ARG_APP_KEY
=
"appKey"
;
...
@@ -32,6 +36,8 @@ public class DjApiInvoker {
...
@@ -32,6 +36,8 @@ public class DjApiInvoker {
private
static
final
String
ARG_TIMESTAMP
=
"timestamp"
;
private
static
final
String
ARG_TIMESTAMP
=
"timestamp"
;
private
static
final
String
ARG_SOURCE
=
"source"
;
private
static
final
String
ARG_SOURCE
=
"source"
;
private
static
ApplicationContext
ctx
;
@Autowired
@Autowired
private
Environment
env
;
private
Environment
env
;
...
@@ -72,6 +78,27 @@ public class DjApiInvoker {
...
@@ -72,6 +78,27 @@ public class DjApiInvoker {
}
}
}
}
private
DjApiInvoker
()
{}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
{
ctx
=
applicationContext
;
}
@Override
public
void
destroy
()
{
ctx
=
null
;
}
/**
* 获取实例
*
* @return 实例
*/
public
static
DjApiInvoker
of
()
{
return
ctx
.
getBean
(
DjApiInvoker
.
class
);
}
/**
/**
* 调用接口
* 调用接口
*
*
...
@@ -117,9 +144,6 @@ public class DjApiInvoker {
...
@@ -117,9 +144,6 @@ public class DjApiInvoker {
paramMap
.
put
(
ARG_TIMESTAMP
,
DateUtil
.
formatDateTime
(
new
Date
()));
paramMap
.
put
(
ARG_TIMESTAMP
,
DateUtil
.
formatDateTime
(
new
Date
()));
paramMap
.
put
(
ARG_SOURCE
,
djSource
);
paramMap
.
put
(
ARG_SOURCE
,
djSource
);
//Map<String, String> signMap = new HashMap<>();
//paramMap.forEach((key, value) -> signMap.put(key, String.valueOf(value)));
//String sign = SignUtils.sign(signMap, djSecret);
String
sign
=
SignUtil
.
signBySha1
(
paramMap
,
djSecret
);
String
sign
=
SignUtil
.
signBySha1
(
paramMap
,
djSecret
);
log
.
info
(
"$$$$ generated sign: {}"
,
sign
);
log
.
info
(
"$$$$ generated sign: {}"
,
sign
);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment