|
@@ -0,0 +1,89 @@
|
|
|
|
+package com.huimv.production.service.impl;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.huimv.production.domain.IndexProductionGroup2;
|
|
|
|
+import com.huimv.production.repo.IndexProductionGroup2Repository;
|
|
|
|
+import com.huimv.production.result.Result;
|
|
|
|
+import com.huimv.production.result.ResultStatus;
|
|
|
|
+import com.huimv.production.service.IndexProductionGroup2Service;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
+
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+@Service
|
|
|
|
+public class IndexProductionGroup2ServiceImpl implements IndexProductionGroup2Service {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IndexProductionGroup2Repository rep;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result add(IndexProductionGroup2 entity){
|
|
|
|
+ if (entity == null){
|
|
|
|
+ return new Result(10002, ResultStatus.addNull);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ rep.save(entity);
|
|
|
|
+ return new Result(10000,ResultStatus.addSuccess);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ return new Result(10001,ResultStatus.addFailed);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result remove(Integer[] ids) {
|
|
|
|
+ if (ids == null || ids.length==0){
|
|
|
|
+ return new Result(10002,ResultStatus.deleteNull);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ for (Integer id : ids) {
|
|
|
|
+ rep.deleteById(id);
|
|
|
|
+ }
|
|
|
|
+ return new Result(10000,ResultStatus.deleteSuccess);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ return new Result(10001,ResultStatus.deleteFailed);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result update(IndexProductionGroup2 entity) {
|
|
|
|
+ if (entity == null){
|
|
|
|
+ return new Result(10002,ResultStatus.updateNull);
|
|
|
|
+ }
|
|
|
|
+ try {
|
|
|
|
+ rep.save(entity);
|
|
|
|
+ return new Result(10000,ResultStatus.updateSuccess);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ return new Result(10001,ResultStatus.updateFailed);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result findAll(String name , Integer pageNum , Integer pageSize) {
|
|
|
|
+ try {
|
|
|
|
+ Map map = new HashMap();
|
|
|
|
+ int size = rep.findAll().size() ;
|
|
|
|
+ Integer startPage = (pageNum-1) * pageSize;
|
|
|
|
+ List<IndexProductionGroup2> all = rep.findAll(name,startPage,pageSize);
|
|
|
|
+ map.put("total",size);
|
|
|
|
+ map.put("totalPageNum",(size + pageSize - 1) / pageSize);
|
|
|
|
+ map.put("data",all);
|
|
|
|
+
|
|
|
|
+ return new Result(10000,ResultStatus.findSuccess,map);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ return new Result(10001,ResultStatus.findFailed,null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result findAllById(Integer id) {
|
|
|
|
+ try {
|
|
|
|
+ IndexProductionGroup2 entity = rep.findById(id).get();
|
|
|
|
+ return new Result(10000,ResultStatus.findSuccess,entity);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ return new Result(10001,ResultStatus.findFailed,null);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|