Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
smalltools
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
王家辉
smalltools
Commits
07875d06
Commit
07875d06
authored
Feb 18, 2019
by
王家辉
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改返回参数,以code和msg返回,方便前端判断
parent
a91c2aeb
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
69 additions
and
13 deletions
+69
-13
src/main/java/com/freemud/Constant/ResponseCode.java
+37
-0
src/main/java/com/freemud/Controller/OrdersController.java
+17
-7
src/main/java/com/freemud/Service/Impl/OrdersServiceImpl.java
+5
-5
src/main/java/com/freemud/Service/OrdersService.java
+1
-1
src/main/java/com/freemud/dto/BaseResponse.java
+9
-0
No files found.
src/main/java/com/freemud/Constant/ResponseCode.java
0 → 100644
View file @
07875d06
package
com
.
freemud
.
Constant
;
import
lombok.Data
;
/**
* All rights Reserved, Designed By www.freemud.cn
*
* @version V1.0
* @Title: ResponseCode
* @Package com.freemud.Constant
* @Description: 简单描述下这个类是做什么用的
* @author: jiahui.wang
* @date: 2019/2/18 11:18
* @Copyright: 2019 www.freemud.cn Inc. All rights reserved.
* 注意:本内容仅限于上海非码科技内部传阅,禁止外泄以及用于其他的商业目的
*/
public
enum
ResponseCode
{
RESPONSE_CODE_100
(
"100"
,
"响应成功"
),
RESPONSE_CODE_101
(
"101"
,
"请求参数不正确"
),
RESPONSE_CODE_102
(
"102"
,
"请求失败"
);
private
String
code
;
private
String
msg
;
ResponseCode
(
String
code
,
String
msg
)
{
this
.
code
=
code
;
this
.
msg
=
msg
;
}
public
String
getCode
()
{
return
code
;
}
public
String
getMsg
()
{
return
msg
;
}
}
src/main/java/com/freemud/Controller/OrdersController.java
View file @
07875d06
...
@@ -12,8 +12,9 @@
...
@@ -12,8 +12,9 @@
*/
*/
package
com
.
freemud
.
Controller
;
package
com
.
freemud
.
Controller
;
import
com.
alibaba.fastjson.JSON
;
import
com.
freemud.Constant.ResponseCode
;
import
com.freemud.Service.OrdersService
;
import
com.freemud.Service.OrdersService
;
import
com.freemud.dto.BaseResponse
;
import
com.freemud.dto.OrderProductDTO
;
import
com.freemud.dto.OrderProductDTO
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
...
@@ -33,24 +34,33 @@ public class OrdersController {
...
@@ -33,24 +34,33 @@ public class OrdersController {
@ApiOperation
(
"获取订单的商品信息"
)
@ApiOperation
(
"获取订单的商品信息"
)
@PostMapping
(
"/getOrder"
)
@PostMapping
(
"/getOrder"
)
@ResponseBody
@ResponseBody
public
String
getOrder
(
@RequestParam
(
"orderId"
)
String
orderId
){
public
BaseResponse
getOrder
(
@RequestParam
(
"orderId"
)
String
orderId
){
if
(
orderId
==
null
){
return
new
BaseResponse
(
ResponseCode
.
RESPONSE_CODE_101
.
getCode
(),
ResponseCode
.
RESPONSE_CODE_101
.
getMsg
(),
"1"
,
"请求参数为空"
);
}
List
<
OrderProductDTO
>
list
=
ordersService
.
getOrderProductDTOByOrderId
(
orderId
);
List
<
OrderProductDTO
>
list
=
ordersService
.
getOrderProductDTOByOrderId
(
orderId
);
return
JSON
.
toJSONString
(
list
);
if
(
list
.
size
()
==
0
){
return
new
BaseResponse
(
ResponseCode
.
RESPONSE_CODE_102
.
getCode
(),
ResponseCode
.
RESPONSE_CODE_102
.
getMsg
(),
"1"
,
"查询不到订单,请输入正确的订单号"
);
}
return
new
BaseResponse
(
ResponseCode
.
RESPONSE_CODE_100
.
getCode
(),
ResponseCode
.
RESPONSE_CODE_100
.
getMsg
(),
"1"
,
list
);
}
}
@ApiOperation
(
"根据正确的sku进行补推"
)
@ApiOperation
(
"根据正确的sku进行补推"
)
@PostMapping
(
"/getRightSkuAndOrderPush"
)
@PostMapping
(
"/getRightSkuAndOrderPush"
)
@ResponseBody
@ResponseBody
public
Integer
getRightSkuAndOrderPush
(
@RequestBody
OrderProductDTO
orderProductDTO
){
public
BaseResponse
getRightSkuAndOrderPush
(
@RequestBody
OrderProductDTO
orderProductDTO
){
String
sku
=
orderProductDTO
.
getSku
();
String
sku
=
orderProductDTO
.
getSku
();
String
id
=
orderProductDTO
.
getId
();
String
id
=
orderProductDTO
.
getId
();
if
(
sku
==
null
||
id
==
null
){
return
new
BaseResponse
(
ResponseCode
.
RESPONSE_CODE_101
.
getCode
(),
ResponseCode
.
RESPONSE_CODE_101
.
getMsg
(),
"1"
,
"请求参数为空"
);
}
// 修复sku
// 修复sku
boolean
isMod
=
ordersService
.
RepairByRightSku
(
id
,
sku
);
boolean
isMod
=
ordersService
.
RepairByRightSku
(
orderProductDTO
);
if
(
isMod
){
if
(
isMod
){
return
1
;
return
new
BaseResponse
(
ResponseCode
.
RESPONSE_CODE_100
.
getCode
(),
ResponseCode
.
RESPONSE_CODE_100
.
getMsg
(),
"1"
,
"修复成功"
)
;
}
else
{
}
else
{
return
0
;
return
new
BaseResponse
(
ResponseCode
.
RESPONSE_CODE_102
.
getCode
(),
ResponseCode
.
RESPONSE_CODE_102
.
getMsg
(),
"1"
,
"修复失败"
)
;
}
}
}
}
...
...
src/main/java/com/freemud/Service/Impl/OrdersServiceImpl.java
View file @
07875d06
...
@@ -59,13 +59,13 @@ public class OrdersServiceImpl implements OrdersService {
...
@@ -59,13 +59,13 @@ public class OrdersServiceImpl implements OrdersService {
}
}
@Override
@Override
public
Boolean
RepairByRightSku
(
String
id
,
String
sku
)
{
public
Boolean
RepairByRightSku
(
OrderProductDTO
orderProductDTO
)
{
// 请求修复接口
// 请求修复接口
String
url
=
RequestUrl
+
"/order/repairByRightSku"
;
String
url
=
RequestUrl
+
"/order/repairByRightSku"
;
String
titles
[]
=
{
"订单联合表主键"
,
"正确的sku"
};
String
titles
[]
=
{
"订单联合表主键"
,
"正确的sku"
};
List
<
String
>
cells
=
new
ArrayList
<>();
List
<
String
>
cells
=
new
ArrayList
<>();
cells
.
add
(
id
);
cells
.
add
(
orderProductDTO
.
getId
()
);
cells
.
add
(
sku
);
cells
.
add
(
orderProductDTO
.
getSku
()
);
File
file
=
ExcelOperationUtils
.
WriteExcel
(
titles
,
cells
,
FileDir
);
File
file
=
ExcelOperationUtils
.
WriteExcel
(
titles
,
cells
,
FileDir
);
if
(!
file
.
exists
()){
if
(!
file
.
exists
()){
log
.
error
(
"文件不存在"
);
log
.
error
(
"文件不存在"
);
...
@@ -76,10 +76,10 @@ public class OrdersServiceImpl implements OrdersService {
...
@@ -76,10 +76,10 @@ public class OrdersServiceImpl implements OrdersService {
String
code
=
restTemplate
.
postForObject
(
url
,
param
,
String
.
class
);
String
code
=
restTemplate
.
postForObject
(
url
,
param
,
String
.
class
);
log
.
info
(
"调用接口{}返回的code:{}"
,
url
,
code
);
log
.
info
(
"调用接口{}返回的code:{}"
,
url
,
code
);
if
(
code
.
equals
(
returnCode
)){
if
(
code
.
equals
(
returnCode
)){
log
.
info
(
"修改sku成功{}
,{}"
,
id
,
sku
);
log
.
info
(
"修改sku成功{}
"
,
JSON
.
toJSONString
(
orderProductDTO
)
);
return
true
;
return
true
;
}
}
log
.
info
(
"修改sku失败:{}
,{}"
,
id
,
sku
);
log
.
info
(
"修改sku失败:{}
"
,
JSON
.
toJSONString
(
orderProductDTO
)
);
return
false
;
return
false
;
}
}
...
...
src/main/java/com/freemud/Service/OrdersService.java
View file @
07875d06
...
@@ -25,6 +25,6 @@ public interface OrdersService {
...
@@ -25,6 +25,6 @@ public interface OrdersService {
*/
*/
List
<
OrderProductDTO
>
getOrderProductDTOByOrderId
(
String
orderId
);
List
<
OrderProductDTO
>
getOrderProductDTOByOrderId
(
String
orderId
);
Boolean
RepairByRightSku
(
String
id
,
String
sku
);
Boolean
RepairByRightSku
(
OrderProductDTO
orderProductDTO
);
}
}
src/main/java/com/freemud/dto/BaseResponse.java
View file @
07875d06
...
@@ -25,4 +25,13 @@ public class BaseResponse <T>{
...
@@ -25,4 +25,13 @@ public class BaseResponse <T>{
protected
T
result
;
protected
T
result
;
public
BaseResponse
(
String
code
,
String
message
,
String
ver
,
T
result
)
{
this
.
code
=
code
;
this
.
message
=
message
;
this
.
ver
=
ver
;
this
.
result
=
result
;
}
public
BaseResponse
()
{
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment