admin
2019-02-14 c573834c796cc77057455ef0b3d8d0412f9792b9
Merge remote-tracking branch 'origin/master'
7个文件已修改
6个文件已添加
1029 ■■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/controller/admin/HelpCenterAdminController.java 277 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5HelpCenterController.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpCenterMapper.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpClassMapper.java 59 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpCenter.java 39 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpClass.java 108 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/exception/HelpClassException.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpCenterMapper.xml 52 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpClassMapper.xml 112 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpCenterServiceImpl.java 15 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java 183 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpCenterService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpClassService.java 93 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/controller/admin/HelpCenterAdminController.java
@@ -2,27 +2,33 @@
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.yeshi.utils.JsonUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.yeshi.fanli.entity.bus.help.HelpCenter;
import com.yeshi.fanli.entity.bus.help.HelpClass;
import com.yeshi.fanli.entity.bus.help.HelpInfo;
import com.yeshi.fanli.exception.HelpCenterException;
import com.yeshi.fanli.exception.HelpClassException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.help.HelpCenterService;
import com.yeshi.fanli.service.inter.help.HelpClassService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.StringUtil;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("admin/new/api/v1/helpCenter")
@@ -30,6 +36,9 @@
    @Resource
    private HelpCenterService helpCenterService;
    @Resource
    private HelpClassService helpClassService;
    
    
    /**
@@ -60,7 +69,6 @@
            try {
                LogHelper.errorDetailInfo(e);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
        }
@@ -85,9 +93,6 @@
            
            HelpInfo helpInfo = helpCenterService.getHelpInfo(id);
            
            JSONObject data = new JSONObject();
            data.put("id",crrent.getId());
            data.put("title",crrent.getTitle());
@@ -99,7 +104,6 @@
            
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (HelpCenterException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
@@ -114,8 +118,8 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize,
            String key, Integer orderMode, PrintWriter out) {
    public void query(String callback, Integer pageIndex, Integer pageSize, String key, Long cid,
            Integer orderMode, PrintWriter out) {
        
        try {
            
@@ -129,14 +133,24 @@
                pageSize = Constant.PAGE_SIZE;
            
            List<HelpCenter> helpCenterList = 
                    helpCenterService.query((pageIndex - 1) * pageSize, pageSize, key,orderMode);
                    helpCenterService.query((pageIndex - 1) * pageSize, pageSize, key, cid, orderMode);
            
            if (helpCenterList == null || helpCenterList.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            } 
            
            long count = helpCenterService.countQuery(key);
            for (HelpCenter helpCenter: helpCenterList) {
                HelpClass helpClass = helpCenter.getHelpClass();
                if (helpClass == null ) {
                    helpClass = new HelpClass();
                    helpClass.setId(0L);
                    helpClass.setName("-未选择-");
                    helpCenter.setHelpClass(helpClass);
                }
            }
            long count = helpCenterService.countQuery(key, cid);
                
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count    / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -159,7 +173,7 @@
    
    
    /**
     * 批量删除
     * 修改
     * @param callback
     * @param idArray
     * @param out
@@ -185,17 +199,10 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
            
        } catch (HelpCenterException e) {
            // TODO Auto-generated catch block
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    
    /**
     * 批量删除
@@ -211,7 +218,6 @@
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("未选择操作的数据"));
                return;
            }
            
            Gson gson = new Gson();
            List<String> idList = gson.fromJson(idArray, new TypeToken<ArrayList<String>>() {}.getType());
@@ -229,11 +235,238 @@
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("删除成功"));
            
        } catch (HelpCenterException e) {
            // TODO Auto-generated catch block
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    
    /**
     * 设置分类
     * @param callback
     * @param out
     */
    @RequestMapping(value = "setClass")
    public void saveModify(String callback, Long id, Long cid, PrintWriter out) {
        try {
            if (id == null || cid == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请传递正确参数"));
                return;
            }
            HelpCenter crrent = helpCenterService.selectByPrimaryKey(id);
            if (crrent == null) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作数据已不存在"));
                return;
            }
            if (cid == 0) {
                crrent.setHelpClass(null);
            } else {
                crrent.setHelpClass(new HelpClass(cid));
            }
            crrent.setUpdatetime(new Date());
            helpCenterService.updateByPrimaryKey(crrent);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (HelpCenterException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    /**
     * 分类保存-新增、修改
     * @param callback
     * @param special
     * @param out
     */
    @RequestMapping(value = "saveClass")
    public void saveClass(String callback, HelpClass helpClass, PrintWriter out) {
        try {
            String name = helpClass.getName();
            if (StringUtil.isNullOrEmpty(name)) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("名称不能为空"));
                return;
            }
            helpClassService.save(helpClass);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (HelpClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
            e.printStackTrace();
        }
    }
    /**
     * 修改系统状态
     * @param callback
     * @param id
     * @param out
     */
    @RequestMapping(value = "updateShowState")
    public void updateShowState(String callback, Long id, PrintWriter out) {
        try {
            int state = helpClassService.updateShowState(id);
            JSONObject data = new JSONObject();
            data.put("showState", state);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (HelpClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e1) {
            e1.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
        }
    }
    /**
     * 修改排序
     * @param callback
     * @param out
     */
    @RequestMapping(value = "updateSort")
    public void updateSort(String callback, Integer moveType, Long id, PrintWriter out) {
        try {
            helpClassService.updateSort(moveType, id);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (HelpClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e1) {
            e1.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
        }
    }
    /**
     *  上传图片
     * @param callback
     * @param out
     */
    @RequestMapping(value = "uploadClassPic")
    public void uploadClassPic(String callback, @RequestParam("file") CommonsMultipartFile file,
            Long id,PrintWriter out) {
        try {
            helpClassService.uploadPic(file, id);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("操作成功"));
        } catch (HelpClassException e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
        } catch (Exception e1) {
            e1.printStackTrace();
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作失败"));
        }
    }
    /**
     * 删除
     * @param callback
     * @param idArray
     * @param out
     */
    @RequestMapping(value = "deleteClass")
    public void deleteClass(String callback, String idArray, PrintWriter out) {
        if (StringUtil.isNullOrEmpty(idArray)) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请选择操作的数据"));
            return;
        }
        try {
            Gson gson = new Gson();
            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 = helpClassService.deleteByPrimaryKeyBatch(list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("成功删除["+ count +"]条数据"));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("删除失败"));
            e.printStackTrace();
        }
    }
    /**
     * 查询
     * @param callback
     * @param pageIndex
     * @param pageSize
     * @param key  模糊查询:说明、标识
     * @param out
     */
    @RequestMapping(value = "queryClass")
    public void queryClass(String callback, Integer pageIndex, Integer pageSize, String key,
            Integer showState, PrintWriter out) {
        if (pageIndex == null || pageIndex < 1) {
            pageIndex = 1;
        }
        if (pageSize == null || pageSize < 1) {
            pageSize = Constant.PAGE_SIZE;
        }
        try {
            List<HelpClass> list = helpClassService.query((pageIndex - 1) * pageSize, pageSize, key, showState);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            long count = helpClassService.countQuery(key, showState);
            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();
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
            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();
        }
    }
    /**
     * 查询所有分类
     * @param out
     */
    @RequestMapping(value = "getProvidedClass")
    public void getAllClass(String callback, PrintWriter out) {
        try {
            HelpClass helpClass = new HelpClass();
            helpClass.setId(0L);
            helpClass.setName("-未选择-");
            List<HelpClass> reslut_list = new ArrayList<HelpClass>();
            reslut_list.add(helpClass);
            List<HelpClass> list = helpClassService.getProvidedClass();
            if (list != null && list.size() > 0) {
                reslut_list.addAll(list);
            }
            JSONObject data = new JSONObject();
            data.put("class_list", reslut_list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/controller/apph5/AppH5HelpCenterController.java
@@ -5,19 +5,20 @@
import javax.annotation.Resource;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
import com.yeshi.fanli.entity.bus.help.HelpCenter;
import com.yeshi.fanli.entity.bus.help.HelpClass;
import com.yeshi.fanli.entity.bus.help.HelpInfo;
import com.yeshi.fanli.exception.HelpCenterException;
import com.yeshi.fanli.service.inter.help.HelpCenterService;
import com.yeshi.fanli.service.inter.help.HelpClassService;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.annotation.RequestNoSignValidate;
import org.yeshi.utils.JsonUtil;
import net.sf.json.JSONObject;
@Controller
@RequestMapping("api/apph5/v1/helpCenter")
@@ -26,6 +27,8 @@
    @Resource
    private HelpCenterService helpCenterService;
    
    @Resource
    private HelpClassService helpClassService;
    
    /**
     * 查询帮助列表
@@ -36,8 +39,7 @@
     * @param out
     */
    @RequestMapping(value = "query")
    public void query(String callback, Integer pageIndex, Integer pageSize,    String key,
            PrintWriter out) {
    public void query(String callback, Integer pageIndex, Integer pageSize,    String key, PrintWriter out) {
        
        try {
            
@@ -48,14 +50,14 @@
                pageSize = Constant.PAGE_SIZE;
            
            List<HelpCenter> helpCenterList = 
                    helpCenterService.queryIdAndTitle((pageIndex - 1) * pageSize, pageSize, key);
                    helpCenterService.queryIdAndTitle((pageIndex - 1) * pageSize, pageSize, key, null);
            
            if (helpCenterList == null || helpCenterList.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(2, "没有更多了"));
                return;
            } 
            
            long count = helpCenterService.countQuery(key);
            long count = helpCenterService.countQuery(key, null);
                
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count    / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
@@ -117,4 +119,30 @@
        }
    }
    
    /**
     * 查询启用的分类
     * @param callback
     * @param out
     */
    @RequestMapping(value = "getClass")
    public void getClass(String callback, PrintWriter out) {
        try {
            List<HelpClass> list = helpClassService.getClassByState(1);
            if (list == null || list.size() == 0) {
                JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
                return;
            }
            JSONObject data = new JSONObject();
            data.put("class_list", list);
            JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
        } catch (Exception e) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
            e.printStackTrace();
        }
    }
}
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpCenterMapper.java
@@ -22,13 +22,15 @@
    int updateByPrimaryKey(HelpCenter record);
    
    
    List<HelpCenter> queryIdAndTitle(@Param("start") int start, @Param("count") int count, @Param("key") String title);
    List<HelpCenter> queryIdAndTitle(@Param("start") int start, @Param("count") int count,
            @Param("key") String title, @Param("cid") Long cid);
    
    
    List<HelpCenter> query(@Param("start") int start, @Param("count") int count, @Param("key") String title,
    List<HelpCenter> query(@Param("start") int start, @Param("count") int count,
            @Param("key") String title, @Param("cid") Long cid,
             @Param("orderMode") Integer orderMode);
    
    long countQuery(@Param("key") String title);
    long countQuery(@Param("key") String title, @Param("cid") Long cid);
    
    /**
     * 批量删除
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/help/HelpClassMapper.java
New file
@@ -0,0 +1,59 @@
package com.yeshi.fanli.dao.mybatis.help;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.yeshi.fanli.dao.BaseMapper;
import com.yeshi.fanli.entity.bus.help.HelpClass;
public interface HelpClassMapper extends BaseMapper<HelpClass>{
    /**
     * 根据主键批量删除
     * @param list
     * @return
     */
    int deleteByPrimaryKeyBatch(List<Long> list);
    /**
     * 后端列表查询
     * @param start
     * @param count
     * @param key
     * @return
     */
    List<HelpClass> listQuery(@Param("start") long start, @Param("count") int count,
            @Param("key") String key, @Param("state") Integer state);
    long countQuery(@Param("key") String key, @Param("state") Integer state);
    /**
     * 获取最大的排序值
     * @return
     */
    int getMaxOrder();
    /**
     * 查询交换排序对象
     * @param type
     * @param sort 排序值
     * @return
     */
    HelpClass getChangeOrder(@Param("type") Integer type, @Param("sort") Integer sort);
    /**
     * 根据状态查询
     * @param state
     * @return
     */
    List<HelpClass> getClassByState(@Param("state") Integer state);
    /**
     * 查询所有分类 提供筛选
     * @return
     */
    List<HelpClass> getProvidedClass();
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpCenter.java
@@ -2,14 +2,7 @@
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Table;
import org.yeshi.utils.mybatis.Column;
/**
 * 帮助中心标题
@@ -18,32 +11,26 @@
 *
 * @date 2018年8月14日
 */
@Entity
@Table(name = "yeshi_ec_help_center")
@org.yeshi.utils.mybatis.Table("yeshi_ec_help_center")
public class HelpCenter {
    @Id
    @Column(name = "h_id")
    @GeneratedValue(strategy = GenerationType.AUTO)
    @org.yeshi.utils.mybatis.Column(name = "h_id")
    private Long id;
    @JoinColumn(name = "h_title")
    @org.yeshi.utils.mybatis.Column(name = "h_title")
    @Column(name = "h_title")
    private String title;// 名称
    @JoinColumn(name = "h_weight")
    @org.yeshi.utils.mybatis.Column(name = "h_weight")
    @Column(name = "h_weight")
    private Integer weight; // 权重
    @Column(name = "h_cid")
    private HelpClass helpClass; // 分类
    @JoinColumn(name = "h_createtime")
    @org.yeshi.utils.mybatis.Column(name = "h_createtime")
    @Column(name = "h_createtime")
    private Date createtime; // 创建时间
    @JoinColumn(name = "h_updatetime")
    @org.yeshi.utils.mybatis.Column(name = "h_updatetime")
    @Column(name = "h_updatetime")
    private Date updatetime; // 更新时间(修改时间)
    public Long getId() {
@@ -86,4 +73,12 @@
        this.updatetime = updatetime;
    }
    public HelpClass getHelpClass() {
        return helpClass;
    }
    public void setHelpClass(HelpClass helpClass) {
        this.helpClass = helpClass;
    }
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/help/HelpClass.java
New file
@@ -0,0 +1,108 @@
package com.yeshi.fanli.entity.bus.help;
import java.util.Date;
import org.yeshi.utils.mybatis.Column;
import org.yeshi.utils.mybatis.Table;
/**
 * 帮助中心分类
 *
 * @author yj
 *
 * @date 2019年01月28日
 */
@Table("yeshi_ec_help_class")
public class HelpClass {
    @Column(name = "hc_id")
    private Long id;
    // 名称
    @Column(name = "hc_name")
    private String name;
    // 图片链接
    @Column(name = "hc_picture")
    private String picture;
    // 排序
    @Column(name = "hc_sort")
    private Integer sort;
    // 显示状态  1显示  0 不显示
    @Column(name = "hc_show_state")
    private Integer showState;
    // 创建时间
    @Column(name = "hc_create_time")
    private Date createTime;
    // 更新时间
    @Column(name = "hc_update_time")
    private Date updateTime;
    public HelpClass() {}
    public HelpClass(Long id) {
        this.id = id;
    }
    public Long getId() {
        return id;
    }
    public void setId(Long id) {
        this.id = id;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getPicture() {
        return picture;
    }
    public void setPicture(String picture) {
        this.picture = picture;
    }
    public Integer getSort() {
        return sort;
    }
    public void setSort(Integer sort) {
        this.sort = sort;
    }
    public Integer getShowState() {
        return showState;
    }
    public void setShowState(Integer showState) {
        this.showState = showState;
    }
    public Date getCreateTime() {
        return createTime;
    }
    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }
    public Date getUpdateTime() {
        return updateTime;
    }
    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }
}
fanli/src/main/java/com/yeshi/fanli/exception/HelpClassException.java
New file
@@ -0,0 +1,32 @@
package com.yeshi.fanli.exception;
public class HelpClassException extends Exception {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    private int code;
    private String msg;
    public int getCode() {
        return code;
    }
    public String getMsg() {
        return msg;
    }
    public HelpClassException(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }
    public HelpClassException() {
    }
    @Override
    public String getMessage() {
        return this.msg;
    }
}
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpCenterMapper.xml
@@ -8,21 +8,26 @@
    <result column="h_weight" property="weight" jdbcType="INTEGER"/>
    <result column="h_createtime" property="createtime" jdbcType="TIMESTAMP"/>
    <result column="h_updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
    <association property="helpClass" column="h_cid"
            javaType="com.yeshi.fanli.entity.bus.help.HelpClass">
            <id column="h_cid" property="id" jdbcType="BIGINT" />
            <id column="hc_name" property="name" jdbcType="VARCHAR" />
    </association>
  </resultMap>
  <sql id="Base_Column_List">h_id,h_title,h_weight,h_createtime,h_updatetime</sql>
  <sql id="Base_Column_List">h_id,h_title,h_weight,h_cid,h_createtime,h_updatetime</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_help_center where h_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center (h_id,h_title,h_weight,h_createtime,h_updatetime) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{weight,jdbcType=INTEGER},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center (h_id,h_title,h_weight,h_cid,h_createtime,h_updatetime) values (#{id,jdbcType=BIGINT},#{title,jdbcType=VARCHAR},#{weight,jdbcType=INTEGER},#{helpClass.id,jdbcType=BIGINT},#{createtime,jdbcType=TIMESTAMP},#{updatetime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_center
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">h_id,</if>
      <if test="title != null">h_title,</if>
      <if test="weight != null">h_weight,</if>
      <if test="helpClass != null">h_cid,</if>
      <if test="createtime != null">h_createtime,</if>
      <if test="updatetime != null">h_updatetime,</if>
    </trim>values
@@ -30,54 +35,56 @@
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="title != null">#{title,jdbcType=VARCHAR},</if>
      <if test="weight != null">#{weight,jdbcType=INTEGER},</if>
      <if test="helpClass != null">#{helpClass.id,jdbcType=BIGINT},</if>
      <if test="createtime != null">#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">#{updatetime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center set h_title = #{title,jdbcType=VARCHAR},h_weight = #{weight,jdbcType=INTEGER},h_createtime = #{createtime,jdbcType=TIMESTAMP},h_updatetime = #{updatetime,jdbcType=TIMESTAMP} where h_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center set h_title = #{title,jdbcType=VARCHAR},h_weight = #{weight,jdbcType=INTEGER},h_cid = #{helpClass.id,jdbcType=BIGINT},h_createtime = #{createtime,jdbcType=TIMESTAMP},h_updatetime = #{updatetime,jdbcType=TIMESTAMP} where h_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpCenter">update yeshi_ec_help_center
    <set>
      <if test="title != null">h_title=#{title,jdbcType=VARCHAR},</if>
      <if test="weight != null">h_weight=#{weight,jdbcType=INTEGER},</if>
      <if test="helpClass != null">h_cid=#{helpClass.id,jdbcType=BIGINT},</if>
      <if test="createtime != null">h_createtime=#{createtime,jdbcType=TIMESTAMP},</if>
      <if test="updatetime != null">h_updatetime=#{updatetime,jdbcType=TIMESTAMP},</if>
    </set> where h_id = #{id,jdbcType=BIGINT}
  </update>
  
   <select id="query" resultMap="BaseResultMap">
      <!-- 根据条件查询所有标签 -->
    SELECT  <include refid="Base_Column_List" />  FROM yeshi_ec_help_center
    SELECT *  FROM yeshi_ec_help_center     ht
    LEFT JOIN  yeshi_ec_help_class hc ON ht.h_cid = hc.hc_id
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
              AND ht.h_title like '%${key}%'
       </if>
       <if test='cid != null'>
              AND ht.h_cid  = cid
       </if>
       
       <if test='orderMode == 1'>
            ORDER BY  h_weight  DESC
            ORDER BY  ht.h_weight  DESC
       </if>
           <if test='orderMode == 2'>
            ORDER BY  h_weight
       <if test='orderMode == 2'>
            ORDER BY  ht.h_weight
       </if>
      
       <if test='orderMode == 3'>
            ORDER BY  h_createtime  DESC
            ORDER BY  ht.h_createtime  DESC
       </if>
       
        <if test='orderMode == 4'>
            ORDER BY h_createtime
            ORDER BY ht.h_createtime
       </if>
       
        <if test='orderMode == 5'>
            ORDER BY  h_updatetime  DESC
            ORDER BY  ht.h_updatetime  DESC
       </if>
       
        <if test='orderMode == 6'>
            ORDER BY  h_updatetime
            ORDER BY  ht.h_updatetime
       </if>
        LIMIT ${start},${count}
   </select>
   <select id="countQuery" resultType="java.lang.Long">
@@ -85,6 +92,9 @@
        WHERE     <![CDATA[1>0]]>
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
       <if test='cid != null'>
              AND h_cid  = cid
       </if>
    </select>
    
@@ -95,7 +105,9 @@
       <if test='key != null and key != ""'>
              AND h_title like '%${key}%'
       </if>
       <if test='cid != null'>
              AND h_cid  = cid
       </if>
        ORDER BY  h_weight  DESC, h_createtime
        LIMIT ${start},${count}
fanli/src/main/java/com/yeshi/fanli/mapping/help/HelpClassMapper.xml
New file
@@ -0,0 +1,112 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeshi.fanli.dao.mybatis.help.HelpClassMapper">
   <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.help.HelpClass">
    <id column="hc_id" property="id" jdbcType="BIGINT"/>
    <result column="hc_name" property="name" jdbcType="VARCHAR"/>
    <result column="hc_picture" property="picture" jdbcType="VARCHAR"/>
    <result column="hc_sort" property="sort" jdbcType="INTEGER"/>
    <result column="hc_show_state" property="showState" jdbcType="INTEGER"/>
    <result column="hc_create_time" property="createTime" jdbcType="TIMESTAMP"/>
    <result column="hc_update_time" property="updateTime" jdbcType="TIMESTAMP"/>
  </resultMap>
  <sql id="Base_Column_List">hc_id,hc_name,hc_picture,hc_sort,hc_show_state,hc_create_time,hc_update_time</sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long">select
    <include refid="Base_Column_List"/>from yeshi_ec_help_class where hc_id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">delete from yeshi_ec_help_class where hc_id = #{id,jdbcType=BIGINT}</delete>
  <insert id="insert" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_class (hc_id,hc_name,hc_picture,hc_sort,hc_show_state,hc_create_time,hc_update_time) values (#{id,jdbcType=BIGINT},#{name,jdbcType=VARCHAR},#{picture,jdbcType=VARCHAR},#{sort,jdbcType=INTEGER},#{showState,jdbcType=INTEGER},#{createTime,jdbcType=TIMESTAMP},#{updateTime,jdbcType=TIMESTAMP})</insert>
  <insert id="insertSelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass" useGeneratedKeys="true" keyProperty="id">insert into yeshi_ec_help_class
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">hc_id,</if>
      <if test="name != null">hc_name,</if>
      <if test="picture != null">hc_picture,</if>
      <if test="sort != null">hc_sort,</if>
      <if test="showState != null">hc_show_state,</if>
      <if test="createTime != null">hc_create_time,</if>
      <if test="updateTime != null">hc_update_time,</if>
    </trim>values
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">#{id,jdbcType=BIGINT},</if>
      <if test="name != null">#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">#{picture,jdbcType=VARCHAR},</if>
      <if test="sort != null">#{sort,jdbcType=INTEGER},</if>
      <if test="showState != null">#{showState,jdbcType=INTEGER},</if>
      <if test="createTime != null">#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">#{updateTime,jdbcType=TIMESTAMP},</if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass">update yeshi_ec_help_class set hc_name = #{name,jdbcType=VARCHAR},hc_picture = #{picture,jdbcType=VARCHAR},hc_sort = #{sort,jdbcType=INTEGER},hc_show_state = #{showState,jdbcType=INTEGER},hc_create_time = #{createTime,jdbcType=TIMESTAMP},hc_update_time = #{updateTime,jdbcType=TIMESTAMP} where hc_id = #{id,jdbcType=BIGINT}</update>
  <update id="updateByPrimaryKeySelective" parameterType="com.yeshi.fanli.entity.bus.help.HelpClass">update yeshi_ec_help_class
    <set>
      <if test="name != null">hc_name=#{name,jdbcType=VARCHAR},</if>
      <if test="picture != null">hc_picture=#{picture,jdbcType=VARCHAR},</if>
      <if test="sort != null">hc_sort=#{sort,jdbcType=INTEGER},</if>
      <if test="showState != null">hc_show_state=#{showState,jdbcType=INTEGER},</if>
      <if test="createTime != null">hc_create_time=#{createTime,jdbcType=TIMESTAMP},</if>
      <if test="updateTime != null">hc_update_time=#{updateTime,jdbcType=TIMESTAMP},</if>
    </set> where hc_id = #{id,jdbcType=BIGINT}
  </update>
   <delete id="deleteByPrimaryKeyBatch" parameterType="java.util.List">
    delete from yeshi_ec_help_class WHERE hc_id in
    <foreach collection="list" item="item" open="(" close=")"
        separator=",">#{item}</foreach>
   </delete>
   <select id="listQuery" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />  FROM yeshi_ec_help_class
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (hc_name like '%${key}%')
           </if>
           <if test='state != null'>
                  AND hc_show_state = #{state}
           </if>
           ORDER BY hc_sort
        LIMIT ${start},${count}
   </select>
   <select id="countQuery" resultType="java.lang.Long">
        SELECT IFNULL(count(hc_id),0)  FROM yeshi_ec_help_class
        WHERE 1=1
           <if test='key != null and key != ""'>
                  AND (hc_name like '%${key}%')
           </if>
           <if test='state != null'>
                  AND hc_show_state = #{state}
           </if>
    </select>
   <select id="getMaxOrder" resultType="java.lang.Integer">
        SELECT IFNULL(MAX(hc_sort),0) FROM yeshi_ec_help_class limit 1
   </select>
   <select id="getChangeOrder" resultMap="BaseResultMap">
        SELECT  <include refid="Base_Column_List" /> FROM yeshi_ec_help_class
        WHERE 1=1
        <if test="type == -1">
            <![CDATA[and hc_sort < #{sort}]]>
            order by hc_sort desc
        </if>
        <if test="type == 1">
            <![CDATA[and hc_sort > #{sort} ]]>
            order by hc_sort
        </if>
        limit 1
   </select>
   <select id="getClassByState" resultMap="BaseResultMap">
        SELECT hc_id,hc_name,hc_picture FROM yeshi_ec_help_class
        WHERE  hc_show_state = #{state}
           ORDER BY hc_sort
   </select>
    <select id="getProvidedClass" resultMap="BaseResultMap">
        SELECT hc_id,hc_name,hc_picture  FROM yeshi_ec_help_class
           ORDER BY hc_sort
   </select>
</mapper>
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpCenterServiceImpl.java
@@ -228,20 +228,21 @@
    }
    @Override
    public List<HelpCenter> query(int pageIndex, int pageSize, String key, Integer orderMode) throws HelpCenterException {
        return helpCenterMapper.query(pageIndex, pageSize, key, orderMode);
    public List<HelpCenter> query(int pageIndex, int pageSize, String key, Long cid, Integer orderMode) throws HelpCenterException {
        return helpCenterMapper.query(pageIndex, pageSize, key, cid, orderMode);
    }
    @Override
    public long countQuery(String key) throws HelpCenterException {
        return helpCenterMapper.countQuery(key);
    public long countQuery(String key, Long cid) throws HelpCenterException {
        return helpCenterMapper.countQuery(key, cid);
    }
    
    @Override
    @Cacheable(value = "helpCenterCache",key="'queryIdAndTitle-'+#pageIndex+'-'+#key")
    public List<HelpCenter> queryIdAndTitle(int pageIndex, int pageSize, String key) throws HelpCenterException {
        return helpCenterMapper.queryIdAndTitle(pageIndex, pageSize, key);
    @Cacheable(value = "helpCenterCache",key="'queryIdAndTitle-'+#pageIndex+'-'+#key+'-'+#cid")
    public List<HelpCenter> queryIdAndTitle(int pageIndex, int pageSize, String key, Long cid)
            throws HelpCenterException {
        return helpCenterMapper.queryIdAndTitle(pageIndex, pageSize, key, cid);
    }
    
    @Override
fanli/src/main/java/com/yeshi/fanli/service/impl/help/HelpClassServiceImpl.java
New file
@@ -0,0 +1,183 @@
package com.yeshi.fanli.service.impl.help;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.yeshi.utils.tencentcloud.COSManager;
import com.yeshi.fanli.dao.mybatis.help.HelpClassMapper;
import com.yeshi.fanli.entity.bus.help.HelpClass;
import com.yeshi.fanli.exception.HelpClassException;
import com.yeshi.fanli.service.inter.help.HelpClassService;
import com.yeshi.fanli.util.StringUtil;
@Service
public class HelpClassServiceImpl implements HelpClassService {
    @Resource
    private HelpClassMapper helpClassMapper;
    @Override
    public int deleteByPrimaryKeyBatch(List<Long> list) {
        return helpClassMapper.deleteByPrimaryKeyBatch(list);
    }
    @Override
    public HelpClass selectByPrimaryKey(Long id) {
        return helpClassMapper.selectByPrimaryKey(id);
    }
    @Override
    public void save(HelpClass helpClass) throws HelpClassException {
        if (helpClass == null) {
            throw new HelpClassException(1, "参数不能为空");
        }
        if (helpClass.getId() == null) {
            String name = helpClass.getName();
            if (StringUtil.isNullOrEmpty(name)) {
                throw new HelpClassException(1, "名称不能为空");
            }
            // 默认不显示
            helpClass.setShowState(0);
            // 排序-末尾
            int maxOrder = helpClassMapper.getMaxOrder();
            helpClass.setSort(maxOrder + 1);
            helpClass.setCreateTime(new Date());
            helpClass.setUpdateTime(new Date());
            helpClassMapper.insertSelective(helpClass);
        } else {
            helpClass.setUpdateTime(new Date());
            helpClassMapper.updateByPrimaryKeySelective(helpClass);
        }
    }
    @Override
    public int updateShowState(Long id) throws HelpClassException {
        if (id == null) {
            throw new HelpClassException(1, "传递参数不能为空");
        }
        HelpClass helpClass = helpClassMapper.selectByPrimaryKey(id);
        if (helpClass == null) {
            throw new HelpClassException(1, "更新数据已不存在");
        }
        Integer showState = helpClass.getShowState();
        if (showState == null || showState == 0) {
            showState = 1;
        } else {
            showState = 0;
        }
        HelpClass help = new HelpClass();
        help.setId(id);
        help.setShowState(showState);
        help.setUpdateTime(new Date());
        helpClassMapper.updateByPrimaryKeySelective(help);
        return showState;
    }
    @Override
    public void updateSort(Integer moveType, Long id) throws HelpClassException {
        if (id == null || moveType == null) {
            throw new HelpClassException(1, "传递参数不能为空");
        }
        HelpClass helpClass = helpClassMapper.selectByPrimaryKey(id);
        if (helpClass == null) {
            throw new HelpClassException(1, "更新数据已不存在");
        }
        HelpClass changeObjct = helpClassMapper.getChangeOrder(moveType, helpClass.getSort());
        if (changeObjct == null) {
            throw new HelpClassException(1, "已经是最边缘位置");
        } else {
            Integer changeSort = changeObjct.getSort();
            // 交换排序序号
            changeObjct.setSort(helpClass.getSort());
            helpClassMapper.updateByPrimaryKeySelective(changeObjct);
            helpClass.setSort(changeSort);
            helpClassMapper.updateByPrimaryKeySelective(helpClass);
        }
    }
    @Override
    public void uploadPic(MultipartFile file, Long id) throws HelpClassException, IOException {
        if (id == null || file == null) {
            throw new HelpClassException(1, "传递参数不能为空");
        }
        HelpClass helpClass = helpClassMapper.selectByPrimaryKey(id);
        if (helpClass == null) {
            throw new HelpClassException(1, "更新数据已不存在");
        }
        InputStream inputStream = file.getInputStream();
        String contentType = file.getContentType();
        String type = contentType.substring(contentType.indexOf("/") + 1);
        String filePath ="/img/HelpClass/" + UUID.randomUUID().toString().replace("-", "") + "." + type;
        /*  修改图片时,先删除已存在图片  */
        String picture = helpClass.getPicture();
        if (!StringUtil.isNullOrEmpty(picture)) {
            COSManager.getInstance().deleteFile(picture);
        }
        String fileUrl = COSManager.getInstance().uploadFile(inputStream, filePath).getUrl();
        /*  更新数据库信息  */
        if (!StringUtil.isNullOrEmpty(fileUrl)) {
            helpClass.setUpdateTime(new Date());
            helpClass.setPicture(fileUrl);
            helpClassMapper.updateByPrimaryKeySelective(helpClass);
        }
    }
    @Override
    public List<HelpClass> query(int start, int count, String key, Integer state)
            throws HelpClassException {
        return helpClassMapper.listQuery(start, count, key, state);
    }
    @Override
    public long countQuery(String key, Integer state) {
        return helpClassMapper.countQuery(key, state);
    }
    @Override
    public List<HelpClass> getClassByState(Integer state) throws HelpClassException {
        return helpClassMapper.getClassByState(state);
    }
    @Override
    public List<HelpClass> getProvidedClass() throws HelpClassException {
        return helpClassMapper.getProvidedClass();
    }
}
fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpCenterService.java
@@ -58,9 +58,10 @@
     * @param endTime   结束时间
     * @return
     */
    public List<HelpCenter> query(int pageIndex, int pageSize, String key, Integer orderMode) throws HelpCenterException;
    public List<HelpCenter> query(int pageIndex, int pageSize, String key, Long cid,
            Integer orderMode) throws HelpCenterException;
    
    public long countQuery(String key) throws HelpCenterException;
    public long countQuery(String key, Long cid) throws HelpCenterException;
    
    /**
@@ -98,7 +99,7 @@
     * @return
     * @throws HelpCenterException
     */
    public List<HelpCenter> queryIdAndTitle(int pageIndex, int pageSize, String key) throws HelpCenterException;
    public List<HelpCenter> queryIdAndTitle(int pageIndex, int pageSize, String key, Long cid) throws HelpCenterException;
    
    /**
fanli/src/main/java/com/yeshi/fanli/service/inter/help/HelpClassService.java
New file
@@ -0,0 +1,93 @@
package com.yeshi.fanli.service.inter.help;
import java.io.IOException;
import java.util.List;
import org.springframework.web.multipart.MultipartFile;
import com.yeshi.fanli.entity.bus.help.HelpClass;
import com.yeshi.fanli.exception.HelpCenterException;
import com.yeshi.fanli.exception.HelpClassException;
public interface HelpClassService {
    /**
     * 批量删除
     * @param idList
     * @return
     * @throws HelpCenterException
     */
    public int deleteByPrimaryKeyBatch(List<Long> idList);
    /**
     * 批量删除
     * @param idList
     * @return
     * @throws HelpCenterException
     */
    public void save(HelpClass helpClass) throws HelpClassException;
    /**
     * 查询
     * @param pageIndex 页码
     * @param pageSize  页面条数
     * @param key        搜索条件
     * @param startTime 起始时间
     * @param endTime   结束时间
     * @return
     */
    public List<HelpClass> query(int start, int count, String key, Integer state) throws HelpClassException;
    public long countQuery(String key, Integer state);
    /**
     * 根据id查询
     * @param id
     * @return
     */
    public HelpClass selectByPrimaryKey(Long id);
    /**
     * 更新装态
     * @param id
     * @return
     * @throws HelpClassException
     */
    public int updateShowState(Long id) throws HelpClassException;
    /**
     * 移动位置
     * @param moveType
     * @param id
     * @throws HelpClassException
     */
    public void updateSort(Integer moveType, Long id) throws HelpClassException;
    /**
     * 上传图片
     * @param file
     * @param id
     * @throws HelpClassException
     */
    public void uploadPic(MultipartFile file, Long id) throws HelpClassException, IOException;
    /**
     * 根据状态查询
     * @param state
     * @return
     * @throws HelpClassException
     */
    public List<HelpClass> getClassByState(Integer state) throws HelpClassException;
    /**
     * 查询所有选项提供选择
     * @return
     * @throws HelpClassException
     */
    public List<HelpClass> getProvidedClass() throws HelpClassException;
}