Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
a5c2aff4
Commit
a5c2aff4
authored
Nov 16, 2018
by
Junling Bu
Browse files
chore[后端服务]: 后端服务代码基于IDEA的reformat code工具格式化代码,但是mybatis generator生成的代码除外。
parent
556f269d
Changes
132
Hide whitespace changes
Inline
Side-by-side
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserService.java
View file @
a5c2aff4
...
...
@@ -7,11 +7,10 @@ import org.linlinjava.litemall.db.domain.LitemallUserExample;
import
org.linlinjava.litemall.db.domain.UserVo
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.StringUtils
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
public
class
LitemallUserService
{
...
...
@@ -51,10 +50,10 @@ public class LitemallUserService {
LitemallUserExample
example
=
new
LitemallUserExample
();
LitemallUserExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
username
)){
if
(!
StringUtils
.
isEmpty
(
username
))
{
criteria
.
andUsernameLike
(
"%"
+
username
+
"%"
);
}
if
(!
StringUtils
.
isEmpty
(
mobile
)){
if
(!
StringUtils
.
isEmpty
(
mobile
))
{
criteria
.
andMobileEqualTo
(
mobile
);
}
criteria
.
andDeletedEqualTo
(
false
);
...
...
@@ -71,10 +70,10 @@ public class LitemallUserService {
LitemallUserExample
example
=
new
LitemallUserExample
();
LitemallUserExample
.
Criteria
criteria
=
example
.
createCriteria
();
if
(!
StringUtils
.
isEmpty
(
username
)){
if
(!
StringUtils
.
isEmpty
(
username
))
{
criteria
.
andUsernameLike
(
"%"
+
username
+
"%"
);
}
if
(!
StringUtils
.
isEmpty
(
mobile
)){
if
(!
StringUtils
.
isEmpty
(
mobile
))
{
criteria
.
andMobileEqualTo
(
mobile
);
}
criteria
.
andDeletedEqualTo
(
false
);
...
...
@@ -86,7 +85,7 @@ public class LitemallUserService {
LitemallUserExample
example
=
new
LitemallUserExample
();
example
.
or
().
andDeletedEqualTo
(
false
);
return
(
int
)
userMapper
.
countByExample
(
example
);
return
(
int
)
userMapper
.
countByExample
(
example
);
}
public
List
<
LitemallUser
>
queryByUsername
(
String
username
)
{
...
...
litemall-db/src/main/java/org/linlinjava/litemall/db/service/StatService.java
View file @
a5c2aff4
...
...
@@ -17,11 +17,11 @@ public class StatService {
return
statMapper
.
statUser
();
}
public
List
<
Map
>
statOrder
(){
public
List
<
Map
>
statOrder
()
{
return
statMapper
.
statOrder
();
}
public
List
<
Map
>
statGoods
(){
public
List
<
Map
>
statGoods
()
{
return
statMapper
.
statGoods
();
}
}
litemall-db/src/main/java/org/linlinjava/litemall/db/util/OrderHandleOption.java
View file @
a5c2aff4
...
...
@@ -9,60 +9,60 @@ public class OrderHandleOption {
private
boolean
refund
=
false
;
// 取消订单并退款操作
private
boolean
rebuy
=
false
;
// 再次购买
public
void
setCancel
(
boolean
cancel
)
{
this
.
cancel
=
cancel
;
}
public
void
setDelete
(
boolean
delete
)
{
this
.
delete
=
delete
;
}
public
void
setPay
(
boolean
pay
)
{
this
.
pay
=
pay
;
}
public
void
setComment
(
boolean
comment
)
{
this
.
comment
=
comment
;
}
public
void
setConfirm
(
boolean
confirm
)
{
this
.
confirm
=
confirm
;
}
public
void
setRefund
(
boolean
refund
)
{
this
.
refund
=
refund
;
}
public
void
setRebuy
(
boolean
rebuy
)
{
this
.
rebuy
=
rebuy
;
}
public
boolean
isCancel
()
{
return
cancel
;
}
public
void
setCancel
(
boolean
cancel
)
{
this
.
cancel
=
cancel
;
}
public
boolean
isDelete
()
{
return
delete
;
}
public
void
setDelete
(
boolean
delete
)
{
this
.
delete
=
delete
;
}
public
boolean
isPay
()
{
return
pay
;
}
public
void
setPay
(
boolean
pay
)
{
this
.
pay
=
pay
;
}
public
boolean
isComment
()
{
return
comment
;
}
public
void
setComment
(
boolean
comment
)
{
this
.
comment
=
comment
;
}
public
boolean
isConfirm
()
{
return
confirm
;
}
public
void
setConfirm
(
boolean
confirm
)
{
this
.
confirm
=
confirm
;
}
public
boolean
isRefund
()
{
return
refund
;
}
public
void
setRefund
(
boolean
refund
)
{
this
.
refund
=
refund
;
}
public
boolean
isRebuy
()
{
return
rebuy
;
}
public
void
setRebuy
(
boolean
rebuy
)
{
this
.
rebuy
=
rebuy
;
}
}
litemall-db/src/main/java/org/linlinjava/litemall/db/util/OrderUtil.java
View file @
a5c2aff4
package
org.linlinjava.litemall.db.util
;
import
org.linlinjava.litemall.db.domain.LitemallOrder
;
import
org.springframework.util.Assert
;
import
java.util.ArrayList
;
import
java.util.List
;
...
...
@@ -76,7 +75,7 @@ public class OrderUtil {
}
public
static
OrderHandleOption
build
(
LitemallOrder
order
){
public
static
OrderHandleOption
build
(
LitemallOrder
order
)
{
int
status
=
order
.
getOrderStatus
().
intValue
();
OrderHandleOption
handleOption
=
new
OrderHandleOption
();
...
...
@@ -84,41 +83,34 @@ public class OrderUtil {
// 如果订单没有被取消,且没有支付,则可支付,可取消
handleOption
.
setCancel
(
true
);
handleOption
.
setPay
(
true
);
}
else
if
(
status
==
102
||
status
==
103
)
{
}
else
if
(
status
==
102
||
status
==
103
)
{
// 如果订单已经取消或是已完成,则可删除
handleOption
.
setDelete
(
true
);
}
else
if
(
status
==
201
)
{
}
else
if
(
status
==
201
)
{
// 如果订单已付款,没有发货,则可退款
handleOption
.
setRefund
(
true
);
}
else
if
(
status
==
202
)
{
}
else
if
(
status
==
202
)
{
// 如果订单申请退款中,没有相关操作
}
else
if
(
status
==
203
)
{
}
else
if
(
status
==
203
)
{
// 如果订单已经退款,则可删除
handleOption
.
setDelete
(
true
);
}
else
if
(
status
==
301
)
{
}
else
if
(
status
==
301
)
{
// 如果订单已经发货,没有收货,则可收货操作,
// 此时不能取消订单
handleOption
.
setConfirm
(
true
);
}
else
if
(
status
==
401
||
status
==
402
)
{
}
else
if
(
status
==
401
||
status
==
402
)
{
// 如果订单已经支付,且已经收货,则可删除、去评论和再次购买
handleOption
.
setDelete
(
true
);
handleOption
.
setComment
(
true
);
handleOption
.
setRebuy
(
true
);
}
else
{
}
else
{
throw
new
IllegalStateException
(
"status不支持"
);
}
return
handleOption
;
}
public
static
List
<
Short
>
orderStatus
(
Integer
showType
){
public
static
List
<
Short
>
orderStatus
(
Integer
showType
)
{
// 全部订单
if
(
showType
==
0
)
{
return
null
;
...
...
@@ -128,23 +120,19 @@ public class OrderUtil {
if
(
showType
.
equals
(
1
))
{
// 待付款订单
status
.
add
((
short
)
101
);
}
else
if
(
showType
.
equals
(
2
))
{
status
.
add
((
short
)
101
);
}
else
if
(
showType
.
equals
(
2
))
{
// 待发货订单
status
.
add
((
short
)
201
);
}
else
if
(
showType
.
equals
(
3
))
{
status
.
add
((
short
)
201
);
}
else
if
(
showType
.
equals
(
3
))
{
// 待收货订单
status
.
add
((
short
)
301
);
}
else
if
(
showType
.
equals
(
4
))
{
status
.
add
((
short
)
301
);
}
else
if
(
showType
.
equals
(
4
))
{
// 待评价订单
status
.
add
((
short
)
401
);
status
.
add
((
short
)
401
);
// 系统超时自动取消,此时应该不支持评价
// status.add((short)402);
}
else
{
}
else
{
return
null
;
}
...
...
litemall-db/src/main/resources/org/linlinjava/litemall/db/dao/OrderMapper.xml
View file @
a5c2aff4
<?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=
"org.linlinjava.litemall.db.dao.OrderMapper"
>
<update
id=
"updateWithOptimisticLocker"
parameterType=
"map"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_order
<set>
<if
test=
"order.id != null"
>
id = #{order.id,jdbcType=INTEGER},
</if>
<if
test=
"order.userId != null"
>
user_id = #{order.userId,jdbcType=INTEGER},
</if>
<if
test=
"order.orderSn != null"
>
order_sn = #{order.orderSn,jdbcType=VARCHAR},
</if>
<if
test=
"order.orderStatus != null"
>
order_status = #{order.orderStatus,jdbcType=SMALLINT},
</if>
<if
test=
"order.consignee != null"
>
consignee = #{order.consignee,jdbcType=VARCHAR},
</if>
<if
test=
"order.mobile != null"
>
mobile = #{order.mobile,jdbcType=VARCHAR},
</if>
<if
test=
"order.address != null"
>
address = #{order.address,jdbcType=VARCHAR},
</if>
<if
test=
"order.message != null"
>
message = #{order.message,jdbcType=VARCHAR},
</if>
<if
test=
"order.goodsPrice != null"
>
goods_price = #{order.goodsPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.freightPrice != null"
>
freight_price = #{order.freightPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.couponPrice != null"
>
coupon_price = #{order.couponPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.integralPrice != null"
>
integral_price = #{order.integralPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.grouponPrice != null"
>
groupon_price = #{order.grouponPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.orderPrice != null"
>
order_price = #{order.orderPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.actualPrice != null"
>
actual_price = #{order.actualPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.payId != null"
>
pay_id = #{order.payId,jdbcType=VARCHAR},
</if>
<if
test=
"order.payTime != null"
>
pay_time = #{order.payTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.shipSn != null"
>
ship_sn = #{order.shipSn,jdbcType=VARCHAR},
</if>
<if
test=
"order.shipChannel != null"
>
ship_channel = #{order.shipChannel,jdbcType=VARCHAR},
</if>
<if
test=
"order.shipTime != null"
>
ship_time = #{order.shipTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.confirmTime != null"
>
confirm_time = #{order.confirmTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.comments != null"
>
comments = #{order.comments,jdbcType=SMALLINT},
</if>
<if
test=
"order.endTime != null"
>
end_time = #{order.endTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.addTime != null"
>
add_time = #{order.addTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.updateTime != null"
>
update_time = #{order.updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.deleted != null"
>
deleted = #{order.deleted,jdbcType=BIT},
</if>
</set>
where id = #{order.id,jdbcType=INTEGER} and update_time = #{lastUpdateTime,jdbcType=INTEGER}
</update>
<update
id=
"updateWithOptimisticLocker"
parameterType=
"map"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_order
<set>
<if
test=
"order.id != null"
>
id = #{order.id,jdbcType=INTEGER},
</if>
<if
test=
"order.userId != null"
>
user_id = #{order.userId,jdbcType=INTEGER},
</if>
<if
test=
"order.orderSn != null"
>
order_sn = #{order.orderSn,jdbcType=VARCHAR},
</if>
<if
test=
"order.orderStatus != null"
>
order_status = #{order.orderStatus,jdbcType=SMALLINT},
</if>
<if
test=
"order.consignee != null"
>
consignee = #{order.consignee,jdbcType=VARCHAR},
</if>
<if
test=
"order.mobile != null"
>
mobile = #{order.mobile,jdbcType=VARCHAR},
</if>
<if
test=
"order.address != null"
>
address = #{order.address,jdbcType=VARCHAR},
</if>
<if
test=
"order.message != null"
>
message = #{order.message,jdbcType=VARCHAR},
</if>
<if
test=
"order.goodsPrice != null"
>
goods_price = #{order.goodsPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.freightPrice != null"
>
freight_price = #{order.freightPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.couponPrice != null"
>
coupon_price = #{order.couponPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.integralPrice != null"
>
integral_price = #{order.integralPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.grouponPrice != null"
>
groupon_price = #{order.grouponPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.orderPrice != null"
>
order_price = #{order.orderPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.actualPrice != null"
>
actual_price = #{order.actualPrice,jdbcType=DECIMAL},
</if>
<if
test=
"order.payId != null"
>
pay_id = #{order.payId,jdbcType=VARCHAR},
</if>
<if
test=
"order.payTime != null"
>
pay_time = #{order.payTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.shipSn != null"
>
ship_sn = #{order.shipSn,jdbcType=VARCHAR},
</if>
<if
test=
"order.shipChannel != null"
>
ship_channel = #{order.shipChannel,jdbcType=VARCHAR},
</if>
<if
test=
"order.shipTime != null"
>
ship_time = #{order.shipTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.confirmTime != null"
>
confirm_time = #{order.confirmTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.comments != null"
>
comments = #{order.comments,jdbcType=SMALLINT},
</if>
<if
test=
"order.endTime != null"
>
end_time = #{order.endTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.addTime != null"
>
add_time = #{order.addTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.updateTime != null"
>
update_time = #{order.updateTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"order.deleted != null"
>
deleted = #{order.deleted,jdbcType=BIT},
</if>
</set>
where id = #{order.id,jdbcType=INTEGER} and update_time = #{lastUpdateTime,jdbcType=INTEGER}
</update>
</mapper>
\ No newline at end of file
litemall-db/src/main/resources/org/linlinjava/litemall/db/dao/StatMapper.xml
View file @
a5c2aff4
<?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=
"org.linlinjava.litemall.db.dao.StatMapper"
>
<select
id=
"statUser"
resultType=
"map"
>
select
substr(add_time,1,10) as day,
count(distinct id) as users
from litemall_user
group by substr(add_time,1,10)
</select>
<select
id=
"statOrder"
resultType=
"map"
>
select
substr(add_time,1,10)
as day,
count(id)
as orders,
count(distinct user_id)
as customers,
sum(actual_price)
as amount,
round(sum(actual_price)/count(distinct user_id),2) as pcr
from litemall_order
where order_status in(103)
group by substr(add_time,1,10)
</select>
<select
id=
"statGoods"
resultType=
"map"
>
select
substr(add_time,1, 10) as day,
count(distinct order_id) as orders,
sum(number)
as products,
sum(number*price) as amount
from litemall_order_goods
group by substr(add_time,1, 10)
</select>
<select
id=
"statUser"
resultType=
"map"
>
select
substr(add_time,1,10) as day,
count(distinct id) as users
from litemall_user
group by substr(add_time,1,10)
</select>
<select
id=
"statOrder"
resultType=
"map"
>
select
substr(add_time,1,10) as day,
count(id) as orders,
count(distinct user_id) as customers,
sum(actual_price) as amount,
round(sum(actual_price)/count(distinct user_id),2) as pcr
from litemall_order
where order_status in(103)
group by substr(add_time,1,10)
</select>
<select
id=
"statGoods"
resultType=
"map"
>
select
substr(add_time,1, 10) as day,
count(distinct order_id) as orders,
sum(number)
as products,
sum(number*price) as amount
from litemall_order_goods
group by substr(add_time,1, 10)
</select>
</mapper>
\ No newline at end of file
litemall-db/src/test/java/org/linlinjava/litemall/db/StatMapperTest.java
View file @
a5c2aff4
...
...
@@ -22,7 +22,7 @@ public class StatMapperTest {
@Test
public
void
testUser
()
{
List
<
Map
>
result
=
statMapper
.
statUser
();
for
(
Map
m
:
result
)
{
for
(
Map
m
:
result
)
{
m
.
forEach
((
k
,
v
)
->
System
.
out
.
println
(
"key:value = "
+
k
+
":"
+
v
));
}
}
...
...
@@ -30,7 +30,7 @@ public class StatMapperTest {
@Test
public
void
testOrder
()
{
List
<
Map
>
result
=
statMapper
.
statOrder
();
for
(
Map
m
:
result
)
{
for
(
Map
m
:
result
)
{
m
.
forEach
((
k
,
v
)
->
System
.
out
.
println
(
"key:value = "
+
k
+
":"
+
v
));
}
}
...
...
@@ -38,7 +38,7 @@ public class StatMapperTest {
@Test
public
void
testGoods
()
{
List
<
Map
>
result
=
statMapper
.
statGoods
();
for
(
Map
m
:
result
)
{
for
(
Map
m
:
result
)
{
m
.
forEach
((
k
,
v
)
->
System
.
out
.
println
(
"key:value = "
+
k
+
":"
+
v
));
}
}
...
...
litemall-wx-api/pom.xml
View file @
a5c2aff4
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
<project
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xmlns=
"http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
litemall-wx-api
</artifactId>
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/Application.java
View file @
a5c2aff4
...
...
@@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.transaction.annotation.EnableTransactionManagement
;
@SpringBootApplication
(
scanBasePackages
=
{
"org.linlinjava.litemall.core"
,
"org.linlinjava.litemall.wx"
,
"org.linlinjava.litemall.db"
})
@SpringBootApplication
(
scanBasePackages
=
{
"org.linlinjava.litemall.core"
,
"org.linlinjava.litemall.wx"
,
"org.linlinjava.litemall.db"
})
@MapperScan
(
"org.linlinjava.litemall.db.dao"
)
@EnableTransactionManagement
@EnableScheduling
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/annotation/support/LoginUserHandlerMethodArgumentResolver.java
View file @
a5c2aff4
...
...
@@ -11,9 +11,10 @@ import org.springframework.web.method.support.ModelAndViewContainer;
public
class
LoginUserHandlerMethodArgumentResolver
implements
HandlerMethodArgumentResolver
{
public
static
final
String
LOGIN_TOKEN_KEY
=
"X-Litemall-Token"
;
@Override
public
boolean
supportsParameter
(
MethodParameter
parameter
)
{
return
parameter
.
getParameterType
().
isAssignableFrom
(
Integer
.
class
)&&
parameter
.
hasParameterAnnotation
(
LoginUser
.
class
);
return
parameter
.
getParameterType
().
isAssignableFrom
(
Integer
.
class
)
&&
parameter
.
hasParameterAnnotation
(
LoginUser
.
class
);
}
@Override
...
...
@@ -22,7 +23,7 @@ public class LoginUserHandlerMethodArgumentResolver implements HandlerMethodArgu
// return new Integer(1);
String
token
=
request
.
getHeader
(
LOGIN_TOKEN_KEY
);
if
(
token
==
null
||
token
.
isEmpty
()){
if
(
token
==
null
||
token
.
isEmpty
())
{
return
null
;
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/config/UseConfig.java
View file @
a5c2aff4
...
...
@@ -4,6 +4,7 @@ import org.linlinjava.litemall.wx.annotation.support.LoginUserHandlerMethodArgum
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
java.util.List
;
@Configuration
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/dao/UserInfo.java
View file @
a5c2aff4
...
...
@@ -9,58 +9,59 @@ public class UserInfo {
private
String
language
;
private
Byte
gender
;
public
String
getCountry
()
{
return
country
;
}
public
void
setCountry
(
String
country
)
{
this
.
country
=
country
;
}
public
void
setProvince
(
String
p
rovince
)
{
this
.
province
=
province
;
public
String
getP
rovince
(
)
{
return
province
;
}
public
void
set
City
(
String
city
)
{
this
.
city
=
city
;
public
void
set
Province
(
String
province
)
{
this
.
province
=
province
;
}
public
void
setLanguage
(
String
language
)
{
this
.
language
=
language
;
public
String
getCity
(
)
{
return
city
;
}
public
void
set
Gender
(
Byte
gender
)
{
this
.
gender
=
gender
;
public
void
set
City
(
String
city
)
{
this
.
city
=
city
;
}
public
String
get
Country
()
{
return
country
;
public
String
get
Language
()
{
return
language
;
}
public
String
getProvince
(
)
{
return
provinc
e
;
public
void
setLanguage
(
String
language
)
{
this
.
language
=
languag
e
;
}
public
String
getCity
()
{
return
city
;
public
Byte
getGender
()
{
return
gender
;
}
public
String
getLanguage
(
)
{
return
language
;
public
void
setGender
(
Byte
gender
)
{
this
.
gender
=
gender
;
}
public
Byte
getGender
()
{
return
gender
;
public
String
getNickName
()
{
return
nickName
;
}
public
void
setNickName
(
String
nickName
)
{
this
.
nickName
=
nickName
;
}
public
void
setAvatarUrl
(
String
avatarUrl
)
{
this
.
avatarUrl
=
avatarUrl
;
}
public
String
getNickName
()
{
return
nickName
;
}
public
String
getAvatarUrl
()
{
return
avatarUrl
;
}
public
void
setAvatarUrl
(
String
avatarUrl
)
{
this
.
avatarUrl
=
avatarUrl
;
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/dao/UserToken.java
View file @
a5c2aff4
...
...
@@ -17,35 +17,35 @@ public class UserToken {
this
.
sessionKey
=
sessionKey
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
void
setExpireTime
(
LocalDateTime
expireTime
)
{
this
.
expireTime
=
expireTime
;
}
public
void
setUpdateTime
(
LocalDateTime
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
public
Integer
getUserId
()
{
return
userId
;
}
public
void
setUserId
(
Integer
userId
)
{
this
.
userId
=
userId
;
}
public
String
getToken
()
{
return
token
;
}
public
void
setToken
(
String
token
)
{
this
.
token
=
token
;
}
public
LocalDateTime
getExpireTime
()
{
return
expireTime
;
}
public
void
setExpireTime
(
LocalDateTime
expireTime
)
{
this
.
expireTime
=
expireTime
;
}
public
LocalDateTime
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
LocalDateTime
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAddressController.java
View file @
a5c2aff4
...
...
@@ -3,10 +3,10 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.RegexUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallAddress
;
import
org.linlinjava.litemall.db.service.LitemallAddressService
;
import
org.linlinjava.litemall.db.service.LitemallRegionService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.util.StringUtils
;
...
...
@@ -14,7 +14,6 @@ import org.springframework.validation.annotation.Validated;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -36,22 +35,22 @@ public class WxAddressController {
*
* @param userId 用户ID
* @return 收货地址列表
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data: xxx
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
@LoginUser
Integer
userId
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
List
<
LitemallAddress
>
addressList
=
addressService
.
queryByUid
(
userId
);
List
<
Map
<
String
,
Object
>>
addressVoList
=
new
ArrayList
<>(
addressList
.
size
());
for
(
LitemallAddress
address
:
addressList
){
for
(
LitemallAddress
address
:
addressList
)
{
Map
<
String
,
Object
>
addressVo
=
new
HashMap
<>();
addressVo
.
put
(
"id"
,
address
.
getId
());
addressVo
.
put
(
"name"
,
address
.
getName
());
...
...
@@ -73,38 +72,38 @@ public class WxAddressController {
* 收货地址详情
*
* @param userId 用户ID
* @param id 收获地址ID
* @param id
收获地址ID
* @return 收货地址详情
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data:
*
{
*
id: xxx,
*
name: xxx,
*
provinceId: xxx,
*
cityId: xxx,
*
areaId: xxx,
*
mobile: xxx,
*
address: xxx,
*
isDefault: xxx,
*
version: xxx
*
provinceName: xxx,
*
cityName: xxx,
*
areaName: xxx
*
}
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* id: xxx,
* name: xxx,
* provinceId: xxx,
* cityId: xxx,
* areaId: xxx,
* mobile: xxx,
* address: xxx,
* isDefault: xxx,
* version: xxx
* provinceName: xxx,
* cityName: xxx,
* areaName: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"detail"
)
public
Object
detail
(
@LoginUser
Integer
userId
,
@NotNull
Integer
id
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
LitemallAddress
address
=
addressService
.
findById
(
id
);
if
(
address
==
null
){
if
(
address
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
...
...
@@ -128,50 +127,50 @@ public class WxAddressController {
private
Object
validate
(
LitemallAddress
address
)
{
String
name
=
address
.
getName
();
if
(
StringUtils
.
isEmpty
(
name
)){
if
(
StringUtils
.
isEmpty
(
name
))
{
return
ResponseUtil
.
badArgument
();
}
// 测试收货手机号码是否正确
String
mobile
=
address
.
getMobile
();
if
(
StringUtils
.
isEmpty
(
mobile
)){
if
(
StringUtils
.
isEmpty
(
mobile
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
RegexUtil
.
isMobileExact
(
mobile
)){
if
(!
RegexUtil
.
isMobileExact
(
mobile
))
{
return
ResponseUtil
.
badArgument
();
}
Integer
pid
=
address
.
getProvinceId
();
if
(
pid
==
null
){
if
(
pid
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
if
(
regionService
.
findById
(
pid
)
==
null
){
if
(
regionService
.
findById
(
pid
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
Integer
cid
=
address
.
getCityId
();
if
(
cid
==
null
){
if
(
cid
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
if
(
regionService
.
findById
(
cid
)
==
null
){
if
(
regionService
.
findById
(
cid
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
Integer
aid
=
address
.
getAreaId
();
if
(
aid
==
null
){
if
(
aid
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
if
(
regionService
.
findById
(
aid
)
==
null
){
if
(
regionService
.
findById
(
aid
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
String
detailedAddress
=
address
.
getAddress
();
if
(
StringUtils
.
isEmpty
(
detailedAddress
)){
if
(
StringUtils
.
isEmpty
(
detailedAddress
))
{
return
ResponseUtil
.
badArgument
();
}
Boolean
isDefault
=
address
.
getIsDefault
();
if
(
isDefault
==
null
){
if
(
isDefault
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
return
null
;
...
...
@@ -180,23 +179,23 @@ public class WxAddressController {
/**
* 添加或更新收货地址
*
* @param userId 用户ID
* @param userId
用户ID
* @param address 用户收货地址
* @return 添加或更新操作结果
*
成功则 { errno: 0, errmsg: '成功' }
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping
(
"save"
)
public
Object
save
(
@LoginUser
Integer
userId
,
@RequestBody
LitemallAddress
address
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
address
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
if
(
address
.
getIsDefault
()){
if
(
address
.
getIsDefault
())
{
// 重置其他收获地址的默认选项
addressService
.
resetDefault
(
userId
);
}
...
...
@@ -207,7 +206,7 @@ public class WxAddressController {
addressService
.
add
(
address
);
}
else
{
address
.
setUserId
(
userId
);
if
(
addressService
.
update
(
address
)
==
0
){
if
(
addressService
.
update
(
address
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
}
...
...
@@ -217,19 +216,19 @@ public class WxAddressController {
/**
* 删除收货地址
*
* @param userId 用户ID
* @param userId
用户ID
* @param address 用户收货地址
* @return 删除结果
*
成功则 { errno: 0, errmsg: '成功' }
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则 { errno: 0, errmsg: '成功' }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping
(
"delete"
)
public
Object
delete
(
@LoginUser
Integer
userId
,
@RequestBody
LitemallAddress
address
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Integer
id
=
address
.
getId
();
if
(
id
==
null
){
if
(
id
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxAuthController.java
View file @
a5c2aff4
...
...
@@ -166,7 +166,7 @@ public class WxAuthController {
}
else
{
user
.
setLastLoginTime
(
LocalDateTime
.
now
());
user
.
setLastLoginIp
(
IpUtil
.
client
(
request
));
if
(
userService
.
updateById
(
user
)
==
0
){
if
(
userService
.
updateById
(
user
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
}
...
...
@@ -192,21 +192,21 @@ public class WxAuthController {
@PostMapping
(
"regCaptcha"
)
public
Object
registerCaptcha
(
@RequestBody
String
body
)
{
String
phoneNumber
=
JacksonUtil
.
parseString
(
body
,
"mobile"
);
if
(
StringUtils
.
isEmpty
(
phoneNumber
)){
if
(
StringUtils
.
isEmpty
(
phoneNumber
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
RegexUtil
.
isMobileExact
(
phoneNumber
)){
if
(!
RegexUtil
.
isMobileExact
(
phoneNumber
))
{
return
ResponseUtil
.
badArgumentValue
();
}
if
(
notifyService
.
isSmsEnable
()){
if
(
notifyService
.
isSmsEnable
())
{
return
ResponseUtil
.
fail
(
404
,
"小程序后台验证码服务不支持"
);
}
String
code
=
CharUtil
.
getRandomNum
(
6
);
notifyService
.
notifySmsTemplate
(
phoneNumber
,
NotifyType
.
CAPTCHA
,
new
String
[]{
code
});
boolean
successful
=
CaptchaCodeManager
.
addToCache
(
phoneNumber
,
code
);
if
(!
successful
){
if
(!
successful
)
{
return
ResponseUtil
.
fail
(
404
,
"验证码未超时1分钟,不能发送"
);
}
...
...
@@ -248,7 +248,7 @@ public class WxAuthController {
String
wxCode
=
JacksonUtil
.
parseString
(
body
,
"wxCode"
);
if
(
StringUtils
.
isEmpty
(
username
)
||
StringUtils
.
isEmpty
(
password
)
||
StringUtils
.
isEmpty
(
mobile
)
||
StringUtils
.
isEmpty
(
wxCode
)
||
StringUtils
.
isEmpty
(
code
))
{
||
StringUtils
.
isEmpty
(
wxCode
)
||
StringUtils
.
isEmpty
(
code
))
{
return
ResponseUtil
.
badArgument
();
}
...
...
@@ -279,16 +279,16 @@ public class WxAuthController {
return
ResponseUtil
.
fail
(
403
,
"openid 获取失败"
);
}
userList
=
userService
.
queryByOpenid
(
openId
);
if
(
userList
.
size
()
>
1
){
if
(
userList
.
size
()
>
1
)
{
return
ResponseUtil
.
fail
(
403
,
"openid 存在多个"
);
}
if
(
userList
.
size
()
==
1
){
LitemallUser
checkUser
=
userList
.
get
(
0
);
String
checkUsername
=
checkUser
.
getUsername
();
String
checkPassword
=
checkUser
.
getPassword
();
if
(!
checkUsername
.
equals
(
openId
)
||
!
checkPassword
.
equals
(
openId
)){
return
ResponseUtil
.
fail
(
403
,
"openid已绑定账号"
);
}
if
(
userList
.
size
()
==
1
)
{
LitemallUser
checkUser
=
userList
.
get
(
0
);
String
checkUsername
=
checkUser
.
getUsername
();
String
checkPassword
=
checkUser
.
getPassword
();
if
(!
checkUsername
.
equals
(
openId
)
||
!
checkPassword
.
equals
(
openId
))
{
return
ResponseUtil
.
fail
(
403
,
"openid已绑定账号"
);
}
}
LitemallUser
user
=
null
;
...
...
@@ -367,7 +367,7 @@ public class WxAuthController {
String
encodedPassword
=
encoder
.
encode
(
password
);
user
.
setPassword
(
encodedPassword
);
if
(
userService
.
updateById
(
user
)
==
0
){
if
(
userService
.
updateById
(
user
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
...
...
@@ -383,7 +383,7 @@ public class WxAuthController {
String
phone
=
phoneNumberInfo
.
getPhoneNumber
();
LitemallUser
user
=
userService
.
findById
(
userId
);
user
.
setMobile
(
phone
);
if
(
userService
.
updateById
(
user
)
==
0
){
if
(
userService
.
updateById
(
user
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
return
ResponseUtil
.
ok
();
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxBrandController.java
View file @
a5c2aff4
...
...
@@ -2,9 +2,9 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallBrand
;
import
org.linlinjava.litemall.db.service.LitemallBrandService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCartController.java
View file @
a5c2aff4
...
...
@@ -3,18 +3,17 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.*
;
import
org.linlinjava.litemall.db.service.*
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.linlinjava.litemall.core.system.SystemConfig
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.math.BigDecimal
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -149,7 +148,7 @@ public class WxCartController {
return
ResponseUtil
.
fail
(
400
,
"库存不足"
);
}
existCart
.
setNumber
((
short
)
num
);
if
(
cartService
.
updateById
(
existCart
)
==
0
){
if
(
cartService
.
updateById
(
existCart
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
}
...
...
@@ -222,7 +221,7 @@ public class WxCartController {
return
ResponseUtil
.
fail
(
400
,
"库存不足"
);
}
existCart
.
setNumber
((
short
)
num
);
if
(
cartService
.
updateById
(
existCart
)
==
0
){
if
(
cartService
.
updateById
(
existCart
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
}
...
...
@@ -284,7 +283,7 @@ public class WxCartController {
}
existCart
.
setNumber
(
number
.
shortValue
());
if
(
cartService
.
updateById
(
existCart
)
==
0
){
if
(
cartService
.
updateById
(
existCart
)
==
0
)
{
return
ResponseUtil
.
updatedDataFailed
();
}
return
ResponseUtil
.
ok
();
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCollectController.java
View file @
a5c2aff4
...
...
@@ -3,19 +3,18 @@ package org.linlinjava.litemall.wx.web;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallCollect
;
import
org.linlinjava.litemall.db.domain.LitemallGoods
;
import
org.linlinjava.litemall.db.service.LitemallCollectService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.core.util.JacksonUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -36,29 +35,29 @@ public class WxCollectController {
* 用户收藏列表
*
* @param userId 用户ID
* @param type 类型,如果是0则是商品收藏,如果是1则是专题收藏
* 目前没有使用
* @param page 分页页数
* @param size 分页大小
* @param type
类型,如果是0则是商品收藏,如果是1则是专题收藏
*
目前没有使用
* @param page
分页页数
* @param size
分页大小
* @return 用户收藏列表
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data:
*
{
*
collectList: xxx,
*
totalPages: xxx
*
}
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* collectList: xxx,
* totalPages: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
@LoginUser
Integer
userId
,
@NotNull
Byte
type
,
@RequestParam
(
defaultValue
=
"1"
)
Integer
page
,
@RequestParam
(
defaultValue
=
"10"
)
Integer
size
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
...
...
@@ -67,7 +66,7 @@ public class WxCollectController {
int
totalPages
=
(
int
)
Math
.
ceil
((
double
)
count
/
size
);
List
<
Object
>
collects
=
new
ArrayList
<>(
collectList
.
size
());
for
(
LitemallCollect
collect
:
collectList
){
for
(
LitemallCollect
collect
:
collectList
)
{
Map
<
String
,
Object
>
c
=
new
HashMap
<
String
,
Object
>();
c
.
put
(
"id"
,
collect
.
getId
());
c
.
put
(
"type"
,
collect
.
getType
());
...
...
@@ -92,42 +91,41 @@ public class WxCollectController {
* 用户收藏添加或删除
*
* @param userId 用户ID
* @param body 请求内容
* @param body
请求内容
* @return 操作结果
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data:
*
{
*
type: xxx,
*
}
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* type: xxx,
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping
(
"addordelete"
)
public
Object
addordelete
(
@LoginUser
Integer
userId
,
@RequestBody
String
body
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
if
(
body
==
null
){
if
(
body
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
Byte
type
=
JacksonUtil
.
parseByte
(
body
,
"type"
);
Integer
valueId
=
JacksonUtil
.
parseInteger
(
body
,
"valueId"
);
if
(!
ObjectUtils
.
allNotNull
(
type
,
valueId
)){
if
(!
ObjectUtils
.
allNotNull
(
type
,
valueId
))
{
return
ResponseUtil
.
badArgument
();
}
LitemallCollect
collect
=
collectService
.
queryByTypeAndValue
(
userId
,
type
,
valueId
);
String
handleType
=
null
;
if
(
collect
!=
null
){
if
(
collect
!=
null
)
{
handleType
=
"delete"
;
collectService
.
deleteById
(
collect
.
getId
());
}
else
{
}
else
{
handleType
=
"add"
;
collect
=
new
LitemallCollect
();
collect
.
setUserId
(
userId
);
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxCommentController.java
View file @
a5c2aff4
package
org.linlinjava.litemall.wx.web
;
import
org.apache.commons.lang3.ObjectUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallComment
;
import
org.linlinjava.litemall.db.domain.LitemallGoodsSpecification
;
import
org.linlinjava.litemall.db.service.LitemallCommentService
;
import
org.linlinjava.litemall.db.service.LitemallGoodsService
;
import
org.linlinjava.litemall.db.service.LitemallTopicService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.linlinjava.litemall.wx.service.UserInfoService
;
import
org.linlinjava.litemall.wx.dao.UserInfo
;
import
org.linlinjava.litemall.wx.service.UserInfoService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
javax.validation.constraints.NotNull
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -44,38 +41,36 @@ public class WxCommentController {
private
Object
validate
(
LitemallComment
comment
)
{
String
content
=
comment
.
getContent
();
if
(
StringUtils
.
isEmpty
(
content
)){
if
(
StringUtils
.
isEmpty
(
content
))
{
return
ResponseUtil
.
badArgument
();
}
Short
star
=
comment
.
getStar
();
if
(
star
==
null
){
if
(
star
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
if
(
star
<
0
||
star
>
5
){
if
(
star
<
0
||
star
>
5
)
{
return
ResponseUtil
.
badArgumentValue
();
}
Byte
type
=
comment
.
getType
();
Integer
valueId
=
comment
.
getValueId
();
if
(
type
==
null
||
valueId
==
null
){
if
(
type
==
null
||
valueId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
if
(
type
==
0
){
if
(
goodsService
.
findById
(
valueId
)
==
null
){
if
(
type
==
0
)
{
if
(
goodsService
.
findById
(
valueId
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
}
else
if
(
type
==
1
){
if
(
topicService
.
findById
(
valueId
)
==
null
){
}
}
else
if
(
type
==
1
)
{
if
(
topicService
.
findById
(
valueId
)
==
null
)
{
return
ResponseUtil
.
badArgumentValue
();
}
}
else
{
}
else
{
return
ResponseUtil
.
badArgumentValue
();
}
Boolean
hasPicture
=
comment
.
getHasPicture
();
if
(
hasPicture
==
null
||
!
hasPicture
){
if
(
hasPicture
==
null
||
!
hasPicture
)
{
comment
.
setPicUrls
(
new
String
[
0
]);
}
return
null
;
...
...
@@ -84,24 +79,24 @@ public class WxCommentController {
/**
* 发表评论
*
* @param userId 用户ID
* @param userId
用户ID
* @param comment 评论内容
* @return 发表评论操作结果
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data: xxx
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data: xxx
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@PostMapping
(
"post"
)
public
Object
post
(
@LoginUser
Integer
userId
,
@RequestBody
LitemallComment
comment
)
{
if
(
userId
==
null
){
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
comment
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
...
...
@@ -113,20 +108,20 @@ public class WxCommentController {
/**
* 评论数量
*
* @param type 类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param type
类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type是0,则是商品ID;如果type是1,则是专题ID。
* @return 评论数量
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data:
*
{
*
allCount: xxx,
*
hasPicCount: xxx
*
}
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* allCount: xxx,
* hasPicCount: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"count"
)
public
Object
count
(
@NotNull
Byte
type
,
@NotNull
Integer
valueId
)
{
...
...
@@ -141,24 +136,24 @@ public class WxCommentController {
/**
* 评论列表
*
* @param type 类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId 商品或专题ID。如果type是0,则是商品ID;如果type是1,则是专题ID。
* @param type
类型ID。 如果是0,则查询商品评论;如果是1,则查询专题评论。
* @param valueId
商品或专题ID。如果type是0,则是商品ID;如果type是1,则是专题ID。
* @param showType 显示类型。如果是0,则查询全部;如果是1,则查询有图片的评论。
* @param page 分页页数
* @param size 分页大小
* @param page
分页页数
* @param size
分页大小
* @return 评论列表
*
成功则
*
{
*
errno: 0,
*
errmsg: '成功',
*
data:
*
{
*
data: xxx,
*
count: xxx,
*
currentPage: xxx
*
}
*
}
*
失败则 { errno: XXX, errmsg: XXX }
* 成功则
* {
* errno: 0,
* errmsg: '成功',
* data:
* {
* data: xxx,
* count: xxx,
* currentPage: xxx
* }
* }
* 失败则 { errno: XXX, errmsg: XXX }
*/
@GetMapping
(
"list"
)
public
Object
list
(
@NotNull
Byte
type
,
...
...
@@ -170,10 +165,10 @@ public class WxCommentController {
int
count
=
commentService
.
count
(
type
,
valueId
,
showType
,
page
,
size
);
List
<
Map
<
String
,
Object
>>
commentVoList
=
new
ArrayList
<>(
commentList
.
size
());
for
(
LitemallComment
comment
:
commentList
){
for
(
LitemallComment
comment
:
commentList
)
{
Map
<
String
,
Object
>
commentVo
=
new
HashMap
<>();
commentVo
.
put
(
"addTime"
,
comment
.
getAddTime
());
commentVo
.
put
(
"content"
,
comment
.
getContent
());
commentVo
.
put
(
"content"
,
comment
.
getContent
());
commentVo
.
put
(
"picList"
,
comment
.
getPicUrls
());
UserInfo
userInfo
=
userInfoService
.
getInfo
(
comment
.
getUserId
());
...
...
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxFeedbackController.java
View file @
a5c2aff4
package
org.linlinjava.litemall.wx.web
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.linlinjava.litemall.core.util.RegexUtil
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallFeedback
;
...
...
@@ -8,12 +10,12 @@ import org.linlinjava.litemall.db.domain.LitemallUser;
import
org.linlinjava.litemall.db.service.LitemallFeedbackService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
import
java.time.LocalDateTime
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
/**
* @author Yogeek
...
...
@@ -32,23 +34,23 @@ public class WxFeedbackController {
private
Object
validate
(
LitemallFeedback
feedback
)
{
String
content
=
feedback
.
getContent
();
if
(
StringUtils
.
isEmpty
(
content
)){
if
(
StringUtils
.
isEmpty
(
content
))
{
return
ResponseUtil
.
badArgument
();
}
String
type
=
feedback
.
getFeedType
();
if
(
StringUtils
.
isEmpty
(
type
)){
if
(
StringUtils
.
isEmpty
(
type
))
{
return
ResponseUtil
.
badArgument
();
}
Boolean
hasPicture
=
feedback
.
getHasPicture
();
if
(
hasPicture
==
null
||
!
hasPicture
){
if
(
hasPicture
==
null
||
!
hasPicture
)
{
feedback
.
setPicUrls
(
new
String
[
0
]);
}
// 测试手机号码是否正确
String
mobile
=
feedback
.
getMobile
();
if
(
StringUtils
.
isEmpty
(
mobile
)){
if
(
StringUtils
.
isEmpty
(
mobile
))
{
return
ResponseUtil
.
badArgument
();
}
if
(!
RegexUtil
.
isMobileExact
(
mobile
))
{
...
...
@@ -58,7 +60,7 @@ public class WxFeedbackController {
}
/**
*
意见反馈
* 意见反馈
*/
@PostMapping
(
"submit"
)
public
Object
submit
(
@LoginUser
Integer
userId
,
@RequestBody
LitemallFeedback
feedback
)
{
...
...
@@ -66,7 +68,7 @@ public class WxFeedbackController {
return
ResponseUtil
.
unlogin
();
}
Object
error
=
validate
(
feedback
);
if
(
error
!=
null
){
if
(
error
!=
null
)
{
return
error
;
}
...
...
Prev
1
2
3
4
5
6
7
Next
Write
Preview
Supports
Markdown
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