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());
|
}
|
}
|
}
|