Merge branch 'div' of ssh://193.112.35.168:29418/fanli-server into div
| | |
| | | List<AppVersionInfo> versionList = null;
|
| | | if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
|
| | | versionList = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(version) && !StringUtil.isNullOrEmpty(platform)) {
|
| | | AppVersionInfo appVersion = appVersionService.getByPlatformAndVersion(platform, version);
|
| | | if (!StringUtil.isNullOrEmpty(version)) {
|
| | | AppVersionInfo appVersion = appVersionService.selectByPrimaryKey(Long.parseLong(version));
|
| | | if (appVersion != null)
|
| | | versionList.add(appVersion);
|
| | | } else if (!StringUtil.isNullOrEmpty(version)) {
|
| | | List<AppVersionInfo> appVersionList = appVersionService.listByVersion(version);
|
| | | if (appVersionList != null) {
|
| | | versionList.addAll(appVersionList);
|
| | | }
|
| | | } else {
|
| | | List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
|
| | | if (appVersionList != null) {
|
| | |
| | | List<Long> versionIdList = new ArrayList<>();
|
| | | for (AppVersionInfo versionInfo : versionList)
|
| | | versionIdList.add(versionInfo.getId());
|
| | | List<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
|
| | | Set<Long> sets = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
|
| | | AdActivityType.special, versionIdList);
|
| | | Set<Long> sets = new HashSet<>();
|
| | | if (sourceIds != null)
|
| | | for (Long sourceId : sourceIds) {
|
| | | sets.add(sourceId);
|
| | | }
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (!sets.contains(list.get(i).getId())) {
|
| | | list.remove(i--);
|
| | |
| | | List<Long> versionList = new ArrayList<>();
|
| | | if (list != null)
|
| | | for (AdActivityVersionControl control : list)
|
| | | versionList.add(control.getId());
|
| | | versionList.add(control.getVersion().getId());
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(versionList));
|
| | | }
|
| | |
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashMap;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Map;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
| | | import com.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.reflect.TypeToken;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperBanner;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | |
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.config.SystemConfigService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperBannerService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.tag.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 轮播图管理
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | |
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SwiperBannerService swiperBannerService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SwiperPictureService swiperPictureService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private SystemConfigService systemConfigService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | | |
| | | |
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Resource
|
| | | private AdActivityVersionControlService adActivityVersionControlService;
|
| | |
|
| | | /**
|
| | | * 新增
|
| | | * |
| | | * @param callback
|
| | | * @param swiperBanner
|
| | | * @param out
|
| | |
| | |
|
| | | /**
|
| | | * 修改
|
| | | * |
| | | * @param callback
|
| | | * @param swiperBanner
|
| | | * @param out
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 修该状态
|
| | | * |
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Integer state = resultObj.getState();
|
| | | if (state == null || state.equals(1) || state == 1) {
|
| | | if (state == null || state.equals(1) || state == 1) {
|
| | | resultObj.setState(0);
|
| | | } else {
|
| | | resultObj.setState(1);
|
| | | }
|
| | |
|
| | | swiperBannerService.updateByPrimaryKeySelective(resultObj);
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("state", resultObj.getState());
|
| | | |
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (SwiperBannerException e) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param key 模糊查询:说明、标识
|
| | | * @param sort 排序 : 创建时间倒序1 默认正序
|
| | | * @param key
|
| | | * 模糊查询:说明、标识
|
| | | * @param sort
|
| | | * 排序 : 创建时间倒序1 默认正序
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "query")
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | | for (SwiperBanner swiperBanne: list) {
|
| | | long TotalPic= swiperPictureService.countQueryByBannerID(swiperBanne.getId());
|
| | | |
| | |
|
| | | for (SwiperBanner swiperBanne : list) {
|
| | | long TotalPic = swiperPictureService.countQueryByBannerID(swiperBanne.getId());
|
| | |
|
| | | swiperBanne.setTotalPic(TotalPic);
|
| | | }
|
| | |
|
| | | long count = swiperBannerService.countQuery(key);
|
| | | |
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); |
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | |
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 删除
|
| | | * |
| | | * @param callback
|
| | | * @param idArray
|
| | | * @param out
|
| | |
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | int count = swiperBannerService.deleteBatchByPrimaryKey(list);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除["+ count +"]条数据"));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @RequestMapping(value = "getEffectiveOption")
|
| | | public void getEffectiveOption(String callback, PrintWriter out) {
|
| | | try {
|
| | | List<Object> list = new ArrayList<Object>();
|
| | | |
| | | Map<String,Object> mapDefalut =new HashMap<String,Object>();
|
| | |
|
| | | Map<String, Object> mapDefalut = new HashMap<String, Object>();
|
| | | mapDefalut.put("key", 0);
|
| | | mapDefalut.put("value", "--未选择--");
|
| | | list.add(mapDefalut);
|
| | | |
| | |
|
| | | List<SwiperBanner> listBanner = swiperBannerService.getEffectiveOption();
|
| | | if (listBanner != null && listBanner.size() > 0) {
|
| | | for (SwiperBanner swiperBanner: listBanner) {
|
| | | Map<String,Object> map =new HashMap<String,Object>();
|
| | | for (SwiperBanner swiperBanner : listBanner) {
|
| | | Map<String, Object> map = new HashMap<String, Object>();
|
| | | map.put("key", swiperBanner.getId());
|
| | | map.put("value", swiperBanner.getTitle());
|
| | | list.add(map);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result_list", list);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | | |
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 查询图片列表
|
| | | * 查询图片列表
|
| | | * |
| | | * @param callback
|
| | | * @param pageIndex
|
| | | * @param pageSize
|
| | | * @param bannerId |
| | | * @param bannerId
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "queryPicInfo")
|
| | | public void queryPicInfo(String callback, Integer pageIndex, Integer pageSize, Long bannerId, PrintWriter out) {
|
| | | public void queryPicInfo(String callback, Integer pageIndex, Integer pageSize, Long bannerId, String version,
|
| | | String platform, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | |
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | pageSize = 100;
|
| | |
|
| | | if (bannerId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("轮播图管理ID不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | List<AppVersionInfo> versionList = null;
|
| | | if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
|
| | | versionList = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(version)) {
|
| | | AppVersionInfo appVersion = appVersionService.selectByPrimaryKey(Long.parseLong(version));
|
| | | if (appVersion != null)
|
| | | versionList.add(appVersion);
|
| | | } else {
|
| | | List<AppVersionInfo> appVersionList = appVersionService.getAppVersionInfoListByPlatform(platform);
|
| | | if (appVersionList != null) {
|
| | | versionList.addAll(appVersionList);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | try {
|
| | | |
| | | List<SwiperPicture> list = swiperPictureService.queryByBannerID((pageIndex - 1) * pageSize, |
| | | pageSize, bannerId);
|
| | |
|
| | | List<SwiperPicture> list = swiperPictureService.queryByBannerID((pageIndex - 1) * pageSize, pageSize,
|
| | | bannerId);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | // 跳转链接
|
| | | for (SwiperPicture swiperPicture: list) {
|
| | | |
| | | for (SwiperPicture swiperPicture : list) {
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | Date startTime = swiperPicture.getStartTime();
|
| | | if (startTime == null) {
|
| | |
| | | } else {
|
| | | swiperPicture.setStartTime_str(sdf.format(startTime));
|
| | | }
|
| | | |
| | |
|
| | | Date endTime = swiperPicture.getEndTime();
|
| | | if (endTime == null) {
|
| | | swiperPicture.setEndTime_str("");
|
| | | } else {
|
| | | swiperPicture.setEndTime_str(sdf.format(endTime));
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | String params = swiperPicture.getParams();
|
| | | if (params == null) {
|
| | | swiperPicture.setParams("");
|
| | | }
|
| | | |
| | |
|
| | | String remark = swiperPicture.getRemark();
|
| | | if (remark == null) {
|
| | | swiperPicture.setRemark("");
|
| | | }
|
| | | |
| | | |
| | |
|
| | | JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
|
| | | if (jumpDetail == null) {
|
| | | // 默认未选择
|
| | |
| | | swiperPicture.setJumpDetail(jumpDetailV2);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | long count = swiperPictureService.countQueryByBannerID(bannerId);
|
| | | |
| | |
|
| | | // 过滤
|
| | | if (versionList != null) {
|
| | | if (versionList.size() > 0) {
|
| | | List<Long> sourceIdList = new ArrayList<>();
|
| | | for (SwiperPicture swiperPicture : list) {
|
| | | sourceIdList.add(swiperPicture.getId());
|
| | | }
|
| | | List<Long> versionIdList = new ArrayList<>();
|
| | | for (AppVersionInfo versionInfo : versionList)
|
| | | versionIdList.add(versionInfo.getId());
|
| | | Set<Long> sets = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
|
| | | AdActivityType.banner, versionIdList);
|
| | |
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (!sets.contains(list.get(i).getId())) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | | count = list.size();
|
| | | } else {
|
| | | list.clear();
|
| | | count = 0;
|
| | | }
|
| | | }
|
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); |
| | | gsonBuilder.serializeNulls();
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy-MM-dd'T'HH:mm").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 保存信息
|
| | | *
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "savePicInfo")
|
| | | public void savePicInfo(String callback, SwiperPicture record, String jumpType, HttpServletRequest request,PrintWriter out) {
|
| | | public void savePicInfo(String callback, SwiperPicture record, String jumpType, HttpServletRequest request,
|
| | | PrintWriter out) {
|
| | | try {
|
| | | // 1. 先判断httpRequest 是否含有文件类型 |
| | | // 1. 先判断httpRequest 是否含有文件类型
|
| | | if (request instanceof MultipartHttpServletRequest) {
|
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | swiperPictureService.saveObject(fileRequest.getFile("file"), record, jumpType);
|
| | | }else{
|
| | | swiperPictureService.saveObject(null, record, jumpType);
|
| | | }
|
| | | |
| | | MultipartHttpServletRequest fileRequest = (MultipartHttpServletRequest) request;
|
| | | swiperPictureService.saveObject(fileRequest.getFile("file"), record, jumpType);
|
| | | } else {
|
| | | swiperPictureService.saveObject(null, record, jumpType);
|
| | | }
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("保存成功"));
|
| | | } catch (SwiperPictureException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 删除图片以及信息
|
| | | * |
| | | * @param callback
|
| | | * @param idArray
|
| | | * @param out
|
| | |
| | | }
|
| | |
|
| | | Gson gson = new Gson();
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType());
|
| | | List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {
|
| | | }.getType());
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | int count = swiperPictureService.deleteBatchByPrimaryKey(list);
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除["+ count +"]条数据"));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 修改排序
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "saveOrder")
|
| | | public void saveOrder(String callback, Long id,Integer moveType, PrintWriter out) {
|
| | | |
| | | public void saveOrder(String callback, Long id, Integer moveType, PrintWriter out) {
|
| | |
|
| | | if (moveType == null || (!moveType.equals(1) && !moveType.equals(-1))) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("传递的类型不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | |
|
| | | SwiperPicture resultObj = swiperPictureService.selectByPrimaryKey(id);
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Long bannerId = resultObj.getBannerId();
|
| | | Integer oldOrder = resultObj.getOrder();
|
| | | List<SwiperPicture> list = swiperPictureService.getOrderByBannerID(bannerId, moveType, oldOrder);
|
| | | |
| | |
|
| | | if (list != null && list.size() > 0) {
|
| | | SwiperPicture changeObj = list.get(0);
|
| | | // 交换排序序号
|
| | | resultObj.setOrder(changeObj.getOrder());
|
| | | |
| | |
|
| | | changeObj.setOrder(oldOrder);
|
| | | |
| | |
|
| | | swiperPictureService.updateByPrimaryKeySelective(changeObj);
|
| | | }
|
| | | |
| | |
|
| | | swiperPictureService.updateByPrimaryKeySelective(resultObj);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | |
| | | }
|
| | |
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 设置版本
|
| | | * |
| | | * @param callback
|
| | | * @param id
|
| | | * @param moveType
|
| | | * @param sex
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "setVersions")
|
| | | public void setVersions(String callback, Long id, String versions, PrintWriter out) {
|
| | | JSONArray versionArray = JSONArray.fromObject(versions);
|
| | | List<Long> versionIds = new ArrayList<>();
|
| | | for (int i = 0; i < versionArray.size(); i++) {
|
| | | Long version = versionArray.optLong(i);
|
| | | versionIds.add(version);
|
| | | }
|
| | | try {
|
| | | swiperPictureService.setVersions(id, versionIds);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(""));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getVersions")
|
| | | public void getVersions(String callback, Long id, PrintWriter out) {
|
| | | List<AdActivityVersionControl> list = adActivityVersionControlService
|
| | | .listByTypeAndSourceId(AdActivityType.banner, id);
|
| | |
|
| | | List<Long> versionList = new ArrayList<>();
|
| | | if (list != null)
|
| | | for (AdActivityVersionControl control : list)
|
| | | versionList.add(control.getVersion().getId());
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(versionList));
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Resource
|
| | | private BanLiShopGoodsSetService banLiShopGoodsSetService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private RedPackForbidService redPackForbidService;
|
| | |
|
| | |
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "goodsList")
|
| | | public void goodsList(AcceptData acceptData, int page,Long uid, String callback, PrintWriter out) {
|
| | | public void goodsList(AcceptData acceptData, int page, Long uid, String callback, PrintWriter out) {
|
| | | if (page <= 0)
|
| | | page = 1;
|
| | | List<BanLiShopGoods> goodsList = banLiShopGoodsService.listGoods(null, BanLiShopGoods.STATE_ONLINE, page,
|
| | | Constant.PAGE_SIZE);
|
| | | long count = banLiShopGoodsService.countGoods(null, BanLiShopGoods.STATE_ONLINE);
|
| | | // 获取banner
|
| | | List<SwiperPicture> pictureList = swiperPictureService.getByBannerCard("hongbao_exchange_goods_list");
|
| | | List<SwiperPicture> pictureList = swiperPictureService.getByBannerCardAndVersion("hongbao_exchange_goods_list",
|
| | | acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if (pictureList != null && pictureList.size() > 0) {
|
| | |
| | | data.put("data", goodsList);
|
| | | data.put("count", count);
|
| | | data.put("redPackLock", redPackForbidService.verifyForbid(uid));
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | else
|
| | |
| | | }
|
| | | }
|
| | | BigDecimal money = redPackBalanceService.getBalance(uid);
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goods", goods);
|
| | | data.put("hongBaoBalance", money);
|
| | |
| | |
|
| | | if (VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | // 我的界面banner
|
| | | List<SwiperPicture> banner = swiperPictureService.getByBannerCard("my_interface_banner");
|
| | | List<SwiperPicture> banner = swiperPictureService.getByBannerCardAndVersion("my_interface_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (banner == null)
|
| | | banner = new ArrayList<SwiperPicture>();
|
| | | data.put("banner", JsonUtil.getApiCommonGson().toJson(banner));
|
| | |
| | | // 轮播图
|
| | | List<SwiperPicture> picList = null;
|
| | | if (swpid != null) {
|
| | | picList = swiperPictureService.getByBannerId(swpid);
|
| | | picList = swiperPictureService.getByBannerId(swpid, acceptData.getPlatform(),
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | }
|
| | | if (picList == null) {
|
| | | picList = new ArrayList<SwiperPicture>();
|
| | |
| | | data.put("activityRules", valueBr);
|
| | | data.put("inviteList", String.format("http://%s/%s/client/share/friends_new.html",
|
| | | Constant.systemCommonConfig.getProjectHost(), Constant.systemCommonConfig.getProjectName()));
|
| | | List<SwiperPicture> pictureList = swiperPictureService.getByBannerCard("invite_top_banner");
|
| | | List<SwiperPicture> pictureList = swiperPictureService.getByBannerCardAndVersion("invite_top_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (pictureList != null && pictureList.size() > 0) {
|
| | | SwiperPicture picture = pictureList.get(0);
|
| | | com.alibaba.fastjson.JSONObject pictureJson = new com.alibaba.fastjson.JSONObject();
|
| | |
| | | if (!StringUtil.isNullOrEmpty(specialCard)) {
|
| | | try {
|
| | |
|
| | | listswiper = swiperPictureService.getByBannerCard(swiperCard);
|
| | | listswiper = swiperPictureService.getByBannerCardAndVersion(swiperCard, acceptData.getPlatform(),
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | |
|
| | | if (listswiper == null) {
|
| | | listswiper = new ArrayList<SwiperPicture>();
|
| | |
| | | JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex);
|
| | |
|
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> topPicList = getSwiperByCard("index_top");
|
| | | List<SwiperPicture> topPicList = getSwiperByCard("index_top",acceptData);
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | } else {
|
| | | invitePicList = getSwiperByCard("index_invite");
|
| | | invitePicList = getSwiperByCard("index_invite",acceptData);
|
| | | }
|
| | |
|
| | | if (invitePicList == null) {
|
| | |
| | | return null;
|
| | | }
|
| | |
|
| | | List<SwiperPicture> invitePicList = getSwiperByCard("index_invite");
|
| | | List<SwiperPicture> invitePicList = getSwiperByCard("index_invite",acceptData);
|
| | |
|
| | | return invitePicList;
|
| | | }
|
| | |
|
| | | public List<SwiperPicture> getSwiperByCard(String card) {
|
| | | public List<SwiperPicture> getSwiperByCard(String card, AcceptData acceptData) {
|
| | | List<SwiperPicture> swiperList = null;
|
| | | try {
|
| | | swiperList = swiperPictureService.getByBannerCard(card);
|
| | | swiperList = swiperPictureService.getByBannerCardAndVersion(card, acceptData.getPlatform(),
|
| | | Integer.parseInt(acceptData.getVersion()));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | // 福利中心图片
|
| | | String topPicture = null;
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> listswiper = swiperPictureService.getByBannerCard("welfare_top");
|
| | | List<SwiperPicture> listswiper = swiperPictureService.getByBannerCardAndVersion("welfare_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (listswiper != null && listswiper.size() > 0) {
|
| | | topPicture = listswiper.get(0).getSrc();
|
| | | }
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | if (page == 1) {
|
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture");
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (oldtopPicList != null && oldtopPicList.size() > 0)
|
| | | topPicList.addAll(oldtopPicList);
|
| | | TaoBaoShop taoBaoShop = taoBaoShopService.selectByPrimaryKey(id);
|
| | |
| | | if (page == 1 && array.size() > 0) {
|
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> topPicList = new ArrayList<>();
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("brand_picture");
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("brand_picture",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (oldtopPicList != null && oldtopPicList.size() > 0)
|
| | | topPicList.addAll(oldtopPicList);
|
| | |
|
| | |
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> bannerList = null;
|
| | | if (Constant.IS_TEST) {
|
| | | bannerList = swiperPictureService.getByBannerCard("index_top");
|
| | | bannerList = swiperPictureService.getByBannerCardAndVersion("index_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | }
|
| | |
|
| | | if (bannerList == null) {
|
| | |
| | | public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) {
|
| | | JSONObject root = new JSONObject();
|
| | | if (cid == 1 && page == 1) {
|
| | | List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("jingdong_special_index");
|
| | | List<SwiperPicture> topPicList = swiperPictureService.getByBannerCardAndVersion("jingdong_special_index",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | |
| | | public void getGoodsInfo(AcceptData acceptData, Long cid, Integer page, PrintWriter out) {
|
| | | JSONObject root = new JSONObject();
|
| | | if (cid == 1 && page == 1) {
|
| | | List<SwiperPicture> topPicList = swiperPictureService.getByBannerCard("pinduoduo_special_index");
|
| | | List<SwiperPicture> topPicList = swiperPictureService.getByBannerCardAndVersion("pinduoduo_special_index",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (topPicList == null) {
|
| | | topPicList = new ArrayList<SwiperPicture>();
|
| | | }
|
| | |
| | | JSONObject root = specialService.listCacheSpecialToIndex(acceptData, deviceSex);
|
| | |
|
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("index_top");
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("index_top",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | |
| | | |
| | | List<SwiperPicture> topPicList = new ArrayList<>();
|
| | | if (oldtopPicList != null && oldtopPicList.size() > 0)
|
| | | topPicList.addAll(oldtopPicList);
|
| | |
| | | && configService.iosOnLining(Integer.parseInt(acceptData.getVersion()))) {
|
| | | // 如果IOS当前版本处于审核状态就不返回
|
| | | } else {
|
| | | invitePicList = swiperPictureService.getByBannerCard("index_invite");
|
| | | invitePicList = swiperPictureService.getByBannerCardAndVersion("index_invite",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | }
|
| | |
|
| | | if (invitePicList == null) {
|
| | |
| | | data.put("count", array.size());
|
| | | data.put("list", array);
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner");
|
| | | List<SwiperPicture> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | |
|
| | | if (bannerList != null && bannerList.size() > 0)
|
| | | data.put("topPicture", bannerList.get(0).getSrc());
|
| | |
| | | data.put("count", array.size());
|
| | | data.put("list", array);
|
| | | if (page == 1) {
|
| | | List<SwiperPicture> bannerList = swiperPictureService.getByBannerCard("zigoulijian_banner");
|
| | | List<SwiperPicture> bannerList = swiperPictureService.getByBannerCardAndVersion("zigoulijian_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | |
|
| | | if (bannerList != null && bannerList.size() > 0)
|
| | | data.put("topPicture", bannerList.get(0).getSrc());
|
| | |
| | | }
|
| | |
|
| | | // 2、顶部轮播图
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCard("redpack_win_detail_banner");
|
| | | List<SwiperPicture> oldtopPicList = swiperPictureService.getByBannerCardAndVersion("redpack_win_detail_banner",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | List<SwiperPicture> topPicList = new ArrayList<>();
|
| | | if (oldtopPicList != null && oldtopPicList.size() > 0)
|
| | | topPicList.addAll(oldtopPicList);
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | if (page == 1) {
|
| | | // 福利中心图片
|
| | | List<SwiperPicture> listswiper = swiperPictureService.getByBannerCard("welfare_top_1.6.5");
|
| | | List<SwiperPicture> listswiper = swiperPictureService.getByBannerCardAndVersion("welfare_top_1.6.5",acceptData.getPlatform(), Integer.parseInt(acceptData.getVersion()));
|
| | | if (listswiper != null && listswiper.size() > 0) {
|
| | | String topPicture = listswiper.get(0).getSrc();
|
| | | data.put("topPicture", topPicture);
|
| | |
| | | WHERE sp.`b_state` = 0
|
| | | AND IF(sp.b_start_time IS NULL,TRUE, sp.b_start_time<![CDATA[<=]]> NOW())
|
| | | AND IF(sp.b_end_time IS NULL,TRUE, sp.b_end_time <![CDATA[>=]]> NOW())
|
| | | <if test="platform == 1">
|
| | | <if test="platform == 1 and versionCode!=null">
|
| | | AND IF(sp.`b_min_android_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_android_version_code,TRUE)
|
| | | </if>
|
| | | <if test="platform == 2">
|
| | | <if test="platform == 2 and versionCode!=null">
|
| | | AND IF(sp.`b_min_ios_version_code` IS NOT NULL, #{versionCode}<![CDATA[>=]]> sp.b_min_ios_version_code,TRUE)
|
| | | </if>
|
| | | <include refid="Sex_Screen" />
|
| | |
| | |
|
| | | @Override
|
| | | public List<AppVersionInfo> listByVersion(String version) {
|
| | | |
| | | |
| | |
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public AppVersionInfo getClientVersion(String platform, int versionCode) {
|
| | | AppVersionInfo appInfo = getAppVersionInfoListByPlatformAndVersion(platform, versionCode);
|
| | | if (appInfo != null)
|
| | | return appInfo;
|
| | | // 如果不存在就降低版本号查询
|
| | | if (versionCode > 0)
|
| | | return getClientVersion(platform, versionCode - 1);
|
| | |
|
| | | return null;
|
| | | }
|
| | |
| | |
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public List<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList) {
|
| | | public Set<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList) {
|
| | | if (sourceIdList == null || sourceIdList.size() == 0)
|
| | | return null;
|
| | |
|
| | |
| | |
|
| | | List<AdActivityVersionControl> list = adActivityVersionControlMapper.listByVersionAndSourceId(sourceIdList,
|
| | | type, versionIdList);
|
| | | List<Long> resultList = new ArrayList<>();
|
| | | Set<Long> resultList = new HashSet<>();
|
| | | if (list != null)
|
| | | for (AdActivityVersionControl control : list)
|
| | | if (control != null && control.getSourceId() != null)
|
| | |
| | | return resultList;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void deleteBySourceAndVersion(Long sourceId, AdActivityType type, Long version) {
|
| | | AdActivityVersionControl control = adActivityVersionControlMapper.selectBySourceIdAndTypeAndVersion(sourceId,
|
| | | type, version);
|
| | | if (control != null)
|
| | | deleteByPrimaryKey(control.getId());
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | import java.util.ArrayList;
|
| | | import java.util.Calendar;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.exception.homemodule.HomeNavbarException;
|
| | | import com.yeshi.fanli.exception.homemodule.SpecialException;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | |
| | | return specialMapper.listByVersion(start, count, card, platform, versionCode);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 专题版本过滤
|
| | | * |
| | | * @param list
|
| | | * @param platform
|
| | | * @param versionCode
|
| | | */
|
| | | private void filterSpecial(List<Special> list, String platform, int versionCode) {
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
|
| | | if (app == null) {
|
| | | list.clear();
|
| | | return;
|
| | | }
|
| | | List<Long> versionIdList = new ArrayList<>();
|
| | | versionIdList.add(app.getId());
|
| | | List<Long> sourceIdList = new ArrayList<>();
|
| | | for (Special special : list) {
|
| | | sourceIdList.add(special.getId());
|
| | | }
|
| | |
|
| | | Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
|
| | | AdActivityType.special, versionIdList);
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (!sourceIds.contains(list.get(i).getId())) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "specialCache", key = "'listCacheSpecialToIndex'+#acceptData.platform+'-'+#acceptData.version+'-'+#sex")
|
| | | public JSONObject listCacheSpecialToIndex(AcceptData acceptData, Integer sex) throws Exception {
|
| | |
| | | else if (VersionUtil.greaterThan_1_5_60(acceptData.getPlatform(), acceptData.getVersion()))
|
| | | indexArc = "index_arc_1.5.6";
|
| | |
|
| | | int platformCode = Constant.getPlatformCode(acceptData.getPlatform());
|
| | | String platform = acceptData.getPlatform();
|
| | | int platformCode = Constant.getPlatformCode(platform);
|
| | | int version = Integer.parseInt(acceptData.getVersion());
|
| | |
|
| | | List<Special> listArc = specialMapper.listByPlaceKey(indexArc, sex, platformCode, version);
|
| | | filterSpecial(listArc, platform, version);
|
| | | if (listArc == null) {
|
| | | listArc = new ArrayList<Special>();
|
| | | } else if (listArc.size() > 0) {
|
| | |
| | | listActivity = specialMapper.listByPlaceKey("index_activity", null, platformCode, version);
|
| | | }
|
| | |
|
| | | filterSpecial(listActivity, platform, version);
|
| | |
|
| | | if (listActivity == null) {
|
| | | listActivity = new ArrayList<Special>();
|
| | | } else if (listActivity.size() > 0) {
|
| | |
| | |
|
| | | JSONObject blockJsonMap = new JSONObject();
|
| | | List<Special> listBlock = specialMapper.listByPlaceKey(indexBlock, sex, platformCode, version);
|
| | | filterSpecial(listBlock, platform, version);
|
| | | if (listBlock == null) {
|
| | | listBlock = new ArrayList<Special>();
|
| | | } else if (listBlock.size() > 0) {
|
| | |
| | | if (special == null) {
|
| | | throw new Exception("专题不存在");
|
| | | }
|
| | |
|
| | | Set<Long> oldSet = new HashSet<>();
|
| | |
|
| | | List<AdActivityVersionControl> versionList = adActivityVersionControlService
|
| | | .listByTypeAndSourceId(AdActivityType.special, special.getId());
|
| | | .listByTypeAndSourceId(AdActivityType.special, specialId);
|
| | | if (versionList != null) {
|
| | | for (AdActivityVersionControl control : versionList)
|
| | | adActivityVersionControlService.deleteByPrimaryKey(control.getId());
|
| | | oldSet.add(control.getVersion().getId());
|
| | | }
|
| | |
|
| | | Set<Long> newSet = new HashSet<>();
|
| | |
|
| | | for (Long version : versions) {
|
| | | newSet.add(version);
|
| | | }
|
| | |
|
| | | Set<Long> delSet = new HashSet<>();
|
| | | delSet.addAll(oldSet);
|
| | | delSet.removeAll(newSet);
|
| | | for (Long versionId : delSet) {
|
| | | adActivityVersionControlService.deleteBySourceAndVersion(specialId, AdActivityType.special, versionId);
|
| | | }
|
| | |
|
| | | Set<Long> addSet = new HashSet<>();
|
| | | addSet.addAll(newSet);
|
| | | addSet.removeAll(oldSet);
|
| | |
|
| | | // 添加映射
|
| | | for (Long versionId : versions) {
|
| | | for (Long versionId : addSet) {
|
| | | AdActivityVersionControl control = new AdActivityVersionControl();
|
| | | control.setCreateTime(new Date());
|
| | | control.setSourceId(special.getId());
|
| | | control.setType(AdActivityType.special);
|
| | | control.setVersion(new AppVersionInfo(versionId));
|
| | | adActivityVersionControlService.addVersionControl(control);
|
| | | try {
|
| | | adActivityVersionControlService.addVersionControl(control);
|
| | | } catch (Exception e) {
|
| | | throw new SwiperPictureException(2, e.getMessage());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | import java.io.InputStream;
|
| | | import java.text.ParseException;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.homemodule.SwiperPictureMapper;
|
| | | import com.yeshi.fanli.entity.AppVersionInfo;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.Special;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | | import com.yeshi.fanli.exception.banner.SwiperPictureException;
|
| | | import com.yeshi.fanli.service.inter.common.JumpDetailV2Service;
|
| | | import com.yeshi.fanli.service.inter.config.AppVersionService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.AdActivityVersionControlService;
|
| | | import com.yeshi.fanli.service.inter.homemodule.SwiperPictureService;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private SwiperPictureMapper swiperPictureMapper;
|
| | | |
| | |
|
| | | @Resource
|
| | | private JumpDetailV2Service jumpDetailV2Service;
|
| | | |
| | |
|
| | | @Resource
|
| | | private AdActivityVersionControlService adActivityVersionControlService;
|
| | |
|
| | | @Resource
|
| | | private AppVersionService appVersionService;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(SwiperPicture record) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public int updateByPrimaryKey(SwiperPicture record){
|
| | | public int updateByPrimaryKey(SwiperPicture record) {
|
| | | return swiperPictureMapper.updateByPrimaryKey(record);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public List<SwiperPicture> queryByBannerID(long start, int count, Long bannerId) throws SwiperPictureException{
|
| | | public List<SwiperPicture> queryByBannerID(long start, int count, Long bannerId) throws SwiperPictureException {
|
| | | return swiperPictureMapper.queryByBannerID(start, count, bannerId);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public long countQueryByBannerID(Long bannerId) throws SwiperPictureException{
|
| | | public long countQueryByBannerID(Long bannerId) throws SwiperPictureException {
|
| | | return swiperPictureMapper.countQueryByBannerID(bannerId);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void saveObject(MultipartFile file, SwiperPicture record, String jumpType) throws SwiperPictureException, Exception{
|
| | | |
| | | public void saveObject(MultipartFile file, SwiperPicture record, String jumpType)
|
| | | throws SwiperPictureException, Exception {
|
| | |
|
| | | if (record == null) {
|
| | | throw new SwiperPictureException(1, "参数不能为空");
|
| | | }
|
| | | |
| | |
|
| | | Long bannerId = record.getBannerId();
|
| | | if (bannerId == null) {
|
| | | throw new SwiperPictureException(1, "标识管理ID不能为空");
|
| | | }
|
| | | |
| | |
|
| | | String params = record.getParams();
|
| | | if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params) ) {
|
| | | if (params == null || params.trim().length() == 0 || "null".equalsIgnoreCase(params)) {
|
| | | record.setParams(null);
|
| | | } else if (!StringUtil.isJson(params)) {
|
| | | throw new SwiperPictureException(1, "跳转参数非JSON格式");
|
| | | }
|
| | | |
| | |
|
| | | if (!StringUtil.isNullOrEmpty(jumpType)) {
|
| | | List<JumpDetailV2> listByType = jumpDetailV2Service.listByType(jumpType);
|
| | | if (listByType !=null && listByType.size() > 0) {
|
| | | if (listByType != null && listByType.size() > 0) {
|
| | | record.setJumpDetail(listByType.get(0));
|
| | | } |
| | | }
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
| | | String startTime_str = record.getStartTime_str();
|
| | |
| | | startTime_str = startTime_str.replaceAll("T", " ");
|
| | | record.setStartTime(format.parse(startTime_str));
|
| | | }
|
| | | |
| | |
|
| | | String endTime_str = record.getEndTime_str();
|
| | | if (endTime_str != null && endTime_str.trim().length() > 0) {
|
| | | endTime_str = endTime_str.replaceAll("T", " ");
|
| | | record.setEndTime(format.parse(endTime_str));
|
| | | }
|
| | | |
| | |
|
| | | } catch (ParseException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | |
|
| | | String remark = record.getRemark();
|
| | | if (remark != null && (remark.trim().length() == 0 || remark.equalsIgnoreCase("null"))) {
|
| | | record.setRemark(null);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | String picture = null;
|
| | | if (file != null) {
|
| | | picture = uploadPicture(file);
|
| | | }
|
| | | |
| | |
|
| | | Long id = record.getId();
|
| | | |
| | |
|
| | | if (id == null) {
|
| | | int maxOrder = swiperPictureMapper.getMaxOrderByBannerID(bannerId);
|
| | | record.setOrder(maxOrder + 1);
|
| | | |
| | |
|
| | | Integer state = record.getState();
|
| | | // 默认停用
|
| | | if (state == null) {
|
| | | record.setState(1);
|
| | | }
|
| | | |
| | |
|
| | | Integer autoControl = record.getAutoControl();
|
| | | if (autoControl == null) {
|
| | | // 默认非系统控制
|
| | |
| | | record.setCreatetime(new Date());
|
| | | record.setUpdatetime(new Date());
|
| | | record.setSrc(picture);
|
| | | |
| | |
|
| | | swiperPictureMapper.insert(record);
|
| | | } else {
|
| | | // 修改
|
| | |
| | | if (resultObj == null) {
|
| | | throw new SwiperPictureException(1, "参数不能为空");
|
| | | }
|
| | | |
| | |
|
| | | if (picture != null && picture.trim().length() > 0) {
|
| | | // 删除已存在图片
|
| | | removePicture(resultObj);
|
| | | |
| | |
|
| | | record.setSrc(picture);
|
| | | } else {
|
| | | record.setSrc(resultObj.getSrc());
|
| | | }
|
| | | |
| | |
|
| | | record.setOrder(resultObj.getOrder());
|
| | | record.setCreatetime(resultObj.getCreatetime());
|
| | | record.setUpdatetime(new Date());
|
| | | |
| | |
|
| | | swiperPictureMapper.updateByPrimaryKey(record);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 上传图片
|
| | | * |
| | | * @param file
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public String uploadPicture(MultipartFile file) throws Exception {
|
| | | |
| | | // 文件解析 |
| | |
|
| | | // 文件解析
|
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | |
| | |
|
| | | // 文件路径
|
| | | String filePath="/img/swiperPic/"+UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | String filePath = "/img/swiperPic/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | // 执行上传
|
| | | String fileLink= COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | | |
| | | String fileLink = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
|
| | |
|
| | | return fileLink;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 删除图片-不更新数据库
|
| | | * |
| | | * @param record
|
| | | * @throws Exception
|
| | | */
|
| | |
| | | COSManager.getInstance().deleteFile(picture);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException{
|
| | | |
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException {
|
| | |
|
| | | List<SwiperPicture> listSwiper = swiperPictureMapper.queryByListPrimaryKey(list);
|
| | | for (SwiperPicture swiperPicture: listSwiper) {
|
| | | for (SwiperPicture swiperPicture : listSwiper) {
|
| | | String src = swiperPicture.getSrc();
|
| | | if (!StringUtil.isNullOrEmpty(src)) {
|
| | | COSManager.getInstance().deleteFile(src);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | return swiperPictureMapper.deleteBatchByPrimaryKey(list);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public int deleteBatchByBannerID(List<Long> list) throws SwiperPictureException{
|
| | | public int deleteBatchByBannerID(List<Long> list) throws SwiperPictureException {
|
| | | return swiperPictureMapper.deleteBatchByBannerID(list);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public List<SwiperPicture> queryByListBannerID(List<Long> list) throws Exception{
|
| | | public List<SwiperPicture> queryByListBannerID(List<Long> list) throws Exception {
|
| | | return swiperPictureMapper.queryByListBannerID(list);
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | public List<SwiperPicture> getOrderByBannerID(Long bannerId, Integer type, Integer order) {
|
| | |
| | | public int getMaxOrderByBannerID(Long bannerId) throws SwiperPictureException {
|
| | | return swiperPictureMapper.getMaxOrderByBannerID(bannerId);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerCard-'+#card")
|
| | | public List<SwiperPicture> getByBannerCard(String card) {
|
| | | List<SwiperPicture> list = swiperPictureMapper.getByBannerCard(card);
|
| | | if (list != null && list.size() > 0) {
|
| | | for (SwiperPicture swiperPicture: list) {
|
| | | for (SwiperPicture swiperPicture : list) {
|
| | | boolean needLogin = swiperPicture.isJumpNeedLogin();
|
| | | JumpDetailV2 jumpDetail = swiperPicture.getJumpDetail();
|
| | | if (jumpDetail != null) {
|
| | |
| | | }
|
| | | return list;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 专题版本过滤
|
| | | * |
| | | * @param list
|
| | | * @param platform
|
| | | * @param versionCode
|
| | | */
|
| | | private void filterSwipePicture(List<SwiperPicture> list, String platform, int versionCode) {
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | AppVersionInfo app = appVersionService.getClientVersion(platform, versionCode);
|
| | | if (app == null) {
|
| | | list.clear();
|
| | | return;
|
| | | }
|
| | | List<Long> versionIdList = new ArrayList<>();
|
| | | versionIdList.add(app.getId());
|
| | | List<Long> sourceIdList = new ArrayList<>();
|
| | | for (SwiperPicture picture : list) {
|
| | | sourceIdList.add(picture.getId());
|
| | | }
|
| | |
|
| | | Set<Long> sourceIds = adActivityVersionControlService.filterSourceIdByVersion(sourceIdList,
|
| | | AdActivityType.banner, versionIdList);
|
| | | for (int i = 0; i < list.size(); i++) {
|
| | | if (!sourceIds.contains(list.get(i).getId())) {
|
| | | list.remove(i--);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerCardAndVersion-'+#card+'-'+#platform+'-'+#version")
|
| | | @Override
|
| | | public List<SwiperPicture> getByBannerCardAndVersion(String card, String platform, int version) {
|
| | | List<SwiperPicture> list = swiperPictureMapper.getByBannerCard(card);
|
| | | filterSwipePicture(list, platform, version);
|
| | | return list;
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerId-'+#bannerId")
|
| | | public List<SwiperPicture> getByBannerId(Long bannerId) {
|
| | | return swiperPictureMapper.getByBannerId(bannerId);
|
| | | }
|
| | | |
| | | }
|
| | |
|
| | | @Cacheable(value = "bannerCache", key = "'getByBannerId-'+#bannerId+'-'+#platform+'-'+#version")
|
| | | @Override
|
| | | public List<SwiperPicture> getByBannerId(Long bannerId, String platform, int version)
|
| | | throws SwiperPictureException {
|
| | | List<SwiperPicture> pictureList = swiperPictureMapper.getByBannerId(bannerId);
|
| | | filterSwipePicture(pictureList, platform, version);
|
| | | return pictureList;
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void setVersions(Long id, List<Long> versions) throws SwiperPictureException {
|
| | | SwiperPicture swiperPicture = selectByPrimaryKey(id);
|
| | | if (swiperPicture == null) {
|
| | | throw new SwiperPictureException(1, "Banner不存在");
|
| | | }
|
| | |
|
| | | Set<Long> oldSet = new HashSet<>();
|
| | |
|
| | | List<AdActivityVersionControl> versionList = adActivityVersionControlService
|
| | | .listByTypeAndSourceId(AdActivityType.banner, swiperPicture.getId());
|
| | | if (versionList != null) {
|
| | | for (AdActivityVersionControl control : versionList)
|
| | | oldSet.add(control.getVersion().getId());
|
| | | }
|
| | |
|
| | | Set<Long> newSet = new HashSet<>();
|
| | |
|
| | | for (Long version : versions) {
|
| | | newSet.add(version);
|
| | | }
|
| | |
|
| | | Set<Long> delSet = new HashSet<>();
|
| | | delSet.addAll(oldSet);
|
| | | delSet.removeAll(newSet);
|
| | | for (Long versionId : delSet) {
|
| | | // 根据
|
| | | adActivityVersionControlService.deleteBySourceAndVersion(id, AdActivityType.banner, versionId);
|
| | | }
|
| | |
|
| | | Set<Long> addSet = new HashSet<>();
|
| | | addSet.addAll(newSet);
|
| | | addSet.removeAll(oldSet);
|
| | |
|
| | | // 添加映射
|
| | | for (Long versionId : addSet) {
|
| | | AdActivityVersionControl control = new AdActivityVersionControl();
|
| | | control.setCreateTime(new Date());
|
| | | control.setSourceId(swiperPicture.getId());
|
| | | control.setType(AdActivityType.banner);
|
| | | control.setVersion(new AppVersionInfo(versionId));
|
| | | try {
|
| | | adActivityVersionControlService.addVersionControl(control);
|
| | | } catch (Exception e) {
|
| | | throw new SwiperPictureException(2, e.getMessage());
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public List<AppVersionInfo> listByVersion(String version);
|
| | |
|
| | | /**
|
| | | * 获取客户端版本
|
| | | * |
| | | * @param platform
|
| | | * @param versionCode
|
| | | * @return
|
| | | */
|
| | | public AppVersionInfo getClientVersion(String platform, int versionCode);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.homemodule;
|
| | |
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.AdActivityVersionControl.AdActivityType;
|
| | |
| | | public void deleteByPrimaryKey(Long id);
|
| | |
|
| | | /**
|
| | | * 根据来源与版本删除
|
| | | * @param sourceId
|
| | | * @param type
|
| | | * @param version
|
| | | */
|
| | | public void deleteBySourceAndVersion(Long sourceId, AdActivityType type, Long version);
|
| | |
|
| | | /**
|
| | | * 根据类型与内容ID查询
|
| | | *
|
| | | * @param type
|
| | |
| | | * @param appVersionId
|
| | | * @return
|
| | | */
|
| | | public List<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList);
|
| | | public Set<Long> filterSourceIdByVersion(List<Long> sourceIdList, AdActivityType type, List<Long> versionIdList);
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.homemodule;
|
| | |
|
| | |
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import org.springframework.web.multipart.MultipartFile;
|
| | |
| | |
|
| | | public interface SwiperPictureService {
|
| | |
|
| | |
|
| | | public int insertSelective(SwiperPicture record);
|
| | |
|
| | | public SwiperPicture selectByPrimaryKey(Long id);
|
| | |
| | | public int updateByPrimaryKeySelective(SwiperPicture record);
|
| | |
|
| | | public int updateByPrimaryKey(SwiperPicture record);
|
| | | |
| | |
|
| | | /**
|
| | | * 查询
|
| | | * |
| | | * @param start
|
| | | * @param count
|
| | | * @param bannerId
|
| | |
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public List<SwiperPicture> queryByBannerID(long start, int count, Long bannerId) throws SwiperPictureException;
|
| | | |
| | |
|
| | | public long countQueryByBannerID(Long bannerId) throws SwiperPictureException;
|
| | | |
| | |
|
| | | /**
|
| | | * 批量删除
|
| | | * @param list 主键id
|
| | | * |
| | | * @param list
|
| | | * 主键id
|
| | | * @return
|
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException;
|
| | | |
| | |
|
| | | /**
|
| | | * 批量删除 |
| | | * @param list 管理id
|
| | | * 批量删除
|
| | | * |
| | | * @param list
|
| | | * 管理id
|
| | | * @return
|
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public int deleteBatchByBannerID(List<Long> list) throws SwiperPictureException;
|
| | | |
| | |
|
| | | /**
|
| | | * 根据管理id集合 查询
|
| | | * |
| | | * @param list
|
| | | * @return
|
| | | * @throws Exception
|
| | | */
|
| | | public List<SwiperPicture> queryByListBannerID(List<Long> list) throws Exception;
|
| | | |
| | |
|
| | | /**
|
| | | * 获取附近排序值
|
| | | * |
| | | * @param bannerId
|
| | | * @param type
|
| | | * @param order
|
| | |
| | |
|
| | | /**
|
| | | * 获取最大排序值
|
| | | * |
| | | * @param bannerId
|
| | | * @return
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 根据 唯一标识查询
|
| | | * @param card 唯一标识
|
| | | * |
| | | * @param card
|
| | | * 唯一标识
|
| | | * @return
|
| | | */
|
| | | public List<SwiperPicture> getByBannerCard(String card);
|
| | |
|
| | | /**
|
| | | * 根据标识与版本查询
|
| | | * |
| | | * @param card
|
| | | * @param platform
|
| | | * @param version
|
| | | * @return
|
| | | */
|
| | | public List<SwiperPicture> getByBannerCardAndVersion(String card, String platform, int version);
|
| | |
|
| | | /**
|
| | | * 保存信息
|
| | | * |
| | | * @param record
|
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public void saveObject(MultipartFile file, SwiperPicture record, String jumpType) throws SwiperPictureException, Exception;
|
| | | public void saveObject(MultipartFile file, SwiperPicture record, String jumpType)
|
| | | throws SwiperPictureException, Exception;
|
| | |
|
| | | /**
|
| | | * 根据管理id 查询有效轮播图
|
| | | * |
| | | * @param bannerId
|
| | | * @return
|
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public List<SwiperPicture> getByBannerId(Long bannerId) throws SwiperPictureException;
|
| | | |
| | | |
| | | /**
|
| | | * 根据管理id 查询有效轮播图(更加版本区分)
|
| | | * @param bannerId
|
| | | * @param platform
|
| | | * @param version
|
| | | * @return
|
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public List<SwiperPicture> getByBannerId(Long bannerId,String platform,int version) throws SwiperPictureException;
|
| | | |
| | |
|
| | | /**
|
| | | * 为banner设置版本
|
| | | * |
| | | * @param id
|
| | | * @param versions
|
| | | * @throws SwiperPictureException
|
| | | */
|
| | | public void setVersions(Long id, List<Long> versions) throws SwiperPictureException;
|
| | |
|
| | | }
|