|
@@ -6,13 +6,16 @@ import com.chelvc.cloud.uc.api.dto.UserDTO;
|
|
|
import com.chelvc.cloud.uc.api.param.UserModifyParam;
|
|
|
import com.chelvc.cloud.uc.api.service.UserService;
|
|
|
import com.chelvc.framework.base.annotation.UnifiedResponseBody;
|
|
|
+import com.chelvc.framework.base.context.SessionContextHolder;
|
|
|
import com.chelvc.framework.base.util.ErrorUtils;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
-import javax.validation.constraints.Min;
|
|
|
|
|
|
/**
|
|
|
* 会员接口
|
|
@@ -30,12 +33,11 @@ public class CustomerController {
|
|
|
/**
|
|
|
* 获取用户信息
|
|
|
*
|
|
|
- * @param id 用户主键
|
|
|
* @return 用户信息
|
|
|
*/
|
|
|
- @GetMapping("/customer/{id}")
|
|
|
- public UserVO getCustomer(@PathVariable("id") @Min(value = 1, message = "用户主键不能小于1") Long id) {
|
|
|
- UserDTO user = this.userService.getUser(id);
|
|
|
+ @GetMapping("/customer")
|
|
|
+ public UserVO getCustomer() {
|
|
|
+ UserDTO user = this.userService.getUser(SessionContextHolder.getId());
|
|
|
ErrorUtils.requireResource(user, "用户不存在");
|
|
|
return UserCopier.INSTANCE.copying(user);
|
|
|
}
|
|
@@ -43,12 +45,10 @@ public class CustomerController {
|
|
|
/**
|
|
|
* 修改用户信息
|
|
|
*
|
|
|
- * @param id 用户主键
|
|
|
* @param param 修改参数
|
|
|
*/
|
|
|
- @PutMapping("/customer/{id}")
|
|
|
- public void updateEmployee(@PathVariable("id") @Min(value = 1, message = "用户主键不能小于1") Long id,
|
|
|
- @RequestBody @Valid UserModifyParam param) {
|
|
|
- this.userService.updateUser(id, param);
|
|
|
+ @PutMapping("/customer")
|
|
|
+ public void updateCustomer(@RequestBody @Valid UserModifyParam param) {
|
|
|
+ this.userService.updateUser(SessionContextHolder.getId(), param);
|
|
|
}
|
|
|
}
|