use of com.itrus.portal.db.ExtraProductReleaseExample in project portal by ixinportal.
the class ExtraProductReleaseServiceImpl method getByprojectId.
/**
* 选择项目下所有的产品信息
*
* @param id
* @return
* @throws Exception
*/
public List<ExtraProductRelease> getByprojectId(Long id) throws Exception {
List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
ExtraProductReleaseExample example = new ExtraProductReleaseExample();
ExtraProductReleaseExample.Criteria criteria = example.or();
criteria.andProjectEqualTo(id);
example.setOrderByClause("priority asc");
extraProductReleases = selectByExample(example);
return extraProductReleases;
}
use of com.itrus.portal.db.ExtraProductReleaseExample in project portal by ixinportal.
the class ExtraProductReleaseServiceImpl method getByprojectAndType.
/**
* 根据项目id,和平台类型,获取对应的发布产品,根据优先级进行排序
* @param id
* @param type
* @return
* @throws Exception
*/
public List<ExtraProductRelease> getByprojectAndType(Long id, String type) throws Exception {
List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
ExtraProductReleaseExample example = new ExtraProductReleaseExample();
ExtraProductReleaseExample.Criteria criteria = example.or();
criteria.andProjectEqualTo(id);
criteria.andAppTypeLike("%" + type + "%");
example.setOrderByClause("priority ASC");
example.setOrderByClause("priority ASC");
extraProductReleases = selectByExample(example);
return extraProductReleases;
}
use of com.itrus.portal.db.ExtraProductReleaseExample in project portal by ixinportal.
the class ExtraProductReleaseServiceImpl method saveByJson.
/**
* 1.先判断本次传入的是新增改是修改. 2.判断是不是有的产品的关联关系没有了(原本数据库中有,但是现在没有了的,就是要删除的)
*
* @param json
* @return
* @throws Exception
*/
public Long saveByJson(String json) throws Exception {
Long projectId = null;
JsonNode jsonNodes = null;
jsonNodes = jsonTool.readTree(json);
// 查询项目原本的关联的产品
JsonNode node = jsonNodes.get(0);
ExtraProductRelease extraProductRe = jsonTool.readValue(node, ExtraProductRelease.class);
List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
extraProductReleases = getByprojectId(extraProductRe.getProject());
projectId = extraProductRe.getProject();
List<Long> productSet = new ArrayList<Long>();
if (null != extraProductReleases && !extraProductReleases.isEmpty()) {
for (ExtraProductRelease extraProductRelease3 : extraProductReleases) {
productSet.add(extraProductRelease3.getExtraProduct());
}
}
for (JsonNode jsonNode : jsonNodes) {
ExtraProductRelease extraProductRelease = jsonTool.readValue(jsonNode, ExtraProductRelease.class);
if (null == extraProductRelease.getId()) {
extraProductRelease.setCreateTime(new Date());
insert(extraProductRelease);
} else {
ExtraProductRelease epr = selectByPrimaryKey(extraProductRelease.getId());
extraProductRelease.setCreateTime(epr.getCreateTime());
extraProductRelease.setModifyTime(new Date());
updateByPrimaryKey(extraProductRelease);
// 将还存在的产品从集合中删除,最后剩下的那些就是要删除的
if (productSet.contains(extraProductRelease.getExtraProduct())) {
productSet.remove(extraProductRelease.getExtraProduct());
}
}
}
// 删除信息
if (null != productSet && !productSet.isEmpty()) {
ExtraProductReleaseExample example = new ExtraProductReleaseExample();
ExtraProductReleaseExample.Criteria criteria = example.or();
criteria.andExtraProductIn(productSet);
List<ExtraProductRelease> extraProductReleases2 = new ArrayList<>();
extraProductReleases2 = selectByExample(example);
if (null != extraProductReleases2 && !extraProductReleases2.isEmpty()) {
for (ExtraProductRelease extraProductRelease : extraProductReleases2) {
deleteByPrimaryKey(extraProductRelease.getId());
}
}
}
return projectId;
}
use of com.itrus.portal.db.ExtraProductReleaseExample in project portal by ixinportal.
the class ExtraProductReleaseController method list.
// 遍历页面
@RequestMapping(produces = "text/html")
public String list(@RequestParam(value = "project", required = false) Long project, @RequestParam(value = "extraProduct", required = false) Long extraProduct, @RequestParam(value = "appType", required = false) Long appType, @RequestParam(value = "appTypeExt", required = false) Long appTypeExt, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, Model uiModel) throws Exception {
if (page == null || page < 1)
page = 1;
if (size == null || size < 1)
size = 10;
Integer offset = size * (page - 1);
ExtraProductReleaseExample example = new ExtraProductReleaseExample();
example.setLimit(size);
example.setOffset(offset);
// 所有的项目信息,以id为主键.以便页面显示信息
Map<Long, Project> projectMap = new HashMap<Long, Project>();
projectMap = projectService.getProjectMapByExample(null);
// 所有的增值产品信息,以id为主键.以便页面显示信息
Map<Long, ExtraProduct> extraProductMap = new HashMap<Long, ExtraProduct>();
extraProductMap = extraProductService.selectMapByExample(null);
Criteria criteria = example.createCriteria();
if (project != null) {
criteria.andProjectEqualTo(project);
}
if (extraProduct != null) {
criteria.andExtraProductEqualTo(extraProduct);
}
criteria.andAppTypeIsNotNull();
criteria.andAppTypeNotEqualTo("");
if (appType != null) {
criteria.andAppTypeLike("%" + appType + "%");
}
List<ExtraProductRelease> extraProductReleases = extraProductReleaseService.selectByExample(example);
// 去除不包含所选 发布平台的记录
if (appType != null) {
Iterator<ExtraProductRelease> it = extraProductReleases.iterator();
while (it.hasNext()) {
ExtraProductRelease epr = it.next();
String appTypes = epr.getAppType();
boolean isHas = false;
for (String at : appTypes.split(",")) {
if (appType.toString().equals(at)) {
isHas = true;
break;
}
}
if (!isHas) {
it.remove();
}
}
}
Integer count = extraProductReleases.size();
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
// page, size
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
uiModel.addAttribute("projectCur", project);
uiModel.addAttribute("extraProductCur", extraProduct);
uiModel.addAttribute("appTypesCur", appType);
uiModel.addAttribute("appTypeExt", appTypeExt);
uiModel.addAttribute("projectMap", projectMap);
uiModel.addAttribute("extraProductMap", extraProductMap);
uiModel.addAttribute("extraProductReleases", extraProductReleases);
return "extraproductrelease/list";
}
use of com.itrus.portal.db.ExtraProductReleaseExample in project portal by ixinportal.
the class ExtraProductReleaseServiceImpl method getByprojectIdAndProductId.
/**
* 选择项目和产品下所有的产品信息
*
* @param id
* @return
* @throws Exception
*/
public List<ExtraProductRelease> getByprojectIdAndProductId(Long projectId, Long productId) throws Exception {
List<ExtraProductRelease> extraProductReleases = new ArrayList<>();
ExtraProductReleaseExample example = new ExtraProductReleaseExample();
ExtraProductReleaseExample.Criteria criteria = example.or();
criteria.andProjectEqualTo(projectId);
criteria.andExtraProductEqualTo(productId);
example.setOrderByClause("priority asc");
extraProductReleases = selectByExample(example);
return extraProductReleases;
}
Aggregations