jiangping
2024-07-12 2ce20c4dd9df60435afe5e6820103a37cf7f684a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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.IamUpateShopModel;
import com.doumee.biz.zbom.model.IamUpateUserModel;
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<String> updateShopInfo(@RequestHeader(name = "token") String token,
                                      @RequestHeader(name = "uuid") String uuid ,
                                      @RequestHeader(name = "timestamp") String timestamp,
                                      @RequestBody List<IamUpateShopModel> shopList,
                                      HttpServletRequest request ) {
        int success = Constants.ZERO;
        ApiResponse<String> r = null;
        try {
            zbomIAMService.updateShopInfo(token,uuid,timestamp,shopList);
            r  = ApiResponse.success("操作成功");
        }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<String> updateUserInfo(@RequestHeader(name = "token") String token,
                                      @RequestHeader(name = "uuid") String uuid ,
                                      @RequestHeader(name = "timestamp") String timestamp,
                                      @RequestBody IamUpateUserModel upateUserModel,
                                      HttpServletRequest request) {
        int success = Constants.ZERO;
        ApiResponse<String> 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;
    }
 
}