zjxpcyc 6 년 전
부모
커밋
8eb477500f

+ 9
- 0
whole-estate/src/main/java/com/example/wholeestate/controller/WxUserController.java 파일 보기

30
         return responseBean;
30
         return responseBean;
31
     }
31
     }
32
 
32
 
33
+    @RequestMapping(value = "/wx/user", method = RequestMethod.PUT)
34
+    @ApiOperation(value = "更新用户", notes = "更新用户")
35
+    @ApiImplicitParams({
36
+            @ApiImplicitParam(paramType = "body", dataTypeClass = String.class, name = "parameter", value = "customerId 用户ID;customerName用户姓名;name昵称;phone手机号;idNum证件号码;openid标记;uuid标记;avatar头像;")
37
+    })
38
+    public ResponseBean updateCustomer(@RequestBody String parameter) {
39
+        return iCustomerService.updateCustomer(parameter);
40
+    }
41
+
33
     @RequestMapping(value = "/wx/info/{openid}", method = RequestMethod.GET)
42
     @RequestMapping(value = "/wx/info/{openid}", method = RequestMethod.GET)
34
     @ApiOperation(value = "获取微信小程序用户信息", notes = "获取微信小程序用户信息")
43
     @ApiOperation(value = "获取微信小程序用户信息", notes = "获取微信小程序用户信息")
35
     @ApiImplicitParams({
44
     @ApiImplicitParams({

+ 2
- 0
whole-estate/src/main/java/com/example/wholeestate/service/ICustomerService.java 파일 보기

42
      */
42
      */
43
     ResponseBean getWXCustomer(String openid);
43
     ResponseBean getWXCustomer(String openid);
44
 
44
 
45
+
46
+    ResponseBean updateCustomer(String parameter);
45
 }
47
 }

+ 23
- 1
whole-estate/src/main/java/com/example/wholeestate/service/impl/CustomerServiceImpl.java 파일 보기

2
 
2
 
3
 import com.alibaba.fastjson.JSONObject;
3
 import com.alibaba.fastjson.JSONObject;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
5
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
8
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
 import com.example.wholeestate.common.uuid.IdGen;
11
 import com.example.wholeestate.common.uuid.IdGen;
11
 import com.example.wholeestate.dao.CustomerMapper;
12
 import com.example.wholeestate.dao.CustomerMapper;
12
 
13
 
13
-import com.example.wholeestate.model.Building;
14
 import com.example.wholeestate.model.Customer;
14
 import com.example.wholeestate.model.Customer;
15
 import com.example.wholeestate.service.ICustomerService;
15
 import com.example.wholeestate.service.ICustomerService;
16
+import org.apache.http.HttpStatus;
16
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.beans.factory.annotation.Autowired;
17
 import org.springframework.stereotype.Service;
18
 import org.springframework.stereotype.Service;
18
 
19
 
93
         responseBean.addSuccess(customer);
94
         responseBean.addSuccess(customer);
94
         return responseBean;
95
         return responseBean;
95
     }
96
     }
97
+
98
+    @Override
99
+    public ResponseBean updateCustomer(String parameter) {
100
+        ResponseBean responseBean = new ResponseBean();
101
+        Customer customer = JSONObject.parseObject(parameter, Customer.class);
102
+
103
+        UpdateWrapper<Customer> updateWrapper = new UpdateWrapper<>();
104
+        updateWrapper.set("customerName", customer.getCustomerName());
105
+        updateWrapper.set("name", customer.getName());
106
+        updateWrapper.set("phone", customer.getPhone());
107
+        updateWrapper.set("idNum", customer.getIdNum());
108
+        updateWrapper.set("remark", customer.getRemark());
109
+        updateWrapper.eq("customer_id", customer.getCustomerId());
110
+
111
+        int success = customerMapper.update(customer, updateWrapper);
112
+        if (success >= 0) {
113
+            responseBean.addError(HttpStatus.SC_INTERNAL_SERVER_ERROR, "更新用户信息失败");
114
+        }
115
+
116
+        return responseBean;
117
+    }
96
 }
118
 }