use of com.itrus.portal.db.App in project portal by ixinportal.
the class AppController method update.
/**
* 修改信息保存
* @return
*/
@RequestMapping(value = "/update")
public String update(@Valid App app, @RequestParam(value = "photofile", required = false) MultipartFile photofile, BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) throws Exception {
if (bindingResult.hasErrors()) {
uiModel.addAttribute("app", app);
return "apps/update";
}
App app0 = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", app.getId());
if (!isRightPhoto(httpServletRequest)) {
uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
uiModel.addAttribute("app", app);
uiModel.addAttribute("photoError", "请设置符合规则的应用图片");
return "apps/update";
}
if (null != app0.getAppIcon()) {
app.setAppIcon(app0.getAppIcon());
}
if (null != photofile && !photofile.isEmpty()) {
File logoFile = appService.saveFile(photofile, app.getId(), FILE_TYPE_JPG);
app.setAppIcon(logoFile.getName());
}
app.setCreateTime(app0.getCreateTime());
app.setUniqueId(app0.getUniqueId());
app.setAuthPass(app0.getAuthPass());
if (StringUtils.isBlank(app0.getUniqueId())) {
app.setUniqueId(UniqueIDUtils.genAppUID(app0, app0.getCreateTime()));
}
if (StringUtils.isBlank(app0.getAuthPass())) {
app.setAuthPass(md5Encoder.encodePassword(app.getUniqueId() + getNameOfAdmin() + new Date().getTime(), null).toUpperCase());
}
sqlSession.update("com.itrus.portal.db.AppMapper.updateByPrimaryKey", app);
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", app.getProject());
String oper = "修改应用";
String info = "项目名称: " + project.getName() + ", 应用名称: " + app.getName() + ", 应用简称: " + app.getShortName();
LogUtil.adminlog(sqlSession, oper, info);
uiModel.addAttribute("app", app);
uiModel.addAttribute("projects", getProjectMapOfAdmin().values());
return "redirect:/apps/show/" + app.getId();
}
use of com.itrus.portal.db.App in project portal by ixinportal.
the class AppController method delete.
/**
* 删除应用
* @param id
* @param session
* @return
*/
@RequestMapping(value = "/{id}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("id") Long id, HttpSession session) {
App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
sqlSession.delete("com.itrus.portal.db.AppMapper.deleteByPrimaryKey", id);
session.setAttribute(APP_DEL_MSG, "应用【" + app.getName() + "】删除成功");
Project project = sqlSession.selectOne("com.itrus.portal.db.ProjectMapper.selectByPrimaryKey", app.getProject());
String oper = "删除应用";
String info = "项目名称: " + project.getName() + ", 应用名称: " + app.getName() + ", 应用简称: " + app.getShortName();
LogUtil.adminlog(sqlSession, oper, info);
return "redirect:/apps";
}
use of com.itrus.portal.db.App in project portal by ixinportal.
the class AppController method getPhoto.
/**
* 显示 修改页面 显示图片
* @param id
* @param response
*/
@RequestMapping(value = "/getPhoto/{id}", method = RequestMethod.GET)
public String getPhoto(@PathVariable("id") Long id, HttpServletResponse response) {
String img = null;
OutputStream os = null;
FileInputStream fis = null;
try {
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
App app = sqlSession.selectOne("com.itrus.portal.db.AppMapper.selectByPrimaryKey", id);
if (null == app) {
return "status403";
}
img = app.getAppIcon();
if (img == null) {
return "status403";
}
File filePath = appService.getFilePathById(id);
if (!filePath.exists()) {
filePath.mkdir();
}
File file = new File(filePath, img);
fis = new FileInputStream(file);
byte[] bb = IOUtils.toByteArray(fis);
os = response.getOutputStream();
os.write(bb);
os.flush();
} catch (IOException e) {
// 未找到
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
} finally {
// 关闭流!
try {
if (null != fis) {
fis.close();
}
if (null != os) {
os.close();
}
} catch (IOException e) {
}
}
return null;
}
use of com.itrus.portal.db.App in project portal by ixinportal.
the class AppServiceImpl method getAppList.
/**
* 根据项目id返回应用管理和增值应用的相关信息
* @param id
* @param type 类型.web.app,客户端,目前是客户端,跟发布平台的值相同:{1:"web", 2:"客户端", 3:"app"}
* @return
*/
public List<AppBean> getAppList(Long id, String type) throws Exception {
// 查询当前项目下的应用信息
List<AppBean> appBeanList = new ArrayList<>();
List<ExtraProduct> extraProductList = null;
AppExample appExample = new AppExample();
AppExample.Criteria ac = appExample.createCriteria();
ac.andProjectEqualTo(id);
if ("1".equals(type)) {
ac.andPcEqualTo(true);
} else if (("2".equals(type))) {
ac.andWindowsEqualTo(true);
} else if (("3".equals(type))) {
// TODO 未区分app 默认为安卓
ac.andAndroidEqualTo(true);
}
List<App> appList = sqlSession.selectList("com.itrus.portal.db.AppMapper.selectByExample", appExample);
// 查询当前项目下增值应用信息
List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.getByprojectAndType(id, type);
// 增值应用集合
if (extraProductReleases != null) {
extraProductList = extraProductService.getproductByEPR(extraProductReleases);
}
if (appList != null) {
for (App app : appList) {
AppBean appBean = new AppBean();
appBean.setType("1");
appBean.setName(app.getName());
appBean.setAppId(app.getId());
appBean.setUrl(app.getAppUrl());
appBean.setOpenType(app.getOpenType());
appBean.setShortName(app.getShortName());
appBeanList.add(appBean);
}
}
// }
return appBeanList;
}
Aggregations