You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
62 lines
1.9 KiB
Java
62 lines
1.9 KiB
Java
package com.gszc.service.impl;
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
|
import com.baomidou.mybatisplus.plugins.Page;
|
|
import com.gszc.entity.Question;
|
|
import com.gszc.entity.Question;
|
|
import com.gszc.entity.Question;
|
|
import com.gszc.mapper.QuestionMapper;
|
|
import com.gszc.service.IQuestionService;
|
|
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
|
|
import org.apache.ibatis.session.RowBounds;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* <p>
|
|
* 服务实现类
|
|
* </p>
|
|
*
|
|
* @author ky
|
|
* @since 2020-05-25
|
|
*/
|
|
@Service
|
|
@Transactional
|
|
public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> implements IQuestionService {
|
|
|
|
@Autowired
|
|
QuestionMapper questionMapper;
|
|
|
|
public void addQuestion(Question question){
|
|
String id = UUID.randomUUID().toString();
|
|
question.setId(id);
|
|
question.setCreateDate(new Date());
|
|
question.setModifyDate(new Date());
|
|
questionMapper.insert(question);
|
|
}
|
|
|
|
public void deleteQuestion(Question question){
|
|
questionMapper.deleteById(question);
|
|
}
|
|
|
|
public void updateQuestion(Question question){
|
|
questionMapper.updateById(question);
|
|
}
|
|
|
|
public JSONObject queryQuestion(Integer pageNum, Integer pageSize){
|
|
|
|
Integer count = questionMapper.selectCount(new EntityWrapper<Question>());
|
|
List<Question> result = questionMapper.selectPage(new RowBounds((pageNum-1)*pageSize,pageSize), new EntityWrapper<Question>().eq("1", "1").orderBy("ix", true));
|
|
JSONObject jsonObject = new JSONObject();
|
|
jsonObject.put("count",count);
|
|
jsonObject.put("data",result);
|
|
return jsonObject;
|
|
}
|
|
}
|