yujian
2020-04-23 9d384facd1f066beb9e3eefe769ee8616dc2710d
后台状态切换
11个文件已修改
330 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/ArticleOfficialAdminController.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SpecialLabelAdminController.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java 144 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java 21 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialLabelImpl.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/ArticleOfficialService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SpecialLabelService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SwiperBannerService.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SwiperPictureService.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/ArticleOfficialAdminController.java
@@ -26,7 +26,7 @@
import net.sf.json.JSONObject;
/**
 * 轮播图管理
 * 学院管理
 * 
 * @author Administrator
 *
@@ -64,6 +64,27 @@
    }
    /**
     * 修改状态
     * @param callback
     * @param id
     * @param out
     */
    @RequestMapping(value = "switchState")
    public void switchState(String callback, String id, PrintWriter out) {
        try {
            articleOfficialService.switchState(id);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (ArticleOfficialException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    /**
     * 删除图片以及信息
     * 
     * @param callback
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SpecialLabelAdminController.java
@@ -51,6 +51,26 @@
        }
    }
    /**
     * 修改状态
     * @param callback
     * @param id
     * @param out
     */
    @RequestMapping(value = "switchState")
    public void switchState(String callback, Long id, PrintWriter out) {
        try {
            specialLabelService.switchState(id);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (SpecialLabelException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    /**
     * 查询
fanli/src/main/java/com/yeshi/fanli/controller/admin/homemodule/SwiperBannerAdminController.java
@@ -5,7 +5,6 @@
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;
@@ -22,8 +21,8 @@
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;
@@ -89,16 +88,18 @@
            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("操作异常"));
@@ -116,7 +117,6 @@
    @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不能为空"));
@@ -136,6 +136,10 @@
                return;
            }
            if (swiperBanner.getState() == null) {
                swiperBanner.setState(1);// 默认停用
            }
            if (StringUtil.isNullOrEmpty(title)) {
                swiperBanner.setTitle(null);
            }
@@ -143,59 +147,34 @@
            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();
        }
    }
    /**
     * 查询
@@ -211,7 +190,6 @@
     */
    @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;
        }
@@ -219,23 +197,24 @@
        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);
@@ -246,14 +225,11 @@
            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();
        }
    }
    /**
@@ -265,7 +241,6 @@
     */
    @RequestMapping(value = "delete")
    public void delete(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
@@ -280,11 +255,8 @@
                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();
@@ -295,7 +267,6 @@
    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", "--未选择--");
@@ -314,7 +285,6 @@
            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();
@@ -333,22 +303,16 @@
    @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<>();
@@ -365,19 +329,23 @@
        }
        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("");
@@ -413,7 +381,6 @@
            }
            long count = swiperPictureService.countQueryByBannerID(bannerId);
            // 过滤
            if (versionList != null) {
                if (versionList.size() > 0) {
@@ -449,9 +416,7 @@
            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();
@@ -487,6 +452,27 @@
        }
    }
    /**
     * 修改状态
     * @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();
        }
    }
    /**
     * 删除图片以及信息
     * 
@@ -496,7 +482,6 @@
     */
    @RequestMapping(value = "deletePicInfo")
    public void deletePicInfo(String callback, String idArray, PrintWriter out) {
        try {
            if (StringUtil.isNullOrEmpty(idArray)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
@@ -513,9 +498,7 @@
            }
            int count = swiperPictureService.deleteBatchByPrimaryKey(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除[" + count + "]条数据"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
@@ -531,7 +514,6 @@
     */
    @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;
@@ -543,7 +525,6 @@
        }
        try {
            SwiperPicture resultObj = swiperPictureService.selectByPrimaryKey(id);
            if (resultObj == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
@@ -558,21 +539,16 @@
                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("操作异常"));
        }
    }
    /**
fanli/src/main/java/com/yeshi/fanli/service/impl/dynamic/ArticleOfficialServiceImpl.java
@@ -169,6 +169,27 @@
    
    
    @Override
    public void switchState(String id) throws ArticleOfficialException {
        if (StringUtil.isNullOrEmpty(id)) {
            throw new ArticleOfficialException(1, "请传递正确参数");
        }
        ArticleOfficial resultObj = articleOfficialDao.getById(id);
        if (resultObj == null) {
            throw new ArticleOfficialException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
        } else {
            state = 0;
        }
        resultObj.setState(state);
        articleOfficialDao.save(resultObj);
    }
    @Override
    public ArticleOfficial getById(String id) {
        return articleOfficialDao.getById(id);
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SpecialLabelImpl.java
@@ -55,6 +55,30 @@
        }
    }
    
    @Override
    public void switchState(Long id) throws SpecialLabelException {
        if (id == null) {
            throw new SpecialLabelException(1, "请传递正确参数");
        }
        SpecialLabel resultObj = specialLabelMapper.selectByPrimaryKey(id);
        if (resultObj == null) {
            throw new SpecialLabelException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
        } else {
            state = 0;
        }
        SpecialLabel updateObj = new SpecialLabel();
        updateObj.setId(id);
        updateObj.setState(state);
        specialLabelMapper.updateByPrimaryKeySelective(updateObj);
    }
    @Override
    public int deleteByPrimaryKeyBatch(List<Long> list){
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperBannerServiceImpl.java
@@ -48,7 +48,7 @@
    }
    @Override
    public int updateByPrimaryKeySelective(SwiperBanner record) throws SwiperBannerException{
    public int updateByPrimaryKeySelective(SwiperBanner record){
        return swiperBannerMapper.updateByPrimaryKeySelective(record);
    }
@@ -58,21 +58,44 @@
    }
    @Override
    public List<SwiperBanner> query(long start, int count, String key, Integer sort) throws SwiperBannerException{
    public List<SwiperBanner> query(long start, int count, String key, Integer sort){
        return swiperBannerMapper.query(start, count, key, sort);
    }
    @Override
    public long countQuery(String key) throws SwiperBannerException{
    public long countQuery(String key) {
        return swiperBannerMapper.countQuery(key);
    }
    @Override
    public void switchState(Long id) throws SwiperBannerException {
        if (id == null) {
            throw new SwiperBannerException(1, "请传递正确参数");
        }
        SwiperBanner resultObj = swiperBannerMapper.selectByPrimaryKey(id);
        if (resultObj == null) {
            throw new SwiperBannerException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
        } else {
            state = 0;
        }
        SwiperBanner updateObj = new SwiperBanner();
        updateObj.setId(id);
        updateObj.setState(state);
        swiperBannerMapper.updateByPrimaryKeySelective(updateObj);
    }
    @Override
    @Transactional(rollbackFor=Exception.class)
    public int deleteBatchByPrimaryKey(List<Long> list) throws Exception {
        List<Long> listPicID = new ArrayList<Long>();
        List<SwiperPicture> listPic = swiperPictureService.queryByListBannerID(list);
        for (SwiperPicture swiperPicture: listPic) {
            String src = swiperPicture.getSrc();
fanli/src/main/java/com/yeshi/fanli/service/impl/homemodule/SwiperPictureServiceImpl.java
@@ -215,10 +215,35 @@
        }
    }
    @Override
    public void switchState(Long id) throws SwiperPictureException {
        if (id == null) {
            throw new SwiperPictureException(1, "请传递正确参数");
        }
        SwiperPicture resultObj = swiperPictureMapper.selectByPrimaryKey(id);
        if (resultObj == null) {
            throw new SwiperPictureException(1, "此内容已不存在");
        }
        Integer state = resultObj.getState();
        if (state == null || state == 0) {
            state = 1;
        } else {
            state = 0;
        }
        SwiperPicture updateObj = new SwiperPicture();
        updateObj.setId(id);
        updateObj.setState(state);
        updateObj.setJumpNeedLogin(resultObj.isJumpNeedLogin());
        swiperPictureMapper.updateByPrimaryKeySelective(updateObj);
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public int deleteBatchByPrimaryKey(List<Long> list) throws SwiperPictureException {
        List<SwiperPicture> listSwiper = swiperPictureMapper.queryByListPrimaryKey(list);
        for (SwiperPicture swiperPicture : listSwiper) {
            String src = swiperPicture.getSrc();
fanli/src/main/java/com/yeshi/fanli/service/inter/dynamic/ArticleOfficialService.java
@@ -51,4 +51,11 @@
    public void updateReadNum(String id);
    /**
     * 状态切换
     * @param id
     * @throws ArticleOfficialException
     */
    public void switchState(String id) throws ArticleOfficialException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SpecialLabelService.java
@@ -43,5 +43,13 @@
     */
    public void stickLabelOnSpecial(List<Long> idList, List<Long> labIdList);
    /**
     * 状态切换
     * @param id
     * @throws SpecialLabelException
     */
    public void switchState(Long id) throws SpecialLabelException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SwiperBannerService.java
@@ -17,13 +17,13 @@
    public SwiperBanner selectByPrimaryKey(Long id);
    public int updateByPrimaryKeySelective(SwiperBanner record) throws SwiperBannerException;
    public int updateByPrimaryKeySelective(SwiperBanner record);
    public int updateByPrimaryKey(SwiperBanner record) throws SwiperBannerException;
    public int updateByPrimaryKey(SwiperBanner record);
    
    public List<SwiperBanner> query(long start, int count, String key, Integer sort) throws SwiperBannerException;
    public List<SwiperBanner> query(long start, int count, String key, Integer sort);
    
    public long countQuery(String key) throws SwiperBannerException;
    public long countQuery(String key);
    
    public int deleteBatchByPrimaryKey(List<Long> list) throws Exception;
@@ -34,4 +34,11 @@
     */
    public List<SwiperBanner> getEffectiveOption();
    
    /**
     * 状态切换
     * @param id
     * @throws SwiperBannerException
     */
    public void switchState(Long id) throws SwiperBannerException;
}
fanli/src/main/java/com/yeshi/fanli/service/inter/homemodule/SwiperPictureService.java
@@ -136,4 +136,12 @@
     */
    public void setVersions(Long id, List<Long> versions) throws SwiperPictureException;
    /**
     * 状态切换
     * @param id
     * @throws SwiperPictureException
     */
    public void switchState(Long id) throws SwiperPictureException;
}