|
@@ -0,0 +1,109 @@
|
|
|
+package com.huimv.admin.service.secondary.impl;
|
|
|
+
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.huimv.admin.domain.secondary.DaJqda;
|
|
|
+import com.huimv.admin.domain.secondary.DaZsda;
|
|
|
+import com.huimv.admin.repo.secondary.DaJqdaRepo;
|
|
|
+import com.huimv.admin.repo.secondary.DaZsdaRepository;
|
|
|
+import com.huimv.admin.service.secondary.DaZsdaService;
|
|
|
+import com.huimv.admin.utils.Result;
|
|
|
+import com.huimv.admin.utils.ResultCode;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+@Service
|
|
|
+@DS("thired")
|
|
|
+public class DaZsdaServiceImpl implements DaZsdaService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DaZsdaRepository rep;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DaJqdaRepo jqdaRepo;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result add(DaZsda entity){
|
|
|
+ if (entity == null){
|
|
|
+
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+
|
|
|
+ entity.setMcid(11);
|
|
|
+ Integer id = rep.findMax().get(0);
|
|
|
+ entity.setXgsj(new Date());
|
|
|
+ DaJqda daJqda =new DaJqda() ;
|
|
|
+ daJqda.setZSID(id);
|
|
|
+ jqdaRepo.save(daJqda);
|
|
|
+ rep.save(entity);
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result remove(Integer[] ids) {
|
|
|
+ if (ids == null || ids.length==0){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ for (Integer id : ids) {
|
|
|
+ rep.deleteById(id);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result update(DaZsda entity) {
|
|
|
+ if (entity == null){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ entity.setMcid(11);
|
|
|
+ entity.setXgsj(new Date());
|
|
|
+ rep.save(entity);
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @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<DaZsda> all = rep.findAll(name,startPage,pageSize);
|
|
|
+ map.put("total",size);
|
|
|
+ map.put("totalPageNum",(size + pageSize - 1) / pageSize);
|
|
|
+ map.put("data",all);
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS,map);
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result findAllById(Integer id) {
|
|
|
+ try {
|
|
|
+ DaZsda entity = rep.findById(id).get();
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }catch (Exception e){
|
|
|
+ return new Result(ResultCode.FAIL);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|