|
@@ -0,0 +1,54 @@
|
|
|
+package com.chelvc.cloud.maintain.controller;
|
|
|
+
|
|
|
+import com.chelvc.cloud.maintain.copier.UserCopier;
|
|
|
+import com.chelvc.cloud.maintain.vo.UserVO;
|
|
|
+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.util.ErrorUtils;
|
|
|
+import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.validation.Valid;
|
|
|
+import javax.validation.constraints.Min;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 会员接口
|
|
|
+ *
|
|
|
+ * @author 七仔
|
|
|
+ * @date 2023/5/22
|
|
|
+ */
|
|
|
+@Validated
|
|
|
+@RestController
|
|
|
+@UnifiedResponseBody
|
|
|
+public class CustomerController {
|
|
|
+ @DubboReference
|
|
|
+ private UserService userService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取用户信息
|
|
|
+ *
|
|
|
+ * @param id 用户主键
|
|
|
+ * @return 用户信息
|
|
|
+ */
|
|
|
+ @GetMapping("/customer/{id}")
|
|
|
+ public UserVO getCustomer(@PathVariable("id") @Min(value = 1, message = "用户主键不能小于1") Long id) {
|
|
|
+ UserDTO user = this.userService.getUser(id);
|
|
|
+ ErrorUtils.requireResource(user, "用户不存在");
|
|
|
+ return UserCopier.INSTANCE.copying(user);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改用户信息
|
|
|
+ *
|
|
|
+ * @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);
|
|
|
+ }
|
|
|
+}
|