|
@@ -0,0 +1,88 @@
|
|
|
+package com.liangjian11.wx.mp.service.impl;
|
|
|
+
|
|
|
+import com.liangjian11.wx.mp.mapper.ApplicationMapper;
|
|
|
+import com.liangjian11.wx.mp.modle.Application;
|
|
|
+import com.liangjian11.wx.mp.service.ApplicationService;
|
|
|
+import com.liangjian11.wx.mp.utils.DateUtil;
|
|
|
+import com.liangjian11.wx.mp.utils.FiltersData;
|
|
|
+import com.liangjian11.wx.mp.utils.ResultInfo;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ApplicationServiceImpl implements ApplicationService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ ApplicationMapper appMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void insertInfo(Application app) throws Exception {
|
|
|
+ appMapper.insert(app);
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResultInfo queryExternalList(FiltersData data) {
|
|
|
+ int start = (data.getPageIndex()-1) * data.getPageSize();
|
|
|
+ int end = (start + 1 + data.getPageSize());
|
|
|
+ //动态条件
|
|
|
+ String sqlStr=data.getFilterString();
|
|
|
+ Integer totalCount=this.appMapper.queryExternalCount(sqlStr);
|
|
|
+
|
|
|
+ List<Application> list = new ArrayList<>();
|
|
|
+ if(totalCount != null && totalCount > 0){
|
|
|
+ list = this.appMapper.queryExternalList(sqlStr,start,end);
|
|
|
+ }
|
|
|
+ ResultInfo result = new ResultInfo(ResultInfo.TYPE_RESULT_SUCCESS,100,"操作成功!");
|
|
|
+ result.setItems(list);
|
|
|
+ result.setTotalCount(totalCount);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void updateByIdSelect(Application app) {
|
|
|
+ appMapper.updateByIdSelect(app);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultInfo save(Application app) {
|
|
|
+ /**
|
|
|
+ * 业务操作
|
|
|
+ */
|
|
|
+ if(app.getId() == null){
|
|
|
+ //新增
|
|
|
+ app.setCreateTime(DateUtil.getNowDateTimeStr());
|
|
|
+ app.setUpdateTime(DateUtil.getNowDateTimeStr());
|
|
|
+ appMapper.insertAppcation(app);
|
|
|
+ } else {
|
|
|
+ //编辑
|
|
|
+ app.setUpdateTime(DateUtil.getNowDateTimeStr());
|
|
|
+ appMapper.updateByIdSelect(app);
|
|
|
+ }
|
|
|
+ return new ResultInfo(ResultInfo.TYPE_RESULT_SUCCESS,200,"操作成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResultInfo updateShelves(Integer id) {
|
|
|
+ /**
|
|
|
+ * 业务校验 目前没有具体业务 直接根据数据库的状态进行修改
|
|
|
+ */
|
|
|
+ Application app = appMapper.selectById(id);
|
|
|
+ if(app == null ){
|
|
|
+ return new ResultInfo(ResultInfo.TYPE_RESULT_INFO,200,"没有对应的应用!");
|
|
|
+ }
|
|
|
+
|
|
|
+ Application updateApp = new Application();
|
|
|
+ updateApp.setId(app.getId());
|
|
|
+ //状态更换
|
|
|
+ if("0".equals(app.getState())){
|
|
|
+ updateApp.setState("1");
|
|
|
+ }else if("1".equals(app.getState())){
|
|
|
+ updateApp.setState("0");
|
|
|
+ }
|
|
|
+ appMapper.updateByIdSelect(updateApp);
|
|
|
+ return new ResultInfo(ResultInfo.TYPE_RESULT_SUCCESS,200,"操作成功!");
|
|
|
+ }
|
|
|
+}
|