forked from kidgrow-microservices-platform

kidgrow-business/kidgrow-usercenter/kidgrow-usercenter-server/src/main/java/com/kidgrow/usercenter/controller/SysDepartmentController.java
@@ -1,28 +1,24 @@
package com.kidgrow.usercenter.controller;
import java.util.Map;
import com.kidgrow.common.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.*;
import com.kidgrow.common.model.PageResult;
import com.kidgrow.common.model.ResultBody;
import com.kidgrow.usercenter.model.SysDepartment;
import com.kidgrow.usercenter.service.ISysDepartmentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import com.kidgrow.usercenter.model.SysDepartment;
import com.kidgrow.usercenter.service.ISysDepartmentService;
import com.kidgrow.common.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.ObjectError;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
@@ -91,6 +87,14 @@
            }
            return ResultBody.failed().msg(errMsg.toString());
        } else {
            //先检查该医院下的该科室名是否已经存在?
            SysDepartment sysDepartmentTemp=new SysDepartment();
            sysDepartmentTemp.setHospitalId(sysDepartment.getHospitalId());
            sysDepartmentTemp.setDepartmentName(sysDepartment.getDepartmentName().trim());
            sysDepartmentTemp=sysDepartmentService.findByObject(sysDepartmentTemp);
            if (sysDepartmentTemp!=null) {
                return ResultBody.failed().msg(String.format("该医院下已经存在 %s",sysDepartment.getDepartmentName()));
            }
            boolean v= sysDepartmentService.saveOrUpdate(sysDepartment);
            if(v) {
                return ResultBody.ok().data(sysDepartment).msg("保存成功");
@@ -115,4 +119,14 @@
            return ResultBody.failed().msg("删除失败");
        }
    }
    /**
     * 根据医院获取  组织,通过组织,获取科室;
     * @param params
     * @return
     */
    @GetMapping("findListByHospitalId")
    public ResultBody findListByHospitalId(@RequestParam Map<String, Object> params) {
        return sysDepartmentService.findListByHospitalId(params);
    }
}