|
@ -1,9 +1,13 @@
|
|
|
package com.yihu.hos.system.controller;
|
|
|
|
|
|
import com.yihu.hos.system.model.SystemApp;
|
|
|
import com.yihu.hos.system.model.SystemServiceEndpoint;
|
|
|
import com.yihu.hos.system.service.intf.IAppManager;
|
|
|
import com.yihu.hos.web.framework.model.Result;
|
|
|
import com.yihu.hos.web.framework.util.controller.BaseController;
|
|
|
import com.yihu.hos.system.service.intf.IAppManager;
|
|
|
import org.apache.commons.beanutils.BeanUtils;
|
|
|
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;
|
|
@ -22,25 +26,288 @@ public class AppController extends BaseController {
|
|
|
@Resource(name = "appManager")
|
|
|
private IAppManager appManager;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 应用管理管理界面
|
|
|
*
|
|
|
* @param model
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/initial")
|
|
|
public String appInitial(Model model) {
|
|
|
model.addAttribute("contentPage", "system/app/app");
|
|
|
return "partView";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 系统参数列表
|
|
|
* 应用列表
|
|
|
*
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/getAppList")
|
|
|
@ResponseBody
|
|
|
public Result getAppList(HttpServletRequest request) {
|
|
|
public Result getAppList(HttpServletRequest request,String name,String status) {
|
|
|
try {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("name", name);
|
|
|
params.put("status", status);
|
|
|
|
|
|
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.getAppList(params);
|
|
|
return result;
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return Result.error(ex.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 应用-新增/修改页面
|
|
|
* @param model
|
|
|
* @param id
|
|
|
* @param categoryId
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/editorApp")
|
|
|
public String editorAppTemplate(Model model, String id, String categoryId) {
|
|
|
try {
|
|
|
SystemApp app = null;
|
|
|
if (id != null && id.length() > 0) {
|
|
|
app = appManager.getAppById(id);
|
|
|
} else {
|
|
|
app = new SystemApp();
|
|
|
}
|
|
|
model.addAttribute("model", app);
|
|
|
model.addAttribute("categoryId", categoryId);
|
|
|
model.addAttribute("contentPage", "/system/app/editorApp");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return "pageView";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 应用详情页
|
|
|
* @param model
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/appDetail")
|
|
|
public String appDetail(Model model, String id) {
|
|
|
try {
|
|
|
SystemApp app = null;
|
|
|
if (id != null && id.length() > 0) {
|
|
|
app = appManager.getAppById(id);
|
|
|
} else {
|
|
|
app = new SystemApp();
|
|
|
}
|
|
|
model.addAttribute("model", app);
|
|
|
model.addAttribute("contentPage", "/system/app/appDetail");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return "pageView";
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 新增应用信息
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("addApp")
|
|
|
@ResponseBody
|
|
|
public Result addApp(HttpServletRequest request) {
|
|
|
try {
|
|
|
SystemApp obj = new SystemApp();
|
|
|
BeanUtils.populate(obj, request.getParameterMap());
|
|
|
|
|
|
return appManager.addApp(obj);
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return Result.error(ex.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除应用信息
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/deleteApp")
|
|
|
@ResponseBody
|
|
|
public Result deleteApp(HttpServletRequest request) {
|
|
|
|
|
|
try {
|
|
|
String id = request.getParameter("id");
|
|
|
appManager.deleteApp(id);
|
|
|
return Result.success("删除成功!");
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
return Result.error("删除失败!");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改应用信息
|
|
|
*/
|
|
|
@RequestMapping("updateApp")
|
|
|
@ResponseBody
|
|
|
public Result updateApp(HttpServletRequest request) {
|
|
|
try {
|
|
|
SystemApp obj = new SystemApp();
|
|
|
BeanUtils.populate(obj, request.getParameterMap());
|
|
|
|
|
|
return appManager.updateApp(obj);
|
|
|
} catch (Exception ex) {
|
|
|
ex.printStackTrace();
|
|
|
return Result.error(ex.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/* ==================================== 应用服务管理部分 =================================== */
|
|
|
|
|
|
@RequestMapping("/initAppService")
|
|
|
public String AppServiceInit(Model model) {
|
|
|
model.addAttribute("contentPage", "system/app/appService");
|
|
|
return "partView";
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 应用管理
|
|
|
* -服务管理页面
|
|
|
*
|
|
|
* @param request
|
|
|
* @return
|
|
|
*/
|
|
|
@RequestMapping("/getAppServiceList")
|
|
|
@ResponseBody
|
|
|
public Result getAppServiceList(HttpServletRequest request,String name,String valid) {
|
|
|
try {
|
|
|
Map<String, Object> params = new HashMap<>();
|
|
|
params.put("name", name);
|
|
|
params.put("valid", valid);
|
|
|
|
|
|
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);
|
|
|
return appManager.getAppList(params);
|
|
|
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) {
|
|
|
try {
|
|
|
SystemServiceEndpoint appService = null;
|
|
|
if (id != null && id.length() > 0) {
|
|
|
appService = appManager.getAppServiceById(id);
|
|
|
} else {
|
|
|
appService = new SystemServiceEndpoint();
|
|
|
}
|
|
|
model.addAttribute("model", appService);
|
|
|
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());
|
|
|
|
|
|
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());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|