d332a7c8c27afa9ef90607e57a6a3dfd6dae3a00..684c97f7c6ba1b5f2fff7a08410b385a3f0c4a8b
2025-03-11 shicf
通用MVC
684c97 对比 | 目录
2025-03-11 shicf
通用MVC实现
c25682 对比 | 目录
已添加2个文件
已修改4个文件
286 ■■■■ 文件已修改
src/main/java/com/product/mobile/core/config/MobileCoreCode.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/controller/ApplicationsController.java 62 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/controller/CommonMVCController.java 95 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/CommonMVCService.java 118 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/FaceMobileService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/service/NavBarManagerService.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/product/mobile/core/config/MobileCoreCode.java
@@ -32,6 +32,7 @@
    
    SIGN_IN_REPEAT_FAIL("考勤打卡失败:重复打卡", "010"),
    SIGN_IN_FAIL("考勤打卡失败", "011"),
    GET_DATA_FAIL("获取数据失败", "012"),
    ;
    MobileCoreCode(String text, String code) {
src/main/java/com/product/mobile/core/controller/ApplicationsController.java
@@ -1,11 +1,21 @@
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.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.module.sys.version.ApiVersion;
/**
 * App移动应用
@@ -19,34 +29,28 @@
    ApplicationsService applicationsService;
    /**
//     * èŽ·å–æ‰€æœ‰app应用
//     *
//     * @param request
//     * @return
//     */
//    @RequestMapping(value = "/apps/list/{version}", method = RequestMethod.POST)
//    @ApiVersion(1)
//    public String appsList(HttpServletRequest request) {
//        FieldSetEntity fse = null;
//        Object bean = request.getAttribute(CoreConst.API_POST_REQUEST_DATA);
//        if (bean != null) {
//            RequestParameterEntity reqp = (RequestParameterEntity) bean;
//            fse = reqp.getFormData();
//        }
//        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());
//        }
//        if (StringUtils.isEmpty(fse.getTableName())) {
//            return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
//        }
//        return this.OK_List(applicationsService.getUserApps(fse));
//    }
     * èŽ·å–ç”¨æˆ·æœ‰æƒé™çš„æ‰€æœ‰app应用
     *
     * @param request
     * @return
     */
    @RequestMapping(value = "/apps/list/{version}", method = RequestMethod.POST)
    @ApiVersion(1)
    public String appsList(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());
        }
        if (StringUtils.isEmpty(fse.getTableName())) {
            return this.error(SystemCode.SYSTEM_TABLE_NODATA.getValue(), SystemCode.SYSTEM_TABLE_NODATA.getText());
        }
        return this.OK_List(applicationsService.getUserApps(fse));
    }
}
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;
    /**
     * æ ¹æ®ä¸šåŠ¡æ•°æ®ï¼ŒæŸ¥è¯¢æ˜¯å¦æœ‰å®¡æ‰¹æµç¨‹ï¼Œ
     * æœ‰åˆ™è¿”回业务审批流程其中一个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);
        }
    }
}
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  æœ‰å¯èƒ½æ˜¯ç±»åž‹ï¼Œæœ‰å¯èƒ½æ˜¯uuid
     * @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);
        }
    }
}
src/main/java/com/product/mobile/core/service/FaceMobileService.java
@@ -182,6 +182,8 @@
            FaceFieldEntity uuid = new FaceFieldEntity();
            FieldSetEntity f = dte.getFieldSetEntity(j);
            if ("pk".equals(f.getString("field_type"))
                    || "created_by".equals(f.getString("field_name"))
                    || "created_utc_datetime".equals(f.getString("field_name"))
                    || "updated_by".equals(f.getString("field_name"))
                    || "updated_utc_datetime".equals(f.getString("field_name"))
                    || "flowsign".equals(f.getString("field_type"))
@@ -197,6 +199,12 @@
            } else {
                uuid.setMultiple("0");
            }
            if ("userids".equals(f.getString("field_type")) || "userid".equals(f.getString("field_type"))) {
                uuid.setOrganizationType("5");
            } else if("orgUuids".equals(f.getString("field_type")) || "orgUuid".equals(f.getString("field_type"))) {
                uuid.setOrganizationType("2");
            }
            uuid.setComponentType("");
            uuid.setPrompt(f.getString("field_reference"));
src/main/java/com/product/mobile/core/service/NavBarManagerService.java
@@ -283,5 +283,5 @@
        }
        return null;
    }
}