Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
dingding
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
dingding
Commits
b82f4903
提交
b82f4903
authored
3月 22, 2020
作者:
liupengfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
开发版 v0.0.1已完成
上级
547107b4
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
275 行增加
和
9 行删除
+275
-9
CustomerController.java
...main/java/com/controller/customer/CustomerController.java
+17
-2
UserController.java
src/main/java/com/controller/dingding/UserController.java
+1
-1
CustomerHasBusinessEnum.java
...main/java/com/enums/customer/CustomerHasBusinessEnum.java
+83
-0
CustomerSigningEnum.java
src/main/java/com/enums/customer/CustomerSigningEnum.java
+82
-0
QueryCustomerForm.java
src/main/java/com/form/customer/QueryCustomerForm.java
+1
-1
Customer.java
src/main/java/com/model/customer/Customer.java
+4
-1
CustomerService.java
src/main/java/com/service/customer/CustomerService.java
+2
-1
CustomerServiceImpl.java
src/main/java/com/service/customer/CustomerServiceImpl.java
+13
-3
PageInfo.java
src/main/java/com/util/PageInfo.java
+55
-0
CustomerVo.java
src/main/java/com/vo/customer/CustomerVo.java
+17
-0
没有找到文件。
src/main/java/com/controller/customer/CustomerController.java
浏览文件 @
b82f4903
...
...
@@ -8,12 +8,14 @@ import org.springframework.web.bind.annotation.PostMapping;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
com.excetion.BaseException
;
import
com.form.customer.QueryCustomerForm
;
import
com.model.customer.Customer
;
import
com.service.customer.CustomerService
;
import
com.util.CallBack
;
import
com.util.PageInfo
;
import
com.util.PageParam
;
import
com.vo.customer.CustomerVo
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
...
...
@@ -30,13 +32,26 @@ public class CustomerController {
@PostMapping
(
"/save"
)
public
CallBack
<?>
save
(
Customer
entity
){
entity
.
setCreateTime
(
new
Date
());
service
.
insert
(
entity
);
if
(
entity
.
getId
()
!=
null
)
{
service
.
updateByPrimaryKey
(
entity
);
}
else
{
service
.
insert
(
entity
);
}
return
CallBack
.
success
();
}
@ApiOperation
(
value
=
"查询客户信息"
,
notes
=
"查询全部客户信息"
)
@GetMapping
(
"/page"
)
public
CallBack
<
PageInfo
<
Customer
>>
page
(
PageParam
pageParam
,
QueryCustomerForm
form
)
{
public
CallBack
<
PageInfo
<
Customer
Vo
>>
page
(
PageParam
pageParam
,
QueryCustomerForm
form
)
{
return
CallBack
.
success
(
service
.
page
(
pageParam
,
form
));
}
@ApiOperation
(
value
=
"根据客户id查询客户信息"
)
@GetMapping
(
"/get"
)
public
CallBack
<
Customer
>
get
(
Integer
id
)
{
if
(
id
==
null
)
{
throw
new
BaseException
(
"id不能为空"
);
}
return
CallBack
.
success
(
service
.
selectByPrimaryKey
(
id
));
}
}
src/main/java/com/controller/dingding/UserController.java
浏览文件 @
b82f4903
...
...
@@ -68,7 +68,7 @@ public class UserController {
if
(
response
.
isSuccess
())
{
SimpleUserListVo
vo
=
JSON
.
parseObject
(
response
.
getBody
(),
SimpleUserListVo
.
class
);
return
ServiceResult
.
success
(
vo
.
getUserlist
());
}
}
return
ServiceResult
.
failure
(
"-3"
,
response
.
getBody
());
}
}
src/main/java/com/enums/customer/CustomerHasBusinessEnum.java
0 → 100644
浏览文件 @
b82f4903
package
com
.
enums
.
customer
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Stream
;
public
enum
CustomerHasBusinessEnum
{
/** 未知 */
NONE
(
"-1"
,
"未知"
),
/** 是 */
YES
(
"1"
,
"有"
),
/** 否 */
NO
(
"0"
,
"无"
);
private
final
String
code
;
private
final
String
name
;
private
static
final
HashMap
<
String
,
String
>
MAP
=
new
HashMap
<
String
,
String
>();
static
{
stream
().
forEach
(
e
->
{
MAP
.
put
(
e
.
code
,
e
.
name
);
});
}
private
CustomerHasBusinessEnum
(
String
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
static
Map
<
String
,
String
>
getMap
(){
return
CustomerHasBusinessEnum
.
MAP
;
}
/**
* @return
* @author lpf
* @date: 2019年3月18日 下午5:05:16
*/
public
static
Stream
<
CustomerHasBusinessEnum
>
stream
(){
return
Stream
.
of
(
values
());
}
/**
* 判断名称是否有效
* @param name
* @return
* @author lpf
* @date: 2018年6月11日 下午6:30:16
*/
public
static
boolean
isExist
(
String
code
)
{
return
stream
().
anyMatch
(
e
->
e
.
code
.
equals
(
code
));
}
/**
* 根据code 获取名字
* @Title getName
* @param code
* @return String
* @author lpf
* @date 2019年3月18日17:14:18
*/
public
static
String
getName
(
String
code
)
{
return
stream
().
filter
(
e
->
e
.
code
.
equals
(
code
)).
findFirst
().
map
(
e
->
e
.
name
).
orElse
(
NONE
.
name
);
}
/**
* 根据名字 获取code
* @Title getCode
* @param name
* @return String
* @author lpf
* @date 2019年3月18日17:14:18
*/
public
static
String
getCode
(
String
name
)
{
return
stream
().
filter
(
e
->
e
.
name
.
equals
(
name
)).
findFirst
().
map
(
e
->
e
.
code
).
orElse
(
NONE
.
code
);
}
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
}
src/main/java/com/enums/customer/CustomerSigningEnum.java
0 → 100644
浏览文件 @
b82f4903
package
com
.
enums
.
customer
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.stream.Stream
;
public
enum
CustomerSigningEnum
{
/** 是 */
YES
(
"1"
,
"已签约"
),
/** 否 */
NO
(
"0"
,
"未签约"
);
private
final
String
code
;
private
final
String
name
;
private
static
final
HashMap
<
String
,
String
>
MAP
=
new
HashMap
<
String
,
String
>();
static
{
stream
().
forEach
(
e
->
{
MAP
.
put
(
e
.
code
,
e
.
name
);
});
}
private
CustomerSigningEnum
(
String
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
public
static
Map
<
String
,
String
>
getMap
(){
return
CustomerSigningEnum
.
MAP
;
}
/**
* @return
* @author lpf
* @date: 2019年3月18日 下午5:05:16
*/
public
static
Stream
<
CustomerSigningEnum
>
stream
(){
return
Stream
.
of
(
values
());
}
/**
* 判断名称是否有效
* @param name
* @return
* @author lpf
* @date: 2018年6月11日 下午6:30:16
*/
public
static
boolean
isExist
(
String
code
)
{
return
stream
().
anyMatch
(
e
->
e
.
code
.
equals
(
code
));
}
/**
* 根据code 获取名字
* @Title getName
* @param code
* @return String
* @author lpf
* @date 2019年3月18日17:14:18
*/
public
static
String
getName
(
String
code
)
{
return
stream
().
filter
(
e
->
e
.
code
.
equals
(
code
)).
findFirst
().
map
(
e
->
e
.
name
).
orElse
(
NO
.
name
);
}
/**
* 根据名字 获取code
* @Title getCode
* @param name
* @return String
* @author lpf
* @date 2019年3月18日17:14:18
*/
public
static
String
getCode
(
String
name
)
{
return
stream
().
filter
(
e
->
e
.
name
.
equals
(
name
)).
findFirst
().
map
(
e
->
e
.
code
).
orElse
(
NO
.
code
);
}
public
String
getCode
()
{
return
code
;
}
public
String
getName
()
{
return
name
;
}
}
src/main/java/com/form/customer/QueryCustomerForm.java
浏览文件 @
b82f4903
...
...
@@ -12,7 +12,7 @@ public class QueryCustomerForm {
private
String
text
;
@ApiModelProperty
(
"是否分配了负责人,0全部,1 未分配,2已分配"
)
private
String
hasUser
;
@ApiModelProperty
(
"商机,''全部 1 有, 0无"
)
@ApiModelProperty
(
"商机,''全部 1 有, 0无
,-1未知
"
)
private
String
hasBusiness
;
@ApiModelProperty
(
"中央级, ''全部 1 是 0 否"
)
private
String
central
;
...
...
src/main/java/com/model/customer/Customer.java
浏览文件 @
b82f4903
...
...
@@ -51,10 +51,13 @@ public class Customer {
private
String
updateName
;
@ApiModelProperty
(
"指派时间"
)
private
Date
allotTime
;
@ApiModelProperty
(
"商机,''全部 1 有, 0无"
)
/** @see com.enums.CustomerHasBusinessEnum */
@ApiModelProperty
(
"商机,''全部 1 有, 0无,-1未知"
)
private
String
hasBusiness
;
/** @see com.enums.BooleanStatusEnum */
@ApiModelProperty
(
"中央级, ''全部 1 是 0 否"
)
private
String
central
;
/** @see com.enums.CustomerSigningEnum */
@ApiModelProperty
(
"签约 '' 全部 1 是 0 否"
)
private
String
signing
;
}
src/main/java/com/service/customer/CustomerService.java
浏览文件 @
b82f4903
...
...
@@ -5,9 +5,10 @@ import com.model.customer.Customer;
import
com.service.BaseService
;
import
com.util.PageInfo
;
import
com.util.PageParam
;
import
com.vo.customer.CustomerVo
;
public
interface
CustomerService
extends
BaseService
<
Customer
,
Integer
>{
PageInfo
<
Customer
>
page
(
PageParam
pageParam
,
QueryCustomerForm
form
);
PageInfo
<
Customer
Vo
>
page
(
PageParam
pageParam
,
QueryCustomerForm
form
);
}
src/main/java/com/service/customer/CustomerServiceImpl.java
浏览文件 @
b82f4903
...
...
@@ -6,13 +6,18 @@ import org.apache.commons.lang3.StringUtils;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
com.enums.BooleanStatusEnum
;
import
com.enums.customer.CustomerHasBusinessEnum
;
import
com.enums.customer.CustomerSigningEnum
;
import
com.form.customer.QueryCustomerForm
;
import
com.mapper.BaseMapper
;
import
com.mapper.customer.CustomerMapper
;
import
com.model.customer.Customer
;
import
com.service.BaseServiceImpl
;
import
com.util.BeanUtils
;
import
com.util.PageInfo
;
import
com.util.PageParam
;
import
com.vo.customer.CustomerVo
;
@Service
public
class
CustomerServiceImpl
extends
BaseServiceImpl
<
Customer
,
Integer
>
implements
CustomerService
{
...
...
@@ -24,13 +29,18 @@ public class CustomerServiceImpl extends BaseServiceImpl<Customer, Integer> impl
return
this
.
mapper
;
}
@Override
public
PageInfo
<
Customer
>
page
(
PageParam
pageParam
,
QueryCustomerForm
form
)
{
if
(
StringUtils
.
is
Not
Blank
(
pageParam
.
getOrderBy
()))
{
public
PageInfo
<
Customer
Vo
>
page
(
PageParam
pageParam
,
QueryCustomerForm
form
)
{
if
(
StringUtils
.
isBlank
(
pageParam
.
getOrderBy
()))
{
pageParam
.
setOrderBy
(
" createTime desc "
);
}
startPage
(
pageParam
);
List
<
Customer
>
list
=
mapper
.
list
(
form
);
return
new
PageInfo
<>(
list
);
List
<
CustomerVo
>
result
=
BeanUtils
.
copyList
(
list
,
CustomerVo
.
class
,
(
r
,
t
)
->
{
t
.
setHasBusinessZh
(
CustomerHasBusinessEnum
.
getName
(
r
.
getHasBusiness
()));
t
.
setCentralZh
(
BooleanStatusEnum
.
getName
(
r
.
getCentral
()));
t
.
setSigningZh
(
CustomerSigningEnum
.
getName
(
r
.
getSigning
()));
});
return
new
PageInfo
<>(
list
,
result
);
}
...
...
src/main/java/com/util/PageInfo.java
浏览文件 @
b82f4903
...
...
@@ -3,6 +3,7 @@ package com.util;
import
java.io.Serializable
;
import
java.util.Collection
;
import
java.util.List
;
import
java.util.function.Consumer
;
import
com.github.pagehelper.Page
;
...
...
@@ -60,6 +61,60 @@ public class PageInfo<T> implements Serializable {
this
(
list
,
8
);
}
public
PageInfo
(
List
<?>
list
,
List
<
T
>
target
)
{
this
(
list
,
8
,
(
p
)
->
{
p
.
list
=
target
;
});
}
/**
* 包装Page对象
*
* @param list page结果
* @param navigatePages 页码数量
* @param con 最后执行 消费PageInfo 对象程序
*/
public
PageInfo
(
List
<?>
list
,
int
navigatePages
,
Consumer
<
PageInfo
<
T
>>
con
)
{
if
(
list
instanceof
Page
)
{
Page
page
=
(
Page
)
list
;
this
.
pageNum
=
page
.
getPageNum
();
this
.
pageSize
=
page
.
getPageSize
();
this
.
pages
=
page
.
getPages
();
this
.
list
=
page
;
this
.
size
=
page
.
size
();
this
.
total
=
page
.
getTotal
();
//由于结果是>startRow的,所以实际的需要+1
if
(
this
.
size
==
0
)
{
this
.
startRow
=
0
;
this
.
endRow
=
0
;
}
else
{
this
.
startRow
=
page
.
getStartRow
()
+
1
;
//计算实际的endRow(最后一页的时候特殊)
this
.
endRow
=
this
.
startRow
-
1
+
this
.
size
;
}
}
else
if
(
list
instanceof
Collection
)
{
this
.
pageNum
=
1
;
this
.
pageSize
=
list
.
size
();
this
.
pages
=
this
.
pageSize
>
0
?
1
:
0
;
this
.
size
=
list
.
size
();
this
.
total
=
list
.
size
();
this
.
startRow
=
0
;
this
.
endRow
=
list
.
size
()
>
0
?
list
.
size
()
-
1
:
0
;
}
if
(
list
instanceof
Collection
)
{
this
.
navigatePages
=
navigatePages
;
//计算导航页
calcNavigatepageNums
();
//计算前后页,第一页,最后一页
calcPage
();
//判断页面边界
judgePageBoudary
();
}
//
con
.
accept
(
this
);
}
/**
* 包装Page对象
*
...
...
src/main/java/com/vo/customer/CustomerVo.java
0 → 100644
浏览文件 @
b82f4903
package
com
.
vo
.
customer
;
import
com.model.customer.Customer
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
@Data
public
class
CustomerVo
extends
Customer
{
@ApiModelProperty
(
"商机,''全部 1 有, 0无,-1未知"
)
private
String
hasBusinessZh
;
@ApiModelProperty
(
"中央级, ''全部 1 是 0 否"
)
private
String
centralZh
;
@ApiModelProperty
(
"签约 '' 全部 1 是 0 否"
)
private
String
signingZh
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论