title CourseServiceImpl.java
-*package cn.edu.hit.education.service
-*description TODO
-*copyright ҵѧ(C) 2019
-*company ҵѧAS&MT
-*author ѩ jinxuesong@163.com
-*date 2021421 4:38:16
-*version v1.0
-* -* Modification History: -* Date Author Version Discription -* ----------------------------------------------------------------------------------- -* 2021421 ѩ 1.0 1.0 -* Why & What is modified: <ԭ> -*/ + *title �� CourseServiceImpl.java
+ *package �� cn.edu.hit.education.service
+ *description ��TODO
+ *copyright �� ��������ҵ��ѧ(C) 2019
+ *company �� ��������ҵ��ѧAS&MT
+ *author �� ��ѩ�� jinxuesong@163.com
+ *date �� 2021��4��21�� ����4:38:16
+ *version �� v1.0
+ * + * Modification History: + * Date Author Version Discription + * ----------------------------------------------------------------------------------- + * 2021��4��21�� ��ѩ�� 1.0 1.0 + * Why & What is modified: <��ԭ������> + */ package cn.edu.hit.education.service; import java.util.ArrayList; import java.util.List; import java.util.Set; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.mgt.DefaultSecurityManager; +import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import cn.edu.hit.education.dao.CourseMapper; import cn.edu.hit.education.pojo.Course; import cn.edu.hit.education.pojo.CourseExample; - +import cn.edu.hit.education.shiro.UserRealm; /** - *classname CourseServiceImpl
- *description TODO
- *author ѩ jinxuesong@163.com
- *date 2021421 4:38:16
+ *+ * classname �� CourseServiceImpl + *
+ *+ * description ��TODO + *
+ *+ * author �� ��ѩ�� jinxuesong@163.com + *
+ *+ * date �� 2021��4��21�� ����4:38:16 + *
*/ @Service public class CourseServiceImpl implements ICourseService { @@ -40,114 +52,133 @@ public class CourseServiceImpl implements ICourseService { @Autowired CourseMapper courseMapper; + @Autowired + IUserService userService; + @Override public int insert(Course course) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return courseMapper.insert(course); } - /* ( Javadoc) - *Title: deleteByPrimaryKey
- *Description:
- * @param id - * @return - * @see cn.edu.hit.education.service.ICourseService#deleteByPrimaryKey(int) - */ - + /* + * (�� Javadoc)Title: deleteByPrimaryKey
Description:
+ * + * @param id + * + * @return + * + * @see cn.edu.hit.education.service.ICourseService#deleteByPrimaryKey(int) + */ + @Override public int deleteByPrimaryKey(int id) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return courseMapper.deleteByPrimaryKey(id); } - /* ( Javadoc) - *Title: update
- *Description:
- * @param course - * @return - * @see cn.edu.hit.education.service.ICourseService#update(cn.edu.hit.education.pojo.Course) - */ - + /* + * (�� Javadoc)Title: update
Description:
+ * + * @param course + * + * @return + * + * @see + * cn.edu.hit.education.service.ICourseService#update(cn.edu.hit.education + * .pojo.Course) + */ + @Override public int update(Course course) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return courseMapper.updateByPrimaryKey(course); } - /* ( Javadoc) - *Title: queryAllCourse
- *Description:
- * @return - * @see cn.edu.hit.education.service.ICourseService#queryAllCourse() - */ - + /* + * (�� Javadoc)Title: queryAllCourse
Description:
+ * + * @return + * + * @see cn.edu.hit.education.service.ICourseService#queryAllCourse() + */ + @Override public ListTitle: queryCoursesByPropertyId
- *Description:
- * @param propertyId - * @return - * @see cn.edu.hit.education.service.ICourseService#queryCoursesByPropertyId(int) - */ - + /* + * (�� Javadoc)Title: queryCoursesByPropertyId
Description:
+ * + * @param propertyId + * + * @return + * + * @see + * cn.edu.hit.education.service.ICourseService#queryCoursesByPropertyId(int) + */ + @Override public ListTitle: queryCoursesBySpecialtyPropertyId
- *Description:
- * @param specialtyId - * @param propertyId - * @return - * @see cn.edu.hit.education.service.ICourseService#queryCoursesBySpecialtyPropertyId(int, int) - */ - + /* + * (�� Javadoc)Title: queryCoursesBySpecialtyPropertyId
+ *Description:
+ * + * @param specialtyId + * + * @param propertyId + * + * @return + * + * @see + * cn.edu.hit.education.service.ICourseService#queryCoursesBySpecialtyPropertyId + * (int, int) + */ + @Override public ListTitle: IRolePermissonService
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +public interface IRolePermissonService { + + int queryPerIdByRoleId(Integer id); + +} diff --git a/src/cn/edu/hit/education/service/IRoleService.java b/src/cn/edu/hit/education/service/IRoleService.java new file mode 100644 index 0000000000000000000000000000000000000000..023fac776e9774a55bcb63989b44c3e502b4dd4a --- /dev/null +++ b/src/cn/edu/hit/education/service/IRoleService.java @@ -0,0 +1,16 @@ +package cn.edu.hit.education.service; + +import cn.edu.hit.education.pojo.Role; + +/** + * +*Title: IRoleService
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +public interface IRoleService { + + Role queryById(int roleId); + +} diff --git a/src/cn/edu/hit/education/service/IScheduleService.java b/src/cn/edu/hit/education/service/IScheduleService.java index 422e122ea71aa3100e91a1f04d6118f8b36fcb82..cd188520449bf91146dc12ae15f3c3d75010fd94 100644 --- a/src/cn/edu/hit/education/service/IScheduleService.java +++ b/src/cn/edu/hit/education/service/IScheduleService.java @@ -47,4 +47,10 @@ public interface IScheduleService { Listtitle ISpecialtyService.java
-*package cn.edu.hit.education.service
-*description TODO
-*copyright ҵѧ(C) 2019
-*company ҵѧAS&MT
-*author ѩ jinxuesong@163.com
-*date 2021421 2:59:59
-*version v1.0
+*title �� ISpecialtyService.java
+*package �� cn.edu.hit.education.service
+*description ��TODO
+*copyright �� ��������ҵ��ѧ(C) 2019
+*company �� ��������ҵ��ѧAS&MT
+*author �� ��ѩ�� jinxuesong@163.com
+*date �� 2021��4��21�� ����2:59:59
+*version �� v1.0
* * Modification History: * Date Author Version Discription * ----------------------------------------------------------------------------------- -* 2021421 ѩ 1.0 1.0 -* Why & What is modified: <ԭ> +* 2021��4��21�� ��ѩ�� 1.0 1.0 +* Why & What is modified: <��ԭ������> */ package cn.edu.hit.education.service; @@ -21,10 +21,10 @@ import java.util.List; import cn.edu.hit.education.pojo.Specialty; /** - *classname ISpecialtyService
- *description TODO
- *author ѩ jinxuesong@163.com
- *date 2021421 2:59:59
+ *classname �� ISpecialtyService
+ *description ��TODO
+ *author �� ��ѩ�� jinxuesong@163.com
+ *date �� 2021��4��21�� ����2:59:59
*/ public interface ISpecialtyService { @@ -39,4 +39,6 @@ public interface ISpecialtyService { ListTitle: IUserRoleService
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +public interface IUserRoleService { + + int queryRoleIdByUser(Integer id); + +} diff --git a/src/cn/edu/hit/education/service/IUserService.java b/src/cn/edu/hit/education/service/IUserService.java new file mode 100644 index 0000000000000000000000000000000000000000..7b71bf51590391049f566bac458a5cf07a2cc610 --- /dev/null +++ b/src/cn/edu/hit/education/service/IUserService.java @@ -0,0 +1,17 @@ +package cn.edu.hit.education.service; + +import cn.edu.hit.education.pojo.User; + +/** + * +*Title: IUserService
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +public interface IUserService { + void login(String username,String password); + + User queryUserByUsername(String username); + +} diff --git a/src/cn/edu/hit/education/service/IUserSpeciatyService.java b/src/cn/edu/hit/education/service/IUserSpeciatyService.java new file mode 100644 index 0000000000000000000000000000000000000000..67644d561b3b7ddf507c3e9964dc37255aa69e49 --- /dev/null +++ b/src/cn/edu/hit/education/service/IUserSpeciatyService.java @@ -0,0 +1,11 @@ +package cn.edu.hit.education.service; + +import java.util.List; + +import cn.edu.hit.education.pojo.UserSpecialty; + +public interface IUserSpeciatyService { + + ListTitle: PermissonServiceImpl
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class PermissonServiceImpl implements IPermissonService { + + @Autowired + PermissionMapper permissonMapper; + + @Override + public Permission queryPermissionById(int permissionId) { + // TODO Auto-generated method stub + return permissonMapper.selectByPrimaryKey(permissionId); + } + + +} diff --git a/src/cn/edu/hit/education/service/RolePermissonServiceImpl.java b/src/cn/edu/hit/education/service/RolePermissonServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..79b99493b3db5c8b23ba802a51713ba2f81684da --- /dev/null +++ b/src/cn/edu/hit/education/service/RolePermissonServiceImpl.java @@ -0,0 +1,28 @@ +package cn.edu.hit.education.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.RolePermissionMapper; + +/** + * +*Title: RolePermissonServiceImpl
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class RolePermissonServiceImpl implements IRolePermissonService { + + + @Autowired + RolePermissionMapper rolePermissionMapper; + + @Override + public int queryPerIdByRoleId(Integer id) { + + return rolePermissionMapper.queryPerIdByRoleId(id); + } + +} diff --git a/src/cn/edu/hit/education/service/RoleServiceImlp.java b/src/cn/edu/hit/education/service/RoleServiceImlp.java new file mode 100644 index 0000000000000000000000000000000000000000..d094cbddb8458bbabcba2ab8b8949ed4a1997a8e --- /dev/null +++ b/src/cn/edu/hit/education/service/RoleServiceImlp.java @@ -0,0 +1,28 @@ +package cn.edu.hit.education.service; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.RoleMapper; +import cn.edu.hit.education.pojo.Role; + + +/** + * +*Title: RoleServiceImlp
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class RoleServiceImlp implements IRoleService{ + @Autowired + RoleMapper roleMapper; + + @Override + public Role queryById(int roleId) { + + return roleMapper.selectByPrimaryKey(roleId); + } + +} diff --git a/src/cn/edu/hit/education/service/ScheduleServiceImpl.java b/src/cn/edu/hit/education/service/ScheduleServiceImpl.java index 9c9aca9419e2c5b7263c6041de62ebdc99d9906f..36ef1351888b053577b3e23d7fe1b209d235af10 100644 --- a/src/cn/edu/hit/education/service/ScheduleServiceImpl.java +++ b/src/cn/edu/hit/education/service/ScheduleServiceImpl.java @@ -160,5 +160,36 @@ public class ScheduleServiceImpl implements IScheduleService { return (scheduleMapper.queryCourseByCourseId(courseId)); } + @Override + public Listtitle SemesterServiceImpl.java
-*package cn.edu.hit.education.service
-*description TODO
-*copyright ҵѧ(C) 2019
-*company ҵѧAS&MT
-*author ѩ jinxuesong@163.com
-*date 2021421 4:39:38
-*version v1.0
+*title �� SemesterServiceImpl.java
+*package �� cn.edu.hit.education.service
+*description ��TODO
+*copyright �� ��������ҵ��ѧ(C) 2019
+*company �� ��������ҵ��ѧAS&MT
+*author �� ��ѩ�� jinxuesong@163.com
+*date �� 2021��4��21�� ����4:39:38
+*version �� v1.0
* * Modification History: * Date Author Version Discription * ----------------------------------------------------------------------------------- -* 2021421 ѩ 1.0 1.0 -* Why & What is modified: <ԭ> +* 2021��4��21�� ��ѩ�� 1.0 1.0 +* Why & What is modified: <��ԭ������> */ package cn.edu.hit.education.service; import java.util.List; +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.subject.Subject; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -26,24 +28,27 @@ import cn.edu.hit.education.pojo.Semester; import cn.edu.hit.education.pojo.SemesterExample; /** - *classname SemesterServiceImpl
- *description TODO
- *author ѩ jinxuesong@163.com
- *date 2021421 4:39:38
+ *classname �� SemesterServiceImpl
+ *description ��TODO
+ *author �� ��ѩ�� jinxuesong@163.com
+ *date �� 2021��4��21�� ����4:39:38
*/ @Service public class SemesterServiceImpl implements ISemesterService { @Autowired SemesterMapper semesterMapper; + + @Autowired + IUserService userService; @Override public int insert(Semester semester) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return semesterMapper.insert(semester); } - /* ( Javadoc) + /* (�� Javadoc) *Title: deleteByPrimaryKey
*Description:
* @param id @@ -53,11 +58,11 @@ public class SemesterServiceImpl implements ISemesterService { @Override public int deleteByPrimaryKey(int id) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return semesterMapper.deleteByPrimaryKey(id); } - /* ( Javadoc) + /* (�� Javadoc) *Title: update
*Description:
* @param semester @@ -67,11 +72,11 @@ public class SemesterServiceImpl implements ISemesterService { @Override public int update(Semester semester) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return semesterMapper.updateByPrimaryKey(semester); } - /* ( Javadoc) + /* (�� Javadoc) *Title: queryAllSemester
*Description:
* @return @@ -80,7 +85,7 @@ public class SemesterServiceImpl implements ISemesterService { @Override public ListTitle: queryByPrimaryKey
*Description:
* @param id @@ -98,7 +103,8 @@ public class SemesterServiceImpl implements ISemesterService { @Override public Semester queryByPrimaryKey(int id) { - // TODO Զɵķ + + // TODO �Զ����ɵķ������ return semesterMapper.selectByPrimaryKey(id); } diff --git a/src/cn/edu/hit/education/service/SpecialtyServiceImpl.java b/src/cn/edu/hit/education/service/SpecialtyServiceImpl.java index 79b29bf8d854347b6535dbc2375d99bcc6c7b613..01f10df9ed9f206838f24334528cec4c6ae2311e 100644 --- a/src/cn/edu/hit/education/service/SpecialtyServiceImpl.java +++ b/src/cn/edu/hit/education/service/SpecialtyServiceImpl.java @@ -1,18 +1,18 @@ /** -*title SpecialtyServiceImpl.java
-*package cn.edu.hit.education.service
-*description TODO
-*copyright ҵѧ(C) 2019
-*company ҵѧAS&MT
-*author ѩ jinxuesong@163.com
-*date 2021421 4:37:51
-*version v1.0
+*title �� SpecialtyServiceImpl.java
+*package �� cn.edu.hit.education.service
+*description ��TODO
+*copyright �� ��������ҵ��ѧ(C) 2019
+*company �� ��������ҵ��ѧAS&MT
+*author �� ��ѩ�� jinxuesong@163.com
+*date �� 2021��4��21�� ����4:37:51
+*version �� v1.0
* * Modification History: * Date Author Version Discription * ----------------------------------------------------------------------------------- -* 2021421 ѩ 1.0 1.0 -* Why & What is modified: <ԭ> +* 2021��4��21�� ��ѩ�� 1.0 1.0 +* Why & What is modified: <��ԭ������> */ package cn.edu.hit.education.service; @@ -26,10 +26,10 @@ import cn.edu.hit.education.pojo.Specialty; import cn.edu.hit.education.pojo.SpecialtyExample; /** - *classname SpecialtyServiceImpl
- *description TODO
- *author ѩ jinxuesong@163.com
- *date 2021421 4:37:51
+ *classname �� SpecialtyServiceImpl
+ *description ��TODO
+ *author �� ��ѩ�� jinxuesong@163.com
+ *date �� 2021��4��21�� ����4:37:51
*/ @Service public class SpecialtyServiceImpl implements ISpecialtyService { @@ -39,11 +39,11 @@ public class SpecialtyServiceImpl implements ISpecialtyService { @Override public int insert(Specialty specialty) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return specialtyMapper.insert(specialty); } - /* ( Javadoc) + /* (�� Javadoc) *Title: deleteByPrimaryKey
*Description:
* @param id @@ -53,11 +53,11 @@ public class SpecialtyServiceImpl implements ISpecialtyService { @Override public int deleteByPrimaryKey(int id) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return specialtyMapper.deleteByPrimaryKey(id); } - /* ( Javadoc) + /* (�� Javadoc) *Title: update
*Description:
* @param specialty @@ -67,11 +67,11 @@ public class SpecialtyServiceImpl implements ISpecialtyService { @Override public int update(Specialty specialty) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return specialtyMapper.updateByPrimaryKey(specialty); } - /* ( Javadoc) + /* (�� Javadoc) *Title: queryAllSpecialty
*Description:
* @return @@ -80,7 +80,7 @@ public class SpecialtyServiceImpl implements ISpecialtyService { @Override public ListTitle: queryAllSpecialtiesByCollegeId
*Description:
* @param collegeId @@ -98,7 +98,7 @@ public class SpecialtyServiceImpl implements ISpecialtyService { @Override public ListTitle: queryByPrimaryKey
*Description:
* @param id @@ -116,8 +116,14 @@ public class SpecialtyServiceImpl implements ISpecialtyService { @Override public Specialty queryByPrimaryKey(int id) { - // TODO Զɵķ + // TODO �Զ����ɵķ������ return specialtyMapper.selectByPrimaryKey(id); } + @Override + public ListTitle: UserRoleServiceImpl
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class UserRoleServiceImpl implements IUserRoleService { + + @Autowired + UserRoleMapper userRoleMapper; + + @Override + public int queryRoleIdByUser(Integer id) { + // TODO Auto-generated method stub + return userRoleMapper.queryRoleIdByUser(id); + } + +} diff --git a/src/cn/edu/hit/education/service/UserServiceImpl.java b/src/cn/edu/hit/education/service/UserServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5a295d4eddd6b926368ad3354a8a34bc708dc05f --- /dev/null +++ b/src/cn/edu/hit/education/service/UserServiceImpl.java @@ -0,0 +1,54 @@ +package cn.edu.hit.education.service; + +import java.util.Arrays; + +import org.apache.shiro.SecurityUtils; +import org.apache.shiro.authc.AuthenticationException; +import org.apache.shiro.authc.UsernamePasswordToken; +import org.apache.shiro.mgt.DefaultSecurityManager; +import org.apache.shiro.subject.Subject; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.UserMapper; +import cn.edu.hit.education.pojo.User; +import cn.edu.hit.education.shiro.UserRealm; + +/** + * +*Title: UserServiceImpl
+*Description:
+* @author 罗成 +* @date 2021年5月4日 + */ +@Service +public class UserServiceImpl implements IUserService { + @Autowired + UserMapper userMapper; + + @Autowired + DefaultSecurityManager securityManager; + + @Autowired + UserRealm userRealm; + + public void login(String username, String password) { + System.out.println("进入了login方法!"); + securityManager.setRealm(userRealm); + SecurityUtils.setSecurityManager(securityManager); + Subject subject = SecurityUtils.getSubject(); + UsernamePasswordToken token = new UsernamePasswordToken(username, + password); + subject.login(token); + + } + + @Override + public User queryUserByUsername(String username) { + System.out.println("进入查询方法!"); + + User user = userMapper.queryUserByUsername(username); + return user; + } + +} diff --git a/src/cn/edu/hit/education/service/UserSpeciatyServiceImpl.java b/src/cn/edu/hit/education/service/UserSpeciatyServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c1a40a1b01a4a37c1f59995d1d4f25724eec6c26 --- /dev/null +++ b/src/cn/edu/hit/education/service/UserSpeciatyServiceImpl.java @@ -0,0 +1,24 @@ +package cn.edu.hit.education.service; + +import java.util.List; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import cn.edu.hit.education.dao.UserSpecialtyMapper; + + + +@Service +public class UserSpeciatyServiceImpl implements IUserSpeciatyService { + @Autowired + UserSpecialtyMapper mapper; + + @Override + public ListTitle: UserRealm
+*Description: 进行了登录的密码认证和授权
+* @author 罗成 +* @date 2021年5月4日 + */ +public class UserRealm extends AuthorizingRealm{ + @Autowired + IUserService userService; + + @Autowired + IUserRoleService userRoleService; + + @Autowired + IRoleService roleService; + + @Autowired + IRolePermissonService rolePermissonService; + + @Autowired + IPermissonService permissonService; + + + + @Override + protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principalCollection) { + //1从主体传过来的授权信息中获取用户名 + User user1 = (User) principalCollection.getPrimaryPrincipal(); + //2.通过用户名来获取数据库或者缓存中的角色数据 + User user = userService.queryUserByUsername(user1.getUsername()); + int roleId = userRoleService.queryRoleIdByUser(user.getId()); + Role role = roleService.queryById(roleId); + //3.通过用户名来获取数据库或者缓存中的权限数据 + int permissionId = rolePermissonService.queryPerIdByRoleId(role.getId()); + Permission permission = permissonService.queryPermissionById(permissionId); + + Set