| | |
| | | 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 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.AdActivityVersionControl.AdActivityType;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperBanner;
|
| | | import com.yeshi.fanli.entity.bus.homemodule.SwiperPicture;
|
| | | import com.yeshi.fanli.entity.common.JumpDetailV2;
|
| | |
| | | String card = swiperBanner.getCard();
|
| | |
|
| | | if (StringUtil.isNullOrEmpty(title) || StringUtil.isNullOrEmpty(card)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("说明与标识不能为空"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("名称与标识不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (swiperBanner.getState() == null) {
|
| | | swiperBanner.setState(1);// 默认停用
|
| | | } |
| | | |
| | | Date nowTime = new Date();
|
| | | swiperBanner.setCreatetime(nowTime);
|
| | | swiperBanner.setUpdatetime(nowTime);
|
| | | swiperBannerService.insert(swiperBanner);
|
| | |
|
| | | swiperBannerService.insertSelective(swiperBanner);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("添加成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | |
| | | @RequestMapping(value = "saveModify")
|
| | | public void saveModify(String callback, SwiperBanner swiperBanner, PrintWriter out) {
|
| | | try {
|
| | |
|
| | | Long id = swiperBanner.getId();
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | if (swiperBanner.getState() == null) {
|
| | | swiperBanner.setState(1);// 默认停用
|
| | | } |
| | | |
| | | if (StringUtil.isNullOrEmpty(title)) {
|
| | | swiperBanner.setTitle(null);
|
| | | }
|
| | |
| | | if (StringUtil.isNullOrEmpty(card)) {
|
| | | swiperBanner.setCard(null);
|
| | | }
|
| | |
|
| | | swiperBanner.setUpdatetime(new Date());
|
| | | swiperBannerService.updateByPrimaryKeySelective(swiperBanner);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("修改成功"));
|
| | |
|
| | | } catch (SwiperBannerException e) {
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 修该状态
|
| | | * |
| | | * 修改状态
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "updateState")
|
| | | public void updateState(String callback, Long id, PrintWriter out) {
|
| | | @RequestMapping(value = "switchState")
|
| | | public void switchState(String callback, Long id, PrintWriter out) {
|
| | | try {
|
| | |
|
| | | if (id == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | SwiperBanner resultObj = swiperBannerService.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Integer state = resultObj.getState();
|
| | | 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));
|
| | |
|
| | | swiperBannerService.switchState(id);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | } catch (SwiperBannerException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 查询
|
| | |
| | | */
|
| | | @RequestMapping(value = "query")
|
| | | public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer sort, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | try {
|
| | | List<SwiperBanner> list = swiperBannerService.query((pageIndex - 1) * pageSize, pageSize, key, sort);
|
| | |
|
| | | if (list == null || list.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | for (SwiperBanner swiperBanne : list) {
|
| | | if (swiperBanne.getState() != null && swiperBanne.getState() == 0) {
|
| | | swiperBanne.setState(1);
|
| | | } else {
|
| | | swiperBanne.setState(0);
|
| | | }
|
| | | 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);
|
| | |
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | */
|
| | | @RequestMapping(value = "delete")
|
| | | public void delete(String callback, String idArray, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未检测到删除的数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | int count = swiperBannerService.deleteBatchByPrimaryKey(list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | |
| | | public void getEffectiveOption(String callback, PrintWriter out) {
|
| | | try {
|
| | | List<Object> list = new ArrayList<Object>();
|
| | |
|
| | | Map<String, Object> mapDefalut = new HashMap<String, Object>();
|
| | | mapDefalut.put("key", 0);
|
| | | mapDefalut.put("value", "--未选择--");
|
| | |
| | | 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();
|
| | |
| | | @RequestMapping(value = "queryPicInfo")
|
| | | public void queryPicInfo(String callback, Integer pageIndex, Integer pageSize, Long bannerId, String version,
|
| | | String platform, PrintWriter out) {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | | }
|
| | |
|
| | | pageSize = 100;
|
| | |
|
| | | if (bannerId == null) {
|
| | | out.print(JsonUtil.loadFalseResult("轮播图管理ID不能为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | if (pageIndex == null || pageIndex < 1) {
|
| | | pageIndex = 1;
|
| | | }
|
| | | if (pageSize == null || pageSize < 1) {
|
| | | pageSize = 100;
|
| | | }
|
| | | List<AppVersionInfo> versionList = null;
|
| | | if (!StringUtil.isNullOrEmpty(version) || !StringUtil.isNullOrEmpty(platform)) {
|
| | | versionList = new ArrayList<>();
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | 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) {
|
| | |
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | for (SwiperPicture swiperPicture : list) {
|
| | | if (swiperPicture.getState() != null && swiperPicture.getState() == 0) {
|
| | | swiperPicture.setState(1);
|
| | | } else {
|
| | | swiperPicture.setState(0);
|
| | | }
|
| | | |
| | | |
| | | Date startTime = swiperPicture.getStartTime();
|
| | | if (startTime == null) {
|
| | | swiperPicture.setStartTime_str("");
|
| | |
| | | }
|
| | |
|
| | | long count = swiperPictureService.countQueryByBannerID(bannerId);
|
| | |
|
| | | // 过滤
|
| | | if (versionList != null) {
|
| | | if (versionList.size() > 0) {
|
| | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(list));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (SwiperPictureException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | e.printStackTrace();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 修改状态
|
| | | * @param callback
|
| | | * @param id
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "switchStatePic")
|
| | | public void switchStatePic(String callback, Long id, PrintWriter out) {
|
| | | try {
|
| | | swiperPictureService.switchState(id);
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | | } catch (SwiperPictureException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | /**
|
| | | * 删除图片以及信息
|
| | | *
|
| | |
| | | */
|
| | | @RequestMapping(value = "deletePicInfo")
|
| | | public void deletePicInfo(String callback, String idArray, PrintWriter out) {
|
| | |
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(idArray)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
|
| | |
| | | }
|
| | |
|
| | | int count = swiperPictureService.deleteBatchByPrimaryKey(list);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
|
| | | e.printStackTrace();
|
| | |
| | | */
|
| | | @RequestMapping(value = "saveOrder")
|
| | | 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;
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | |
|
| | | SwiperPicture resultObj = swiperPictureService.selectByPrimaryKey(id);
|
| | | if (resultObj == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
|
| | |
| | | SwiperPicture changeObj = list.get(0);
|
| | | // 交换排序序号
|
| | | resultObj.setOrder(changeObj.getOrder());
|
| | |
|
| | | changeObj.setOrder(oldOrder);
|
| | |
|
| | | swiperPictureService.updateByPrimaryKeySelective(changeObj);
|
| | | }
|
| | |
|
| | | swiperPictureService.updateByPrimaryKeySelective(resultObj);
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | /**
|