v0.1.7 完成高校院系模块后端接口,完成用户与高校之间的数据交互
parent
f2a45f123b
commit
0a9e8cd815
|
|
@ -1,4 +1,4 @@
|
|||
package com.bruce.sams.Constant;
|
||||
package com.bruce.sams.constant;
|
||||
|
||||
/**
|
||||
* 返回状态码
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.bruce.sams.controller;
|
||||
|
||||
import com.bruce.sams.utils.AjaxResult;
|
||||
import com.bruce.sams.domain.sms.College;
|
||||
import com.bruce.sams.service.CollegeService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 高校院系管理控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/college")
|
||||
public class CollegeController {
|
||||
|
||||
@Autowired
|
||||
private CollegeService collegeService;
|
||||
|
||||
/**
|
||||
* 获取所有高校
|
||||
*/
|
||||
@GetMapping("/universities")
|
||||
public AjaxResult getAllUniversities() {
|
||||
List<College> universities = collegeService.getAllUniversities();
|
||||
return AjaxResult.success("查询成功", universities);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某高校的所有院系
|
||||
*/
|
||||
@GetMapping("/{universityId}/departments")
|
||||
public AjaxResult getDepartments(@PathVariable Long universityId) {
|
||||
List<College> departments = collegeService.getDepartmentsByUniversity(universityId);
|
||||
return AjaxResult.success("查询成功", departments);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取某院系的详细信息
|
||||
*/
|
||||
@GetMapping("/{collegeId}")
|
||||
public AjaxResult getCollegeById(@PathVariable Long collegeId) {
|
||||
College college = collegeService.getCollegeById(collegeId);
|
||||
return college != null ? AjaxResult.success("查询成功", college) : AjaxResult.error("院系不存在");
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加高校或院系
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
public AjaxResult addCollege(@RequestBody College college) {
|
||||
collegeService.addCollege(college);
|
||||
return AjaxResult.success("添加成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新高校或院系信息
|
||||
*/
|
||||
@PutMapping("/update")
|
||||
public AjaxResult updateCollege(@RequestBody College college) {
|
||||
collegeService.updateCollege(college);
|
||||
return AjaxResult.success("更新成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除高校或院系
|
||||
*/
|
||||
@DeleteMapping("/delete/{collegeId}")
|
||||
public AjaxResult deleteCollege(@PathVariable Long collegeId) {
|
||||
collegeService.deleteCollege(collegeId);
|
||||
return AjaxResult.success("删除成功");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.bruce.sams.controller;
|
||||
|
||||
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||
import com.bruce.sams.service.CollegeLeaderService;
|
||||
import com.bruce.sams.utils.AjaxResult;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 高校/院系负责人管理控制器
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/admin/college-leader")
|
||||
public class CollegeLeaderController {
|
||||
|
||||
@Autowired
|
||||
private CollegeLeaderService collegeLeaderService;
|
||||
|
||||
/**
|
||||
* 查询高校/院系负责人
|
||||
*/
|
||||
@GetMapping("/{collegeId}")
|
||||
public AjaxResult getCollegeLeader(@PathVariable Long collegeId) {
|
||||
CollegeLeader leader = collegeLeaderService.getCollegeLeader(collegeId);
|
||||
return leader != null ? AjaxResult.success("查询成功", leader) : AjaxResult.error("未找到负责人");
|
||||
}
|
||||
|
||||
/**
|
||||
* 指派负责人
|
||||
*/
|
||||
@PostMapping("/assign")
|
||||
public AjaxResult assignLeader(@RequestAttribute Long adminUserId,
|
||||
@RequestParam Long collegeId,
|
||||
@RequestParam Long userId) {
|
||||
collegeLeaderService.assignLeader(collegeId, userId, adminUserId);
|
||||
return AjaxResult.success("指派成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除负责人
|
||||
*/
|
||||
@DeleteMapping("/remove/{collegeId}")
|
||||
public AjaxResult removeLeader(@RequestAttribute Long adminUserId, @PathVariable Long collegeId) {
|
||||
collegeLeaderService.removeLeader(collegeId, adminUserId);
|
||||
return AjaxResult.success("负责人移除成功");
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
package com.bruce.sams.domain.sms;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 高校及院系表
|
||||
* @TableName sms_college
|
||||
*/
|
||||
@TableName(value ="sms_college")
|
||||
@Data
|
||||
public class College {
|
||||
/**
|
||||
* 院系ID
|
||||
*/
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long collegeId;
|
||||
|
||||
/**
|
||||
* 名称(高校或院系)
|
||||
*/
|
||||
private String collegeName;
|
||||
|
||||
/**
|
||||
* 父院系ID(高校此值为空)
|
||||
*/
|
||||
private Long parentId;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
*/
|
||||
private String email;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
College other = (College) that;
|
||||
return (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId()))
|
||||
&& (this.getCollegeName() == null ? other.getCollegeName() == null : this.getCollegeName().equals(other.getCollegeName()))
|
||||
&& (this.getParentId() == null ? other.getParentId() == null : this.getParentId().equals(other.getParentId()))
|
||||
&& (this.getEmail() == null ? other.getEmail() == null : this.getEmail().equals(other.getEmail()))
|
||||
&& (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode());
|
||||
result = prime * result + ((getCollegeName() == null) ? 0 : getCollegeName().hashCode());
|
||||
result = prime * result + ((getParentId() == null) ? 0 : getParentId().hashCode());
|
||||
result = prime * result + ((getEmail() == null) ? 0 : getEmail().hashCode());
|
||||
result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", collegeId=").append(collegeId);
|
||||
sb.append(", collegeName=").append(collegeName);
|
||||
sb.append(", parentId=").append(parentId);
|
||||
sb.append(", email=").append(email);
|
||||
sb.append(", createdAt=").append(createdAt);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
package com.bruce.sams.domain.sms;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 院系负责人表
|
||||
* @TableName sms_college_leader
|
||||
*/
|
||||
@TableName(value ="sms_college_leader")
|
||||
@Data
|
||||
public class CollegeLeader {
|
||||
/**
|
||||
* 院系ID
|
||||
*/
|
||||
@TableId
|
||||
private Long collegeId;
|
||||
|
||||
/**
|
||||
* 负责人ID
|
||||
*/
|
||||
@TableId
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 指派时间
|
||||
*/
|
||||
private Date assignedAt;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (this == that) {
|
||||
return true;
|
||||
}
|
||||
if (that == null) {
|
||||
return false;
|
||||
}
|
||||
if (getClass() != that.getClass()) {
|
||||
return false;
|
||||
}
|
||||
CollegeLeader other = (CollegeLeader) that;
|
||||
return (this.getCollegeId() == null ? other.getCollegeId() == null : this.getCollegeId().equals(other.getCollegeId()))
|
||||
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
|
||||
&& (this.getAssignedAt() == null ? other.getAssignedAt() == null : this.getAssignedAt().equals(other.getAssignedAt()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((getCollegeId() == null) ? 0 : getCollegeId().hashCode());
|
||||
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
|
||||
result = prime * result + ((getAssignedAt() == null) ? 0 : getAssignedAt().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [");
|
||||
sb.append("Hash = ").append(hashCode());
|
||||
sb.append(", collegeId=").append(collegeId);
|
||||
sb.append(", userId=").append(userId);
|
||||
sb.append(", assignedAt=").append(assignedAt);
|
||||
sb.append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bruce.sams.exception;
|
||||
|
||||
import com.bruce.sams.Constant.HttpStatus;
|
||||
import com.bruce.sams.constant.HttpStatus;
|
||||
|
||||
/**
|
||||
* 账号被禁用异常
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bruce.sams.exception;
|
||||
|
||||
import com.bruce.sams.Constant.HttpStatus;
|
||||
import com.bruce.sams.constant.HttpStatus;
|
||||
|
||||
/**
|
||||
* 密码错误异常
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bruce.sams.exception;
|
||||
|
||||
import com.bruce.sams.Constant.HttpStatus;
|
||||
import com.bruce.sams.constant.HttpStatus;
|
||||
|
||||
/**
|
||||
* 用户未找到异常
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.bruce.sams.mapper;
|
||||
|
||||
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
/**
|
||||
* @author bruce
|
||||
* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Mapper
|
||||
* @createDate 2025-02-14 14:46:05
|
||||
* @Entity com.bruce.sams.domain.sms.CollegeLeader
|
||||
*/
|
||||
@Mapper
|
||||
public interface CollegeLeaderMapper extends BaseMapper<CollegeLeader> {
|
||||
/**
|
||||
* 查询某个高校/院系的负责人
|
||||
*/
|
||||
@Select("SELECT * FROM sms_college_leader WHERE college_id = #{collegeId}")
|
||||
CollegeLeader findLeaderByCollegeId(Long collegeId);
|
||||
|
||||
/**
|
||||
* 移除某个高校/院系的负责人
|
||||
*/
|
||||
@Delete("DELETE FROM sms_college_leader WHERE college_id = #{collegeId}")
|
||||
void removeLeaderByCollegeId(Long collegeId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.bruce.sams.mapper;
|
||||
|
||||
import com.bruce.sams.domain.sms.College;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bruce
|
||||
* @description 针对表【sms_college(高校及院系表)】的数据库操作Mapper
|
||||
* @createDate 2025-02-14 13:18:44
|
||||
* @Entity com.bruce.sams.domain.sms.College
|
||||
*/
|
||||
@Mapper
|
||||
public interface CollegeMapper extends BaseMapper<College> {
|
||||
/**
|
||||
* 查询某个高校的所有院系
|
||||
*/
|
||||
@Select("SELECT * FROM sms_college WHERE parent_id = #{collegeId}")
|
||||
List<College> findDepartmentsByUniversityId(Long collegeId);
|
||||
|
||||
/**
|
||||
* 获取所有高校
|
||||
*/
|
||||
@Select("SELECT * FROM sms_college WHERE parent_id IS NULL")
|
||||
List<College> findAllUniversities();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -12,7 +12,7 @@ import org.apache.ibatis.annotations.Select;
|
|||
* @Entity generator.domain.SysRole
|
||||
*/
|
||||
@Mapper
|
||||
public interface SysRoleMapper extends BaseMapper<Role> {
|
||||
public interface RoleMapper extends BaseMapper<Role> {
|
||||
@Select("SELECT * FROM sys_role WHERE role_id = #{roleId}")
|
||||
Role findByRoleId(Long roleId);
|
||||
|
||||
|
|
@ -6,7 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
@Mapper
|
||||
public interface SysUserMapper extends BaseMapper<User> {
|
||||
public interface UserMapper extends BaseMapper<User> {
|
||||
|
||||
// 通过用户名查询用户
|
||||
@Select("SELECT * FROM sys_user WHERE user_name = #{identifier}")
|
||||
|
|
@ -12,5 +12,5 @@ public interface AuthService {
|
|||
* @param loginRequest 登录请求体(包含 username / schoolId / email + password)
|
||||
* @return JWT 令牌(成功)或 null(失败)
|
||||
*/
|
||||
public String authenticate(LoginRequest loginRequest);
|
||||
String authenticate(LoginRequest loginRequest);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.bruce.sams.service;
|
||||
|
||||
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @author bruce
|
||||
* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Service
|
||||
* @createDate 2025-02-14 14:46:05
|
||||
*/
|
||||
public interface CollegeLeaderService extends IService<CollegeLeader> {
|
||||
/**
|
||||
* 查询高校/院系负责人
|
||||
*/
|
||||
CollegeLeader getCollegeLeader(Long collegeId);
|
||||
|
||||
/**
|
||||
* 指派高校/院系负责人(系统管理员 或 学校管理员)
|
||||
*/
|
||||
public void assignLeader(Long collegeId, Long userId, Long adminUserId);
|
||||
|
||||
/**
|
||||
* 移除负责人
|
||||
*/
|
||||
public void removeLeader(Long collegeId, Long adminUserId);
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.bruce.sams.service;
|
||||
|
||||
import com.bruce.sams.domain.sms.College;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author bruce
|
||||
* @description 针对表【sms_college(高校及院系表)】的数据库操作Service
|
||||
* @createDate 2025-02-14 13:18:44
|
||||
*/
|
||||
public interface CollegeService extends IService<College> {
|
||||
/**
|
||||
* 查询所有高校
|
||||
*/
|
||||
public List<College> getAllUniversities();
|
||||
|
||||
/**
|
||||
* 查询某高校的所有院系
|
||||
*/
|
||||
public List<College> getDepartmentsByUniversity(Long universityId);
|
||||
|
||||
/**
|
||||
* 查询院系详情
|
||||
*/
|
||||
public College getCollegeById(Long collegeId);
|
||||
|
||||
/**
|
||||
* 添加高校或院系
|
||||
*/
|
||||
public void addCollege(College college);
|
||||
|
||||
/**
|
||||
* 更新高校/院系信息
|
||||
*/
|
||||
public void updateCollege(College college);
|
||||
|
||||
/**
|
||||
* 删除高校/院系
|
||||
*/
|
||||
public void deleteCollege(Long collegeId);
|
||||
|
||||
}
|
||||
|
|
@ -5,8 +5,8 @@ import com.bruce.sams.domain.sys.User;
|
|||
import com.bruce.sams.exception.AccountDisabledException;
|
||||
import com.bruce.sams.exception.PasswordIncorrectException;
|
||||
import com.bruce.sams.exception.UserNotFoundException;
|
||||
import com.bruce.sams.mapper.SysRoleMapper;
|
||||
import com.bruce.sams.mapper.SysUserMapper;
|
||||
import com.bruce.sams.mapper.RoleMapper;
|
||||
import com.bruce.sams.mapper.UserMapper;
|
||||
import com.bruce.sams.service.AuthService;
|
||||
import com.bruce.sams.utils.PasswordUtil;
|
||||
import com.bruce.sams.utils.TokenUtil;
|
||||
|
|
@ -20,10 +20,10 @@ import org.springframework.stereotype.Service;
|
|||
public class AuthServiceImpl implements AuthService {
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
private UserMapper userMapper;
|
||||
|
||||
@Autowired
|
||||
private SysRoleMapper roleMapper;
|
||||
private RoleMapper roleMapper;
|
||||
|
||||
/**
|
||||
* 处理用户认证,支持用户名、学号、邮箱登录
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
package com.bruce.sams.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bruce.sams.constant.HttpStatus;
|
||||
import com.bruce.sams.domain.sms.CollegeLeader;
|
||||
import com.bruce.sams.domain.sys.User;
|
||||
import com.bruce.sams.exception.AccountDisabledException;
|
||||
import com.bruce.sams.exception.CustomException;
|
||||
import com.bruce.sams.exception.UserNotFoundException;
|
||||
import com.bruce.sams.mapper.UserMapper;
|
||||
import com.bruce.sams.service.CollegeLeaderService;
|
||||
import com.bruce.sams.mapper.CollegeLeaderMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author bruce
|
||||
* @description 针对表【sms_college_leader(院系负责人表)】的数据库操作Service实现
|
||||
* @createDate 2025-02-14 14:46:05
|
||||
*/
|
||||
@Service
|
||||
public class CollegeLeaderServiceImpl extends ServiceImpl<CollegeLeaderMapper, CollegeLeader>
|
||||
implements CollegeLeaderService{
|
||||
|
||||
@Autowired
|
||||
private CollegeLeaderMapper collegeLeaderMapper;
|
||||
|
||||
@Autowired
|
||||
private UserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 查询高校/院系负责人
|
||||
*/
|
||||
public CollegeLeader getCollegeLeader(Long collegeId) {
|
||||
return collegeLeaderMapper.findLeaderByCollegeId(collegeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 指派高校/院系负责人(系统管理员 或 学校管理员)
|
||||
*/
|
||||
public void assignLeader(Long collegeId, Long userId, Long adminUserId) {
|
||||
// 查询用户是否存在
|
||||
User user = userMapper.selectById(userId);
|
||||
if (user == null) {
|
||||
throw new UserNotFoundException();
|
||||
}
|
||||
|
||||
// 检查是否禁用
|
||||
if ("banned".equals(user.getStatus())) {
|
||||
throw new AccountDisabledException();
|
||||
}
|
||||
|
||||
// 检查指派权限(系统管理员只能指派学校管理员,学校管理员只能指派学院管理员)
|
||||
User adminUser = userMapper.selectById(adminUserId);
|
||||
if (adminUser == null || adminUser.getRoleId() > 1) { // roleId=0 为系统管理员,roleId=1 为学校管理员
|
||||
throw new CustomException(HttpStatus.FORBIDDEN, "无权指派负责人");
|
||||
}
|
||||
|
||||
// 如果已存在负责人,先移除
|
||||
collegeLeaderMapper.removeLeaderByCollegeId(collegeId);
|
||||
|
||||
// 指派新负责人
|
||||
CollegeLeader leader = new CollegeLeader();
|
||||
leader.setCollegeId(collegeId);
|
||||
leader.setUserId(userId);
|
||||
leader.setAssignedAt(new Date());
|
||||
|
||||
collegeLeaderMapper.insert(leader);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除负责人
|
||||
*/
|
||||
public void removeLeader(Long collegeId, Long adminUserId) {
|
||||
User adminUser = userMapper.selectById(adminUserId);
|
||||
if (adminUser == null || adminUser.getRoleId() > 1) {
|
||||
throw new CustomException(HttpStatus.FORBIDDEN, "无权移除负责人");
|
||||
}
|
||||
|
||||
collegeLeaderMapper.removeLeaderByCollegeId(collegeId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,65 @@
|
|||
package com.bruce.sams.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bruce.sams.domain.sms.College;
|
||||
import com.bruce.sams.service.CollegeService;
|
||||
import com.bruce.sams.mapper.CollegeMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CollegeServiceImpl extends ServiceImpl<CollegeMapper, College>
|
||||
implements CollegeService{
|
||||
|
||||
@Autowired
|
||||
private CollegeMapper collegeMapper;
|
||||
|
||||
/**
|
||||
* 查询所有高校
|
||||
*/
|
||||
public List<College> getAllUniversities() {
|
||||
return collegeMapper.findAllUniversities();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询某高校的所有院系
|
||||
*/
|
||||
public List<College> getDepartmentsByUniversity(Long universityId) {
|
||||
return collegeMapper.findDepartmentsByUniversityId(universityId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询院系详情
|
||||
*/
|
||||
public College getCollegeById(Long collegeId) {
|
||||
return collegeMapper.selectById(collegeId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加高校或院系
|
||||
*/
|
||||
public void addCollege(College college) {
|
||||
collegeMapper.insert(college);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新高校/院系信息
|
||||
*/
|
||||
public void updateCollege(College college) {
|
||||
collegeMapper.updateById(college);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除高校/院系
|
||||
*/
|
||||
public void deleteCollege(Long collegeId) {
|
||||
collegeMapper.deleteById(collegeId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -5,7 +5,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
import com.bruce.sams.domain.sys.User;
|
||||
import com.bruce.sams.exception.PasswordIncorrectException;
|
||||
import com.bruce.sams.exception.UserNotFoundException;
|
||||
import com.bruce.sams.mapper.SysUserMapper;
|
||||
import com.bruce.sams.mapper.UserMapper;
|
||||
import com.bruce.sams.service.UserService;
|
||||
import com.bruce.sams.utils.PasswordUtil;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
|
@ -14,11 +14,11 @@ import org.springframework.stereotype.Service;
|
|||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl extends ServiceImpl<SysUserMapper, User>
|
||||
public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
implements UserService {
|
||||
|
||||
@Autowired
|
||||
private SysUserMapper userMapper;
|
||||
private UserMapper userMapper;
|
||||
|
||||
/**
|
||||
* 批量导入用户
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
package com.bruce.sams.utils;
|
||||
|
||||
import com.bruce.sams.Constant.HttpStatus;
|
||||
import com.bruce.sams.constant.HttpStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
|
@ -23,19 +23,8 @@ public class AjaxResult extends HashMap<String, Object>
|
|||
/** 数据对象 */
|
||||
public static final String DATA_TAG = "data";
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
|
||||
*/
|
||||
public AjaxResult()
|
||||
{
|
||||
}
|
||||
public AjaxResult() {}
|
||||
|
||||
/**
|
||||
* 初始化一个新创建的 AjaxResult 对象
|
||||
*
|
||||
* @param code 状态码
|
||||
* @param msg 返回内容
|
||||
*/
|
||||
public AjaxResult(int code, String msg)
|
||||
{
|
||||
super.put(CODE_TAG, code);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bruce.sams.mapper.CollegeLeaderMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sms.CollegeLeader">
|
||||
<id property="collegeId" column="college_id" />
|
||||
<id property="userId" column="user_id" />
|
||||
<result property="assignedAt" column="assigned_at" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
college_id,user_id,assigned_at
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bruce.sams.mapper.CollegeMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sms.College">
|
||||
<id property="collegeId" column="college_id" />
|
||||
<result property="collegeName" column="college_name" />
|
||||
<result property="parentId" column="parent_id" />
|
||||
<result property="email" column="email" />
|
||||
<result property="createdAt" column="created_at" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_Column_List">
|
||||
college_id,college_name,parent_id,email,created_at
|
||||
</sql>
|
||||
</mapper>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bruce.sams.mapper.SysRoleMapper">
|
||||
<mapper namespace="com.bruce.sams.mapper.RoleMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sys.Role">
|
||||
<id property="roleId" column="role_id" />
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.bruce.sams.mapper.SysUserMapper">
|
||||
<mapper namespace="com.bruce.sams.mapper.UserMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bruce.sams.domain.sys.User">
|
||||
<id property="userId" column="user_id" />
|
||||
Loading…
Reference in New Issue