yonge пре 5 година
родитељ
комит
381507a050

+ 1 - 1
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/AuthServerApplication.java

@@ -16,7 +16,7 @@ import com.spring4all.swagger.EnableSwagger2Doc;
 
 @SpringBootApplication
 @EnableDiscoveryClient
-@EnableFeignClients({"com.ym.mec.im"})
+@EnableFeignClients({"com.ym.mec"})
 @MapperScan("com.ym.mec.auth.dal.dao")
 @ComponentScan(basePackages="com.ym.mec")
 @Configuration

+ 15 - 8
mec-auth/mec-auth-server/src/main/java/com/ym/mec/auth/service/impl/SysUserServiceImpl.java

@@ -1,5 +1,14 @@
 package com.ym.mec.auth.service.impl;
 
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.userdetails.UsernameNotFoundException;
+import org.springframework.stereotype.Service;
+
 import com.ym.mec.auth.api.dto.SysUserInfo;
 import com.ym.mec.auth.api.entity.SysUser;
 import com.ym.mec.auth.api.enums.SysUserType;
@@ -14,14 +23,7 @@ import com.ym.mec.common.entity.ImUserModel;
 import com.ym.mec.common.exception.BizException;
 import com.ym.mec.common.service.impl.BaseServiceImpl;
 import com.ym.mec.im.ImFeignService;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.security.core.userdetails.UsernameNotFoundException;
-import org.springframework.stereotype.Service;
-
-import java.util.Date;
-import java.util.List;
+import com.ym.mec.user.UserFeignService;
 
 @Service
 public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implements SysUserService {
@@ -37,6 +39,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implem
 
 	@Autowired
 	private ImFeignService imFeignService;
+	
+	@Autowired
+	private UserFeignService userFeignService;
 
 	@Value("${message.autoRegister}")
 	private boolean autoRegister;
@@ -166,7 +171,9 @@ public class SysUserServiceImpl extends BaseServiceImpl<Integer, SysUser> implem
 			sysUser.setPhone(phone);
 			sysUser.setUserType(SysUserType.STUDENT);
 			sysUserDao.insert(sysUser);
+            //添加用户现金账户
 			imFeignService.register(new ImUserModel(sysUser.getId().toString(),phone,null));
+			userFeignService.createCashAccount(sysUser.getId());
 			return queryUserInfoByPhone(phone);
 		}
 		throw new UsernameNotFoundException("404.9");

+ 15 - 0
mec-client-api/src/main/java/com/ym/mec/user/UserFeignService.java

@@ -0,0 +1,15 @@
+package com.ym.mec.user;
+
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+
+import com.ym.mec.common.config.FeignConfiguration;
+import com.ym.mec.user.fallback.UserFeignServiceFallback;
+
+@FeignClient(name = "web-server", configuration = FeignConfiguration.class, fallback = UserFeignServiceFallback.class)
+public interface UserFeignService {
+
+	@GetMapping(value = "api/createCashAccount/{userId}")
+	public Boolean createCashAccount(@PathVariable("userId") Integer userId);
+}

+ 13 - 0
mec-client-api/src/main/java/com/ym/mec/user/fallback/UserFeignServiceFallback.java

@@ -0,0 +1,13 @@
+package com.ym.mec.user.fallback;
+
+import org.springframework.stereotype.Component;
+
+import com.ym.mec.user.UserFeignService;
+
+@Component
+public class UserFeignServiceFallback implements UserFeignService {
+
+	@Override
+	public Boolean createCashAccount(Integer userId) {
+		return false;
+	}}

+ 31 - 0
mec-web/src/main/java/com/ym/mec/web/controller/APIController.java

@@ -0,0 +1,31 @@
+package com.ym.mec.web.controller;
+
+import io.swagger.annotations.Api;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import com.ym.mec.biz.dal.dao.SysUserCashAccountDao;
+import com.ym.mec.biz.dal.entity.SysUserCashAccount;
+import com.ym.mec.common.controller.BaseController;
+
+@RequestMapping("api")
+@Api(tags = "对外接口")
+@RestController
+public class APIController extends BaseController {
+
+	@Autowired
+	private SysUserCashAccountDao sysUserCashAccountDao;
+
+	@GetMapping("/createCashAccount/{userId}")
+	public Boolean createCashAccount(@PathVariable("userId") Integer userId) {
+		// 添加用户现金账户
+		sysUserCashAccountDao.insert(new SysUserCashAccount(userId, "CNY"));
+
+		return true;
+	}
+
+}