杜洪波
2026-03-27 9a1cd4f99b081a3edf84d82cbea4c569702f2865
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package com.product.saas.controller;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
 
import com.product.saas.config.SaasCode;
import com.product.saas.service.TenantApplyService;
import com.product.saas.service.idel.ITenantApplyService;
import com.product.core.config.CoreConst;
import com.product.core.controller.support.AbstractBaseController;
import com.product.core.entity.FieldSetEntity;
import com.product.core.entity.RequestParameterEntity;
import com.product.core.exception.BaseException;
import com.product.file.service.FileManagerService;
import com.product.module.sys.version.ApiVersion;
import com.product.util.BaseUtil;
 
/**
 * 系统租户申请
 */
@RestController
@RequestMapping("/api/tenant-apply")
public class TenantApplyController extends AbstractBaseController{
 
    @Autowired
    TenantApplyService tenantApplyService;
    
    @Autowired
    FileManagerService fileManagerService;
    
    /**
     *     验证租户信息(白名单调用)
     * @param request
     * @return
     */
    @RequestMapping(value = "/valid-tenant-info/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String validTenantInfo(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            tenantApplyService.validTenantInfo(fse);
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            return this.error(e.getCode(), e.getMessageInfo());
        } catch (Exception e) {
            e.printStackTrace();
            return error(SaasCode.TENANT_APPLY_VALID_INFO_FAIL.getValue(), SaasCode.TENANT_APPLY_VALID_INFO_FAIL.getText() + e.getMessage());
        }
    }
    
    /**
     *     获取指定申请,根据申请人手机号(白名单调用)
     * @param request
     * @return
     */
    @RequestMapping(value = "/get-tenant-apply/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String getTenantApplyByPhone(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            return OK_List(tenantApplyService.getTenantApplyByPhone(fse.getString("applicant_phone")));
        } catch (BaseException e) {
            e.printStackTrace();
            return this.error(e.getCode(), e.getMessageInfo());
        } catch (Exception e) {
            e.printStackTrace();
            return error(SaasCode.TENANT_AAPLY_INFO_GET_FAIL.getValue(), SaasCode.TENANT_AAPLY_INFO_GET_FAIL.getText() + e.getMessage());
        }
    }
    
    /**
     *     保存租户申请,根据申请人手机号(白名单调用)
     * @param request
     * @return
     */
    @RequestMapping(value = "/save-tenant-apply/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String saveTenantApplyByPhone(HttpServletRequest request) {
        try {
            Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
            FieldSetEntity fse = null;
            if (bean != null) {
                RequestParameterEntity rpe = (RequestParameterEntity) bean;
                fse = rpe.getFormData();
                String fileModified = fse.getString("fileModified");
                if ("1".equals(fileModified)) {
                    // 新上传营业执照
                     FieldSetEntity fseFile = fileManagerService.uploadFile(rpe);
                     fse.setValue("business_license", fseFile.getString("business_license"));
                 }
            }
            // 保存申请信息
            ITenantApplyService service = (ITenantApplyService)getProxyInstance(tenantApplyService);
            service.saveTenantApply(fse);
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            return this.error(e.getCode(), e.getMessageInfo());
        } catch (Exception e) {
            e.printStackTrace();
            return error(SaasCode.TENANT_AAPLY_INFO_SUBMIT_FAIL.getValue(), SaasCode.TENANT_AAPLY_INFO_SUBMIT_FAIL.getText() + e.getMessage());
        }
    }
    
    /**
     *     撤销租户申请,根据申请人手机号(白名单调用)
     * @param request
     * @return
     */
    @RequestMapping(value = "/cancel-tenant-apply/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String cancelTenantApplyByPhone(HttpServletRequest request) {
        try {
            FieldSetEntity fse = BaseUtil.getFieldSetEntity(request);
            // 保存申请信息
            ITenantApplyService service = (ITenantApplyService)getProxyInstance(tenantApplyService);
            service.cancelTenantApply(fse);
            return OK();
        } catch (BaseException e) {
            e.printStackTrace();
            return this.error(e.getCode(), e.getMessageInfo());
        } catch (Exception e) {
            e.printStackTrace();
            return error(SaasCode.TENANT_AAPLY_INFO_CANCEL_FAIL.getValue(), SaasCode.TENANT_AAPLY_INFO_CANCEL_FAIL.getText() + e.getMessage());
        }
    }
}