|
@ -86,7 +86,11 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
* @return
|
|
|
*/
|
|
|
public void deleteQuestion(String id){
|
|
|
questionDao.updateDelById(id, 0);
|
|
|
String str[] = id.split(",");
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
questionDao.updateDelById(str[i], 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@ -97,7 +101,8 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
* @param status
|
|
|
*/
|
|
|
public MixEnvelop selectQuestionList(String name,String type,String status,Integer page,Integer size){
|
|
|
String condition = " and del = 1 order by sort asc,create_time desc ";
|
|
|
String orderBy = " and del = 1 order by sort asc,create_time desc ";
|
|
|
String condition = " ";
|
|
|
String sql = "SELECT\n" +
|
|
|
"\tid,\n" +
|
|
|
"\ttype,\n" +
|
|
@ -112,15 +117,15 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
"FROM\n" +
|
|
|
"\tbase_knowledge_question where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(name)){
|
|
|
condition +=" and question_name like '"+name+"' ";
|
|
|
condition +=" and question_name like '%"+name+"%' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(type)){
|
|
|
condition +=" and type ='"+type+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)){
|
|
|
condition +=" and status ='"+type+"' ";
|
|
|
condition +=" and status ='"+status+"' ";
|
|
|
}
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+condition, page, size);
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+condition+orderBy, page, size);
|
|
|
String sqlCount ="select COUNT(1) as total from base_knowledge_question where 1=1 ";
|
|
|
List<Map<String, Object>> rstotal = hibenateUtils.createSQLQuery(sqlCount+condition);
|
|
|
Long count = 0L;
|
|
@ -143,24 +148,44 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
/**
|
|
|
* 问题设置排序
|
|
|
* @param id
|
|
|
* @param flag 1上移2下移
|
|
|
* @param flag 1上移2下移3置顶
|
|
|
*/
|
|
|
public BaseKnowledgeQuestion setQuestionSortById(String id,Integer flag){
|
|
|
BaseKnowledgeQuestion knowledgeQuestion = questionDao.findById(id).get();
|
|
|
int sort = 0;
|
|
|
if (flag==1){
|
|
|
sort = knowledgeQuestion.getSort()-1;
|
|
|
String sql = "select sort from base_knowledge_question where sort<'"+knowledgeQuestion.getSort()+"' and del=1 order by sort desc limit 1";
|
|
|
List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql);
|
|
|
Integer count = 0;
|
|
|
if (mapList != null && mapList.size() > 0) {
|
|
|
count = Integer.parseInt(mapList.get(0).get("sort").toString());
|
|
|
}
|
|
|
if (count==0){
|
|
|
sort = 0;
|
|
|
}else {
|
|
|
sort=count;
|
|
|
}
|
|
|
BaseKnowledgeQuestion knowledgeQuestion1= questionDao.selectBySort(sort);
|
|
|
if (knowledgeQuestion1!=null){
|
|
|
knowledgeQuestion1.setSort(knowledgeQuestion.getSort()+1);
|
|
|
knowledgeQuestion1.setSort(knowledgeQuestion.getSort());
|
|
|
questionDao.save(knowledgeQuestion1);
|
|
|
}
|
|
|
|
|
|
}else if (flag==2){
|
|
|
sort = knowledgeQuestion.getSort()+1;
|
|
|
String sql = "select sort from base_knowledge_question where sort>'"+knowledgeQuestion.getSort()+"' and del=1 order by sort asc limit 1";
|
|
|
List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql);
|
|
|
Integer count = 0;
|
|
|
if (mapList != null && mapList.size() > 0) {
|
|
|
count = Integer.parseInt(mapList.get(0).get("sort").toString());
|
|
|
}
|
|
|
if (count==0){
|
|
|
sort = 0;
|
|
|
}else {
|
|
|
sort=count;
|
|
|
}
|
|
|
BaseKnowledgeQuestion knowledgeQuestion1= questionDao.selectBySort(sort);
|
|
|
if (knowledgeQuestion1!=null){
|
|
|
knowledgeQuestion1.setSort(knowledgeQuestion.getSort()-1);
|
|
|
knowledgeQuestion1.setSort(knowledgeQuestion.getSort());
|
|
|
questionDao.save(knowledgeQuestion1);
|
|
|
}
|
|
|
|
|
@ -217,7 +242,11 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
* @return
|
|
|
*/
|
|
|
public void deleteQuestions(String id){
|
|
|
questionsDao.updateDelById(id, 0);
|
|
|
String str[] = id.split(",");
|
|
|
for (int i=0;i<str.length;i++){
|
|
|
questionsDao.updateDelById(str[i], 0);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@ -244,13 +273,13 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
"FROM\n" +
|
|
|
"\tbase_knowledge_questions where 1=1 ";
|
|
|
if (StringUtils.isNoneBlank(name)){
|
|
|
condition +=" and questions_name like '"+name+"' ";
|
|
|
condition +=" and questions_name like '%"+name+"%' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(type)){
|
|
|
condition +=" and business_type ='"+type+"' ";
|
|
|
}
|
|
|
if (StringUtils.isNoneBlank(status)){
|
|
|
condition +=" and status ='"+type+"' ";
|
|
|
condition +=" and status ='"+status+"' ";
|
|
|
}
|
|
|
condition += " and del = 1";
|
|
|
List<Map<String, Object>> list = hibenateUtils.createSQLQuery(sql+condition+orderBy, page, size);
|
|
@ -299,18 +328,38 @@ public class BaseKnowledgeQuestionService extends BaseJpaService<BaseKnowledgeQu
|
|
|
BaseKnowledgeQuestions knowledgeQuestions = questionsDao.findById(id).get();
|
|
|
int sort = 0;
|
|
|
if (flag==1){
|
|
|
sort = knowledgeQuestions.getSort()-1;
|
|
|
String sql = "select sort from base_knowledge_questions where sort<'"+knowledgeQuestions.getSort()+"' and del=1 order by sort desc limit 1";
|
|
|
List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql);
|
|
|
Integer count = 0;
|
|
|
if (mapList != null && mapList.size() > 0) {
|
|
|
count = Integer.parseInt(mapList.get(0).get("sort").toString());
|
|
|
}
|
|
|
if (count==0){
|
|
|
sort = 0;
|
|
|
}else {
|
|
|
sort=count;
|
|
|
}
|
|
|
BaseKnowledgeQuestions knowledgeQuestions1= questionsDao.selectBySort(sort);
|
|
|
if (knowledgeQuestions1!=null){
|
|
|
knowledgeQuestions1.setSort(knowledgeQuestions.getSort()+1);
|
|
|
knowledgeQuestions1.setSort(knowledgeQuestions.getSort());
|
|
|
questionsDao.save(knowledgeQuestions1);
|
|
|
}
|
|
|
|
|
|
}else if (flag==2){
|
|
|
sort = knowledgeQuestions.getSort()+1;
|
|
|
String sql = "select sort from base_knowledge_questions where sort>'"+knowledgeQuestions.getSort()+"' and del=1 order by sort asc limit 1";
|
|
|
List<Map<String,Object>> mapList = hibenateUtils.createSQLQuery(sql);
|
|
|
Integer count = 0;
|
|
|
if (mapList != null && mapList.size() > 0) {
|
|
|
count = Integer.parseInt(mapList.get(0).get("sort").toString());
|
|
|
}
|
|
|
if (count==0){
|
|
|
sort = 0;
|
|
|
}else {
|
|
|
sort=count;
|
|
|
}
|
|
|
BaseKnowledgeQuestions knowledgeQuestions1= questionsDao.selectBySort(sort);
|
|
|
if (knowledgeQuestions1!=null){
|
|
|
knowledgeQuestions1.setSort(knowledgeQuestions.getSort()-1);
|
|
|
knowledgeQuestions1.setSort(knowledgeQuestions.getSort());
|
|
|
questionsDao.save(knowledgeQuestions1);
|
|
|
}
|
|
|
}else if (flag==3){
|