/** 得到活动图片下载对象 */ public FileDownMode getFileInfo(HttpServletRequest request, String id) { FindActivity findActivity = findActivityDao.get(Long.valueOf(id)); FileDownMode fileDownMode = new FileDownMode(); fileDownMode.setSaveName(findActivity.getFileName()); fileDownMode.setFilePath( findActivity.getRootPath() + findActivity.getRelativePath() + findActivity.getDiskFileName()); return fileDownMode; }
/** * 得到列表 * * @param request 访问对象 * @param unitId 单位Id * @return 活动列表数据 */ public Map<String, Object> getGridData(HttpServletRequest request, long unitId) { Map<String, Object> gridData = new HashMap<String, Object>(); String page = request.getParameter("page"); String pagesize = request.getParameter("pagesize"); String sortname = request.getParameter("sortname"); String sortorder = request.getParameter("sortorder"); String ifQuery = request.getParameter("ifQuery"); if (sortname != null && !sortname.equals("")) { if (sortname.equals("ACTIVITY_LEVEL_NAME")) { sortname = "fa.activity_level"; } else { sortname = "fa." + sortname.toLowerCase(); } } Map<String, Object> map = new HashMap<String, Object>(); map.put("page", Integer.parseInt(page)); map.put("pagesize", Integer.parseInt(pagesize)); map.put("sortname", sortname); map.put("sortorder", sortorder); map.put("unitId", unitId); map.put("ifQuery", ifQuery); List<Map<String, Object>> dataList = findActivityDao.getListMap(map); long totalRows = findActivityDao.getListRows(map); if (null == dataList) { dataList = new ArrayList<Map<String, Object>>(); } gridData.put("Rows", dataList); gridData.put("Total", totalRows); return gridData; }
public FindActivity get(long id) { // TODO Auto-generated method stub return findActivityDao.get(id); }
public void update(FindActivity findActivity) { // TODO Auto-generated method stub findActivityDao.update(findActivity); }
public void delete(long id) { // TODO Auto-generated method stub findActivityDao.deleteById(id); }
/** * Add data, pay attention to the path of the gain of algorithm * * @param findActivity */ public void add(FindActivity findActivity) { // TODO Auto-generated method stub findActivityDao.add(findActivity); }
/** * 保存操作 * * @param request 访问对象 * @param op 操作类型 add:添加 modify:修改 * @param findActivity 活动对象 * @param dictPath 字典维护的保存路径 */ @Transactional(rollbackFor = Exception.class) public void save( HttpServletRequest request, String op, FindActivity findActivity, String dictPath, SysUser sysUser) { String[] goodsId_array = request.getParameterValues("goodsId"); String[] file_array = request.getParameterValues("activity_file"); if (op.equals("add")) { findActivity.setUnitId(sysUser.getUnitId()); findActivity.setUserId(sysUser.getId()); findActivity.setActivityStatus(0); findActivity.setCreateDate(DateUtil.getSystemTime()); // 图片 setFileData(file_array, findActivity, dictPath); findActivityDao.add(findActivity); } else { FindActivity findActivity2 = findActivityDao.get(findActivity.getId()); findActivity.setCreateDate(findActivity2.getCreateDate()); findActivity.setUpdateDate(DateUtil.getSystemTime()); findActivity.setUserId(sysUser.getId()); findActivity.setUnitId(sysUser.getUnitId()); findActivity.setActivityStatus(0); findActivity.setFileName(findActivity2.getFileName()); findActivity.setDiskFileName(findActivity2.getDiskFileName()); findActivity.setRootPath(findActivity2.getRootPath()); findActivity.setRelativePath(findActivity2.getRelativePath()); findActivity.setFileSize(findActivity2.getFileSize()); findActivity.setFileSuffix(findActivity2.getFileSuffix()); // 图片 setFileData(file_array, findActivity, dictPath); int flag = findActivityDao.update(findActivity); // 删除原消息推送 if (flag > 0) { Map<String, Object> postMap = new HashMap<String, Object>(); postMap.put("sourceType", PushUtil.PushLoginType.datasourceType.value); postMap.put("sourceId", findActivity.getId()); DataRequestUtil.getRequestData("msg/deleteUnpushedMsg.htm", postMap); } // 删除商品关联 // findActivityGoodsDao.deleteByActivityId(findActivity.getId()); } // 添加活动商品关联,暂时不用关联商品 if (null != goodsId_array && goodsId_array.length > 0) { List<FindActivityGoods> activityGoodsList = new ArrayList<FindActivityGoods>(); for (String goodsId : goodsId_array) { FindActivityGoods findActivityGoods = new FindActivityGoods(); findActivityGoods.setActivityId(findActivity.getId()); findActivityGoods.setGoodsId(Long.valueOf(goodsId)); activityGoodsList.add(findActivityGoods); } findActivityGoodsDao.addBatch(activityGoodsList); } // 消息推送 if (1 == findActivity.getIfSetPush() && 0 == findActivity.getActivityStatus()) { pushMsg(findActivity); } }