package com.home.xining.controller;
|
|
import com.home.xining.config.CmnConst;
|
import com.home.xining.config.SystemCode;
|
import com.product.admin.service.PublicService;
|
import com.product.admin.service.idel.IPublicService;
|
import com.product.core.config.CoreConst;
|
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.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
import com.product.util.support.AbstractBaseController;
|
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;
|
|
/**
|
* @Title: XiNingPublicController
|
* @Date: 2022-01-24 11:30:48
|
* @Author: luoxin
|
* @Description: 通用接口,
|
*/
|
@RequestMapping("/api/xining/controller")
|
@RestController
|
public class XiNingPublicController extends AbstractBaseController {
|
|
@Autowired
|
PublicService publicService;
|
|
@RequestMapping(value ="/list/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String list(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();
|
}
|
//判断参数是否为空
|
if (bean == null || fse == null) {
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
String createdByField = fse.getString(CmnConst.CREATED_BY_FIELD);
|
if(BaseUtil.strIsNull(createdByField)){
|
|
}
|
return OK_List(publicService.listTable(fse, true, 2, null, createdByField));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.GET_DATALIST_FILE.getValue(), SystemCode.GET_DATALIST_FILE.getText());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.GET_DATALIST_FILE.getValue(), SystemCode.GET_DATALIST_FILE.getText());
|
}
|
}
|
|
@RequestMapping(value = "/get/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String get(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();
|
}
|
//判断参数是否为空
|
if (bean == null || fse == null) {
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
return OK_List(publicService.getFieldSetEntity(fse,true));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.GET_DATA_FILE.getValue(), SystemCode.GET_DATA_FILE.getText());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.GET_DATA_FILE.getValue(), SystemCode.GET_DATA_FILE.getText());
|
}
|
}
|
|
@RequestMapping(value = "/save/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String save(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();
|
}
|
//判断参数是否为空
|
if (bean == null || fse == null) {
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
IPublicService service = (IPublicService) getProxyInstance(publicService);
|
return OK_Add(service.saveFieldSetEntity(fse));
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.SAVE_DATA_FILE.getValue(), SystemCode.SAVE_DATA_FILE.getText());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.SAVE_DATA_FILE.getValue(), SystemCode.SAVE_DATA_FILE.getText());
|
}
|
}
|
|
@RequestMapping(value = "/delete/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String delete(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();
|
}
|
//判断参数是否为空
|
if (bean == null || fse == null) {
|
return this.error(SystemCode.SYSTEM_FORM_NODATA.getValue(), SystemCode.SYSTEM_FORM_NODATA.getText());
|
}
|
IPublicService service = (IPublicService) getProxyInstance(publicService);
|
if(service.delete(fse)){
|
return OK();
|
}
|
return this.error(SystemCode.DELETE_DATA_FILE.getValue(), SystemCode.DELETE_DATA_FILE.getText());
|
} catch (BaseException e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.DELETE_DATA_FILE.getValue(), SystemCode.DELETE_DATA_FILE.getText());
|
} catch (Exception e) {
|
e.printStackTrace();
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return this.error(SystemCode.DELETE_DATA_FILE.getValue(), SystemCode.DELETE_DATA_FILE.getText());
|
}
|
}
|
}
|