Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
head_group
xyqb-user2
Commits
803d5ac4
Commit
803d5ac4
authored
Feb 14, 2017
by
zhouqian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加修改接口
parent
b2b93a1d
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
184 additions
and
7 deletions
+184
-7
InnerController.java
...tgroup/xyqb/controller/external/user/InnerController.java
+77
-6
Address.java
src/main/java/cn/quantgroup/xyqb/entity/Address.java
+1
-1
AddressRet.java
src/main/java/cn/quantgroup/xyqb/model/AddressRet.java
+43
-0
ContactRet.java
src/main/java/cn/quantgroup/xyqb/model/ContactRet.java
+54
-0
IContactService.java
...java/cn/quantgroup/xyqb/service/user/IContactService.java
+2
-0
ContactServiceImpl.java
...quantgroup/xyqb/service/user/impl/ContactServiceImpl.java
+7
-0
No files found.
src/main/java/cn/quantgroup/xyqb/controller/external/user/InnerController.java
View file @
803d5ac4
package
cn
.
quantgroup
.
xyqb
.
controller
.
external
.
user
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserDetail
;
import
cn.quantgroup.xyqb.entity.UserExtInfo
;
import
cn.quantgroup.xyqb.entity.*
;
import
cn.quantgroup.xyqb.entity.enumerate.*
;
import
cn.quantgroup.xyqb.model.*
;
import
cn.quantgroup.xyqb.service.auth.IIdCardService
;
import
cn.quantgroup.xyqb.service.user.IUserDetailService
;
import
cn.quantgroup.xyqb.service.user.IUserExtInfoService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.service.user.*
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.TypeReference
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.sql.Timestamp
;
...
...
@@ -36,6 +36,10 @@ public class InnerController {
private
IIdCardService
idCardService
;
@Autowired
private
IUserExtInfoService
userExtInfoService
;
@Autowired
private
IContactService
contactService
;
@Autowired
private
IAddressService
addressService
;
@RequestMapping
(
"/user/search/phoneNo"
)
...
...
@@ -190,6 +194,73 @@ public class InnerController {
return
JsonResult
.
buildSuccessResult
(
null
,
null
);
}
@RequestMapping
(
"/contact/search/user_id"
)
public
JsonResult
findContactsByUserId
(
Long
userId
)
{
if
(
null
==
userId
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
contacts
=
contactService
.
findByUserId
(
userId
);
return
JsonResult
.
buildErrorStateResult
(
null
,
ContactRet
.
contacts2ContactRets
(
contacts
));
}
@RequestMapping
(
"/contact/save/contacts"
)
public
JsonResult
save2Contact
(
Long
userId
,
@RequestParam
(
value
=
"contacts"
)
String
contactsStr
)
{
if
(
StringUtils
.
isEmpty
(
contactsStr
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
if
(
userId
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
List
<
Contact
>
contacts
=
JSONObject
.
parseObject
(
contactsStr
,
new
TypeReference
<
List
<
Contact
>>()
{});
if
(
CollectionUtils
.
isEmpty
(
contacts
))
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
for
(
Contact
c
:
contacts
)
{
c
.
setId
(
null
);
c
.
setUserId
(
userId
);
c
.
setCreatedAt
(
now
);
c
.
setUpdateAt
(
now
);
}
List
<
Contact
>
result
=
contactService
.
save
(
contacts
);
return
JsonResult
.
buildSuccessResult
(
null
,
ContactRet
.
contacts2ContactRets
(
result
));
}
@RequestMapping
(
"/address/search/user_id"
)
public
JsonResult
findAddressByUserId
(
Long
userId
)
{
if
(
userId
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Address
address
=
addressService
.
findByUserId
(
userId
);
if
(
address
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
return
JsonResult
.
buildSuccessResult
(
null
,
AddressRet
.
address2AddressRet
(
address
));
}
@RequestMapping
(
"/address/save"
)
public
JsonResult
saveAddress
(
Long
userId
,
Long
provinceCode
,
Long
cityCode
,
String
city
,
Long
districtCode
,
String
district
,
String
address
,
String
province
)
{
if
(
userId
==
null
||
provinceCode
==
null
||
cityCode
==
null
)
{
return
JsonResult
.
buildErrorStateResult
(
null
,
null
);
}
Timestamp
now
=
new
Timestamp
(
System
.
currentTimeMillis
());
Address
addressObj
=
new
Address
();
addressObj
.
setUserId
(
userId
);
addressObj
.
setProvinceCode
(
provinceCode
);
addressObj
.
setCityCode
(
cityCode
);
addressObj
.
setCity
(
city
);
addressObj
.
setDistrictCode
(
districtCode
);
addressObj
.
setDistrict
(
district
);
addressObj
.
setAddress
(
address
);
addressObj
.
setProvince
(
province
);
addressObj
.
setCreatedAt
(
now
);
addressObj
.
setUpdateAt
(
now
);
return
JsonResult
.
buildSuccessResult
(
null
,
AddressRet
.
address2AddressRet
(
addressObj
));
}
@RequestMapping
(
"/user_ext_info/update"
)
public
JsonResult
updateMarryStatus
(
Long
userId
,
IncomeEnum
incomeEnum
,
IncomeRangeEnum
incomeRangeEnum
,
...
...
src/main/java/cn/quantgroup/xyqb/entity/Address.java
View file @
803d5ac4
...
...
@@ -32,7 +32,7 @@ public class Address implements Serializable{
@Column
(
name
=
"city"
)
private
String
city
;
@Column
(
name
=
"districtCode"
)
private
Long
district
_c
ode
;
private
Long
district
C
ode
;
@Column
(
name
=
"district"
)
private
String
district
;
@Column
(
name
=
"address"
)
...
...
src/main/java/cn/quantgroup/xyqb/model/AddressRet.java
0 → 100644
View file @
803d5ac4
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.Address
;
import
lombok.Data
;
/**
* Created by Miraculous on 2017/2/14.
*/
@Data
public
class
AddressRet
{
private
static
final
long
serialVersionUID
=
-
1L
;
private
Long
id
;
private
Long
userId
;
private
Long
provinceCode
;
private
String
province
;
private
Long
cityCode
;
private
String
city
;
private
Long
districtCode
;
private
String
district
;
private
String
address
;
private
Long
createdAt
;
private
Long
updateAt
;
public
static
AddressRet
address2AddressRet
(
Address
address
)
{
if
(
address
==
null
)
{
return
null
;
}
AddressRet
ret
=
new
AddressRet
();
ret
.
setId
(
address
.
getId
());
ret
.
setUserId
(
address
.
getUserId
());
ret
.
setProvinceCode
(
address
.
getProvinceCode
());
ret
.
setCityCode
(
address
.
getCityCode
());
ret
.
setDistrictCode
(
address
.
getDistrictCode
());
ret
.
setDistrict
(
address
.
getDistrict
());
ret
.
setProvince
(
address
.
getProvince
());
ret
.
setCity
(
address
.
getCity
());
ret
.
setAddress
(
address
.
getAddress
());
ret
.
setCreatedAt
(
address
.
getCreatedAt
().
getTime
());
ret
.
setUpdateAt
(
address
.
getUpdateAt
().
getTime
());
return
ret
;
}
}
src/main/java/cn/quantgroup/xyqb/model/ContactRet.java
0 → 100644
View file @
803d5ac4
package
cn
.
quantgroup
.
xyqb
.
model
;
import
cn.quantgroup.xyqb.entity.Contact
;
import
cn.quantgroup.xyqb.entity.enumerate.Relation
;
import
lombok.Data
;
import
org.apache.commons.collections.CollectionUtils
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.List
;
/**
* Created by Miraculous on 2017/2/14.
*/
@Data
public
class
ContactRet
implements
Serializable
{
private
static
final
long
serialVersionUID
=
-
1L
;
private
Long
id
;
private
Long
userId
;
private
String
name
;
private
String
phoneNo
;
private
Relation
relation
;
private
Long
createdAt
;
private
Long
updateAt
;
public
static
ContactRet
contact2ContactRet
(
Contact
c
)
{
if
(
c
==
null
)
{
return
null
;
}
ContactRet
ret
=
new
ContactRet
();
ret
.
setId
(
c
.
getId
());
ret
.
setUserId
(
c
.
getUserId
());
ret
.
setName
(
c
.
getName
());
ret
.
setPhoneNo
(
c
.
getPhoneNo
());
ret
.
setRelation
(
c
.
getRelation
());
ret
.
setCreatedAt
(
c
.
getCreatedAt
().
getTime
());
ret
.
setUpdateAt
(
c
.
getUpdateAt
().
getTime
());
return
ret
;
}
public
static
List
<
ContactRet
>
contacts2ContactRets
(
List
<
Contact
>
cs
)
{
if
(
CollectionUtils
.
isEmpty
(
cs
))
{
return
Collections
.
emptyList
();
}
List
<
ContactRet
>
contactRets
=
new
ArrayList
<>();
for
(
Contact
c
:
cs
)
{
contactRets
.
add
(
contact2ContactRet
(
c
));
}
return
contactRets
;
}
}
src/main/java/cn/quantgroup/xyqb/service/user/IContactService.java
View file @
803d5ac4
...
...
@@ -9,4 +9,6 @@ import java.util.List;
*/
public
interface
IContactService
{
List
<
Contact
>
findByUserId
(
Long
userId
);
List
<
Contact
>
save
(
List
<
Contact
>
contacts
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/ContactServiceImpl.java
View file @
803d5ac4
...
...
@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.entity.Contact;
import
cn.quantgroup.xyqb.repository.IContactRepository
;
import
cn.quantgroup.xyqb.service.user.IContactService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.stereotype.Service
;
...
...
@@ -24,5 +25,11 @@ public class ContactServiceImpl implements IContactService {
return
contactRepository
.
findByUserId
(
userId
);
}
@Override
@CacheEvict
(
value
=
"contact"
,
key
=
"'contact' + #contacts.get(0).userId"
,
cacheManager
=
"cacheManager"
)
public
List
<
Contact
>
save
(
List
<
Contact
>
contacts
)
{
return
contactRepository
.
save
(
contacts
);
}
}
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