This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
package jnpf.account;
|
||||
|
||||
import jnpf.account.fallback.PTenantAccountApiFallBackFactory;
|
||||
import jnpf.base.ActionResult;
|
||||
import jnpf.exception.HandleException;
|
||||
import jnpf.model.TenantGenerateDefaultAvatarVO;
|
||||
import jnpf.model.personnels.dto.turnover.SaveTenantUserForm;
|
||||
import jnpf.model.personnels.req.roster.UserAccountDto;
|
||||
import jnpf.model.user.GenerateHeadForm;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@FeignClient(name = "jnpf-tenant", fallbackFactory = PTenantAccountApiFallBackFactory.class, path = "/tenantUser")
|
||||
public interface PTenantAccountApi {
|
||||
|
||||
|
||||
@PutMapping("/batchAddUserAccount")
|
||||
ActionResult<List<UserAccountDto>> batchAddUserAccount(@RequestBody List<UserAccountDto> userAccountForms);
|
||||
|
||||
@PutMapping("/batchDisabledUserAccount")
|
||||
ActionResult<List<UserAccountDto>> batchDisabledUserAccount(@RequestBody List<UserAccountDto> userAccountForms);
|
||||
|
||||
@GetMapping("/generateDefaultAvatar")
|
||||
ActionResult generateDefaultAvatar(@RequestParam("name") String name) throws IOException;
|
||||
|
||||
|
||||
/**
|
||||
* 批量异步生成头像 调用方自己要触发保底
|
||||
* @param names 用户名
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/batch/generate/default/avatar")
|
||||
List<TenantGenerateDefaultAvatarVO> batchGenerateDefaultAvatar(@RequestBody List<String> names);
|
||||
|
||||
/**
|
||||
* 用户状态修改
|
||||
* @param saveTenantUserForm
|
||||
* @return
|
||||
*/
|
||||
@PutMapping("/updateJobStatus")
|
||||
ActionResult updateJobStatus(@RequestBody SaveTenantUserForm saveTenantUserForm);
|
||||
|
||||
|
||||
@PutMapping("/userInfoSynchronous")
|
||||
ActionResult userInfoSynchronous(@RequestBody SaveTenantUserForm saveTenantUserForm);
|
||||
|
||||
@DeleteMapping("/deleteUser/{id}")
|
||||
ActionResult deleteUser(@PathVariable("id") String id);
|
||||
|
||||
/**
|
||||
* 删除用户(同步删除租户用户)
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return ActionResult
|
||||
*/
|
||||
@DeleteMapping("/deleteUserWithPlatform/{userId}")
|
||||
Boolean deleteUserWithPlatform(@PathVariable("userId") String userId);
|
||||
|
||||
/**
|
||||
* 批量删除用户
|
||||
*/
|
||||
@DeleteMapping("/deleteUsers")
|
||||
ActionResult<Void> deleteUsers(@RequestBody List<String> userIds) ;
|
||||
|
||||
@PostMapping("/generateDefaultAvatarCustomFilename")
|
||||
ActionResult generateDefaultAvatar(@RequestBody GenerateHeadForm generateHeadForm) throws IOException;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package jnpf.account.fallback;
|
||||
|
||||
import jnpf.account.PTenantAccountApi;
|
||||
import jnpf.base.ActionResult;
|
||||
import jnpf.exception.HandleException;
|
||||
import jnpf.model.TenantGenerateDefaultAvatarVO;
|
||||
import jnpf.model.personnels.dto.turnover.SaveTenantUserForm;
|
||||
import jnpf.model.personnels.req.roster.UserAccountDto;
|
||||
import jnpf.model.user.GenerateHeadForm;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class PTenantAccountApiFallBack implements PTenantAccountApi {
|
||||
|
||||
@Override
|
||||
public ActionResult<List<UserAccountDto>> batchAddUserAccount(List<UserAccountDto> userAccountForms) {
|
||||
log.error("调用批量添加用户接口失败,降级");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<List<UserAccountDto>> batchDisabledUserAccount(List<UserAccountDto> userAccountForms) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult generateDefaultAvatar(String name) throws IOException {
|
||||
log.error("调用生成默认头像接口失败,降级");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TenantGenerateDefaultAvatarVO> batchGenerateDefaultAvatar(List<String> names) {
|
||||
log.error("调用生成默认头像接口失败,降级");
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult updateJobStatus(SaveTenantUserForm saveTenantUserForm) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult userInfoSynchronous(SaveTenantUserForm saveTenantUserForm) {
|
||||
log.error("调用同步用户信息接口失败,降级");
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult deleteUser(String id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean deleteUserWithPlatform(String userId) {
|
||||
log.error("调用删除租户用户接口失败,降级");
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult<Void> deleteUsers(List<String> userIds) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ActionResult generateDefaultAvatar(GenerateHeadForm generateHeadForm) throws IOException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package jnpf.account.fallback;
|
||||
|
||||
import feign.FeignException;
|
||||
import feign.Request;
|
||||
import jnpf.account.PTenantAccountApi;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class PTenantAccountApiFallBackFactory implements FallbackFactory<PTenantAccountApi> {
|
||||
|
||||
@Override
|
||||
public PTenantAccountApi create(Throwable cause) {
|
||||
log.error("服务降级了");
|
||||
cause.printStackTrace();
|
||||
log.error(cause.getMessage(), cause);
|
||||
return new PTenantAccountApiFallBack();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user