|
@@ -0,0 +1,59 @@
|
|
|
+package com.example.opc_da.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.example.opc_common.entity.Log;
|
|
|
+import com.example.opc_common.entity.TextEditor;
|
|
|
+import com.example.opc_common.enums.ResultEnum;
|
|
|
+import com.example.opc_common.util.Result;
|
|
|
+import com.example.opc_da.dao.TextEditorDao;
|
|
|
+import com.example.opc_da.service.TextEditorService;
|
|
|
+import com.example.opc_da.util.UserUtil;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+@Transactional
|
|
|
+public class TextEditorServiceImpl implements TextEditorService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TextEditorDao textEditorDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UserUtil userUtil;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result addTextEditor(TextEditor textEditor) {
|
|
|
+ textEditor.setUserId(userUtil.getCurrentUserId());
|
|
|
+ if (textEditorDao.addTextEditor(textEditor) <= 0) {
|
|
|
+ return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "新增失败");
|
|
|
+ }
|
|
|
+ return Result.ok("新增成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getAllTextEditor(Integer page, Integer limit) {
|
|
|
+ String userId = userUtil.getCurrentUserId();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ Long count = textEditorDao.getTextEditorCount(userId);
|
|
|
+ Long startNum = Long.valueOf((page - 1) * limit);
|
|
|
+ List<TextEditor> textEditorList = textEditorDao.getAllTextEditor(startNum, Long.valueOf(limit), userId);
|
|
|
+ jsonObject.put("count", count);
|
|
|
+ jsonObject.put("textEditorList", textEditorList);
|
|
|
+ return Result.ok(jsonObject);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getTextEditorNew() {
|
|
|
+ return Result.ok(textEditorDao.getTextEditorNew());
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getTextEditorById(Integer id) {
|
|
|
+ return Result.ok(textEditorDao.getTextEditorById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|