package com.gr.geias.controller;
import com.gr.geias.dto.ClassGradeAndSpecialty;
import com.gr.geias.dto.CollegeAndPerson;
import com.gr.geias.dto.SpecialtyAndCollege;
import com.gr.geias.entity.ClassGrade;
import com.gr.geias.entity.College;
import com.gr.geias.entity.PersonInfo;
import com.gr.geias.entity.Specialty;
import com.gr.geias.enums.EnableStatusEnums;
import com.gr.geias.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.util.*;
/**
* @author maitentai
* @version 1.0
* @date 2020-03-08 19:52
*/
@RestController
@RequestMapping("/organizationcontroller")
public class OrganizationController {
@Autowired
CollegeService collegeService;
@Autowired
PersonInfoService personInfoService;
@Autowired
OrganizationNumService organizationNumService;
@Autowired
SpecialtyService specialtyService;
@Autowired
ClassGradeService classGradeService;
/**
* 返回学院"详细"信息 (2级权限)
*
* @param name
* @return
*/
@RequestMapping(value = "/getcollegelist", method = RequestMethod.GET)
public Map<String, Object> getCollegeList(@RequestParam(value = "name", required = false) String name) {
Map<String, Object> map = new HashMap<>(3);
List<College> college = collegeService.getCollege(null);
List<CollegeAndPerson> list = new ArrayList<>();
for (int i = 0; i < college.size(); i++) {
CollegeAndPerson collegeAndPerson = new CollegeAndPerson();
College college1 = college.get(i);
collegeAndPerson.setCollege(college1);
PersonInfo personById = personInfoService.getPersonById(college1.getAdminId());
collegeAndPerson.setPersonInfo(personById);
Integer integer = organizationNumService.getcollegeCount(college1.getCollegeId());
collegeAndPerson.setSum(integer);
list.add(collegeAndPerson);
}
map.put("success", true);
map.put("List", list);
return map;
}
/**
* 查询所有空闲的学院管理员 enable_Status=1 and college_id = null 权限 2
*
* @param collegeadminId
* @return
*/
@RequestMapping(value = "/getcollegeadmin", method = RequestMethod.GET)
public Map<String, Object> getCollegeAdmin(@RequestParam(value = "collegeadminId", required = false) Integer collegeadminId) {
Map<String, Object> map = new HashMap<>(3);
List<PersonInfo> collegePerson = personInfoService.getCollegePerson();
if (collegePerson.size() > 0) {
map.put("success", true);
map.put("collegePerson", collegePerson);
return map;
} else {
map.put("success", false);
map.put("errMsg", "请保证至少有一名学院管理身份的闲置用户存在");
return map;
}
}
/**
* 添加学院 权限 2
*
* @param collegeName
* @param personId
* @return
*/
@RequestMapping(value = "/addcollege", method = RequestMethod.GET)
public Map<String, Object> addCollege(@RequestParam("collegeName") String collegeName,
@RequestParam("personId") Integer personId) {
Map<String, Object> map = new HashMap<>(3);
if (collegeName == null || collegeName.equals("") || personId == null || personId == 0) {
map.put("success", false);
map.put("errMsg", "输入信息错误");
}
College college = new College();
college.setAdminId(personId);
college.setCollegeName(collegeName);
college.setCreateTime(new Date());
try {
Boolean aBoolean = collegeService.addCollege(college);
map.put("success", true);
} catch (Exception e) {
map.put("success", false);
map.put("errMsg", e.getMessage());
}
return map;
}
/**
* 更新学院 权限2
*
* @param collegeName
* @param personId
* @param collegeId
* @return
*/
@RequestMapping(value = "/updatecollege", method = RequestMethod.GET)
public Map<String, Object> updateCollege(@RequestParam(value = "collegeName", required = false) String collegeName,
@RequestParam(value = "personId", required = false) Integer personId,
@RequestParam("collegeId") Integer collegeId) {
Map<String, Object> map = new HashMap<>(3);
if (personId == null || personId == 0) {
personId = null;
}
College college = new College();
college.setCollegeId(collegeId);
college.setCollegeName(collegeName);
college.setAdminId(personId);
try {
Boolean aBoolean = collegeService.updateCollege(college);
if (aBoolean) {
map.put("success", true);
}
} catch (RuntimeException e) {
map.put("success", false);
map.put("errMsg", e.getMessage());
}
return map;
}
/**
* 删除学院 权限2
*
* @param collegeId
* @return
*/
@RequestMapping(value = "/delcollege", method = RequestMethod.GET)
public Map<String, Object> delCollege(@RequestParam("collegeId") Integer collegeId) {
Map<String, Object> map = new HashMap<>(3);
if (collegeId != null && collegeId != null) {
try {
collegeService.delCollege(collegeId);
map.put("success", true);
} catch (RuntimeException e) {
map.put("success", false);
map.put("errMsg", e.getMessage());
}
} else {
map.put("success", false);
map.put("errMsg", "信息错误");
}
return map;
}
/**
* 根据用户权限获取学院列表(简化信息) 权限 1,2
*
* @param request
* @return
*/
@RequestMapping(value = "/getcollegeinit", method = RequestMethod.GET)
public Map<String, Object> getCollegeinit(HttpServletRequest request) {
Map<String, Object> map = new HashMap<>(3);
PersonInfo person = (PersonInfo) request.getSession().getAttribute("person");
List<College> college = null;
if (person.getEnableStatus() == EnableStatusEnums.schoolmaster.getState()) {
college = collegeService.getCollege(null);
}
if (person.getEnableStatus() == EnableStatusEnums.PREXY.getState()) {
college = collegeService.getCollege(person.getPersonId());
}
if (college != null) {
map.put("success", true);
map.put("collegeList", college);
} else {
map.put("success", false);
map.put("errMsg", "查找学院信息错误");
}
return map;
}
/**
* 获取专业详细列表 权限 1,2
*
* @param collegeId
* @param request
* @return
*/
@RequestMapping(value = "/getspecialty", method = RequestMethod.GET)
public Map<String, Object> getSpecialty(@RequestParam(value = "collegeId", required = false) Integer collegeId,
HttpServletRequest request) {
Map<String, Object> map = new HashMap<>(3);
PersonInfo person = (PersonInfo) request.getSession().getAttribute("person");
List<Specialty> specialtyList = null;
College college = null;
if (person.getEnableStatus() == EnableStatusEnums.PREXY.getState()) {
List<College> college
辣椒种子
- 粉丝: 4238
- 资源: 5837
最新资源
- 免费下载:2023年注册会计师全国统一考试辅导教材---税法 (中国财政经济出版社) _U008u.zip
- jsp网上购书系统设计(源代码+论文).rar
- 免费下载:Android Runtime源码解析 (史宁宁) _PhGoy.zip
- 免费下载:ACCA Financial Reporting 2024 (Kaplan) _tvOoo.zip
- JSP网上教学资源共享系统(源代码+论文).rar
- jsp网上书店系统(源代码+论文).rar
- JSP网上校友录设计(源代码+论文).rar
- jsp微博系统-毕业设计.rar
- jsp学生管理系统-毕业设计.rar
- jsp物流中心仓储信息管理系统(源代码+论文+开题报告).rar
- python基础数据类型详细讲解.pdf
- jsp物流信息网建设(源代码+论文).rar
- jsp学生课绩管理系统(源代码+论文).rar
- JSP学生网上选课系统设计(源代码+论文+答辩PPT).rar
- JSP学生学籍管理系统(源代码+论文).rar
- 小黑课堂二级C语言题库(24年9月最新).exe
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈