forked from kidgrow-microservices-platform

kidgrow-business/kidgrow-opration-center/kidgrow-opration-center-biz/src/main/java/com/kidgrow/oprationcenter/service/impl/DataNeedServiceImpl.java
@@ -1,22 +1,24 @@
package com.kidgrow.oprationcenter.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kidgrow.common.model.PageResult;
import com.kidgrow.common.model.ResultBody;
import com.kidgrow.common.model.SysDoctor;
import com.kidgrow.common.model.SysUser;
import com.kidgrow.common.service.impl.SuperServiceImpl;
import com.kidgrow.oprationcenter.mapper.DataNeedMapper;
import com.kidgrow.oprationcenter.model.DataNeed;
import com.kidgrow.oprationcenter.service.IDataNeedService;
import com.kidgrow.oprationcenter.vo.DataNeedExcel;
import com.kidgrow.usercenter.feign.SysDoctorService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import com.kidgrow.common.model.PageResult;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kidgrow.common.service.impl.SuperServiceImpl;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.apache.commons.collections4.MapUtils;
import lombok.extern.slf4j.Slf4j;
import com.kidgrow.oprationcenter.model.DataNeed;
import com.kidgrow.oprationcenter.mapper.DataNeedMapper;
import com.kidgrow.oprationcenter.service.IDataNeedService;
import java.util.*;
/**
 * 石家庄喜高科技有限责任公司 版权所有 © Copyright 2020<br>
@@ -29,6 +31,8 @@
@Slf4j
@Service
public class DataNeedServiceImpl extends SuperServiceImpl<DataNeedMapper, DataNeed> implements IDataNeedService {
    @Autowired
    private SysDoctorService sysDoctorService;
    /**
     * 列表
     * @param params
@@ -83,4 +87,39 @@
            return ResultBody.ok();
        }
    }
    @Override
    public ResultBody updateDelete(Long id,SysUser sysUser) {
        if(id==null){
            return ResultBody.failed("请选择一条数据");
        }else {
            DataNeed dataNeed = baseMapper.selectById(id);
            if (dataNeed != null) {
                dataNeed.setIsDel(true);
                dataNeed.setUpdateTime(new Date());
                dataNeed.setUpdateUserId(sysUser.getId());
                dataNeed.setUpdateUserName(sysUser.getUsername());
                int u=baseMapper.updateById(dataNeed);
                return ResultBody.ok().data(u>0);
            }else {
                return ResultBody.failed("查找数据失败");
            }
        }
    }
    @Override
    public ResultBody FindAllByHId(Map<String, Object> map, SysUser sysUser) {
            Map<String,Object> doctoerMap =new HashMap<>();
            doctoerMap.put("user_id",sysUser.getId());
            ResultBody listByMap = sysDoctorService.getListByMap(doctoerMap);
            List<SysDoctor> sysDoctors = JSON.parseArray(JSON.toJSONString(listByMap.getData()), SysDoctor.class);
            if (sysDoctors!=null&&sysDoctors.size()>0){
                Page<DataNeed> page = new Page<>(MapUtils.getInteger(map, "page"), MapUtils.getInteger(map, "limit"));
//                List<DataNeed> dataNeedList=baseMapper.findHList(map);
                List<DataNeed> list  =  baseMapper.findList(page, map);
                PageResult<DataNeed> build = PageResult.<DataNeed>builder().data(list).code(0).count(page.getTotal()).build();
                return ResultBody.ok().data(build);
            }else {
                return ResultBody.failed("非管理用户无权查看");
            }
    }
}