Commit df78ccbc by huluobin

色系

parent f59368fb
......@@ -111,4 +111,12 @@ public interface CustomerService extends IService<Customer> {
* @return
*/
List<String> getAgeGroups();
/**
* h5用户根据订单Id登录
*
* @param orderId
* @return
*/
String h5Login(Integer orderId);
}
......@@ -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表情替换成空串
......
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;
}
}
}
......@@ -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);
}
}
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment