增加添加和获取联系人接口,AesAttributeConverter中autoApply = false取消全局加密
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package com.onekeycall.videotablet.controller;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.onekeycall.videotablet.entity.Contact;
|
||||
import com.onekeycall.videotablet.entity.DeviceInfo;
|
||||
import com.onekeycall.videotablet.entity.User;
|
||||
import com.onekeycall.videotablet.result.Result;
|
||||
import com.onekeycall.videotablet.service.ContactService;
|
||||
import com.onekeycall.videotablet.service.DeviceSnService;
|
||||
import com.onekeycall.videotablet.service.UserService;
|
||||
import com.onekeycall.videotablet.utils.JwtUtil;
|
||||
@@ -13,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/contact")
|
||||
@@ -23,6 +27,8 @@ public class ContactController {
|
||||
private UserService userService;
|
||||
@Autowired
|
||||
private DeviceSnService deviceSnService;
|
||||
@Autowired
|
||||
private ContactService contactService;
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
@@ -33,7 +39,9 @@ public class ContactController {
|
||||
public Result userAddContact(
|
||||
@RequestHeader("Authorization") String authHeader, @RequestHeader("Device-ID") String deviceId,
|
||||
@RequestParam(value = "user_id") String userId, @RequestParam(value = "sn") String sn,
|
||||
@Valid @RequestBody Contact contact) {
|
||||
@RequestPart(value = "file", required = false) MultipartFile file,
|
||||
@RequestPart("contact_json") String jsonData
|
||||
) throws JsonProcessingException {
|
||||
|
||||
if (!authHeader.startsWith("Bearer ")) {
|
||||
return Result.error().message("Invalid Authorization header");
|
||||
@@ -57,6 +65,17 @@ public class ContactController {
|
||||
return Result.error().message("device not belong to user");
|
||||
}
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
Contact contact = mapper.readValue(jsonData, Contact.class);
|
||||
|
||||
if (contactService.isExistByPhoneNumberAndSn(contact.getPhoneNumber(), sn)) {
|
||||
return Result.error().message("contact already exist");
|
||||
}
|
||||
|
||||
contact.setUserId(userId);
|
||||
contact.setSn(sn);
|
||||
contactService.save(contact);
|
||||
|
||||
return Result.ok();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user