package com.product.administration.controller;
|
|
import com.product.administration.config.SystemCode;
|
import com.product.admin.service.PublicService;
|
import com.product.administration.config.CmnConst;
|
import com.product.administration.service.KnowledgeSharingService;
|
import com.product.administration.service.ide.IKnowledgeSharingService;
|
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.module.sys.version.ApiVersion;
|
import com.product.util.BaseUtil;
|
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;
|
|
/**
|
* Copyright © 6c
|
*
|
* @Date 2022年06月14日 16:46
|
* @Author 6c
|
* @Description
|
*/
|
@RequestMapping("/api/knowledgeSharing")
|
@RestController
|
public class KnowledgeSharingController extends AbstractBaseController {
|
@Autowired
|
private KnowledgeSharingService knowledgeSharingService;
|
@Autowired
|
private PublicService publicService;
|
|
/**
|
* 列表
|
* @param request
|
* @return
|
*/
|
@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 error(SystemCode.SYSTEM_FORM_NODATA);
|
}
|
// 判断表名是否正常
|
if (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
return BaseUtil.success(knowledgeSharingService.list(fse));
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_LIST_FAIL);
|
}
|
}
|
|
/**
|
* 保存
|
* @param request
|
* @return
|
*/
|
@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());
|
}
|
// 判断表名是否正常
|
if (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
IKnowledgeSharingService service = (IKnowledgeSharingService) getProxyInstance(knowledgeSharingService);
|
return OK_Add(service.save(fse));
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_SAVE_FAIL);
|
}
|
}
|
|
/**
|
* 删除
|
* @param request
|
* @return
|
*/
|
@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());
|
}
|
// 判断表名是否正常
|
if (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
IKnowledgeSharingService service = (IKnowledgeSharingService) getProxyInstance(knowledgeSharingService);
|
service.delete(fse);
|
return OK();
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_DELETE_FAIL);
|
}
|
}
|
|
/**
|
* 获取详情-修改
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/get-info/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String getInfo(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());
|
}
|
// 判断表名是否正常
|
if (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
return OK_List(publicService.getFieldSetEntity(fse, false));
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_GET_INFO_FAIL);
|
}
|
}
|
|
/**
|
* 获取详情-查看
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/view-info/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String viewInfo(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());
|
}
|
// 判断表名是否正常
|
if (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
return OK_List(knowledgeSharingService.viewInfo(fse));
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_GET_INFO_FAIL);
|
}
|
}
|
|
/**
|
* 获取分类
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/get-type/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String getType(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 (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
return OK_List(knowledgeSharingService.getType());
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_GET_TYPE_FAIL);
|
}
|
}
|
|
/**
|
* 获取标签
|
* @param request
|
* @return
|
*/
|
@RequestMapping(value = "/get-tag/{version}", method = RequestMethod.POST)
|
@ApiVersion(1)
|
public String getTag(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 (!CmnConst.PRODUCT_OA_KNOWLEDGE_SHARING.equals(fse.getTableName())) {
|
return error(SystemCode.SYSTEM_TABLE_NODATA);
|
}
|
return OK_List(knowledgeSharingService.getTag());
|
} catch (BaseException e) {
|
return error(e);
|
} catch (Exception e) {
|
SpringMVCContextHolder.getSystemLogger().error(e);
|
return error(SystemCode.KNOWLEDGE_SHARING_GET_TAG_FAIL);
|
}
|
}
|
}
|