From 684c97f7c6ba1b5f2fff7a08410b385a3f0c4a8b Mon Sep 17 00:00:00 2001 From: shicf <shi_chongfu@163.com> Date: 星期二, 11 三月 2025 09:24:22 +0800 Subject: [PATCH] 通用MVC --- src/main/java/com/product/mobile/core/service/CommonMVCService.java | 118 +++++++++++++++++++++++++++++ src/main/java/com/product/mobile/core/controller/CommonMVCController.java | 95 +++++++++++++++++++++++ 2 files changed, 213 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/product/mobile/core/controller/CommonMVCController.java b/src/main/java/com/product/mobile/core/controller/CommonMVCController.java new file mode 100644 index 0000000..ad82496 --- /dev/null +++ b/src/main/java/com/product/mobile/core/controller/CommonMVCController.java @@ -0,0 +1,95 @@ +package com.product.mobile.core.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.admin.service.PublicService; +import com.product.core.config.CoreConst; +import com.product.core.controller.support.AbstractBaseController; +import com.product.core.entity.DataTableEntity; +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.mobile.core.service.NavBarManagerService; +import com.product.mobile.core.service.SignInService; +import com.product.module.sys.version.ApiVersion; +import com.product.org.admin.config.CmnCode; + +/** + * 鎵嬫満绔�氱敤鏌ヨ + * + * @author shicf + */ +@RequestMapping("/api/mobile") +@RestController +public class CommonMVCController extends AbstractBaseController { + @Autowired + PublicService publicService; + @Autowired + CommonMVCService commonMVCService; + /** + * 鏍规嵁涓氬姟鏁版嵁锛屾煡璇㈡槸鍚︽湁瀹℃壒娴佺▼锛� + * 鏈夊垯杩斿洖涓氬姟瀹℃壒娴佺▼鍏朵腑涓�涓猽uid + * 鏃犲垯 杩斿洖涓氬姟鏁版嵁锛屽寘鎷墍鏈夊瓙琛紝鏁版嵁缁撴瀯 + * @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); + } + } +} diff --git a/src/main/java/com/product/mobile/core/service/CommonMVCService.java b/src/main/java/com/product/mobile/core/service/CommonMVCService.java new file mode 100644 index 0000000..f418f38 --- /dev/null +++ b/src/main/java/com/product/mobile/core/service/CommonMVCService.java @@ -0,0 +1,118 @@ +package com.product.mobile.core.service; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import com.aspose.p6a2feef8.p995e1fda.pbdb106a0.b; +import com.product.common.lang.StringUtils; +import com.product.core.config.CoreConst; +import com.product.core.config.Global; +import com.product.core.dao.BaseDao; +import com.product.core.entity.DataTableEntity; +import com.product.core.entity.FieldSetEntity; +import com.product.core.exception.BaseException; +import com.product.core.log.SystemLogger; +import com.product.core.service.support.AbstractBaseService; +import com.product.core.spring.context.SpringMVCContextHolder; +import com.product.mobile.core.config.MobileCoreCode; +import com.product.mobile.core.config.MobileCoreConst; +import com.product.module.sys.entity.SystemUser; +import com.product.util.BaseUtil; + +/** + * 鎵嬫満绔紝鑾峰彇鐢ㄦ埛鎵�鏈夊簲鐢� + * @author Administrator + * + */ +@Component +public class CommonMVCService extends AbstractBaseService{ + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //鍒跺畾杈撳嚭鏍煎紡 + + @Autowired + public BaseDao baseDao; + /** + * 鏌ヨ鏁版嵁鏁版嵁鏄惁鏈夎蛋瀹℃壒娴佺▼ + * @param table + * @param uuid + */ + public String getApproveDetailUUID(String table,String uuid) { + + DataTableEntity dt = getBaseDao().listTable("product_sys_flow_detail", " record_uuid=? and table_name=? ",new Object[]{uuid,table}); + if(dt.isEmpty()) { + return null; + }else { + return dt.getFieldSetEntity(0).getUUID(); + } + } + /** + * 鏌ュ嚭MVC涓寜閽搷浣滅殑鐣岄潰锛岀晫闈㈠悗闈㈢殑鎵�鏈夋寜閽� + * @param button 鏈夊彲鑳芥槸绫诲瀷锛屾湁鍙兘鏄痷uid + * @param table + * @param functionUuid + * @return + * @throws BaseException + */ + public FieldSetEntity getPageButtons(FieldSetEntity fse) throws BaseException{ + + String buttonUuid=fse.getString("buttonUuid"); + + String table=fse.getString(CoreConst.SYSTEM_TABLE_NAME_LABEL); + if(table==null) table=fse.getTableName(); + String functionUuid=fse.getString("functionUuid"); + String buttonType=fse.getString("buttonType"); + if(StringUtils.isEmpty(functionUuid) && !StringUtils.isEmpty(table)) { + ///鏍规嵁琛ㄥ幓鏌ュ姛鑳斤紝濡傛湁澶氫釜锛屽彇绗竴涓� + FieldSetEntity f=baseDao.getFieldSetByFilter("product_sys_functions", "table_uuid=(select uuid from product_sys_datamodel_table where table_name=?) or table_uuid=? ", new String[] {table,table}, false); + if(!FieldSetEntity.isEmpty(f)) { + functionUuid=f.getUUID(); + } + } + FieldSetEntity page=null; + + if(!StringUtils.isEmpty(functionUuid)) { + //鏍规嵁鎸夐挳绫诲瀷鏌ュ嚭鎸夐挳uuid + if(StringUtils.isEmpty(buttonUuid)&& !StringUtils.isEmpty(buttonType) ) { + DataTableEntity d=baseDao.listTable("product_sys_function_buttons", " function_uuid=? and button_category_uuid=? ", new String[] {functionUuid,buttonType},"button_type"); + if(!DataTableEntity.isEmpty(d)) { + buttonUuid=d.getFieldSetEntity(0).getUUID();//鍙栫涓�鏉� + } + } + //鏌ュ嚭鎸夐挳瀵瑰簲鐣岄潰锛屽彲鑳芥寜閽湁澶氫釜锛屽彇绗竴涓� + if(!StringUtils.isEmpty(buttonUuid)) { + StringBuilder b=new StringBuilder(); + b.append("select * from product_sys_mvc_page where function_uuid=? and uuid in (\r\n") + .append("select line_to from product_sys_link where function_uuid=? and line_from=?\r\n") + .append(" union all ") + .append("select line_to from product_sys_link where function_uuid=? and line_from=\r\n") + .append(" (select line_to mainUuid from product_sys_link where function_uuid=? and line_from=?) ") + .append(")"); + DataTableEntity d=baseDao.listTable(b.toString() , new String[] {functionUuid,functionUuid,buttonUuid,functionUuid,functionUuid,buttonUuid} ); + if(!DataTableEntity.isEmpty(d)) { + page=d.getFieldSetEntity(0);//鍙栫涓�鏉� + }else { + + } + } + if(page!=null) { + //鏌ョ晫闈㈠悗鐨勬墍鏈夋寜閽� + StringBuilder b=new StringBuilder(); + b.append("select * from product_sys_function_buttons where function_uuid=? and uuid in(\r\n") + .append("select line_to from product_sys_link where function_uuid=? and line_from=?\r\n") + .append(")"); + DataTableEntity d=baseDao.listTable(b.toString() , new String[] {functionUuid,functionUuid,page.getUUID()} ); + page.addSubDataTable(d); + }else { + throw new BaseException(MobileCoreCode.GET_ROUTER_FAIL); + } + return page; + }else { + throw new BaseException(MobileCoreCode.GET_ROUTER_FAIL); + } + } + +} -- Gitblit v1.9.2