package om.product.mobile.test;
|
|
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;
|
|
import com.product.admin.config.SystemCode;
|
import com.product.common.lang.StringUtils;
|
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.spring.context.SpringMVCContextHolder;
|
import com.product.mobile.core.service.ApplicationsService;
|
import com.product.mobile.core.service.SystemTableMetaService;
|
import com.product.module.sys.version.ApiVersion;
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONArray;
|
|
/**
|
* App指定表结构信息
|
*
|
* @author shicf
|
*/
|
@RequestMapping("/api/mobile")
|
@RestController
|
public class SystemTableMetaController extends AbstractBaseController {
|
@Autowired
|
SystemTableMetaService systemTableMetaService;
|
|
/**
|
* 获取指定表的数据结构信息
|
*
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/system/table/list-meta/{version}", method = RequestMethod.POST)
|
@ApiVersion(2)
|
public String tableMetaList(HttpServletRequest request) {
|
FieldSetEntity fse = null;
|
Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
|
if (bean != null) {
|
RequestParameterEntity reqp = (RequestParameterEntity) bean;
|
fse = reqp.getFormData();
|
}
|
if (bean == null || fse == null) {
|
SpringMVCContextHolder.getSystemLogger().error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
return this.OK_List(systemTableMetaService.getSystemTableMeta(fse));
|
}
|
|
/**
|
* 返回数据库初始表
|
* @return
|
*/
|
public static String initTableMeta() {
|
|
JSONObject data=new JSONObject();
|
data.put("message", "成功");
|
data.put("~table~", "product_sys_datamodel_field");
|
data.put("success", true);
|
JSONArray devices=new JSONArray();
|
data.put("device_archives", devices);
|
|
JSONObject device_name=new JSONObject();
|
devices.add(device_name);
|
device_name.put("field_name","device_name");
|
device_name.put("field_show_name", "设备名称");
|
device_name.put("field_reference", "");
|
device_name.put("field_type", "string");
|
device_name.put("field_length", 200);
|
device_name.put("is_more_value", 0);
|
|
JSONObject device_number=new JSONObject();
|
devices.add(device_number);
|
device_number.put("field_name","device_number");
|
device_number.put("field_show_name", "设备编码");
|
device_number.put("field_reference", "");
|
device_number.put("field_type", "string");
|
device_number.put("field_length", 100);
|
device_number.put("is_more_value", 0);
|
|
JSONObject specification_model=new JSONObject();
|
devices.add(specification_model);
|
specification_model.put("field_name","specification_model");
|
specification_model.put("field_show_name", "规格型号");
|
specification_model.put("field_reference", "");
|
specification_model.put("field_type", "string");
|
specification_model.put("field_length", 200);
|
specification_model.put("is_more_value", 0);
|
|
JSONObject run_status=new JSONObject();
|
devices.add(run_status);
|
run_status.put("field_name","run_status");
|
run_status.put("field_show_name", "运行状态");
|
run_status.put("field_reference", "《DEVICE-RUN-STATUS》");//code------
|
run_status.put("field_type", "int");
|
run_status.put("field_length", 200);
|
run_status.put("is_more_value", 0);
|
|
JSONObject status=new JSONObject();
|
devices.add(status);
|
status.put("field_name","status");
|
status.put("field_show_name", "设备状态");
|
status.put("field_reference", "《DEVICE-STATUS》"); //code------
|
status.put("field_type", "int");
|
status.put("field_length", 200);
|
status.put("is_more_value", 0);
|
|
JSONObject company_id=new JSONObject();
|
devices.add(company_id);
|
company_id.put("field_name","company_id");
|
company_id.put("field_show_name", "所属公司");
|
company_id.put("field_reference", "orgs"); //code------
|
company_id.put("field_type", "int");
|
company_id.put("field_length", 300);
|
company_id.put("is_more_value", 0);
|
|
JSONObject use_dept_id=new JSONObject();
|
devices.add(use_dept_id);
|
use_dept_id.put("field_name","use_dept_id");
|
use_dept_id.put("field_show_name", "使用部门");
|
use_dept_id.put("field_reference", "orgss"); //code------
|
use_dept_id.put("field_type", "int");
|
use_dept_id.put("field_length", 300);
|
use_dept_id.put("is_more_value", 0);
|
|
JSONObject plant=new JSONObject();
|
devices.add(plant);
|
plant.put("field_name","plant");
|
plant.put("field_show_name", "所属工厂");
|
plant.put("field_reference", "orgs"); //code------
|
plant.put("field_type", "int");
|
plant.put("field_length", 300);
|
plant.put("is_more_value", 0);
|
|
JSONObject workshop=new JSONObject();
|
devices.add(workshop);
|
workshop.put("field_name","workshop");
|
workshop.put("field_show_name", "车间");
|
workshop.put("field_reference", "orgs"); //------
|
workshop.put("field_type", "int");
|
workshop.put("field_length", 300);
|
workshop.put("is_more_value", 0);
|
|
JSONObject device_manager=new JSONObject();
|
devices.add(device_manager);
|
device_manager.put("field_name","device_manager");
|
device_manager.put("field_show_name", "设备管理员");
|
device_manager.put("field_reference", "users"); //------
|
device_manager.put("field_type", "int");
|
device_manager.put("field_length", 300);
|
device_manager.put("is_more_value", 0);
|
|
|
|
|
return data.toJSONString();
|
}
|
}
|