package com.doumee.api.business; import com.alibaba.fastjson.JSONObject; import com.doumee.api.BaseController; import com.doumee.biz.zbom.ZbomIAMService; import com.doumee.biz.zbom.model.IamUpdateRoleModel; import com.doumee.biz.zbom.model.IamUpdateShopModel; import com.doumee.biz.zbom.model.IamUpdateUserModel; import com.doumee.core.exception.BusinessException; import com.doumee.core.model.ApiResponse; import com.doumee.core.utils.Constants; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import java.util.List; /** * @author 江蹄蹄 * @date 2024/07/04 14:40 */ @Api(tags = "对外提供接口") @RestController @RequestMapping("/push") public class PushController extends BaseController { @Autowired private ZbomIAMService zbomIAMService; @ApiOperation("组织信息更新推送") @PostMapping("/iam/updateShopInfo") public ApiResponse updateShopInfo(@RequestHeader(name = "token") String token, @RequestHeader(name = "uuid") String uuid , @RequestHeader(name = "timestamp") String timestamp, @RequestBody List shopList, HttpServletRequest request ) { int success = Constants.ZERO; ApiResponse r = null; try { zbomIAMService.updateShopInfo(token,uuid,timestamp,shopList); r = ApiResponse.successIam("操作成功"); }catch (BusinessException e){ success = Constants.ONE; r = ApiResponse.failed(StringUtils.defaultString(e.getMessage(),"操作失败")); }catch (Exception e){ e.printStackTrace(); success = Constants.ONE; r = ApiResponse.failed("操作失败"); }finally { zbomIAMService.saveInterfaceLog("/push/iam/updateUserInfo",Constants.ONE,"IAM推送组织信息", token, uuid, timestamp, shopList,success, JSONObject.toJSONString(r)); } return r; } @ApiOperation("人员账号信息更新推送") @PostMapping("/iam/updateUserInfo") public ApiResponse updateUserInfo(@RequestHeader(name = "token") String token, @RequestHeader(name = "uuid") String uuid , @RequestHeader(name = "timestamp") String timestamp, @RequestBody IamUpdateUserModel upateUserModel, HttpServletRequest request) { int success = Constants.ZERO; ApiResponse r = null; try { zbomIAMService.updateUserInfo(token,uuid,timestamp,upateUserModel); r = ApiResponse.successIam("操作成功"); }catch (BusinessException e){ success = Constants.ONE; r = ApiResponse.failed(StringUtils.defaultString(e.getMessage(),"操作失败")); }catch (Exception e){ success = Constants.ONE; e.getMessage(); r = ApiResponse.failed("操作失败"); }finally { zbomIAMService.saveInterfaceLog("/push/iam/updateUserInfo",Constants.ONE,"IAM推送人员账号信息", token, uuid, timestamp, upateUserModel,success, JSONObject.toJSONString(r)); } return r; } @ApiOperation("角色信息更新推送") @PostMapping("/iam/updateRoleInfo") public ApiResponse updateRoleInfo(@RequestHeader(name = "token") String token, @RequestHeader(name = "uuid") String uuid , @RequestHeader(name = "timestamp") String timestamp, @RequestBody IamUpdateRoleModel upateModel, HttpServletRequest request) { int success = Constants.ZERO; ApiResponse r = null; try { zbomIAMService.updateRoleInfo(token,uuid,timestamp,upateModel); r = ApiResponse.successIam("操作成功"); }catch (BusinessException e){ success = Constants.ONE; r = ApiResponse.failed(StringUtils.defaultString(e.getMessage(),"操作失败")); }catch (Exception e){ success = Constants.ONE; e.getMessage(); r = ApiResponse.failed("操作失败"); }finally { zbomIAMService.saveInterfaceLog("/push/iam/updateRoleInfo",Constants.ONE,"IAM推送角色账号信息", token, uuid, timestamp, upateModel,success, JSONObject.toJSONString(r)); } return r; } }