Browse Source

api管理提交

chenyongxing 7 years ago
parent
commit
a187e10ad7

+ 59 - 0
src/main/java/com/yihu/hos/fegin/AppApiFegin.java

@ -0,0 +1,59 @@
package com.yihu.hos.fegin;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.hos.core.constants.MicroServices;
import com.yihu.ehr.constants.ServiceApi;
import com.yihu.hos.system.model.AppApi;
import com.yihu.hos.web.framework.constant.SystemContants;
import com.yihu.hos.web.framework.model.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = MicroServices.HosApp)
@RequestMapping(ApiVersion.Version1_0)
public interface AppApiFegin {
    @RequestMapping(value = SystemContants.AppApi.Tree, method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤AppFeature列表(不分页)")
    @ResponseBody
    String tree(@RequestParam(value="appId",required = false) String appId,
                       @RequestParam(value="appName",required = false) String appName,
                       @RequestParam(value="schemaName",required = false) String schemaName);
    @RequestMapping(value = SystemContants.AppApi.GetById, method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取appFeature")
    Envelop getById(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id") Integer id,
            @ApiParam(name = "schemaName", value = "schemaName")
            @RequestParam(value = "schemaName") String schemaName) throws Exception;
    @RequestMapping(value = SystemContants.AppApi.DeleteById, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除AppApi")
    @ResponseBody
    Envelop delete(
            @ApiParam(name = "id", value = "id", defaultValue = "")
            @PathVariable(value = "id") Integer id,
            @RequestParam(value = "schemaName", required = false) String schemaName);
    @RequestMapping(value = SystemContants.AppApi.Create, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    @ApiOperation(value = "创建AppApi")
    AppApi create(
            @ApiParam(name = "json", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String json,
            @RequestParam(value = "schemaName", required = false) String schemaName) throws Exception ;
    @RequestMapping(value = ServiceApi.AppApi.AppApisNoPage, method = RequestMethod.GET)
    @ApiOperation(value = "获取过滤AppFeature列表(不分页)")
    Envelop getApiNoPage(
            @ApiParam(name = "filters", value = "过滤器,为空检索所有条件")
            @RequestParam(value = "filters", required = false) String filters,
            @RequestParam(value = "roleId", required = false) String roleId,
            @RequestParam(value = "schemaName", required = false) String schemaName) throws Exception ;
}

+ 55 - 0
src/main/java/com/yihu/hos/fegin/AppServiceFegin.java

@ -0,0 +1,55 @@
package com.yihu.hos.fegin;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixProperty;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.hos.core.constants.MicroServices;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.web.framework.constant.SystemContants;
import com.yihu.hos.web.framework.model.Envelop;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@FeignClient(name = MicroServices.HosApp)
@RequestMapping(ApiVersion.Version1_0)
public interface AppServiceFegin {
    @RequestMapping(value = SystemContants.AppService.GetById, method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "获取App服务")
    SystemServiceEndpoint getAppService(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id") String id,
            @RequestParam(value = "schemaName", required = false) String schemaName) throws Exception;
    @RequestMapping(value = SystemContants.AppService.Create, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ResponseBody
    @ApiOperation(value = "创建App服务")
    @HystrixCommand(commandProperties = {
            @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "-1"),//超时时间
            @HystrixProperty(name = "execution.timeout.enabled", value = "false") })
    SystemServiceEndpoint create(
            @ApiParam(name = "json", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String json,
            @RequestParam(value = "schemaName", required = false) String schemaName) throws Exception ;
    @RequestMapping(value = SystemContants.AppService.Update, method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @ApiOperation(value = "更新App服务")
    @ResponseBody
    SystemServiceEndpoint update(
            @ApiParam(name = "app", value = "对象JSON结构体", allowMultiple = true)
            @RequestBody String json,
            @RequestParam(value = "schemaName", required = false) String schemaName) throws Exception ;
    @RequestMapping(value = SystemContants.AppService.DeleteById, method = RequestMethod.DELETE)
    @ApiOperation(value = "删除App服务")
    @ResponseBody
    Envelop delete(
            @ApiParam(name = "id", value = "id")
            @PathVariable(value = "id") String id,
            @RequestParam(value = "schemaName", required = false) String schemaName) throws Exception;
}

+ 120 - 0
src/main/java/com/yihu/hos/system/controller/AppApiController.java

@ -0,0 +1,120 @@
package com.yihu.hos.system.controller;
import com.yihu.hos.fegin.AppApiFegin;
import com.yihu.hos.system.model.AppApi;
import com.yihu.hos.web.framework.constant.ContextAttributes;
import com.yihu.hos.web.framework.model.Envelop;
import com.yihu.hos.web.framework.thread.LocalContext;
import com.yihu.hos.web.framework.util.controller.BaseController;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.HashMap;
import java.util.Map;
/**
 * 应用管理
 */
@RequestMapping("/app/api")
@Controller
public class AppApiController extends BaseController {
    @Autowired
    private AppApiFegin appApiFegin;
    /**
     *  跳转到appApi列表页面
     *
     * @param model
     * @return
     */
    @RequestMapping("/initial")
    public String gotoList(Model model, String appId){
        model.addAttribute("appId",appId);
        model.addAttribute("contentPage", "system/app/api/appApi");
        return "partView";
    }
    @RequestMapping(value="/tree",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object tree(String appId, String appName) {
        Map<String, Object> params = new HashMap<>();
        String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
        String tree = appApiFegin.tree(appId, appName, schemaName);
        return tree;
    }
    @RequestMapping(value="/list",produces = "application/json;charset=UTF-8")
    @ResponseBody
    public Object search(String parentId, String appId){
        try{
            Map<String, Object> params = new HashMap<>();
            Map<String, Object> filtersMap = new HashMap<>();
            filtersMap.put("parentId",parentId);
            filtersMap.put("appId",appId);
            String filters = JSONObject.fromObject(filtersMap).toString();
            params.put("filters",filters);
            String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
            Envelop envelop = appApiFegin.getApiNoPage(filters, null, schemaName);
            return toJson(envelop);
        } catch (Exception e) {
            e.printStackTrace();
            Envelop result = new Envelop();
            result.setSuccessFlg(false);
            result.setErrorMsg("系统错误");
            return toJson(result);
        }
    }
    @RequestMapping("/gotoModify")
    public Object gotoModify(Model model, Integer id, String mode, String extParms,String appId,Integer parentId){
        try {
            Envelop envelop = new Envelop();
            Map<String, Object> params = new HashMap<>();
            params.put("id",id);
            params.put("mode",mode);
            params = putAll(extParms, params);
            if (!StringUtils.isEmpty(id)){ //如果id不为空,则通过微服务查询
                String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
                envelop = appApiFegin.getById(id,schemaName);
            }
            Object appApi;
            if(envelop.getObj()==null){
                AppApi tem = new AppApi();
                tem.setAppId(appId);
                tem.setParentId(parentId);
                appApi = tem;
            } else {
                appApi =envelop.getObj();
            }
            model.addAttribute("model",toJson(appApi));
            model.addAttribute("mode",mode);
            model.addAttribute("contentPage", "/system/app/api/dialog");
            if("add".equals(mode)){
                model.addAttribute("flag", "");
            }else {
                model.addAttribute("flag", "disabled");
            }
            model.addAttribute("staged", params.get("staged"));
            return "pageView";
        } catch (Exception e) {
            e.printStackTrace();
            Envelop result = new Envelop();
            result.setSuccessFlg(false);
            result.setErrorMsg("系统错误");
            return result;
        }
    }
}

+ 0 - 145
src/main/java/com/yihu/hos/system/controller/AppController.java

@ -4,7 +4,6 @@ import com.yihu.ehr.constants.ApiVersion;
import com.yihu.hos.config.BeanConfig;
import com.yihu.hos.fegin.AppFegin;
import com.yihu.hos.system.model.SystemApp;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.system.service.AppManager;
import com.yihu.hos.web.framework.constant.ContextAttributes;
import com.yihu.hos.web.framework.model.Envelop;
@ -25,7 +24,6 @@ import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -259,147 +257,4 @@ public class AppController extends BaseController {
        }
    }
    /*  ==================================== 应用服务管理部分 ===================================  */
    @RequestMapping("/initAppService")
    public String AppServiceInit(Model model,String appId) {
        model.addAttribute("appId", appId);
        model.addAttribute("contentPage", "system/app/appService");
        return "partView";
    }
    /**
     * 应用管理
     *   -服务管理页面
     *
     * @param request
     * @return
     */
    @RequestMapping("/getAppServiceList")
    @ResponseBody
    public Result getAppServiceList(HttpServletRequest request, String name, String valid, String appId) {
        try {
            Map<String, Object> params = new HashMap<>();
            params.put("name", name);
            params.put("valid", valid);
            params.put("appId", appId);
            String page = StringUtils.isEmpty(request.getParameter("page")) ? "1" : request.getParameter("page");
            String rows = StringUtils.isEmpty(request.getParameter("rows")) ? "10" : request.getParameter("rows");
            params.put("page", page);
            params.put("rows", rows);
            Result result = appManager.getAppServiceList(params);
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    /**
     * 服务修改页面
     * @param model
     * @param id
     * @return
     */
    @RequestMapping("/editorAppService")
    public String editorAppServicePage(Model model, String id,String appId) {
        try {
            SystemServiceEndpoint appService = null;
            if (id != null && id.length() > 0) {
                appService = appManager.getAppServiceById(id);
            }  else {
                appService = new SystemServiceEndpoint();
            }
            model.addAttribute("model", appService);
            model.addAttribute("appId", appId);
            model.addAttribute("contentPage", "/system/app/editorAppService");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "pageView";
    }
    /**
     * 服务详情页
     * @param model
     * @param id
     * @returnServiceS
     */
    @RequestMapping("/appServiceDetail")
    public String appServiceDetail(Model model, String id) {
        try {
            SystemServiceEndpoint app = null;
            if (id != null && id.length() > 0) {
                app = appManager.getAppServiceById(id);
            }  else {
                app = new SystemServiceEndpoint();
            }
            model.addAttribute("model", app);
            model.addAttribute("contentPage", "/system/app/appServiceDetail");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "pageView";
    }
    /**
     * 新增服务信息
     * @param request
     * @return
     */
    @RequestMapping("addAppService")
    @ResponseBody
    public Result addAppService(HttpServletRequest request) {
        try {
            SystemServiceEndpoint obj = new SystemServiceEndpoint();
            BeanUtils.populate(obj, request.getParameterMap());
            obj.setCreateDate(new Date());
            return appManager.addAppService(obj);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    /**
     * 删除服务信息
     * @param request
     * @return
     */
    @RequestMapping("/deleteAppService")
    @ResponseBody
    public Result deleteAppService(HttpServletRequest request) {
        try {
            String id = request.getParameter("id");
            appManager.deleteAppService(id);
            return Result.success("删除成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("删除失败!");
        }
    }
    /**
     * 修改服务信息
     */
    @RequestMapping("updateAppService")
    @ResponseBody
    public Result updateAppService(HttpServletRequest request) {
        try {
            SystemServiceEndpoint obj = new SystemServiceEndpoint();
            BeanUtils.populate(obj, request.getParameterMap());
            return appManager.updateAppService(obj);
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
}

+ 1 - 3
src/main/java/com/yihu/hos/system/controller/AppFeatureController.java

@ -1,7 +1,6 @@
package com.yihu.hos.system.controller;
import com.yihu.ehr.constants.ApiVersion;
import com.yihu.hos.config.BeanConfig;
import com.yihu.hos.fegin.AppFeatureFegin;
import com.yihu.hos.system.model.AppFeature;
import com.yihu.hos.web.framework.constant.ContextAttributes;
@ -34,8 +33,7 @@ import java.util.Map;
@RequestMapping("/app/feature")
@Controller
public class AppFeatureController extends BaseController {
    @Autowired
    private BeanConfig beanConfig;
    @Autowired
    private RestTemplate restTemplate;

+ 201 - 0
src/main/java/com/yihu/hos/system/controller/AppServiceController.java

@ -0,0 +1,201 @@
package com.yihu.hos.system.controller;
import com.yihu.hos.fegin.AppServiceFegin;
import com.yihu.hos.system.model.SystemServiceEndpoint;
import com.yihu.hos.system.service.AppManager;
import com.yihu.hos.web.framework.constant.ContextAttributes;
import com.yihu.hos.web.framework.model.Result;
import com.yihu.hos.web.framework.thread.LocalContext;
import com.yihu.hos.web.framework.util.controller.BaseController;
import net.sf.json.JSONObject;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
 * 应用管理
 */
@RequestMapping("/app")
@Controller
public class AppServiceController extends BaseController {
    @Resource(name = AppManager.BEAN_ID)
    private AppManager appManager;
    @Autowired
    private AppServiceFegin appServiceFegin;
    @RequestMapping("/initAppService")
    public String AppServiceInit(Model model,String appId) {
        model.addAttribute("appId", appId);
        model.addAttribute("contentPage", "system/app/appService");
        return "partView";
    }
    /**
     * 应用管理
     *   -服务管理页面
     *
     * @param request
     * @return
     */
    @RequestMapping("/getAppServiceList")
    @ResponseBody
    public Result getAppServiceList(HttpServletRequest request, String name, String valid, String appId) {
        try {
            Map<String, Object> params = new HashMap<>();
            params.put("name", name);
            params.put("valid", valid);
            params.put("appId", appId);
            String pageStr = StringUtils.isEmpty(request.getParameter("page")) ? "1" : request.getParameter("page");
            Integer page = Integer.valueOf(pageStr);
            String rowsStr = StringUtils.isEmpty(request.getParameter("rows")) ? "10" : request.getParameter("rows");
            Integer rows = Integer.valueOf(rowsStr);
            params.put("page", page);
            params.put("rows", rows);
            String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
            params.put("schemaName",schemaName);
            //todo 改成从微服务获取列表
            Result result = appManager.getAppServiceList(params);
            return result;
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    /**
     * 服务修改页面
     * @param model
     * @param id
     * @return
     */
    @RequestMapping("/editorAppService")
    public String editorAppServicePage(Model model, String id,String appId) {
        try {
            SystemServiceEndpoint appService = null;
            if (id != null && id.length() > 0) {
                String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
                appService = appServiceFegin.getAppService(id,schemaName);
            }  else {
                appService = new SystemServiceEndpoint();
            }
            model.addAttribute("model", appService);
            model.addAttribute("appId", appId);
            model.addAttribute("contentPage", "/system/app/editorAppService");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "pageView";
    }
    /**
     * 服务详情页
     * @param model
     * @param id
     * @returnServiceS
     */
    @RequestMapping("/appServiceDetail")
    public String appServiceDetail(Model model, String id) {
        try {
            SystemServiceEndpoint app = null;
            if (id != null && id.length() > 0) {
                String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
                app = appServiceFegin.getAppService(id,schemaName);
            }  else {
                app = new SystemServiceEndpoint();
            }
            model.addAttribute("model", app);
            model.addAttribute("contentPage", "/system/app/appServiceDetail");
        } catch (Exception e) {
            e.printStackTrace();
        }
        return "pageView";
    }
    /**
     * 新增服务信息
     * @param request
     * @return
     */
    @RequestMapping("addAppService")
    @ResponseBody
    public Result addAppService(HttpServletRequest request) {
        try {
            SystemServiceEndpoint obj = new SystemServiceEndpoint();
            BeanUtils.populate(obj, request.getParameterMap());
            JSONObject jsonObj = JSONObject.fromObject(obj);
            String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
            SystemServiceEndpoint service = appServiceFegin.create(jsonObj.toString(), schemaName);
            if(service!=null){
                return Result.success("保存成功");
            }else{
                return Result.error("保存失败,应用Code已存在");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
    /**
     * 删除服务信息
     * @param request
     * @return
     */
    @RequestMapping("/deleteAppService")
    @ResponseBody
    public Result deleteAppService(HttpServletRequest request) {
        try {
            String id = request.getParameter("id");
            String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
            appServiceFegin.delete(id, schemaName);
            return Result.success("删除成功!");
        } catch (Exception e) {
            e.printStackTrace();
            return Result.error("删除失败!");
        }
    }
    /**
     * 修改服务信息
     */
    @RequestMapping("updateAppService")
    @ResponseBody
    public Result updateAppService(HttpServletRequest request) {
        try {
            SystemServiceEndpoint obj = new SystemServiceEndpoint();
            BeanUtils.populate(obj, request.getParameterMap());
            JSONObject jsonObj = JSONObject.fromObject(obj);
            String schemaName = LocalContext.getContext().getAttachment(ContextAttributes.SCHEMA);
            SystemServiceEndpoint app = appServiceFegin.update(jsonObj.toString(),schemaName);
            if(app!=null){
                return Result.success("更新成功");
            }else{
                return Result.error("更新失败,应用Code已存在");
            }
        } catch (Exception ex) {
            ex.printStackTrace();
            return Result.error(ex.getMessage());
        }
    }
}

+ 190 - 0
src/main/java/com/yihu/hos/system/model/AppApi.java

@ -0,0 +1,190 @@
package com.yihu.hos.system.model;
import javax.persistence.*;
/**
 * APP_api对象。
 *
 * @author linzhuo
 * @version 1.0
 * @created 2016年7月7日17:45:30
 */
@Entity
public class AppApi {
    private Integer id;
    private String appId;
    private String name;
    private String description;
    private String type;
    private String method;
    private String protocol;
    private String version;
    private Integer parentId;
    private String parameterDemo;
    private String activityType;
    private String responseDemo;
    private String openLevel;
    private String auditLevel;
    private String methodName;
    private String microServiceUri;
    private String msMethodName;
    private String microServiceName;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "id", unique = true, nullable = false)
    public Integer getId() {
        return id;
    }
    public void setId(Integer id) {
        this.id = id;
    }
    @Column(name = "app_id", nullable = true)
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    @Column(name = "name", nullable = true)
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    @Column(name = "description", nullable = true)
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    @Column(name = "type", nullable = true)
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    @Column(name = "method", nullable = true)
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    @Column(name = "protocol", nullable = true)
    public String getProtocol() {
        return protocol;
    }
    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }
    @Column(name = "version", nullable = true)
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    @Column(name = "parent_id", nullable = true)
    public Integer getParentId() {
        return parentId;
    }
    public void setParentId(Integer parentId) {
        this.parentId = parentId;
    }
    @Column(name = "parameter_demo", nullable = true)
    public String getParameterDemo() {
        return parameterDemo;
    }
    public void setParameterDemo(String parameterDemo) {
        this.parameterDemo = parameterDemo;
    }
    @Column(name = "activity_type", nullable = true)
    public String getActivityType() {
        return activityType;
    }
    public void setActivityType(String activityType) {
        this.activityType = activityType;
    }
    @Column(name = "response_demo", nullable = true)
    public String getResponseDemo() {
        return responseDemo;
    }
    public void setResponseDemo(String responseDemo) {
        this.responseDemo = responseDemo;
    }
    @Column(name = "open_level", nullable = true)
    public String getOpenLevel() {
        return openLevel;
    }
    public void setOpenLevel(String openLevel) {
        this.openLevel = openLevel;
    }
    @Column(name = "audit_level", nullable = true)
    public String getAuditLevel() {
        return auditLevel;
    }
    public void setAuditLevel(String auditLevel) {
        this.auditLevel = auditLevel;
    }
    @Column(name = "method_name", nullable = true)
    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
    @Column(name = "micro_service_url", nullable = true)
    public String getMicroServiceUri() {
        return microServiceUri;
    }
    public void setMicroServiceUri(String microServiceUri) {
        this.microServiceUri = microServiceUri;
    }
    @Column(name = "ms_method_name", nullable = true)
    public String getMsMethodName() {
        return msMethodName;
    }
    public void setMsMethodName(String msMethodName) {
        this.msMethodName = msMethodName;
    }
    @Column(name = "micro_service_name", nullable = true)
    public String getMicroServiceName() {
        return microServiceName;
    }
    public void setMicroServiceName(String microServiceName) {
        this.microServiceName = microServiceName;
    }
}

+ 230 - 0
src/main/java/com/yihu/hos/system/model/AppApiModel.java

@ -0,0 +1,230 @@
package com.yihu.hos.system.model;
/**
 * APP_api对象。
 *
 * @author linzhuo
 * @version 1.0
 * @created 2016年7月7日17:45:30
 */
public class AppApiModel {
    private Integer id;
    private String appId;
    private String name;
    private String description;
    private String type;
    private String typeName;
    private String method;
    private String protocol;
    private String version;
    private Integer parentId;
    private String parameterDemo;
    private String activityType;
    private String activityTypeName;
    private String responseDemo;
    private String openLevel;
    private String auditLevel;
    private String openLevelName;
    private String auditLevelName;
    private String methodName;
    private String microServiceUri;
    private String msMethodName;
    private String microServiceName;
    public String getMicroServiceUri() {
        return microServiceUri;
    }
    public void setMicroServiceUri(String microServiceUri) {
        this.microServiceUri = microServiceUri;
    }
    public String getMsMethodName() {
        return msMethodName;
    }
    public void setMsMethodName(String msMethodName) {
        this.msMethodName = msMethodName;
    }
    public String getMicroServiceName() {
        return microServiceName;
    }
    public void setMicroServiceName(String microServiceName) {
        this.microServiceName = microServiceName;
    }
    public String getOpenLevelName() {
        return openLevelName;
    }
    public void setOpenLevelName(String openLevelName) {
        this.openLevelName = openLevelName;
    }
    public String getAuditLevelName() {
        return auditLevelName;
    }
    public void setAuditLevelName(String auditLevelName) {
        this.auditLevelName = auditLevelName;
    }
    /**
     * 界面上适配选中是否适配用做界面展示,代表是否以及被适配
     */
    private Boolean ischecked;
    private String roleId;
    public String getRoleId() {
        return roleId;
    }
    public void setRoleId(String roleId) {
        this.roleId = roleId;
    }
    public Boolean getIschecked() {
        return ischecked;
    }
    public void setIschecked(Boolean ischecked) {
        this.ischecked = ischecked;
    }
    public String getTypeName() {
        return typeName;
    }
    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }
    public String getActivityTypeName() {
        return activityTypeName;
    }
    public void setActivityTypeName(String activityTypeName) {
        this.activityTypeName = activityTypeName;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public String getAppId() {
        return appId;
    }
    public void setAppId(String appId) {
        this.appId = appId;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getType() {
        return type;
    }
    public void setType(String type) {
        this.type = type;
    }
    public String getMethod() {
        return method;
    }
    public void setMethod(String method) {
        this.method = method;
    }
    public String getProtocol() {
        return protocol;
    }
    public void setProtocol(String protocol) {
        this.protocol = protocol;
    }
    public String getVersion() {
        return version;
    }
    public void setVersion(String version) {
        this.version = version;
    }
    public int getParentId() {
        return parentId;
    }
    public void setParentId(int parentId) {
        this.parentId = parentId;
    }
    public String getParameterDemo() {
        return parameterDemo;
    }
    public void setParameterDemo(String parameterDemo) {
        this.parameterDemo = parameterDemo;
    }
    public String getActivityType() {
        return activityType;
    }
    public void setActivityType(String activityType) {
        this.activityType = activityType;
    }
    public String getResponseDemo() {
        return responseDemo;
    }
    public void setResponseDemo(String responseDemo) {
        this.responseDemo = responseDemo;
    }
    public String getOpenLevel() {
        return openLevel;
    }
    public void setOpenLevel(String openLevel) {
        this.openLevel = openLevel;
    }
    public String getAuditLevel() {
        return auditLevel;
    }
    public void setAuditLevel(String auditLevel) {
        this.auditLevel = auditLevel;
    }
    public String getMethodName() {
        return methodName;
    }
    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }
}

+ 3 - 0
src/main/java/com/yihu/hos/system/model/SystemServiceEndpoint.java

@ -1,5 +1,7 @@
package com.yihu.hos.system.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
@ -29,6 +31,7 @@ public class SystemServiceEndpoint implements java.io.Serializable {
    private String metricsEndpoint;
    private Integer valid;
    private String requestFormat;
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+08:00")
    private Date createDate;
    public SystemServiceEndpoint() {

+ 136 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/api/appApi.jsp

@ -0,0 +1,136 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<!--######用户管理页面Title设置######-->
<style>
    .grid_edit {
        display: inline-block;
        width: 40px;
        height: 40px;
        cursor: pointer;
        background: url(/esb/develop/images/bianji01_btn.png) center no-repeat;
    }
    .grid_delete {
        display: inline-block;
        width: 40px;
        height: 40px;
        cursor: pointer;
        background: url(/esb/develop/images/shanchu01_btn.png) center no-repeat;
    }
    .m-grid-body{
        width:100% !important;
    }
    .l-grid-body-inner{
        width:100% !important;
    }
    .l-grid-body-table{
        width:100% !important;
    }
    .l-grid-row-cell-inner{
        width:100% !important;
    }
    .row-icon{
        width: 16px;
        height: 16px;
        float: left;
        margin-top: 12px;
        margin-right: 10px;
        margin-left: 5px;
    }
    .image-create{
        display: inline-block;
        margin-left: -4px;
        margin-top: 10px;
        width: 20px;
        height: 30px;
        background: url(${staticRoot}/images/tianjia_btn.png) no-repeat;
    }
    .image-create:hover{
        cursor: pointer;
        background: url(${staticRoot}/images/tianjia_pre.png) no-repeat;
    }
    .retrieve-border{
        display:block;
        border: 1px solid #D6D6D6;
        border-bottom: 0px
    }
    .l-tree .l-tree-text-height{
        height: 22px;
        line-height: 22px;
    }
    .l-tree span{
        height: 22px;
        line-height: 22px;
    }
    .body-head input{
        border: 0;
        font-size: 12px;
        width: 120px;
    }
    .back{
        border-right: 1px solid #d3d3d3;
    }
    .l-grid-tree-content div{
        line-height: 40px;
     }
    #div_right .l-grid-row-cell .l-grid-row-cell-inner div{
        line-height: 40px;
        text-align: center;
    }
</style>
<!-- ####### 页面部分 ####### -->
<div>
    <div id="div_wrapper">
        <%--<div id="conditionArea" class="f-mb10 f-mr10" align="right">
            <div class="body-head f-h30" align="left" style="line-height: 30px">
                <a id="btn_back" class="f-fwb">返回上一层 </a>
            </div>
        </div>--%>
        <div id="grid_content" style="width: 100%">
            <!--   属性菜单 -->
            <div id="div_left" style=" width:360px;float: left;">
                <div id="l_searchForm" style="border: 1px solid rgb(214, 214, 214); border-bottom: none"
                     class="m-retrieve-area f-h50 f-pr m-form-inline condition" data-role-form>
                    <div class="m-retrieve-inner m-form-group f-mt10 l-tools" style="margin-left: 10px;">
                        <div class="m-form-control">
                            <input type="text" id="l_search_name" placeholder="请输入关键词" class="f-ml10" data-attr-scan="name"/>
                        </div>
                    </div>
                </div>
                <div id="treeMenuWrap" style="border: 1px solid #D6D6D6; width: 360px; height: 100px; overflow: hidden">
                    <div style="width: 360px">
                        <div id="treeMenu" style="margin-top: -42px;  "></div>
                    </div>
                </div>
            </div>
            <!--   列表   -->
            <div id="div_right" style="float: left;width: 700px;margin-left: 10px">
                <div id="r_searchForm" style="border: 1px solid rgb(214, 214, 214); border-bottom: none"
                     class="m-retrieve-area f-h50 f-pr m-form-inline condition" data-role-form>
                    <div class="m-retrieve-inner m-form-group f-mt10 r-tools" style="margin-left: 10px;">
                        <input type="hidden" id="parentId" data-attr-scan="parentId">
                        <div class="m-form-control">
                            <input type="text" id="r_search_name" placeholder="请输入名称" class="f-ml10" data-attr-scan="name"/>
                        </div>
                        <div class="m-form-control f-ml10">
                            <input type="text" id="r_search_open_lv"  placeholder="开放程度" data-type="select" data-attr-scan="openLevel">
                        </div>
                    </div>
                </div>
                <div id="rightGrid"></div>
            </div>
        </div>
    </div>
</div>

+ 53 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/api/appApiCss.jsp

@ -0,0 +1,53 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="utf-8"%>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<style>
    .image-create{
        display: inline-block;
        margin-left: -4px;
        margin-top: 10px;
        width: 20px;
        height: 30px;
        background: url(${staticRoot}/images/tianjia_btn.png) no-repeat;
    }
    .image-create:hover{
        cursor: pointer;
        background: url(${staticRoot}/images/tianjia_pre.png) no-repeat;
    }
    .retrieve-border{
        display:block;
        border: 1px solid #D6D6D6;
        border-bottom: 0px
    }
    .l-tree .l-tree-text-height{
        height: 22px;
        line-height: 22px;
    }
    .l-tree span{
        height: 22px;
        line-height: 22px;
    }
    .body-head input{
        border: 0;
        font-size: 12px;
        width: 120px;
    }
    .back{
        border-right: 1px solid #d3d3d3;
    }
    .l-grid-row-hide{display: none !important}
    .row-icon{
        width: 16px;
        height: 16px;
        float: left;
        margin-top: 12px;
        margin-right: 10px;
        margin-left: 5px;
    }
</style>

+ 384 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/api/appApiJs.jsp

@ -0,0 +1,384 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<script src="${staticRoot}/lib/ehrjs/formFieldTools.js"></script>
<script src="${staticRoot}/lib/ehrjs/ligerGridEx.js"></script>
<script src="${staticRoot}/lib/plugin/scrollbar/jquery.mCustomScrollbar.js"></script>
<script src="${staticRoot}/lib/module/pubsub.js"></script>
<script src="${staticRoot}/lib/ehrjs/gridTools.js"></script>
<script src="${staticRoot}/lib/ehrjs/searchTree.js"></script>
<script src="${staticRoot}/lib/ehrjs/toolBar.js"></script>
<script src="${staticRoot}/lib/ligerui/plugins/ligerGrid.js"></script>
<script src="${staticRoot}/lib/module/ajax.js"></script>
<script src="${staticRoot}/lib/module/baseObject.js"></script>
<script src="${staticRoot}/lib/module/dataModel.js"></script>
<script src="${staticRoot}/lib/plugin/notice/topNotice.js"></script>
<style>
    .row-icon{
        width: 16px;
        height: 16px;
        float: left;
        margin-top: 12px;
        margin-right: 10px;
        margin-left: 5px;
    }
    .image-create{
        display: inline-block;
        margin-left: -4px;
        margin-top: 10px;
        width: 20px;
        height: 30px;
        background: url(${staticRoot}/images/tianjia_btn.png) no-repeat;
    }
    .image-create:hover{
        cursor: pointer;
        background: url(${staticRoot}/images/tianjia_pre.png) no-repeat;
    }
    .retrieve-border{
        display:block;
        border: 1px solid #D6D6D6;
        border-bottom: 0px
    }
    .l-tree .l-tree-text-height{
        height: 22px;
        line-height: 22px;
    }
    .l-tree span{
        height: 22px;
        line-height: 22px;
    }
    .body-head input{
        border: 0;
        font-size: 12px;
        width: 120px;
    }
    .back{
        border-right: 1px solid #d3d3d3;
    }
</style>
<script>
    var Util = $.Util;
    var openedDialog;
    var appId = '${appId}';
    var contentH = $('.l-layout-center').height();
    var parms = {"appId":appId};
    var urls = {
        gotoModify: '${contextRoot}/app/api/gotoModify',
        tree: '${contextRoot}/app/api/tree',
        list: '${contextRoot}/app/api/list',
        del: '${contextRoot}/app/api/delete',
        apiEdit: "${contextRoot}/app/api/edit",
        existence: "${contextRoot}/app/api/existence"
    };
    var initSub = function () {
        $('#btn_back').click(function () {
            $('#contentPage').empty();
            $('#contentPage').load('${contextRoot}/app/initial', {dataModel: 1});
        });
    }();
    function searchParent(searchDoms){
        var parent = [], p = null;
        $.each(searchDoms, function (i, v) {
            $(v).removeClass('l-grid-row-hide');
            if(( p = master.tree.getParent( v )))
                parent.push(master.tree.getRowObj(p));
        })
        if(parent.length>0)
            searchParent(parent);
    }
    var master = {
        tree: undefined,
        dialog: undefined,
        init: function () {
            var m = this;
            m.filters();
            m.rendTreeGrid();
        },
        searchFun: function (t) {
            var name = $('#l_search_name').val();
            sessionStorage.setItem("appApiTreeParm", name);
            var treeDom = master.tree.grid;
            var allrow =  $('.l-grid-row', treeDom);
            if(name==''){
                allrow.removeClass('l-grid-row-hide');
                allrow.show();
                $('.l-grid-body.l-grid-body2.l-scroll', treeDom).height($('.l-grid-row:visible', treeDom).length * 41);
            }else{
                master.tree.expandAll();
                allrow.addClass('l-grid-row-hide');
                var searchDoms = $('.l-grid-row-cell-inner[title*="'+ name +'"]', treeDom).parent().parent();
                searchParent(searchDoms);
            }
            if(!t){
                $('.l-grid-body-inner', $('#rightGrid')).empty();
                $('.l-grid-body.l-grid-body1', $('#rightGrid')).empty();
            }
        },
        filters: function(){
            var vo = [{type: 'text', id: 'l_search_name', searchFun: master.searchFun}];
            initFormFields(vo, $('.l-tools'));
        },
        rendTreeGrid: function () {
            this.tree = $("#treeMenu").ligerGrid($.LigerGridEx.config({
                rownumbers: false,
                allowAdjustColWidth: false,
                usePager: false,
                height: contentH - 12,
                tree: {columnId: 'name'},
                url: urls.tree,
                parms: parms,
                columns: [
                    {
                        display: '组织结构名称', name: 'name', id: 'name', align: 'left', width: '290',
                        render: function (row) {
                            var iconName = "";
                            switch (parseInt(row.type)){
                                case -1: iconName= '1ji_icon'; break;
                                case 0: iconName= '3ji_icon'; break;
                                case 2: iconName= '2ji_icon'; break;
                                default : iconName= '3ji_icon';
                            }
                            return '<img src="${contextRoot}/develop/images/'+ iconName +'.png" class="row-icon">'
                                +'<div id="t_'+ row.id +'">'+ row.name +'</div>';
                        }
                    },
                    {
                        display: '操作', name: 'operator', align: 'left', width: '70', render: function (row) {
                        var html =
                            '<a class="image-create" href="#" title="新增" ' +
                            'onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}','{3}','{4}', '{5}', '{6}'])", "app:plf:api:modify", row.id, 'add', row.type, 0, row.__id, row.appId) + '"></a>';
                        if(row.id>0){
                            html +=  '<a class="grid_delete" href="#" style="width: 30px; margin-left:4px" title="删除" ' +
                                'onclick="javascript:' + Util.format("$.publish('{0}',['{1}', '{2}', '{3}'])", "app:plf:api:del", row.id, 0, row.__id) + '"></a>';
                        }
                        return html;
                    }
                    }
                ],
                onSelectRow: function (rowData, rowId, rowObj) {
                    sessionStorage.setItem("appApiTreeSelId", rowData.id);
                    em.find(rowData.id);
                },
                onDblClickRow: function (rowData, rowId, rowObj) {
                    if( rowData.id &&  rowData.id>0)
                        em.gotoModify(undefined, rowData.id, 'view', rowData.type, 0, rowId);
                },
                onAfterShowData: function () {
                    if(appId==1){
                        var appApiEm = sessionStorage.getItem("appApiEm");
                        if(appApiEm){
                            appApiEm = eval('('+appApiEm +')');
                            fillForm(appApiEm, $('#r_searchForm'));
                        }
                        $('#l_search_name').val(sessionStorage.getItem("appApiTreeParm") || '');
                        master.searchFun(1);
                        var selId = sessionStorage.getItem("appApiTreeSelId");
                        if(selId){
                            var rowDom = $('#t_'+selId, master.tree.tree).parent().parent().parent().parent().parent();
                            master.tree.select(rowDom.attr('id').split('|')[2]);
                        }
                    }
                }
            }));
        }
    }
    var em = {
        grid: undefined, dialog: undefined, params: {},
        //初始化
        init: function () {
            var m = this;
            m.filters();
            m.rendGrid();
            m.publishFunc();
        },
        filters: function(){
            var vo = [
                {type: 'text', id: 'r_search_name'},
                {type: 'select', id: 'r_search_open_lv', opts:{width: 140}, dictId: 40},
                {type: 'searchBtn', id: 'search_btn', searchFun: em.find}
            ];
            initFormFields(vo, $('.r-tools'));
        },
        //初始化表格
        rendGrid: function () {
            var m = em;
            var columns = [
                {display: 'ID', name: 'id', hide: true},
                {display: '名称', name: 'name', width: '35%', align: 'left'},
                {display: '描述', name: 'description', width: '35%', align: 'left'},
                {display: '开放程度', name: 'openLevelName', width: '10%', align: 'left'},
                {display: '操作', name: 'operator', width: '20%', render: m.opratorRender}];
            m.grid = initGrid($('#rightGrid'), urls.list, {}, columns, {
                delayLoad: true,
                rownumbers: true,
                usePager: false,
                heightDiff: 20,
                checkbox: false,
                onDblClickRow: function (rowData, rowId, rowObj) {
                    if( rowData.id &&  rowData.id>0)
                        em.gotoModify(undefined, rowData.id, 'view', rowData.type, 0, rowId);
                }
            });
        },
        //操作栏渲染器
        opratorRender: function (row) {
            var vo = [
                {
                    type: 'edit',
                    clkFun: "$.publish('app:plf:api:modify',['" + row['id'] + "', 'modify', '" + row['type'] + "', '1', '"+ row.__id +"'])"
                },
                {type: 'del', clkFun: "$.publish('app:plf:api:del',['" + row['id'] + "', 1, '" + row.__id + "', '" + row.parentId + "', '" + row.type + "'])"}
            ];
            return initGridOperator(vo);
        },
        //修改、新增点击事件
        gotoModify: function (event, id, mode, type, frm, rowId, appId) {
            if(type==1){
                var obj = em.grid.getRow(rowId);
                var url = urls.apiEdit + '?treePid=1&treeId=11&mode='+ mode;
                $("#contentPage").empty();
                $("#contentPage").load(url, obj);
            }else{
                var params;
                if(mode == 'add'){
                    em.params = {upType: type, upId: id, frm: frm, rowId: rowId, appId: appId}
                    params = {mode: mode}
                }else{
                    em.params = {frm: frm,  rowId: rowId}
                    params = {id: id, mode: mode, rowId: rowId}
                }
                var title = mode=='add'?'新增': mode=='modify'? '修改': '查看';
                em.dialog = $.ligerDialog.open({
                    height: 600,
                    width: 500,
                    title: title,
                    url: urls.gotoModify,
                    //load: true,
                    urlParms: params
                });
            }
        },
        del: function (event, id, frm, rowId, parentId, type) {
            function del(){
                $.ligerDialog.confirm("确定删除?", function (yes) {
                    if (yes){
                        var dialog = $.ligerDialog.waitting('正在处理中,请稍候...');
                        var dataModel = $.DataModel.init();
                        dataModel.updateRemote(urls.del, {
                            data: {ids: id, idField: "id", type: "uniq"},
                            success: function (data) {
                                if (data.successFlg) {
                                    $.Notice.success('删除成功!');
                                    if(frm==0)
                                        master.tree.remove(master.tree.getRow(rowId));
                                    else{
                                        if(type==1){
                                            em.grid.remove(em.grid.getRow( rowId ));
                                        }else{
                                            var cell = $('#t_'+ id, $('#treeMenu')).parent().parent().parent().parent();
                                            var treeRowId = $(cell).attr('id').split('|')[2];
                                            master.tree.remove( master.tree.getRow( treeRowId ) );
                                            cell = $('#t_'+ parentId, $('#treeMenu')).parent().parent().parent().parent();
                                            treeRowId = $(cell).attr('id').split('|')[2];
                                            master.tree.select( master.tree.getRow( treeRowId ) );
                                        }
                                    }
                                } else {
                                    $.Notice.error(data.errorMsg);
                                }
                            },
                            complete: function () {dialog.close();},
                            error: function(){$.Notice.error('请求错误!');}
                        });
                    }
                });
            }
            var dataModel = $.DataModel.init();
            dataModel.updateRemote(urls.existence, {
                data: {filters: "parentId="+id},
                success: function (data) {
                    if (data.successFlg) {
                        if(data.detailModelList.length==0)
                            del();
                        else
                            $.Notice.error("该删除项存在子项,请先删除子项!");
                    } else {
                        $.Notice.error("验证错误!");
                    }
                },
                error: function(){$.Notice.error('请求出错!');}
            });
        },
        //查询列表方法
        find: function (parentId) {
            if(parentId>=0 || parentId==-1)
                $('#parentId').val(parentId);
            var vo = [
                {name: 'name', logic: '?'},
                {name: 'openLevel', logic: '='},
                {name: 'parentId', logic: '='}];
            var $form = $('#r_searchForm');
            $form.attrScan();
            sessionStorage.setItem("appApiEm", JSON.stringify($form.Fields.getValues()));
            var params = {filters: covertFilters(vo, $form), page: 1, rows: 999};
            reloadGrid(em.grid, 1, params);
        },
        publishFunc: function () {
            var m = em;
             $.subscribe('app:plf:api:modify', m.gotoModify);
             $.subscribe('app:plf:api:del', m.del);
        }
    }
    window.closeDialog = function (msg, data) {
        openedDialog.close();
        if (msg)
            $.Notice.success(msg);
        if(data){
            if(em.params.frm==0){
                if(data.obj.type==1){
                    em.grid.appendRow(data.obj);
                }else{
                    var parent = master.tree.getRow(em.params.rowId);
                    master.tree.appendRow(data.obj, parent);
                    master.tree.select(parent);
                }
            }else{
                var rowDom = em.grid.getRow(em.params.rowId);
                em.grid.updateRow(rowDom, data.obj);
                if(data.obj.type!=1){
                    rowDom = master.tree.getRow($('#t_'+ data.obj.id, $('#treeMenu')).parent().parent().parent().parent().attr('id').split('|')[2]);
                    master.tree.updateRow(rowDom, data.obj);
                }
            }
        }
    }
    var resizeContent = function () {
        var contentW = $('#grid_content').width();
        var leftW = $('#div_left').width();
        $('#div_right').width(contentW - leftW - 20);
        $('#treeMenuWrap').height(contentH - 104);
        $('#treeMenu').height(contentH - 64);
    };
    $(function () {
        resizeContent();
        //窗体改变大小事件
        $(window).bind('resize', resizeContent);
        em.init();
        master.init();
    });
</script>

+ 96 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/api/dialog.jsp

@ -0,0 +1,96 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="utf-8"%>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<div id="infoForm" data-role-form class="m-form-inline f-mt20">
  <input type="hidden" data-attr-scan="id">
  <input type="hidden" id="appId" data-attr-scan="appId">
  <input type="hidden" id="parentId" data-attr-scan="parentId">
  <div class="m-form-group">
    <label>名称<spring:message code="spe.colon"/></label>
    <div class="l-text-wrapper m-form-control essential">
      <input type="text" id="ipt_api_name" class="required ajax"  data-attr-scan="name">
    </div>
  </div>
  <div id="methodNameDiv" class="m-form-group">
    <label>方法名<spring:message code="spe.colon"/></label>
    <div class="l-text-wrapper m-form-control essential apiProto">
      <input type="text" id="ipt_api_methodName" class="required"  data-attr-scan="methodName">
    </div>
  </div>
  <div class="m-form-group">
    <label>类别<spring:message code="spe.colon"/></label>
    <div class="l-text-wrapper m-form-control essential f-pr0">
      <input type="text" id="ipt_api_type" data-type="select" class="required" data-attr-scan="type">
    </div>
  </div>
  <div class="m-form-group">
    <label>开放程度<spring:message code="spe.colon"/></label>
    <div class="l-text-wrapper m-form-control essential f-pr0">
      <input type="text" id="ipt_api_openLevel" data-type="select" class="required" data-attr-scan="openLevel">
    </div>
  </div>
  <div class="m-form-group">
    <label>审计程度<spring:message code="spe.colon"/></label>
    <div class="l-text-wrapper m-form-control essential f-pr0">
      <input type="text" id="ipt_api_auditLevel" data-type="select" class="required" data-attr-scan="auditLevel">
    </div>
  </div>
  <div class="m-form-group">
    <label>状态<spring:message code="spe.colon"/></label>
    <div class="l-text-wrapper m-form-control essential f-pr0">
      <input type="text" id="ipt_api_activityType" data-type="select" class="required" data-attr-scan="activityType">
    </div>
  </div>
  <div>
    <div class="m-form-group">
      <label>版本<spring:message code="spe.colon"/></label>
      <div class="l-text-wrapper m-form-control essential apiProto">
        <input type="text" id="ipt_api_version" class="required"  data-attr-scan="version">
      </div>
    </div>
    <div class="m-form-group">
      <label>协议<spring:message code="spe.colon"/></label>
      <div class="l-text-wrapper m-form-control essential apiProto">
        <input type="text" id="ipt_api_protocol" data-type="select" class="required" data-attr-scan="protocol">
      </div>
    </div>
    <div class="m-form-group">
      <label>方法<spring:message code="spe.colon"/></label>
      <div class="l-text-wrapper m-form-control essential apiProto">
        <input type="text" id="ipt_api_method" data-type="select" class="required" data-attr-scan="method">
      </div>
    </div>
    <div class="m-form-group">
      <label>描述<spring:message code="spe.colon"/></label>
      <div class="l-text-wrapper m-form-control essential">
        <textarea id="ipt_api_description" class="required" data-attr-scan="description">
          </textarea>
      </div>
    </div>
  </div>
  <div class="m-form-group f-pa update-footer">
    <div class="m-form-control">
      <div id="btn_save" class="l-button u-btn u-btn-primary u-btn-large f-ib f-vam f-mr10" >
        <span>保存</span>
      </div>
      <div id="btn_cancel" class="l-button u-btn u-btn-cancel u-btn-large f-ib f-vam f-mr10" >
        <span>关闭</span>
      </div>
    </div>
  </div>
</div>

+ 8 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/api/dialogCss.jsp

@ -0,0 +1,8 @@
<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="utf-8"%>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<style>
    .m-form-inline .m-form-group label{ width: 130px; }
    .update-footer{right: 10px;bottom: 0;}
    .add-image{margin-top: 4px;}
</style>

+ 175 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/api/dialogJs.jsp

@ -0,0 +1,175 @@
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" %>
<%@include file="/WEB-INF/ehr/commons/jsp/commonInclude.jsp" %>
<script type="text/javascript">
        var urls = {
            update: "${contextRoot}/app/api/update",
            existence: "${contextRoot}/app/api/existence",
            apiEdit: "${contextRoot}/app/api/edit",
            list: "${contextRoot}/app/api/list",
            appCombo: "${contextRoot}/app/platform/list"
        }
        var model = ${model};
        var mode = '${mode}';
        //todo cyx 从上个页面获取信息
        //var extParms = getEditParms();//其他信息
        var hasChildType;
        var getChild = function (){
            if(mode=='modify' || mode=='view' || extParms.upType==-1)
                return;
            $.ajax({
                url: urls.list,
                async: false,
                data:{page: 1, rows: 1, filters: "parentId="+ extParms.upId},
                success: function (data) {
                    data = eval('('+ data +')');
                    if(!data.successFlg){
                        $.Notice.error("数据请求错误,请刷新页面或联系管理员!");
                        throw new Error("数据请求错误,请刷新页面或联系管理员!");
                        return;
                    }
                    if(data.detailModelList.length>0){
                        hasChildType = data.detailModelList[0].type;
                    }
                },
                error: function () {
                    $.Notice.error("链接请求错误,请刷新页面或联系管理员!");
                    throw new Error("链接请求错误,请刷新页面或联系管理员!");
                }
            })
        }();
        var $form =  $("#infoForm");
        var validator;
        function initValidation(){
            validator = initValidate($form, function (elm) {
                var field = $(elm).attr('id');
                var val = $('#' + field).val();
                if(field=='ipt_api_name' && val!=model.name){
                    return uniqValid4List(urls.existence, "name="+val+" g1;parentId="+ model.parentId, "该应用代码已存在!");
                }
            });
        }
        var appCombo;
        var initForm = function () {
            var vo = [
                {type: 'text', id: 'ipt_api_description', opts: {height: 100}},
                {type: 'select', id: 'ipt_api_type', dictId: 46, opts: {disabled: mode=='modify', onSuccess: function (data) {
                        if(mode=='new'){
                            var newData = [];
                            switch (parseInt(extParms.upType)){
                                case -1: $.each(data, function (i, v) {if(v.code==2) newData.push(v);}); break;
                                case 0: ;
                                case 2: $.each(data, function (i, v) {
                                    if(!hasChildType){if(v.code==0 || v.code==1) newData.push(v);}
                                    else if(hasChildType==v.code) newData.push(v);
                                }); break;
                                default: newData = data;
                            }
                            this.setData(newData);
                            this.selectItemByIndex(0);
                        }
                    }, onSelected: function (v, t) {
                        var version = $('#ipt_api_version').ligerGetTextBoxManager();
                        var protocol = $('#ipt_api_protocol').ligerGetCheckBoxManager();
                        var method = $('#ipt_api_method').ligerGetCheckBoxManager();
                        var methodName = $('#ipt_api_methodName').ligerGetTextBoxManager();
                        if(v==1){
                                $('.apiProto').addClass("essential").find('input').addClass('required');
                                version.setEnabled(true);
                                protocol.setEnabled(true);
                                method.setEnabled(true);
                                methodName.setEnabled(true);
                        } else{
                            $('.apiProto').removeClass("essential").find('input').removeClass('required');
                            version.setDisabled(true);
                            protocol.setDisabled(true);
                            method.setDisabled(true);
                            methodName.setDisabled(true);
                            version.setValue('');
                            protocol.setValue('');
                            method.setValue('');
                            methodName.setValue('');
                        }
                        validator.reset();
                    }
                }},
                {type: 'select', id: 'ipt_api_openLevel', dictId: 40, opts:{initVal: mode=='new'? '1': undefined}},
                {type: 'select', id: 'ipt_api_auditLevel', dictId: 41, opts:{initVal: mode=='new'? '1': undefined}},
                {type: 'select', id: 'ipt_api_activityType', dictId: 43},
                {type: 'text', id: 'ipt_api_version'},
                {type: 'select', id: 'ipt_api_protocol', dictId: 44},
                {type: 'select', id: 'ipt_api_method', dictId: 45},
                {type: 'text', id: 'ipt_api_methodName'}
            ];
            if(extParms.upType==-1 || model.type==2)
                appCombo = $('#ipt_api_name').customCombo(
                        urls.appCombo, {fields: 'id,name', filters: 'sourceType=1'}, function (id, name) {
                            if(mode=='new')
                                $('#ipt_api_name').blur();
                            if(appCombo.getLigerComboBox().getSelected())
                                $('#appId').val(appCombo.getLigerComboBox().getSelected().id);
                        }, undefined, false, {selectBoxHeight: 280, valueField: 'name', disabled: mode=='modify',
                            conditionSearchClick: function(g){
                                var searchParm = g.rules.length > 0 ? g.rules[0].value : '';
                                var parms = g.grid.get("parms");
                                parms.filters = 'sourceType=1;';
                                if(searchParm)
                                    parms.filters += 'name?'+searchParm+' g1';
                                g.grid.set({
                                    parms: parms,
                                    newPage: 1
                                });
                                g.grid.reload();
                            }});
            else
                vo.push({type: 'text', id: 'ipt_api_name'});
            initFormFields(vo);
        };
        var initBtn = function () {
            initValidation();
            $('#btn_save').click(function () {
                saveForm({url: urls.update, $form: $form, modelName: 'model', validator: validator,
                    onSuccess: function (data) {
                        data.obj.openLevelName = $('#ipt_api_openLevel').ligerGetComboBoxManager().findTextByValue(data.obj.openLevel);
                        if(data.obj.type==1){
                            $.Notice.confirm("保存成功,是否继续编辑接口详细信息?", function (y) {
                                if(y){
                                    var url = urls.apiEdit + '?treePid=1&treeId=11&mode=modify';
                                    closeDialog();
                                    $("#contentPage").empty();
                                    $("#contentPage").load(url, data.obj);
                                }else
                                    closeDialog(undefined, data);
                            })
                        }else
                            closeDialog("保存成功!", data);
                    }});
            });
            $('#btn_cancel').click(function () {
                closeDialog();
            });
        };
        var init = function () {
            if(mode=='new'){
                model.parentId = extParms.upId;
                model.appId = extParms.appId;
            }
            initForm();
            initBtn();
            fillForm(model, $('#infoForm'));
            if(mode=='modify' && appCombo){
                appCombo.setValueText(model.appId, model.name);
            }else if(mode=='view'){
                $('#infoForm').addClass('m-form-readonly');
                $('#btn_save').hide();
            }
        }();
</script>

+ 8 - 0
src/main/webapp/WEB-INF/ehr/jsp/system/app/appJs.jsp

@ -51,6 +51,8 @@
                        html += "<a class=\"m-btn\" style=\"padding-right:10px\" onclick=\"app.editorDialog('"+row.id+"','disabled')\">查看详情</a>";
                        html += "<a class=\"m-btn\" style=\"padding-right:10px\" onclick=\"app.appServiceManage('"+row.id+"')\">服务管理</a>";
                        html += "<a class=\"m-btn\" style=\"padding-right:10px\" onclick=\"app.appFunctionManage('"+row.id+"','"+row.name+"')\">功能管理</a>";
                        html += "<a class=\"m-btn\" style=\"padding-right:10px\" onclick=\"app.apiManage('"+row.id+"','"+row.name+"')\">API管理</a>";
                        //html += '<a class="label_a" style="margin-left:10px"  href="javascript:void(0)" onclick="javascript:' + Util.format("$.publish('{0}',['{1}','{2}','{3}'])", "app:api:manager", row.id,row.name) + '">
//                        html += "<a class=\"m-btn\"  onclick=\"app.dialogDetail('"+row.id+"')\">应用标准</a>";
                        html += "<a class=\"m-btn-edit\" onclick=\"app.editorDialog('"+row.id+"','')\"></a>";
                        html += "<a class=\"m-btn-delete\" onclick=\"app.delete('"+row.id+"','"+row.icon+"')\"></a>";
@ -170,6 +172,12 @@
            }
            indexPage.openChildPage("",'${contextRoot}/app/feature/initial','',data);
        },
        apiManage:function(id){
            var data = {
                'appId':id
            }
            indexPage.openChildPage("",'${contextRoot}/app/api/initial','',data);
        },
        anthorize: function (id) {
        },

+ 3 - 4
src/main/webapp/WEB-INF/ehr/jsp/system/app/feature/appFeatureJs.jsp

@ -343,14 +343,13 @@
    $(window).bind('resize', resizeContent);
    window.getEditParms = function () {
        return em.params;
    }
    $(function () {
        em.init();
        master.init();
        window.getEditParms = function () {
            return em.params;
        }
    });
</script>

+ 17 - 17
src/main/webapp/develop/lib/ehrjs/formFieldTools.js

@ -74,23 +74,23 @@ function initSelDom(el, url, params, opts){
 * @returns {ligerComboBox}
 */
function initSystemSelDom(el, dictId, opts){
    var defaultOpts = {
        url: $.Context.PATH + '/dict/searchDictEntryList',
        valueField: 'code',
        textField: 'value',
        dataParmName: 'detailModelList',
        parms: {dictId: dictId, page: 1, rows: 500}
    };
    opts = $.extend({}, defaultOpts, opts);
    if(opts.initVal){
        var onSucFun = opts.onSuccess;
        opts.onSuccess = function(data){
            this.selectValue(opts.initVal);
            if(onSucFun)
                this.call(onSucFun, data);
        }
    }
    return $(el).ligerComboBox(opts);
    // var defaultOpts = {
    //     url: $.Context.PATH + '/dict/searchDictEntryList',
    //     valueField: 'code',
    //     textField: 'value',
    //     dataParmName: 'detailModelList',
    //     parms: {dictId: dictId, page: 1, rows: 500}
    // };
    // opts = $.extend({}, defaultOpts, opts);
    // if(opts.initVal){
    //     var onSucFun = opts.onSuccess;
    //     opts.onSuccess = function(data){
    //         this.selectValue(opts.initVal);
    //         if(onSucFun)
    //             this.call(onSucFun, data);
    //     }
    // }
    // return $(el).ligerComboBox(opts);
}
function initValidate($form, onElementValidateForAjax){