Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gogirl-miniapp-backend
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
huluobin
gogirl-miniapp-backend
Commits
df78ccbc
Commit
df78ccbc
authored
Mar 27, 2020
by
huluobin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
色系
parent
f59368fb
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
127 additions
and
15 deletions
+127
-15
CustomerService.java
...com/gogirl/application/user/customer/CustomerService.java
+8
-0
CustomerServiceImpl.java
...l/application/user/customer/impl/CustomerServiceImpl.java
+24
-11
BASE64DecodedMultipartFile.java
...ogirl/infrastructure/util/BASE64DecodedMultipartFile.java
+77
-0
CustomerController.java
...n/java/com/gogirl/interfaces/user/CustomerController.java
+8
-4
XcxController.java
src/main/java/com/gogirl/interfaces/xcx/XcxController.java
+10
-0
No files found.
src/main/java/com/gogirl/application/user/customer/CustomerService.java
View file @
df78ccbc
...
...
@@ -111,4 +111,12 @@ public interface CustomerService extends IService<Customer> {
* @return
*/
List
<
String
>
getAgeGroups
();
/**
* h5用户根据订单Id登录
*
* @param orderId
* @return
*/
String
h5Login
(
Integer
orderId
);
}
src/main/java/com/gogirl/application/user/customer/impl/CustomerServiceImpl.java
View file @
df78ccbc
...
...
@@ -405,17 +405,30 @@ public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer> i
return
Lists
.
newArrayList
(
ageGroups
);
}
// //todo 替换成hashcode
// //字符串中所有字符相加得到一个int
// private int openid1GetInt(String openid1) {
// StringBuilder sb = new StringBuilder(openid1);
// int sum = 0;
// int length = sb.length();
// for (int i = 20; i < length; i++) {
// sum += sb.charAt(i);
// }
// return sum;
// }
@Override
public
String
h5Login
(
Integer
orderId
)
{
OrderManage
orderManage
=
orderManageMapper
.
selectById
(
orderId
);
if
(
orderManage
==
null
)
{
throw
new
RRException
(
"订单不存在"
);
}
Customer
customer
=
customerMapper
.
selectById
(
orderManage
.
getOrderUser
());
if
(
customer
==
null
)
{
throw
new
RRException
(
"订单用户不存在"
);
}
String
token
=
customer
.
getId
()
+
"_"
+
IdWorker
.
getIdStr
().
substring
(
6
);
GogirlToken
gogirlToken
=
GogirlToken
.
builder
()
.
customerId
(
customer
.
getId
())
.
openid
(
customer
.
getOpenid1
())
.
createTime
(
new
Date
())
.
token
(
token
)
.
sysId
(
1
)
.
phone
(
customer
.
getPhone
())
.
build
();
gogirlTokenService
.
save
(
gogirlToken
);
return
token
;
}
/**
* 将emoji表情替换成空串
...
...
src/main/java/com/gogirl/infrastructure/util/BASE64DecodedMultipartFile.java
0 → 100644
View file @
df78ccbc
package
com
.
gogirl
.
infrastructure
.
util
;
import
org.springframework.web.multipart.MultipartFile
;
import
sun.misc.BASE64Decoder
;
import
java.io.*
;
public
class
BASE64DecodedMultipartFile
implements
MultipartFile
{
private
final
byte
[]
imgContent
;
private
final
String
header
;
public
BASE64DecodedMultipartFile
(
byte
[]
imgContent
,
String
header
)
{
this
.
imgContent
=
imgContent
;
this
.
header
=
header
.
split
(
";"
)[
0
];
}
@Override
public
String
getName
()
{
return
System
.
currentTimeMillis
()
+
Math
.
random
()
+
"."
+
header
.
split
(
"/"
)[
1
];
}
@Override
public
String
getOriginalFilename
()
{
return
System
.
currentTimeMillis
()
+
(
int
)
Math
.
random
()
*
10000
+
"."
+
header
.
split
(
"/"
)[
1
];
}
@Override
public
String
getContentType
()
{
return
header
.
split
(
":"
)[
1
];
}
@Override
public
boolean
isEmpty
()
{
return
imgContent
==
null
||
imgContent
.
length
==
0
;
}
@Override
public
long
getSize
()
{
return
imgContent
.
length
;
}
@Override
public
byte
[]
getBytes
()
throws
IOException
{
return
imgContent
;
}
@Override
public
InputStream
getInputStream
()
throws
IOException
{
return
new
ByteArrayInputStream
(
imgContent
);
}
@Override
public
void
transferTo
(
File
dest
)
throws
IOException
,
IllegalStateException
{
new
FileOutputStream
(
dest
).
write
(
imgContent
);
}
public
static
MultipartFile
base64ToMultipart
(
String
base64
)
{
try
{
String
[]
baseStrs
=
base64
.
split
(
","
);
BASE64Decoder
decoder
=
new
BASE64Decoder
();
byte
[]
b
=
new
byte
[
0
];
b
=
decoder
.
decodeBuffer
(
baseStrs
[
1
]);
for
(
int
i
=
0
;
i
<
b
.
length
;
++
i
)
{
if
(
b
[
i
]
<
0
)
{
b
[
i
]
+=
256
;
}
}
return
new
BASE64DecodedMultipartFile
(
b
,
baseStrs
[
0
]);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
}
src/main/java/com/gogirl/interfaces/user/CustomerController.java
View file @
df78ccbc
...
...
@@ -7,10 +7,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestHeader
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RestController
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.List
;
...
...
@@ -58,4 +55,11 @@ public class CustomerController {
customerService
.
updateCustomerDetail
(
birthdayMonth
,
birthdayDay
,
ageGroup
,
customerId
,
orderId
,
orderServeId
,
storeRecordRealName
,
sex
,
age
,
job
,
preference
,
character
,
customerSource
);
return
JsonResult
.
success
();
}
@ApiOperation
(
value
=
"h5用户登录"
)
@GetMapping
(
"/customer/no_h5Login"
)
public
JsonResult
<
String
>
h5Login
(
@RequestParam
Integer
orderId
)
{
String
token
=
customerService
.
h5Login
(
orderId
);
return
JsonResult
.
success
(
token
);
}
}
src/main/java/com/gogirl/interfaces/xcx/XcxController.java
View file @
df78ccbc
...
...
@@ -9,6 +9,7 @@ import com.gogirl.domain.user.customer.Customer;
import
com.gogirl.infrastructure.common.base.JsonResult
;
import
com.gogirl.infrastructure.config.property.GogirlProperties
;
import
com.gogirl.infrastructure.mapper.user.customer.CustomerMapper
;
import
com.gogirl.infrastructure.util.BASE64DecodedMultipartFile
;
import
com.gogirl.infrastructure.util.ImageUtil
;
import
com.gogirl.shared.user.query.qry.CustomerQuery
;
import
io.swagger.annotations.Api
;
...
...
@@ -98,6 +99,15 @@ public class XcxController {
return
JsonResult
.
success
(
imgUrl
);
}
@ApiOperation
(
value
=
"base64图片上传"
)
@PostMapping
(
"/customer/xcx/no_base64Upload"
)
public
JsonResult
<
String
>
base64Upload
(
@RequestBody
String
base64
)
throws
Exception
{
log
.
info
(
"图片上传"
);
MultipartFile
multipartFile
=
BASE64DecodedMultipartFile
.
base64ToMultipart
(
base64
);
String
imgUrl
=
ImageUtil
.
saveImage
(
gogirlProperties
.
getPicturePath
(),
multipartFile
);
return
JsonResult
.
success
(
imgUrl
);
}
@ApiOperation
(
value
=
"美甲师根据code获取token"
)
@GetMapping
(
value
=
"/technician/xcx/login_t"
)
public
JsonResult
<
String
>
technicianLogin
(
@RequestParam
String
code
)
{
...
...
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