package org.ycm.sims.service.impl;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.ycm.sims.VO.*;
import org.ycm.sims.converter.Map2TeacherVO;
import org.ycm.sims.dao.InformationDao;
import org.ycm.sims.dao.RoleDao;
import org.ycm.sims.dto.*;
import org.ycm.sims.entity.*;
import org.ycm.sims.enums.*;
import org.ycm.sims.exception.SimsException;
import org.ycm.sims.service.InformationService;
import org.ycm.sims.service.RoleService;
import org.ycm.sims.service.SystemService;
import org.ycm.sims.utils.CompareDataUtil;
import org.ycm.sims.utils.FormatConversionUtil;
import org.ycm.sims.utils.SessionUtil;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Create by yangchangmin
* on 2018/4/22 1:05
*/
@Service
public class InformationServiceImpl implements InformationService {
@Autowired
private HttpServletRequest request;
@Autowired
private RoleDao roleDao;
@Autowired
private InformationDao informationDao;
@Autowired
private RoleService roleService;
@Autowired
private SystemService systemService;
@Override
public NumberAndClassesVO createInformationVO() {
Role role = SessionUtil.LoginNameCheckSession(request, roleDao);
List<Classes> classesList = informationDao.findClasses(new Classes());
List<String> classList = new ArrayList<>();
for (Classes classes : classesList){
classList.add(classes.getName());
}
String maxNumber = null;
if (role.getRoleType() == 0){
maxNumber = informationDao.findNumberMax();
}
if (role.getRoleType() == 1){
maxNumber = informationDao.findStudentNumberMax();
}
if (role.getRoleType() != 0 && role.getRoleType() != 1){
throw new SimsException(ExceptionEnum.UNAUTHORIZED_OPERATION);
}
NumberAndClassesVO numberAndClassesVO = new NumberAndClassesVO(classList, maxNumber);
return numberAndClassesVO;
}
@Override
public NumberAndClassesVO teacherClasses() {
Role role = SessionUtil.LoginNameCheckSession(request, roleDao);
List<Classes> classesList = informationDao.findTeaClassCount(role.getLoginName(), "");
List<String> classList = new ArrayList<>();
for (Classes classes : classesList){
String str = classes.getName();
classList.add(str);
}
NumberAndClassesVO numberAndClassesVO = new NumberAndClassesVO(classList);
return numberAndClassesVO;
}
@Override
@Transactional
public CheckVO createInformation(TeacherInformationDTO teacherInformationDTO) {
RoleCheckVO roleCheckVO = roleService.createRole(new RoleDTO(
teacherInformationDTO.getLoginName(),
teacherInformationDTO.getLoginPassword(),
teacherInformationDTO.getRoleType()));
if (roleCheckVO.getStatus() != 0){
return new CheckVO(roleCheckVO.getStatus(), roleCheckVO.getMessage());
}
if (informationDao.findInformationLoginName(teacherInformationDTO.getLoginName()) >= 1){
throw new SimsException(ResultEnum.INFORMATION_EXIST);
}
if (informationDao.findInformationNumber(teacherInformationDTO.getNumber()) >= 1){
throw new SimsException(ResultEnum.NUMBER_EXIST);
}
TeacherInformation teacherInformation = new TeacherInformation();
BeanUtils.copyProperties(teacherInformationDTO, teacherInformation);
teacherInformation.setDepartment(FormatConversionUtil.ListFormatString(teacherInformationDTO.getDepartment()));
teacherInformation.setClasses(FormatConversionUtil.ListFormatString(teacherInformationDTO.getClasses()));
if (informationDao.createInformation(teacherInformation) == 1){
return new CheckVO(ResultEnum.SUCCESS);
}else {
throw new SimsException(ExceptionEnum.SYSTEM_ERROR);
}
}
@Override
public PageVO<TeacherInformationVO> teacherInformationPage(RoleManagerDTO roleManagerDTO) {
Role role = SessionUtil.LoginNameCheckSession(request, roleDao);
if (roleManagerDTO.getRoleType() - role.getRoleType() == 1){
int count = informationDao.teacherInformationCount(new TeacherInformation(roleManagerDTO.getLoginName()));
Role roles = new Role();
BeanUtils.copyProperties(roleManagerDTO, roles);
PageHelper.startPage(roleManagerDTO.getPage(), roleManagerDTO.getLimit());
List<TeacherInformation> teacherInformationList = informationDao.informationList(roles);
List<TeacherInformationVO> teacherInformationVOList = new ArrayList<TeacherInformationVO>();
for (TeacherInformation teacherInformation: teacherInformationList){
TeacherInformationVO teacherInformationVO = new TeacherInformationVO();
BeanUtils.copyProperties(teacherInformation, teacherInformationVO);
teacherInformationVO.setCreateTime(FormatConversionUtil.DateFormatUtil(teacherInformation.getCreateTime()));
teacherInformationVOList.add(teacherInformationVO);
}
PageVO<TeacherInformationVO> pageVO = new PageVO(ResultEnum.SUCCESS, count,teacherInformationVOList);
return pageVO;
}else {
throw new SimsException(ExceptionEnum.UNAUTHORIZED_OPERATION);
}
}
@Override
@Transactional
public CheckVO updateTeacherInformation(TeacherInformationDTO teacherInformationDTO) {
Role role = SessionUtil.LoginNameCheckSession(request, roleDao);
TeacherInformation tI = informationDao.findByInformation(new TeacherInformation(teacherInformationDTO.getLoginName()));
if (FormatConversionUtil.roleTypeFormatUitl(teacherInformationDTO.getRoleType()) - role.getRoleType() == 1 || teacherInformationDTO.getLoginName().equals(role.getLoginName())){
TeacherInformation teacherInformation = new TeacherInformation();
BeanUtils.copyProperties(teacherInformationDTO, teacherInformation);
teacherInformation.setDepartment(FormatConversionUtil.ListFormatString(teacherInformationDTO.getDepartment()));
teacherInformation.setClasses(FormatConversionUtil.ListFormatString(teacherInformationDTO.getClasses()));
if (informationDao.findInformationNumber(teacherInformation.getNumber()) >= 1){
throw new SimsException(ResultEnum.NUMBER_EXIST);
}
if (teacherInformation.getClasses() == ""){
teacherInformation.setClasses(ParameterEnum.NO_CLASSES.getValue());
}
int row = informationDao.updateTeacherInformation(teacherInformation);
if (row == 1){
List<RecordDTO> recordDTOList = CompareDataUtil.CompareTeacherInformationData(tI, teacherInformation);
for (RecordDTO recordDTO : recordDTOList){
recordDTO.setLoginName(role.getLoginName());
recordDTO.setTableName(TableEnum.TEACHER_INFORMATION.getValue());
recordDTO.setKeyId(tI.getId());
systemService.addRecord(recordDTO);
}
return new CheckVO(ResultEnum.SUCCESS);
}else{
throw new SimsException(ExceptionEnum.DATA_BASE_ERROR);
}
}else {
throw new SimsException(ExceptionEnum.UNAUTHORIZED_OPERATION);
}
}
@Override
@Transactional
public CheckVO classManage(ClassManagerDTO classManagerDTO) {
Role role = SessionUtil.LoginNameCheckSession(request, roleDao);
int departmentCou
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计--学生信息管理系统_sims.zip (311个子文件)
bootstrap.min.css 118KB
layui.css 59KB
font-awesome.min.css 30KB
layer.css 14KB
style.css 10KB
layui.mobile.css 10KB
laydate.css 7KB
select.css 1KB
code.css 1KB
signin.css 793B
layui-font.css 369B
iconfont.eot 40KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
37.gif 1KB
68.gif 1KB
52.gif 777B
loading-1.gif 701B
.gitignore 268B
class_manager.html 23KB
information.html 21KB
class_manager.html 19KB
information.html 19KB
create_teacher.html 17KB
create_student.html 14KB
my_information_t.html 13KB
menu.html 13KB
my_information_s.html 12KB
t_class_manager.html 7KB
roleList.html 6KB
add_achievement.html 6KB
共 311 条
- 1
- 2
- 3
- 4
资源评论
好家伙VCC
- 粉丝: 2060
- 资源: 9145
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于SSM的医院管理系统的设计与实现
- 1055892_1_Level! 但它是一首歌 (重置版) B大调高难度还原_首调简谱.pdf
- 1075516_1_Level!重置版(改编自Qlimtzsinxdz)_首调简谱.pdf
- Nginx安装.docx
- 网络路由技术:华为设备上配置直连路由
- 【java毕业设计】交通事故档案管理系统源码(ssm+mysql+说明文档+LW).zip
- 【java毕业设计】健康管理系统源码(ssm+mysql+说明文档).zip
- 【java毕业设计】见福便利店信息管理系统源码(ssm+mysql+说明文档+LW).zip
- 信息打点技术在APP与小程序中的应用探索及实例演示
- 大学生职业生涯规划策划书.pdf
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功