package com.product.mobile.core.controller;
|
|
import com.product.admin.service.PublicService;
|
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.core.spring.context.SpringMVCContextHolder;
|
import com.product.mobile.core.config.MobileCoreCode;
|
import com.product.mobile.core.service.CommonMVCService;
|
import com.product.module.sys.version.ApiVersion;
|
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 javax.servlet.http.HttpServletRequest;
|
|
/**
|
* 手机端通用查询
|
*
|
* @author shicf
|
*/
|
@RequestMapping("/api/mobile")
|
@RestController
|
public class CommonMVCController extends AbstractBaseController {
|
@Autowired
|
PublicService publicService;
|
@Autowired
|
CommonMVCService commonMVCService;
|
/**
|
* 根据业务数据,查询是否有审批流程,
|
* 有则返回业务审批流程其中一个uuid
|
* 无则 返回业务数据,包括所有子表,数据结构
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/find-table/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String listData(HttpServletRequest request) {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
try {
|
String flow_detail_uuid=commonMVCService.getApproveDetailUUID(fse.getTableName(),fse.getString("uuid"));
|
if(flow_detail_uuid==null) {
|
FieldSetEntity fs=publicService.getFieldSetEntity(fse, true);
|
|
return this.result_OK_List(fs);
|
}else {
|
return this.OK_Add(flow_detail_uuid);
|
}
|
} catch (BaseException e) {
|
return this.error(e);
|
} catch (Exception e) {
|
|
return this.error(MobileCoreCode.GET_DATA_FAIL);
|
}
|
}
|
/**
|
* 加载MVC,包括,当前按钮,按钮操作界面,界面后面的更按钮
|
* ///查出MVC中按钮操作的界面,界面后面的所有按钮
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/find-button-page/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String findMVC(HttpServletRequest request) {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
try {
|
return result_OK_List(commonMVCService.getPageButtons(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return this.error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return this.error(MobileCoreCode.GET_ROUTER_FAIL);
|
}
|
}
|
/**
|
* 执行移动端送来的表达式到数据库中执行,得到结果返回
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/excute-exp/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String excuteExp(HttpServletRequest request) {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
try {
|
return result_OK_List(commonMVCService.excuteExp(fse.getString("exp")));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
return this.error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return this.error(MobileCoreCode.GET_ROUTER_FAIL);
|
}
|
}
|
|
/**
|
* 根据按钮uuid找到连接的第一个页面
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/get-next-page-info/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String getNextPageByButtonUUID(HttpServletRequest request) {
|
try {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
return OK_List(commonMVCService.getNextPageByButtonUUID(fse));
|
} catch (BaseException e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
e.printStackTrace();
|
return error(e);
|
} catch (Exception e) {
|
e.printStackTrace();
|
return error(MobileCoreCode.GET_MVC_PAGE_INFO_FAIL);
|
}
|
}
|
}
|