|
@@ -9,10 +9,14 @@ import com.imed.costaccount.common.util.BeanUtil;
|
|
|
import com.imed.costaccount.common.util.PageUtils;
|
|
|
import com.imed.costaccount.mapper.DepartmentMapper;
|
|
|
import com.imed.costaccount.model.Department;
|
|
|
+import com.imed.costaccount.model.User;
|
|
|
import com.imed.costaccount.model.dto.DepartmentRequest;
|
|
|
import com.imed.costaccount.model.vo.DepartmentVO;
|
|
|
import com.imed.costaccount.service.DepartmentService;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Propagation;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.List;
|
|
@@ -65,11 +69,14 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
|
|
|
/**
|
|
|
* 保存科室信息
|
|
|
- *
|
|
|
+ * TODO 检验科室信息是否存在
|
|
|
* @param departmentRequest
|
|
|
*/
|
|
|
@Override
|
|
|
public void addDepartment(DepartmentRequest departmentRequest) {
|
|
|
+ User user = (User) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ Integer hospId = user.getHospId();
|
|
|
+ departmentRequest.setHospId(hospId);
|
|
|
Department department = BeanUtil.convertObj(departmentRequest, Department.class);
|
|
|
department.setId(null);
|
|
|
department.setCreateTime(System.currentTimeMillis());
|
|
@@ -82,7 +89,10 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
* @param departmentRequest
|
|
|
*/
|
|
|
@Override
|
|
|
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public void updateByDepartment(DepartmentRequest departmentRequest) {
|
|
|
+ User user = (User) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ Integer hospId = user.getHospId();
|
|
|
Integer id = departmentRequest.getId();
|
|
|
Department department = baseMapper.selectById(id);
|
|
|
if (Objects.isNull(department)){
|
|
@@ -93,6 +103,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
Department departmentResponse = BeanUtil.convertObj(departmentRequest, Department.class);
|
|
|
departmentResponse.setId(null);
|
|
|
departmentResponse.setCreateTime(System.currentTimeMillis());
|
|
|
+ departmentResponse.setHospId(hospId);
|
|
|
baseMapper.insert(departmentResponse);
|
|
|
}
|
|
|
}
|