Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
A
Afrishop refactored project
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Whispa
Afrishop refactored project
Commits
fc316131
提交
fc316131
authored
1月 23, 2021
作者:
吴德鹏
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
地址优化
上级
3fdfed2f
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
79 行增加
和
30 行删除
+79
-30
AddressController.java
...om/example/afrishop_v3/controllers/AddressController.java
+12
-9
AuthController.java
...a/com/example/afrishop_v3/controllers/AuthController.java
+9
-12
FlutterWaveController.java
...xample/afrishop_v3/controllers/FlutterWaveController.java
+1
-1
ItemController.java
...a/com/example/afrishop_v3/controllers/ItemController.java
+32
-2
TbCfItemCollection.java
...va/com/example/afrishop_v3/models/TbCfItemCollection.java
+6
-3
TbCfItemComment.java
.../java/com/example/afrishop_v3/models/TbCfItemComment.java
+10
-0
TbCfAddressRepository.java
...example/afrishop_v3/repository/TbCfAddressRepository.java
+2
-2
TbCfItemCommentRepository.java
...ple/afrishop_v3/repository/TbCfItemCommentRepository.java
+7
-1
没有找到文件。
src/main/java/com/example/afrishop_v3/controllers/AddressController.java
浏览文件 @
fc316131
...
...
@@ -46,8 +46,8 @@ public class AddressController extends Controller {
// return new Result(e.getCode(), "Delivery name is required");
// if (address.getPhone() == null || address.getPhone().trim().isEmpty())
// return new Result(e.getCode(), "Phone is required");
// if (repository.existsByAddressDetailAndUserId(address.getAddress1
().trim(), userId))
//
return new Result(e.getCode(), "Address already existed");
if
(
repository
.
existsByAddressDetailAndUserId
(
address
.
getAddressDetail
().
trim
(),
userId
))
return
new
Result
(
e
.
getCode
(),
"Address already existed"
);
//客户新增第一条地址,设置为默认
...
...
@@ -95,13 +95,14 @@ public class AddressController extends Controller {
// if (address.getPhone() == null || address.getPhone().trim().isEmpty())
// return new Result(e.getCode(), "Phone is required");
//
if (repository.existsByAddressDetailAndUserIdAndAddressIdIsNot(address.getAddressDetail().trim(), userId, addressId))
//
return new Result(e.getCode(), "Address already existed");
if
(
repository
.
existsByAddressDetailAndUserIdAndAddressIdIsNot
(
address
.
getAddressDetail
().
trim
(),
userId
,
addressId
))
return
new
Result
(
e
.
getCode
(),
"Address already existed"
);
address
.
setAddressDetail
(
address
.
getAddressDetail
().
trim
());
address
.
setAddressId
(
addressId
);
address
.
setUpdateTime
(
new
Date
());
address
.
setDefaultFlag
(
address
.
getDefaultFlag
());
address
.
setUserId
(
userId
);
TbCfAddress
save
=
repository
.
save
(
address
);
// configDefaultAddress(save.getAddressId());
...
...
@@ -136,16 +137,18 @@ public class AddressController extends Controller {
TbCfUserInfo
user
=
this
.
user
.
user
();
System
.
out
.
println
(
"address:"
+
address
);
repository
.
resetToDefault
(
user
.
getUserId
());
System
.
out
.
println
(
"address1:"
+
address
);
repository
.
resetToDefaultAndAddressIdIsNot
(
user
.
getUserId
(),
addressId
);
address
.
setDefaultFlag
(
StateConstant
.
VALID
);
repository
.
save
(
address
);
TbCfAddress
save
=
repository
.
save
(
address
);
user
.
setAddress
(
address
);
userRepository
.
save
(
user
);
System
.
out
.
println
(
"address2:"
+
save
);
return
new
Result
<>(
ResultCodeEnum
.
SUCCESS
.
getDesc
());
return
new
Result
(
save
);
}
...
...
src/main/java/com/example/afrishop_v3/controllers/AuthController.java
浏览文件 @
fc316131
...
...
@@ -320,21 +320,18 @@ public class AuthController extends Controller {
return
"Password is Empty"
;
}
if
(!
isPasswordValid
(
password
))
{
String
string
=
"Password is not strong"
;
if
(!
isPasswordValidDigit
(
password
))
{
string
+=
", a digit must occur at least once"
;
}
// if (!isPasswordValidDigit(password)) {
// string += ", a digit must occur at least once";
// }
//
// if (!isPasswordValidUpperCase(password)) {
// string += ", an upper case letter must occur at least once";
// }
if
(!
isPasswordValidUpperCase
(
password
))
{
string
+=
", an upper case letter must occur at least once"
;
}
if
(!
isPasswordValidLength
(
password
))
{
String
string
=
"Password is not strong, at least eight characters though"
;
if
(!
isPasswordValidLength
(
password
))
{
string
+=
", at least eight characters though"
;
}
return
string
;
}
...
...
src/main/java/com/example/afrishop_v3/controllers/FlutterWaveController.java
浏览文件 @
fc316131
...
...
@@ -81,7 +81,7 @@ public class FlutterWaveController extends Controller {
public
ResponseEntity
<
String
>
payForOrderByCard
(
@RequestParam
(
"orderId"
)
String
orderId
,
@RequestBody
FlutterWaveCard
flutterWaveCard
)
{
RaveConstant
.
PUBLIC_KEY
=
PUBLIC_KEY
;
RaveConstant
.
SECRET_KEY
=
SECRET_KEY
;
RaveConstant
.
ENVIRONMENT
=
Environment
.
STAGING
;
//or live
RaveConstant
.
ENVIRONMENT
=
Environment
.
LIVE
;
//or live
// Result result = new Result();
Optional
<
TbCfOrder
>
byId
=
repository
.
findById
(
orderId
);
...
...
src/main/java/com/example/afrishop_v3/controllers/ItemController.java
浏览文件 @
fc316131
...
...
@@ -4,6 +4,7 @@ import com.example.afrishop_v3.base.Result;
import
com.example.afrishop_v3.enums.ResultCodeEnum
;
import
com.example.afrishop_v3.models.*
;
import
com.example.afrishop_v3.repository.*
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.data.domain.Page
;
...
...
@@ -29,9 +30,10 @@ public class ItemController {
private
final
TbCfItemCollectionRepository
collectionRepository
;
private
final
TbCfItemParamRepository
itemParamRepository
;
private
final
TbCfRecommendRepository
recommendRepository
;
private
final
TbCfItemCommentRepository
commentRepository
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ItemController
.
class
);
public
ItemController
(
TbCfStationItemRepository
repository
,
TbCfGoodstwotypeRepository
goodstwotypeRepository
,
TbCfGoodstypeRepository
goodstypeRepository
,
TbCfDescripitonRepository
descriptionRepository
,
TbCfCategoryRepository
categoryRepository
,
TbCfItemSkuRepository
skuRepository
,
TbCfItemDescRepository
descRepository
,
TbCfItemCollectionRepository
collectionRepository
,
TbCfItemParamRepository
itemParamRepository
,
TbCfRecommendRepository
recommendRepository
)
{
public
ItemController
(
TbCfStationItemRepository
repository
,
TbCfGoodstwotypeRepository
goodstwotypeRepository
,
TbCfGoodstypeRepository
goodstypeRepository
,
TbCfDescripitonRepository
descriptionRepository
,
TbCfCategoryRepository
categoryRepository
,
TbCfItemSkuRepository
skuRepository
,
TbCfItemDescRepository
descRepository
,
TbCfItemCollectionRepository
collectionRepository
,
TbCfItemParamRepository
itemParamRepository
,
TbCfRecommendRepository
recommendRepository
,
TbCfItemCommentRepository
commentRepository
)
{
this
.
repository
=
repository
;
this
.
goodstwotypeRepository
=
goodstwotypeRepository
;
this
.
goodstypeRepository
=
goodstypeRepository
;
...
...
@@ -42,6 +44,7 @@ public class ItemController {
this
.
collectionRepository
=
collectionRepository
;
this
.
itemParamRepository
=
itemParamRepository
;
this
.
recommendRepository
=
recommendRepository
;
this
.
commentRepository
=
commentRepository
;
}
@GetMapping
(
"/queryAll"
)
...
...
@@ -129,7 +132,7 @@ public class ItemController {
Page
<
TbCfStationItem
>
recommendItems
=
repository
.
getRecommendItems
(
itemId
,
stationItem
.
getItemDescritionId
(),
stationItem
.
getItemCategorytwo
(),
stationItem
.
getItemCategory
(),
PageRequest
.
of
(
pageNum
,
pageSize
));
return
new
Result
<>(
recommendItems
);
}
else
logger
.
warn
(
"Recommended item not found"
);
}
else
logger
.
warn
(
"Recommended item not found"
);
return
new
Result
<>(
new
ArrayList
<>(),
ResultCodeEnum
.
ILLEGAL_ARGUMENT
.
getCode
(),
"Item id is invalid or not found"
);
}
...
...
@@ -216,4 +219,31 @@ public class ItemController {
return
new
Result
<>(
map
);
}
@GetMapping
(
"/queryItemComments"
)
public
Result
queryItemLastComment
(
@RequestParam
(
"itemId"
)
String
itemId
,
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"0"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"6"
)
Integer
pageSize
,
@RequestParam
(
value
=
"limit"
,
required
=
false
)
Integer
limit
)
{
Result
result
=
new
Result
();
if
(
StringUtils
.
isBlank
(
itemId
))
{
result
.
setCode
(
ResultCodeEnum
.
VALIDATE_ERROR
.
getCode
());
result
.
setMessage
(
"The itemId parameter cannot be empty"
);
return
result
;
}
// try {
Page
<
TbCfItemComment
>
allByItemId
=
commentRepository
.
findAllByItemId
(
itemId
,
PageRequest
.
of
(
pageNum
,
pageSize
,
Sort
.
by
(
Sort
.
Order
.
desc
(
"createTime"
))));
List
<
TbCfItemComment
>
comments
=
allByItemId
.
toList
();
if
(
limit
!=
null
)
comments
.
stream
().
limit
(
limit
);
result
.
setData
(
comments
);
// } catch (Exception e) {
// result.setCode(ResultCodeEnum.SERVICE_ERROR.getCode());
// result.setMessage(ResultCodeEnum.SERVICE_ERROR.getDesc());
// }
return
result
;
}
}
src/main/java/com/example/afrishop_v3/models/TbCfItemCollection.java
浏览文件 @
fc316131
package
com
.
example
.
afrishop_v3
.
models
;
import
lombok.Data
;
import
org.hibernate.annotations.NotFound
;
import
org.hibernate.annotations.NotFoundAction
;
import
javax.persistence.Entity
;
import
javax.persistence.Id
;
...
...
@@ -35,13 +37,14 @@ public class TbCfItemCollection {
@ManyToOne
@JoinColumn
(
columnDefinition
=
"item_id"
,
name
=
"item_id"
)
@NotFound
(
action
=
NotFoundAction
.
IGNORE
)
private
TbCfStationItem
item
;
/**
* 删除
*/
private
Integer
delFlag
;
/**
* 创建时间
* 创建时间
*/
private
Date
createTime
;
/**
...
...
@@ -106,14 +109,14 @@ public class TbCfItemCollection {
return
delFlag
;
}
/**
* 设置:创建时间
* 设置:创建时间
*/
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
/**
* 获取:创建时间
* 获取:创建时间
*/
public
Date
getCreateTime
()
{
return
createTime
;
...
...
src/main/java/com/example/afrishop_v3/models/TbCfItemComment.java
浏览文件 @
fc316131
...
...
@@ -2,8 +2,12 @@ package com.example.afrishop_v3.models;
import
com.fasterxml.jackson.annotation.JsonIgnore
;
import
lombok.Data
;
import
org.apache.commons.lang3.StringUtils
;
import
org.hibernate.annotations.Formula
;
import
org.hibernate.annotations.NotFound
;
import
org.hibernate.annotations.NotFoundAction
;
import
javax.annotation.Nullable
;
import
javax.persistence.*
;
import
java.io.Serializable
;
import
java.util.Date
;
...
...
@@ -30,6 +34,7 @@ public class TbCfItemComment{
@ManyToOne
@JsonIgnore
@JoinColumn
(
columnDefinition
=
"user_id"
,
name
=
"user_id"
)
@NotFound
(
action
=
NotFoundAction
.
IGNORE
)
private
TbCfUserInfo
user
;
/**
* 订单ID
...
...
@@ -79,6 +84,9 @@ public class TbCfItemComment{
* 创建时间
*/
private
Date
createTime
;
// @Transient
private
Integer
real
;
/**
* 更新时间
*/
...
...
@@ -347,4 +355,6 @@ public class TbCfItemComment{
public
Date
getUpdateTime
()
{
return
updateTime
;
}
}
src/main/java/com/example/afrishop_v3/repository/TbCfAddressRepository.java
浏览文件 @
fc316131
...
...
@@ -15,8 +15,8 @@ public interface TbCfAddressRepository extends PagingAndSortingRepository<TbCfAd
@Transactional
@Modifying
@Query
(
value
=
"update tb_cf_address set default_flag=0 where user_id=:user_id"
,
nativeQuery
=
true
)
void
resetToDefault
(
@Param
(
"user_id"
)
String
userI
d
);
@Query
(
value
=
"update tb_cf_address set default_flag=0 where user_id=:user_id
and address_id!=:address_id
"
,
nativeQuery
=
true
)
void
resetToDefault
AndAddressIdIsNot
(
@Param
(
"user_id"
)
String
userId
,
@Param
(
"address_id"
)
String
address_i
d
);
boolean
existsByAddressDetailAndUserId
(
String
addressDetail
,
String
userId
);
...
...
src/main/java/com/example/afrishop_v3/repository/TbCfItemCommentRepository.java
浏览文件 @
fc316131
...
...
@@ -9,9 +9,15 @@ import org.springframework.data.jpa.repository.Query;
import
org.springframework.data.repository.PagingAndSortingRepository
;
import
org.springframework.data.repository.query.Param
;
public
interface
TbCfItemCommentRepository
extends
PagingAndSortingRepository
<
TbCfItemComment
,
String
>
{
import
java.util.List
;
public
interface
TbCfItemCommentRepository
extends
PagingAndSortingRepository
<
TbCfItemComment
,
String
>
{
boolean
existsByUserUserIdAndItemId
(
String
userId
,
String
itemId
);
Page
<
TbCfItemComment
>
findAllByItemId
(
String
itemId
,
Pageable
pageable
);
@Query
(
"select a as itemComment, count(x) as commented from #{#entityName} a left join TbCfItemLike x on a=x.comment and x.user=:user where a.itemId=:itemId group by a"
)
Page
<
CommentCount
>
findAllByItemIdAndUser
(
@Param
(
"itemId"
)
String
itemId
,
@Param
(
"user"
)
TbCfUserInfo
user
,
Pageable
pageable
);
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论