dcs il y a 1 mois
Parent
commit
b32099b0b9

+ 1 - 9
virgo.core/src/main/java/com/bosshand/virgo/core/controller/CustomerController.java

@@ -51,7 +51,7 @@ public class CustomerController {
         return Response.ok();
     }
 
-    @ApiOperation("指定用户为客服")
+    @ApiOperation("更新")
     @RequestMapping(value = "", method = RequestMethod.PUT)
     public Response update(@RequestBody Customer customer) {
         Customer c = customerService.getOrganizationId(customer.getOrganizationId(), customer.getUserId());
@@ -62,14 +62,6 @@ public class CustomerController {
         return Response.ok();
     }
 
-    @ApiOperation("更新名称或头像")
-    @RequestMapping(value = "/update", method = RequestMethod.PUT)
-    public Response updateInfo(@RequestBody Customer customer) {
-        customerService.updateInfo(customer);
-        return Response.ok();
-    }
-
-
     @ApiOperation("详情")
     @RequestMapping(value = "/{id}", method = RequestMethod.GET)
     public Response get(@PathVariable long id) {

+ 1 - 1
virgo.core/src/main/java/com/bosshand/virgo/core/dao/CustomerDao.java

@@ -23,6 +23,6 @@ public interface CustomerDao {
 
     Customer get(long id);
 
-    List<Customer> getOrganizationId(long organizationId, long userId);
+    Customer getOrganizationId(long organizationId, long userId);
 
 }

+ 12 - 12
virgo.core/src/main/java/com/bosshand/virgo/core/service/CustomerService.java

@@ -55,6 +55,18 @@ public class CustomerService {
      * 指定用户为客服
      */
     public int update(Customer customer) {
+        Customer c = customerDao.get(customer.getId());
+        JSONObject js = new JSONObject();
+        if (customer.getNickName() != null) {
+            js.put("nickname", customer.getNickName());
+        }
+        if (customer.getAvatarUrl() != null) {
+            js.put("avatarUrl", customer.getAvatarUrl());
+        }
+        if (js.size() != 0) {
+            String str = WeChatUtil.httpPost("https://www.waywish.com/im/user/update", js, getToken(c.getCustomerId()));
+            log.info("updateCustomerChatUser=" + str);
+        }
         return customerDao.update(customer);
     }
 
@@ -102,16 +114,4 @@ public class CustomerService {
         return customerDao.getOrganizationId(organizationId, userId);
     }
 
-    @Transactional
-    public int updateInfo(Customer customer) {
-        Customer c = customerDao.get(customer.getId());
-        String token = getToken(c.getCustomerId());
-        JSONObject js = new JSONObject();
-        js.put("nickname", customer.getNickName());
-        js.put("avatarUrl", customer.getAvatarUrl());
-        String str = WeChatUtil.httpPost("https://www.waywish.com/im/user/update", js, token);
-        log.info("updateCustomerChatUser=" + str);
-        return customerDao.update(customer);
-    }
-
 }