This commit is contained in:
ray.ma 2025-01-17 18:33:19 +08:00
commit b1694a4035
93 changed files with 2154 additions and 0 deletions

38
.gitignore vendored Normal file
View File

@ -0,0 +1,38 @@
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### IntelliJ IDEA ###
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store

8
.idea/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml

15
.idea/dataSources.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DataSourceManagerImpl" format="xml" multifile-model="true">
<data-source source="LOCAL" name="local-sqlite" uuid="34953a02-477d-48dc-b843-513dce0d0933">
<driver-ref>sqlite.xerial</driver-ref>
<synchronize>true</synchronize>
<jdbc-driver>org.sqlite.JDBC</jdbc-driver>
<jdbc-url>jdbc:sqlite:$PROJECT_DIR$/datasource/myds.db</jdbc-url>
<jdbc-additional-properties>
<property name="com.intellij.clouds.kubernetes.db.enabled" value="false" />
</jdbc-additional-properties>
<working-dir>$ProjectFileDir$</working-dir>
</data-source>
</component>
</project>

7
.idea/encodings.xml Normal file
View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
</component>
</project>

14
.idea/misc.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="zulu-11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

BIN
datasource/myds.db Normal file

Binary file not shown.

79
pom.xml Normal file
View File

@ -0,0 +1,79 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mwj</groupId>
<artifactId>wj-manger-system</artifactId>
<version>1.0-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.13</version>
<relativePath/>
</parent>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<!-- validation 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
<!-- spring boot web 依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- &lt;!&ndash; thymeleaf &ndash;&gt;-->
<!-- <dependency>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-starter-thymeleaf</artifactId>-->
<!-- </dependency>-->
<!-- springboot test依赖 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- lombok 依赖 -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.22</version>
</dependency>
<!-- commons工具依赖 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.17.0</version>
</dependency>
<!-- jwt 依赖 -->
<dependency>
<groupId>com.auth0</groupId>
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<!-- SQLite 驱动 -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.21.0.1</version>
</dependency>
<!-- mybatis-plus 依赖 -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.7</version>
</dependency>
</dependencies>
</project>

5
readme.md Normal file
View File

@ -0,0 +1,5 @@
## 操作指南
### 1. 使用流程
管理员录入教师账户 -> 教师新建班级、科目 -> 学生注册账户并加入对应班级 -> 教师录入学生成绩 -> 学生、教师查看成绩

View File

@ -0,0 +1,14 @@
package com.wj.manager;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;
@SpringBootApplication
@MapperScan("com.wj.manager.mapper")
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}

View File

@ -0,0 +1,12 @@
package com.wj.manager.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface LoginCheck {
boolean required() default false;
}

View File

@ -0,0 +1,9 @@
package com.wj.manager.common;
import lombok.Data;
@Data
public class BaseRequest {
private Long userId;
private Integer role;
}

View File

@ -0,0 +1,6 @@
package com.wj.manager.common;
public class Constant {
public static final String USER_ID_KEY = "userId";
public static final String ROLE_KEY = "role";
}

View File

@ -0,0 +1,53 @@
package com.wj.manager.common;
import com.wj.manager.exception.BaseCode;
import lombok.*;
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode
@Builder
public class Result<T> {
private Integer ret_code;
private String ret_msg;
private T result;
public static <T> Result<T> success() {
return Result.<T>builder()
.ret_code(0)
.ret_msg("success")
.build();
}
public static <T> Result<T> success(T result) {
return Result.<T>builder()
.ret_code(0)
.ret_msg("success")
.result(result)
.build();
}
public static <T> Result<T> fail() {
return Result.<T>builder()
.ret_code(-1)
.ret_msg("fail")
.build();
}
public static <T> Result<T> fail(BaseCode baseCode) {
return Result.<T>builder()
.ret_code(baseCode.getCode())
.ret_msg(baseCode.getMessage())
.build();
}
public static <T> Result<T> fail(int code, String message) {
return Result.<T>builder()
.ret_code(code)
.ret_msg(message)
.build();
}
}

View File

@ -0,0 +1,11 @@
package com.wj.manager.common.req;
import lombok.Data;
@Data
public class AccountRequest {
private String username;
private String password;
private Long classId;
}

View File

@ -0,0 +1,18 @@
package com.wj.manager.common.req;
import lombok.Data;
@Data
public class ClassAddReq {
private Long id;
// 入学年份
private Integer year;
// 导员账户id
private Long counselorAccountId;
// 专业
private String major;
// 班级名称
private String name;
// 学生人数
private Integer studentCount;
}

View File

@ -0,0 +1,14 @@
package com.wj.manager.common.req;
import lombok.Data;
@Data
public class CreateAccountReq {
private String username;
private String password;
private Integer gender;
private String birthday;
private String phone;
private String college;
private Long classId;
}

View File

@ -0,0 +1,16 @@
package com.wj.manager.common.req;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Data
public class LoginReq {
@NotNull
@Min(1)
private Long accountId;
@NotBlank
private String password;
}

View File

@ -0,0 +1,28 @@
package com.wj.manager.common.req;
import lombok.Data;
@Data
public class ScoreReq {
private Long id;
/**
* 学生账户id
*/
private Long studentId;
/**
* 科目id
*/
private Long subjectId;
/**
* 成绩
*/
private Integer score;
/**
* 年份
*/
private Integer year;
/**
* 学期
*/
private Integer term;
}

View File

@ -0,0 +1,23 @@
package com.wj.manager.common.req;
import lombok.Data;
@Data
public class StudentScoreReq {
/**
* 学生账户id
*/
private Long accountId;
/**
* 科目id
*/
private Long subjectId;
/**
* 年份
*/
private Integer year;
/**
* 学期
*/
private Integer term;
}

View File

@ -0,0 +1,23 @@
package com.wj.manager.common.req;
import lombok.Data;
@Data
public class SubjectReq {
/**
* 科目id
*/
private Long id;
/**
* 科目名称
*/
private String name;
/**
* 科目类型1-必修2-选修
*/
private Integer type;
/**
* 学分
*/
private Integer credit;
}

View File

@ -0,0 +1,18 @@
package com.wj.manager.common.resp;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class AccountTokenResp {
private String token;
private Long userId;
private Integer role;
private String username;
private Long classId;
}

View File

@ -0,0 +1,14 @@
package com.wj.manager.common.resp;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class LoginResp {
private Long accountId;
private String username;
private String headImg;
private Integer role;
private String token;
}

View File

@ -0,0 +1,37 @@
package com.wj.manager.common.resp;
import com.wj.manager.entity.AccountEntity;
import com.wj.manager.entity.StudentScoreEntity;
import com.wj.manager.entity.SubjectEntity;
import lombok.Data;
@Data
public class ScoreInfo {
private Long id;
private Long studentId;
private String studentName;
private Long classId;
private Long subjectId;
private String subjectName;
private Integer year;
private Integer term;
private Integer score;
public static ScoreInfo build(StudentScoreEntity score, AccountEntity account, SubjectEntity subject) {
ScoreInfo scoreInfo = new ScoreInfo();
scoreInfo.setId(score.getId());
scoreInfo.setStudentId(score.getAccountId());
scoreInfo.setStudentName(account == null ? "": account.getUsername());
scoreInfo.setClassId(account == null ? 0: account.getClassId());
scoreInfo.setSubjectId(score.getSubjectId());
scoreInfo.setSubjectName(subject == null ? "": subject.getName());
scoreInfo.setYear(score.getYear());
scoreInfo.setTerm(score.getTerm());
scoreInfo.setScore(score.getScore());
return scoreInfo;
}
}

View File

@ -0,0 +1,29 @@
package com.wj.manager.config;
import com.wj.manager.common.Result;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.exception.BizException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import javax.servlet.http.HttpServletRequest;
@RestControllerAdvice
@Slf4j
public class CommonExceptionAdvice {
@ExceptionHandler(BizException.class)
@ResponseStatus(HttpStatus.OK)
public Result<String> handleBizException(BizException e, HttpServletRequest request) {
return Result.fail(e.getCode(), e.getErrorMessage());
}
@ExceptionHandler(MethodArgumentNotValidException.class)
public Result<String> handleValidationExceptions(MethodArgumentNotValidException ex) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
}

View File

@ -0,0 +1,67 @@
package com.wj.manager.config;
import com.wj.manager.annotation.LoginCheck;
import com.wj.manager.common.Constant;
import com.wj.manager.entity.AccountEntity;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.exception.BizException;
import com.wj.manager.service.AccountService;
import com.wj.manager.utils.JWTUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@Component
public class LoginCheckInterceptor implements HandlerInterceptor {
@Resource
private AccountService accountService;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 不是映射到方法直接通过
if (!(handler instanceof HandlerMethod)) {
return true;
}
// 判断是不是加了LoginCheck注解
HandlerMethod handlerMethod = (HandlerMethod) handler;
LoginCheck loginCheck = handlerMethod.getMethodAnnotation(LoginCheck.class);
if (loginCheck == null) {
return true;
}
boolean required = loginCheck.required();
String token = request.getHeader("token");
String userId = JWTUtils.verifyToken(token);
// 如果必须登录但是token无效抛出异常
if (required && StringUtils.isEmpty(userId)) {
throw new BizException(BaseErrorCode.AUTHORIZE_ERROR);
}
if (StringUtils.isNotEmpty(userId)) {
Long uid = Long.parseLong(userId);
AccountEntity accountEntity = accountService.getById(uid);
if (accountEntity == null && required) {
throw new BizException(BaseErrorCode.AUTHORIZE_ERROR);
}
if (accountEntity != null) {
MDC.put(Constant.USER_ID_KEY, String.valueOf(accountEntity.getId()));
MDC.put(Constant.ROLE_KEY, String.valueOf(accountEntity.getRole()));
}
}
return true;
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
MDC.remove(Constant.USER_ID_KEY);
MDC.remove(Constant.ROLE_KEY);
}
}

View File

@ -0,0 +1,29 @@
package com.wj.manager.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.annotation.Resource;
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
@Resource
private LoginCheckInterceptor loginCheckInterceptor;
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(loginCheckInterceptor)
.addPathPatterns("/**");
}
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedHeaders("*")
.allowedMethods("GET", "POST", "PUT", "DELETE")
.maxAge(3600);
}
}

View File

@ -0,0 +1,116 @@
package com.wj.manager.controller;
import com.wj.manager.annotation.LoginCheck;
import com.wj.manager.common.Result;
import com.wj.manager.common.req.AccountRequest;
import com.wj.manager.common.req.CreateAccountReq;
import com.wj.manager.common.req.LoginReq;
import com.wj.manager.common.resp.AccountTokenResp;
import com.wj.manager.common.resp.LoginResp;
import com.wj.manager.dto.AccountInfoDTO;
import com.wj.manager.enums.RoleTypeEnum;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api/account")
public class AccountController extends CommonController {
@Resource
private AccountService accountService;
// 学生账户录入
@LoginCheck(required = true)
@PostMapping("/student/add")
public Result<Boolean> addStudent(@RequestBody CreateAccountReq req) {
return Result.success(accountService.addAccount(req, RoleTypeEnum.STUDENT));
}
// 登录
@PostMapping("/login")
public Result<LoginResp> login(@Valid @RequestBody LoginReq req) {
return Result.success(accountService.login(req));
}
// 教师账户录入
@LoginCheck(required = true)
@PostMapping("/teacher-register")
public Result<Boolean> teacherRegister(@RequestBody AccountRequest req) {
// 参数校验
if (StringUtils.isEmpty(req.getUsername()) || StringUtils.isEmpty(req.getPassword())) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
if (getUserRole() != RoleTypeEnum.ADMIN) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(accountService.teacherRegister(req));
}
/**
* 获取用户信息
* @return 用户信息
*/
@LoginCheck(required = true)
@GetMapping("/info")
public Result<AccountInfoDTO> info() {
Long userId = getUserId();
return Result.success(accountService.userInfo(userId));
}
/**
* 获取班级学生列表
* @param classId 班级id
* @return 学生列表
*/
@LoginCheck(required = true)
@GetMapping("/list")
public Result<List<AccountInfoDTO>> getClassStudentList(@RequestParam(required = false) Long classId, @RequestParam(required = false) Long uid) {
RoleTypeEnum userRole = getUserRole();
return Result.success(accountService.classStudentList(classId, userRole, uid));
}
// 删除账户
@LoginCheck(required = true)
@GetMapping("/delete")
public Result<Boolean> deleteAccount(@RequestParam Long id) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(accountService.removeById(id));
}
// 删除账户
@LoginCheck(required = true)
@PostMapping("/update")
public Result<Boolean> updateAccount(@RequestBody AccountInfoDTO req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(accountService.updateAccount(req));
}
// 获取用户信息
@LoginCheck(required = true)
@GetMapping("/detail")
public Result<AccountInfoDTO> detail(@RequestParam Long id) {
return Result.success(accountService.userInfo(id));
}
// 获取教师列表
@LoginCheck(required = true)
@GetMapping("/teacher-list")
public Result<List<AccountInfoDTO>> teacherList() {
return Result.success(accountService.teacherList());
}
}

View File

@ -0,0 +1,78 @@
package com.wj.manager.controller;
import com.wj.manager.annotation.LoginCheck;
import com.wj.manager.common.Result;
import com.wj.manager.common.req.ClassAddReq;
import com.wj.manager.entity.ClassEntity;
import com.wj.manager.enums.RoleTypeEnum;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.service.ClassService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api/class")
public class ClassController extends CommonController {
@Resource
private ClassService classService;
/**
* 获取班级列表
* @return 班级列表
*/
@GetMapping("/list")
public Result<List<ClassEntity>> list(@RequestParam(required = false) Long id,
@RequestParam(required = false) String name,
@RequestParam(required = false) String major) {
return Result.success(classService.list(id, name, major));
}
// 班级新增
@LoginCheck(required = true)
@PostMapping("/add")
public Result<ClassEntity> add(@RequestBody ClassAddReq req) {
RoleTypeEnum userRole = getUserRole();
if (!RoleTypeEnum.isAdminOrTeacher(userRole)) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(classService.add(req));
}
// 班级新增
@LoginCheck(required = true)
@PostMapping("/update")
public Result<Boolean> update(@RequestBody ClassAddReq req) {
RoleTypeEnum userRole = getUserRole();
if (!RoleTypeEnum.isAdminOrTeacher(userRole)) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
if (req.getId() == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
return Result.success(classService.update(req));
}
@LoginCheck(required = true)
@PostMapping("/delete")
public Result<Boolean> delete(@RequestBody ClassAddReq req) {
RoleTypeEnum userRole = getUserRole();
if (!RoleTypeEnum.isAdminOrTeacher(userRole)) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
if (req.getId() == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
return Result.success(classService.removeById(req.getId()));
}
// 班级信息
@GetMapping("/info")
public Result<ClassEntity> info(@RequestParam Long id) {
return Result.success(classService.getById(id));
}
}

View File

@ -0,0 +1,25 @@
package com.wj.manager.controller;
import com.wj.manager.common.Constant;
import com.wj.manager.enums.RoleTypeEnum;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
public class CommonController {
protected Long getUserId() {
String userIdStr = MDC.get(Constant.USER_ID_KEY);
if (StringUtils.isEmpty(userIdStr)) {
return null;
}
return Long.valueOf(userIdStr);
}
protected RoleTypeEnum getUserRole() {
String roleStr = MDC.get(Constant.ROLE_KEY);
if (StringUtils.isEmpty(roleStr)) {
return RoleTypeEnum.UNKNOWN;
}
return RoleTypeEnum.getByCode(Integer.valueOf(roleStr));
}
}

View File

@ -0,0 +1,99 @@
package com.wj.manager.controller;
import com.wj.manager.annotation.LoginCheck;
import com.wj.manager.common.Result;
import com.wj.manager.common.req.ScoreReq;
import com.wj.manager.common.resp.ScoreInfo;
import com.wj.manager.enums.RoleTypeEnum;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.exception.BizException;
import com.wj.manager.service.StudentScoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api/score")
public class ScoreController extends CommonController{
@Resource
private StudentScoreService studentScoreService;
@LoginCheck(required = true)
@GetMapping("/list")
public Result<List<ScoreInfo>> list(@RequestParam(required = false) Long accountId,
@RequestParam(required = false) Long subjectId,
@RequestParam(required = false) Long classId,
@RequestParam(required = false) Integer year,
@RequestParam(required = false) Integer term) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
throw new BizException(BaseErrorCode.NO_PERMISSION);
}
return Result.success(studentScoreService.list(accountId, subjectId, classId, year, term));
}
// 成绩录入
@LoginCheck(required = true)
@PostMapping("/add")
public Result<Boolean> add(@RequestBody ScoreReq req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
if (req.getStudentId() == null || req.getSubjectId() == null || req.getScore() == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
return Result.success(studentScoreService.addScore(req));
}
// 成绩修改
@LoginCheck(required = true)
@PostMapping("/update")
public Result<Boolean> update(@RequestBody ScoreReq req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
if (req.getId() == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
return Result.success(studentScoreService.updateScore(req));
}
// 成绩删除
@LoginCheck(required = true)
@PostMapping("/delete")
public Result<Boolean> delete(@RequestBody ScoreReq req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
if (req.getId() == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
return Result.success(studentScoreService.deleteScore(req.getId()));
}
@LoginCheck(required = true)
@GetMapping("/info")
public Result<ScoreInfo> info(@RequestParam Long id) {
if (id == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
return Result.success(studentScoreService.getScoreInfo(id));
}
// 学生各科成绩查询: 指定学年学期的学生各科成绩查询
@LoginCheck(required = true)
@GetMapping("/subjects")
public Result<List<ScoreInfo>> subjectList(@RequestParam Long accountId, @RequestParam Integer year, @RequestParam Integer term) {
if (year == null || term == null) {
return Result.fail(BaseErrorCode.PARAM_INVALID);
}
if (accountId == null) {
accountId = getUserId();
}
return Result.success(studentScoreService.studentScoreList(accountId, year, term));
}
}

View File

@ -0,0 +1,66 @@
package com.wj.manager.controller;
import com.wj.manager.annotation.LoginCheck;
import com.wj.manager.common.Result;
import com.wj.manager.common.req.SubjectReq;
import com.wj.manager.entity.SubjectEntity;
import com.wj.manager.enums.RoleTypeEnum;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.service.SubjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@Slf4j
@RestController
@RequestMapping("/api/subject")
public class SubjectController extends CommonController {
@Resource
private SubjectService subjectService;
@LoginCheck
@GetMapping("/list")
public Result<List<SubjectEntity>> list(@RequestParam(required = false) Long id,
@RequestParam(required = false) String name,
@RequestParam(required = false) Integer type) {
return Result.success(subjectService.list(id, name, type));
}
// 新增科目
@LoginCheck(required = true)
@PostMapping("/add")
public Result<Boolean> add(@RequestBody SubjectReq req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(subjectService.add(req));
}
@LoginCheck(required = true)
@PostMapping("/update")
public Result<Boolean> update(@RequestBody SubjectReq req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(subjectService.update(req));
}
@LoginCheck(required = true)
@PostMapping("/delete")
public Result<Boolean> delete(@RequestBody SubjectReq req) {
if (!RoleTypeEnum.isAdminOrTeacher(getUserRole())) {
return Result.fail(BaseErrorCode.NO_PERMISSION);
}
return Result.success(subjectService.delete(req.getId()));
}
@LoginCheck(required = true)
@GetMapping("/info")
public Result<SubjectEntity> info(@RequestParam Long id) {
return Result.success(subjectService.getById(id));
}
}

View File

@ -0,0 +1,13 @@
package com.wj.manager.controller.page;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
@Controller
public class PageController {
@GetMapping({"/index", "/"})
public String index(Model model) {
return "forward:/index.html";
}
}

View File

@ -0,0 +1,28 @@
package com.wj.manager.dto;
import com.wj.manager.entity.AccountEntity;
import com.wj.manager.enums.CollegeTypeEnum;
import lombok.Data;
@Data
public class AccountInfoDTO {
private Long userId;
private String username;
private Integer role;
private Long classId;
private String gender;
private String birthday;
private String phone;
private String college;
public AccountInfoDTO(AccountEntity entity) {
this.userId = entity.getId();
this.username = entity.getUsername();
this.role = entity.getRole();
this.classId = entity.getClassId();
this.gender = entity.getGender() == 1 ? "" : "";
this.birthday = entity.getBirthday();
this.phone = entity.getPhone();
this.college = CollegeTypeEnum.getNameByType(entity.getCollege());
}
}

View File

@ -0,0 +1,8 @@
package com.wj.manager.dto;
import lombok.Data;
@Data
public class ClassInfoDTO {
}

View File

@ -0,0 +1,64 @@
package com.wj.manager.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* 用户账户表
*/
@Data
@TableName("tb_account")
public class AccountEntity {
@TableId(type = IdType.AUTO)
private Long id;
/**
* 姓名
*/
private String username;
/**
* 密码
*/
private String password;
/**
* 性别1-2-
*/
private Integer gender;
/**
* 出生日期
*/
private String birthday;
/**
* 手机号
*/
private String phone;
/**
* 学院
*/
private String college;
/**
* 班级id
*/
private Long classId;
/**
* 角色1-管理员2-教师3-学生
*/
private Integer role;
/**
* 头像
*/
private String headImg;
/**
* 状态1-正常0-禁用
*/
private Integer status;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -0,0 +1,54 @@
package com.wj.manager.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* 班级表
*/
@Data
@TableName("tb_class")
public class ClassEntity {
/**
* 班级id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 入学年份
*/
private Integer year;
/**
* 班级名称
*/
private String name;
/**
* 专业
*/
private String major;
/**
* 导员账户id
*/
private Long counselorAccountId;
/**
* 学生人数
*/
private Integer studentCount;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -0,0 +1,48 @@
package com.wj.manager.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
@Data
@TableName("tb_student_score")
public class StudentScoreEntity {
@TableId(type = IdType.AUTO)
private Long id;
/**
* 学生账户id
*/
private Long accountId;
/**
* 科目id
*/
private Long subjectId;
/**
* 成绩
*/
private Integer score;
/**
* 年份
*/
private Integer year;
/**
* 学期
*/
private Integer term;
/**
* 班级id
*/
private Long classId;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -0,0 +1,41 @@
package com.wj.manager.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* 科目表
*/
@Data
@TableName("tb_subject")
public class SubjectEntity {
/**
* 科目id
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* 科目名称
*/
private String name;
/**
* 科目类型1-必修2-选修
*/
private Integer type;
/**
* 学分
*/
private Integer credit;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -0,0 +1,36 @@
package com.wj.manager.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 学院类型枚举
*/
@AllArgsConstructor
@Getter
public enum CollegeTypeEnum {
COMPUTER("computer", "计算机"),
ELECTRONIC("electronic", "电子信息"),
MECHANICAL("mechanical", "机械工程"),
;
private final String type;
private final String name;
public static String getNameByType(String type) {
for (CollegeTypeEnum value : CollegeTypeEnum.values()) {
if (value.getType().equals(type)) {
return value.getName();
}
}
return "";
}
public static String getByName(String name) {
for (CollegeTypeEnum value : CollegeTypeEnum.values()) {
if (value.getName().equals(name)) {
return value.type;
}
}
return "";
}
}

View File

@ -0,0 +1,14 @@
package com.wj.manager.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum EnableStatusEnum {
ENABLE(1, "启用"),
DISABLE(0, "禁用"),
;
private final Integer code;
private final String message;
}

View File

@ -0,0 +1,30 @@
package com.wj.manager.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum RoleTypeEnum {
UNKNOWN(0, "未知"),
ADMIN(1, "管理员"),
TEACHER(2, "教师"),
STUDENT(3, "学生"),
;
private final Integer code;
private final String message;
public static RoleTypeEnum getByCode(Integer code) {
for (RoleTypeEnum roleTypeEnum : RoleTypeEnum.values()) {
if (roleTypeEnum.code.equals(code)) {
return roleTypeEnum;
}
}
return UNKNOWN;
}
// 管理员或老师
public static boolean isAdminOrTeacher(RoleTypeEnum roleType) {
return ADMIN.equals(roleType) || TEACHER.equals(roleType);
}
}

View File

@ -0,0 +1,6 @@
package com.wj.manager.exception;
public interface BaseCode {
Integer getCode();
String getMessage();
}

View File

@ -0,0 +1,22 @@
package com.wj.manager.exception;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum BaseErrorCode implements BaseCode {
PARAM_INVALID(1000, "参数不合法"),
CLASS_NOT_EXIST(1001, "班级不存在"),
AUTHORIZE_ERROR(1002, "用户身份认证失败"),
USER_NOT_EXIST(1003, "用户不存在"),
USER_ALREADY_EXIST(1004, "用户已存在"),
PASSWORD_ERROR(1005, "密码错误"),
NO_PERMISSION(1006, "无权限访问"),
SUBJECT_NOT_EXIST(1007, "科目不存在"),
SCORE_ALREADY_EXIST(1008, "成绩已存在"),
SCORE_NOT_EXIST(1009, "成绩不存在"),
;
private final Integer code;
private final String message;
}

View File

@ -0,0 +1,24 @@
package com.wj.manager.exception;
import lombok.Data;
import lombok.EqualsAndHashCode;
@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException {
private int code;
private String errorMessage;
public BizException(final int code, final String errorMessage) {
super(errorMessage);
this.code = code;
this.errorMessage = errorMessage;
}
public BizException(BaseCode baseCode) {
super(baseCode.getMessage());
this.code = baseCode.getCode();
this.errorMessage = baseCode.getMessage();
}
}

View File

@ -0,0 +1,7 @@
package com.wj.manager.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wj.manager.entity.AccountEntity;
public interface AccountMapper extends BaseMapper<AccountEntity> {
}

View File

@ -0,0 +1,7 @@
package com.wj.manager.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wj.manager.entity.ClassEntity;
public interface ClassMapper extends BaseMapper<ClassEntity> {
}

View File

@ -0,0 +1,7 @@
package com.wj.manager.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wj.manager.entity.StudentScoreEntity;
public interface StudentScoreMapper extends BaseMapper<StudentScoreEntity> {
}

View File

@ -0,0 +1,7 @@
package com.wj.manager.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.wj.manager.entity.SubjectEntity;
public interface SubjectMapper extends BaseMapper<SubjectEntity> {
}

View File

@ -0,0 +1,27 @@
package com.wj.manager.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wj.manager.common.req.AccountRequest;
import com.wj.manager.common.req.CreateAccountReq;
import com.wj.manager.common.req.LoginReq;
import com.wj.manager.common.resp.AccountTokenResp;
import com.wj.manager.common.resp.LoginResp;
import com.wj.manager.dto.AccountInfoDTO;
import com.wj.manager.entity.AccountEntity;
import com.wj.manager.enums.RoleTypeEnum;
import java.util.List;
public interface AccountService extends IService<AccountEntity> {
boolean teacherRegister(AccountRequest req);
// AccountTokenResp login(AccountRequest req);
AccountInfoDTO userInfo(Long userId);
List<AccountInfoDTO> classStudentList(Long classId, RoleTypeEnum role, Long userId);
boolean addAccount(CreateAccountReq req, RoleTypeEnum role);
LoginResp login(LoginReq req);
boolean updateAccount(AccountInfoDTO dto);
List<AccountInfoDTO> teacherList();
}

View File

@ -0,0 +1,14 @@
package com.wj.manager.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wj.manager.common.req.ClassAddReq;
import com.wj.manager.entity.ClassEntity;
import java.util.List;
public interface ClassService extends IService<ClassEntity> {
// 班级新增
ClassEntity add(ClassAddReq req);
List<ClassEntity> list(Long id, String name, String major);
boolean update(ClassAddReq req);
}

View File

@ -0,0 +1,25 @@
package com.wj.manager.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wj.manager.common.req.ScoreReq;
import com.wj.manager.common.resp.ScoreInfo;
import com.wj.manager.entity.StudentScoreEntity;
import java.util.List;
public interface StudentScoreService extends IService<StudentScoreEntity> {
// 成绩录入
boolean addScore(ScoreReq req);
// 成绩修改
boolean updateScore(ScoreReq req);
// 成绩删除
boolean deleteScore(Long id);
List<ScoreInfo> studentScoreList(Long accountId, Integer year, Integer term);
List<ScoreInfo> list(Long accountId, Long subjectId, Long classId, Integer year, Integer term);
ScoreInfo getScoreInfo(Long id);
}

View File

@ -0,0 +1,22 @@
package com.wj.manager.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.wj.manager.common.req.SubjectReq;
import com.wj.manager.entity.SubjectEntity;
import java.util.List;
public interface SubjectService extends IService<SubjectEntity> {
/**
* 新增科目
* @param req 新增科目请求
* @return 新增科目
*/
boolean add(SubjectReq req);
List<SubjectEntity> list(Long id, String name, Integer type);
boolean update(SubjectReq req);
boolean delete(Long id);
}

View File

@ -0,0 +1,167 @@
package com.wj.manager.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wj.manager.common.req.AccountRequest;
import com.wj.manager.common.req.CreateAccountReq;
import com.wj.manager.common.req.LoginReq;
import com.wj.manager.common.resp.AccountTokenResp;
import com.wj.manager.common.resp.LoginResp;
import com.wj.manager.dto.AccountInfoDTO;
import com.wj.manager.entity.AccountEntity;
import com.wj.manager.entity.ClassEntity;
import com.wj.manager.enums.CollegeTypeEnum;
import com.wj.manager.enums.EnableStatusEnum;
import com.wj.manager.enums.RoleTypeEnum;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.exception.BizException;
import com.wj.manager.mapper.AccountMapper;
import com.wj.manager.service.AccountService;
import com.wj.manager.service.ClassService;
import com.wj.manager.utils.JWTUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountEntity> implements AccountService {
@Resource
private ClassService classService;
@Override
public boolean teacherRegister(AccountRequest req) {
AccountEntity accountEntity = new AccountEntity();
accountEntity.setUsername(req.getUsername());
accountEntity.setPassword(req.getPassword());
accountEntity.setClassId(0L);
accountEntity.setRole(RoleTypeEnum.TEACHER.getCode());
accountEntity.setStatus(EnableStatusEnum.ENABLE.getCode());
accountEntity.setCreateTime(new Date());
accountEntity.setUpdateTime(new Date());
return save(accountEntity);
}
// 登录
public LoginResp login(LoginReq req) {
// 查询用户信息
AccountEntity account = getById(req.getAccountId());
if (account == null) {
throw new BizException(BaseErrorCode.USER_NOT_EXIST);
}
// 密码校验
if (!req.getPassword().equals(account.getPassword())) {
throw new BizException(BaseErrorCode.PASSWORD_ERROR);
}
// token生成
String token = JWTUtils.createToken(account.getId().toString());
return LoginResp.builder()
.accountId(account.getId())
.username(account.getUsername())
.headImg(account.getHeadImg())
.role(account.getRole())
.token(token)
.build();
}
@Override
public boolean updateAccount(AccountInfoDTO dto) {
AccountEntity accountEntity = getById(dto.getUserId());
if (accountEntity == null) {
throw new BizException(BaseErrorCode.USER_NOT_EXIST);
}
String collegeValue = CollegeTypeEnum.getByName(dto.getCollege());
if (StringUtils.isEmpty(collegeValue)) {
collegeValue = dto.getCollege();
}
String gender = dto.getGender();
switch (gender) {
case "":
accountEntity.setGender(1);
break;
case "":
accountEntity.setGender(2);
break;
default:
accountEntity.setGender(Integer.parseInt(gender));
}
String birthday = dto.getBirthday().substring(0, 10);
accountEntity.setUsername(dto.getUsername());
accountEntity.setClassId(dto.getClassId());
accountEntity.setBirthday(birthday);
accountEntity.setPhone(dto.getPhone());
accountEntity.setCollege(collegeValue);
accountEntity.setUpdateTime(new Date());
return updateById(accountEntity);
}
@Override
public List<AccountInfoDTO> teacherList() {
LambdaQueryWrapper<AccountEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AccountEntity::getRole, RoleTypeEnum.TEACHER.getCode());
return list(queryWrapper).stream()
.map(AccountInfoDTO::new)
.collect(Collectors.toList());
}
@Override
public AccountInfoDTO userInfo(Long userId) {
if (userId == null || userId <= 0) {
throw new BizException(BaseErrorCode.PARAM_INVALID);
}
AccountEntity accountEntity = getById(userId);
if (accountEntity == null) {
throw new BizException(BaseErrorCode.USER_NOT_EXIST);
}
return new AccountInfoDTO(accountEntity);
}
@Override
public List<AccountInfoDTO> classStudentList(Long classId, RoleTypeEnum role, Long userId) {
// 非教师管理员无权限
if (!RoleTypeEnum.isAdminOrTeacher(role)) {
throw new BizException(BaseErrorCode.NO_PERMISSION);
}
LambdaQueryWrapper<AccountEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(AccountEntity::getRole, RoleTypeEnum.STUDENT.getCode());
if (classId != null ) {
queryWrapper.eq(AccountEntity::getClassId, classId);
}
return list(queryWrapper).stream()
.map(AccountInfoDTO::new)
.filter(accountInfoDTO -> userId == null || userId.equals(accountInfoDTO.getUserId()))
.filter(accountInfoDTO -> classId == null || classId.equals(accountInfoDTO.getClassId()))
.collect(Collectors.toList());
}
@Override
public boolean addAccount(CreateAccountReq req, RoleTypeEnum role) {
AccountEntity accountEntity = new AccountEntity();
accountEntity.setUsername(req.getUsername());
accountEntity.setPassword(req.getBirthday());
accountEntity.setGender(req.getGender());
accountEntity.setBirthday(req.getBirthday());
accountEntity.setPhone(req.getPhone());
accountEntity.setCollege(req.getCollege());
accountEntity.setClassId(req.getClassId());
accountEntity.setRole(role.getCode());
accountEntity.setStatus(EnableStatusEnum.ENABLE.getCode());
accountEntity.setRole(role.getCode());
accountEntity.setCreateTime(new Date());
accountEntity.setUpdateTime(new Date());
return save(accountEntity);
}
}

View File

@ -0,0 +1,63 @@
package com.wj.manager.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wj.manager.common.req.ClassAddReq;
import com.wj.manager.entity.ClassEntity;
import com.wj.manager.mapper.ClassMapper;
import com.wj.manager.service.ClassService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@Slf4j
@Service
public class ClassServiceImpl extends ServiceImpl<ClassMapper, ClassEntity> implements ClassService {
@Override
public ClassEntity add(ClassAddReq req) {
ClassEntity classEntity = new ClassEntity();
classEntity.setYear(req.getYear());
classEntity.setCounselorAccountId(req.getCounselorAccountId());
classEntity.setStudentCount(req.getStudentCount());
classEntity.setMajor(req.getMajor());
classEntity.setName(req.getName());
classEntity.setCreateTime(new Date());
classEntity.setUpdateTime(new Date());
save(classEntity);
return classEntity;
}
@Override
public List<ClassEntity> list(Long id, String name, String major) {
return list().stream().filter(classEntity -> {
if (id != null && !id.equals(classEntity.getId())) {
return false;
}
if (StringUtils.isNotEmpty(name) && !name.equals(classEntity.getName())) {
return false;
}
if (StringUtils.isNotEmpty(major) && !major.equals(classEntity.getMajor())) {
return false;
}
return true;
}).collect(Collectors.toList());
}
@Override
public boolean update(ClassAddReq req) {
ClassEntity classEntity = getById(req.getId());
if (classEntity == null) {
return false;
}
classEntity.setYear(req.getYear());
classEntity.setCounselorAccountId(req.getCounselorAccountId());
classEntity.setStudentCount(req.getStudentCount());
classEntity.setMajor(req.getMajor());
classEntity.setName(req.getName());
classEntity.setUpdateTime(new Date());
return updateById(classEntity);
}
}

View File

@ -0,0 +1,183 @@
package com.wj.manager.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wj.manager.common.req.ScoreReq;
import com.wj.manager.common.resp.ScoreInfo;
import com.wj.manager.entity.AccountEntity;
import com.wj.manager.entity.StudentScoreEntity;
import com.wj.manager.entity.SubjectEntity;
import com.wj.manager.exception.BaseErrorCode;
import com.wj.manager.exception.BizException;
import com.wj.manager.mapper.StudentScoreMapper;
import com.wj.manager.service.AccountService;
import com.wj.manager.service.StudentScoreService;
import com.wj.manager.service.SubjectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@Slf4j
@Service
public class StudentScoreServiceImpl extends ServiceImpl<StudentScoreMapper, StudentScoreEntity> implements StudentScoreService {
@Resource
private AccountService accountService;
@Resource
private SubjectService subjectService;
@Override
public boolean addScore(ScoreReq req) {
// 账户检查
AccountEntity accountEntity = accountService.getById(req.getStudentId());
if (accountEntity == null) {
log.error("addScore error, account not exist, req:{}", req);
throw new BizException(BaseErrorCode.USER_NOT_EXIST);
}
// 科目检查
SubjectEntity subjectEntity = subjectService.getById(req.getSubjectId());
if (subjectEntity == null) {
log.error("addScore error, subject not exist, req:{}", req);
throw new BizException(BaseErrorCode.SUBJECT_NOT_EXIST);
}
// 成绩检查
LambdaQueryWrapper<StudentScoreEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StudentScoreEntity::getAccountId, req.getStudentId());
queryWrapper.eq(StudentScoreEntity::getSubjectId, req.getSubjectId());
queryWrapper.eq(StudentScoreEntity::getYear, req.getYear());
queryWrapper.eq(StudentScoreEntity::getTerm, req.getTerm());
StudentScoreEntity studentScoreEntity = getOne(queryWrapper);
if (studentScoreEntity != null) {
log.error("addScore error, score already exist, req:{}", req);
throw new BizException(BaseErrorCode.SCORE_ALREADY_EXIST);
}
// 成绩录入
StudentScoreEntity entity = new StudentScoreEntity();
entity.setClassId(accountEntity.getClassId());
entity.setAccountId(req.getStudentId());
entity.setSubjectId(req.getSubjectId());
entity.setScore(req.getScore());
entity.setYear(req.getYear());
entity.setTerm(req.getTerm());
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
return save(entity);
}
@Override
public boolean updateScore(ScoreReq req) {
StudentScoreEntity score = getById(req.getId());
if (score == null) {
log.error("updateScore error, score not exist, req:{}", req);
throw new BizException(BaseErrorCode.SCORE_NOT_EXIST);
}
score.setScore(req.getScore());
score.setSubjectId(req.getSubjectId());
score.setYear(req.getYear());
score.setTerm(req.getTerm());
score.setUpdateTime(new Date());
return updateById(score);
}
@Override
public boolean deleteScore(Long id) {
StudentScoreEntity score = getById(id);
if (score == null) {
log.error("deleteScore error, score not exist, id:{}", id);
throw new BizException(BaseErrorCode.SCORE_NOT_EXIST);
}
return removeById(id);
}
@Override
public List<ScoreInfo> studentScoreList(Long accountId, Integer year, Integer term) {
LambdaQueryWrapper<StudentScoreEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StudentScoreEntity::getAccountId, accountId);
queryWrapper.eq(StudentScoreEntity::getYear, year);
queryWrapper.eq(StudentScoreEntity::getTerm, term);
List<StudentScoreEntity> scoreList = list(queryWrapper);
if (CollectionUtils.isEmpty(scoreList)) {
return new ArrayList<>();
}
AccountEntity accountEntity = accountService.getById(accountId);
if (accountEntity == null) {
log.error("studentScoreList error, account not exist, accountId:{}", accountId);
throw new BizException(BaseErrorCode.USER_NOT_EXIST);
}
Set<Long> subjectIds = scoreList.stream().map(StudentScoreEntity::getSubjectId).collect(Collectors.toSet());
List<SubjectEntity> subjectEntities = subjectService.listByIds(subjectIds);
if (CollectionUtils.isEmpty(subjectEntities)) {
log.error("studentScoreList error, subject not exist, subjectIds:{}", subjectIds);
throw new BizException(BaseErrorCode.SUBJECT_NOT_EXIST);
}
Map<Long, SubjectEntity> subjectMap = subjectEntities.stream().collect(Collectors.toMap(SubjectEntity::getId, Function.identity()));
return scoreList.stream().map(score -> {
ScoreInfo scoreInfo = new ScoreInfo();
scoreInfo.setStudentId(accountId);
scoreInfo.setStudentName(accountEntity.getUsername());
scoreInfo.setClassId(accountEntity.getClassId());
scoreInfo.setSubjectId(score.getSubjectId());
scoreInfo.setSubjectName(subjectMap.get(score.getSubjectId()).getName());
scoreInfo.setYear(score.getYear());
scoreInfo.setTerm(score.getTerm());
scoreInfo.setScore(score.getScore());
return scoreInfo;
}).collect(Collectors.toList());
}
@Override
public List<ScoreInfo> list(Long accountId, Long subjectId, Long classId, Integer year, Integer term) {
LambdaQueryWrapper<StudentScoreEntity> queryWrapper = new LambdaQueryWrapper<>();
if (accountId != null) {
queryWrapper.eq(StudentScoreEntity::getAccountId, accountId);
}
if (subjectId != null) {
queryWrapper.eq(StudentScoreEntity::getSubjectId, subjectId);
}
if (year != null) {
queryWrapper.eq(StudentScoreEntity::getYear, year);
}
if (term != null) {
queryWrapper.eq(StudentScoreEntity::getTerm, term);
}
if (classId != null) {
queryWrapper.eq(StudentScoreEntity::getClassId, classId);
}
List<StudentScoreEntity> scoreList = list(queryWrapper);
if (CollectionUtils.isEmpty(scoreList)) {
return new ArrayList<>();
}
Set<Long> accountIds = scoreList.stream().map(StudentScoreEntity::getAccountId).collect(Collectors.toSet());
List<AccountEntity> accountEntities = accountService.listByIds(accountIds);
Map<Long, AccountEntity> studentmap = accountEntities.stream().collect(Collectors.toMap(AccountEntity::getId, Function.identity()));
Set<Long> subjectIds = scoreList.stream().map(StudentScoreEntity::getSubjectId).collect(Collectors.toSet());
List<SubjectEntity> subjectEntities = subjectService.listByIds(subjectIds);
Map<Long, SubjectEntity> subjectMap = subjectEntities.stream().collect(Collectors.toMap(SubjectEntity::getId, Function.identity()));
return scoreList.stream()
.map(score -> {
AccountEntity account = studentmap.get(score.getAccountId());
SubjectEntity subject = subjectMap.get(score.getSubjectId());
return ScoreInfo.build(score, account, subject);
})
.collect(Collectors.toList());
}
@Override
public ScoreInfo getScoreInfo(Long id) {
StudentScoreEntity score = getById(id);
if (score == null) {
log.error("getScoreInfo error, score not exist, id:{}", id);
throw new BizException(BaseErrorCode.SCORE_NOT_EXIST);
}
AccountEntity account = accountService.getById(score.getAccountId());
SubjectEntity subject = subjectService.getById(score.getSubjectId());
return ScoreInfo.build(score, account, subject);
}
}

View File

@ -0,0 +1,68 @@
package com.wj.manager.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wj.manager.common.req.SubjectReq;
import com.wj.manager.entity.SubjectEntity;
import com.wj.manager.mapper.SubjectMapper;
import com.wj.manager.service.SubjectService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
@Slf4j
@Service
public class SubjectServiceImpl extends ServiceImpl<SubjectMapper, SubjectEntity> implements SubjectService {
@Override
public boolean add(SubjectReq req) {
SubjectEntity entity = new SubjectEntity();
entity.setName(req.getName());
entity.setType(req.getType());
entity.setCredit(req.getCredit());
entity.setCreateTime(new Date());
entity.setUpdateTime(new Date());
return save(entity);
}
@Override
public List<SubjectEntity> list(Long id, String name, Integer type) {
LambdaQueryWrapper<SubjectEntity> wrapper = new LambdaQueryWrapper<>();
if (id != null) {
wrapper.eq(SubjectEntity::getId, id);
}
if (StringUtils.isNotEmpty(name)) {
wrapper.like(SubjectEntity::getName, name);
}
if (type != null) {
wrapper.eq(SubjectEntity::getType, type);
}
return list(wrapper);
}
@Override
public boolean update(SubjectReq req) {
if (req.getId() == null) {
return false;
}
SubjectEntity entity = getById(req.getId());
if (entity == null) {
return false;
}
entity.setName(req.getName());
entity.setType(req.getType());
entity.setCredit(req.getCredit());
entity.setUpdateTime(new Date());
return updateById(entity);
}
@Override
public boolean delete(Long id) {
if (id != null) {
return removeById(id);
}
return false;
}
}

View File

@ -0,0 +1,55 @@
package com.wj.manager.utils;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.interfaces.DecodedJWT;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
@Slf4j
public class JWTUtils {
private static final String SECRET = "20250101";
private static final String ISSUER = "xiaojing";
// token过期时间7天
private static final long EXPIRE_TIME = 1000 * 60 * 60 * 24 * 7;
public static String createToken(String userId) {
Algorithm algorithm = Algorithm.HMAC256(SECRET);
return JWT.create()
.withIssuer(ISSUER)
.withSubject(userId)
.withIssuedAt(new Date())
.withExpiresAt(new Date(System.currentTimeMillis() + EXPIRE_TIME))
.sign(algorithm);
}
public static String verifyToken(String token) {
if (StringUtils.isEmpty(token)) {
return null;
}
try {
Algorithm algorithm = Algorithm.HMAC256(SECRET);
JWTVerifier verifier = JWT.require(algorithm)
.withIssuer(ISSUER)
.build();
DecodedJWT decodedJWT = verifier.verify(token);
return decodedJWT.getSubject();
} catch (Exception e) {
log.error("token验证失败", e);
return null;
}
}
public static void main(String[] args) {
String token = createToken("110");
System.out.println(token);
String userId = verifyToken(token);
System.out.println(userId);
}
}

View File

@ -0,0 +1,9 @@
spring:
application:
name: wj-manager-system
datasource:
url: jdbc:sqlite:datasource/myds.db
driver-class-name: org.sqlite.JDBC
server:
port: 8080

View File

@ -0,0 +1,46 @@
CREATE TABLE tb_account
(
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 用户账户唯一标识符
username TEXT NOT NULL, -- 姓名,不能为空
password TEXT NOT NULL, -- 密码,不能为空
gender INTEGER, -- 性别1-男2-女
birthday TEXT, -- 生日
phone TEXT, -- 手机号
college TEXT, -- 学院
class_id INTEGER, -- 班级ID
role INTEGER, -- 用户角色1-管理员2-教师3-学生
headImg TEXT default 'https://www.bybit.com/bycsi-root/static-nft/nft/midia/-pjBxM6DaA0GycjR-ADok2jWoZjY0ASYU9gFTMHynbE.png', -- 头像
status INTEGER, -- 状态1-正常0-禁用
create_time DATETIME, -- 创建时间
update_time DATETIME -- 更新时间
);
CREATE TABLE tb_class
(
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 班级唯一标识符
grade INTEGER, -- 年级1 - 大一2 - 大二3 - 大三4 - 大四
counselorAccountId INTEGER, -- 导员账户ID
studentCount INTEGER, -- 学生人数
createTime DATETIME, -- 创建时间
updateTime DATETIME -- 更新时间
);
CREATE TABLE tb_student_score
(
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 成绩唯一标识符
accountId INTEGER, -- 学生账户ID
subjectId INTEGER, -- 科目ID
score INTEGER, -- 成绩
createTime DATETIME, -- 创建时间
updateTime DATETIME -- 更新时间
);
CREATE TABLE tb_subject
(
id INTEGER PRIMARY KEY AUTOINCREMENT, -- 科目唯一标识符
name TEXT NOT NULL, -- 科目名称,不能为空
type INTEGER, -- 科目类型1-必修2-选修
credit INTEGER, -- 学分
createTime DATETIME, -- 创建时间
updateTime DATETIME -- 更新时间
);

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
.wscn-http404-container[data-v-c095f994]{-webkit-transform:translate(-50%,-50%);transform:translate(-50%,-50%);position:absolute;top:40%;left:50%}.wscn-http404[data-v-c095f994]{position:relative;width:1200px;padding:0 50px;overflow:hidden}.wscn-http404 .pic-404[data-v-c095f994]{position:relative;float:left;width:600px;overflow:hidden}.wscn-http404 .pic-404__parent[data-v-c095f994]{width:100%}.wscn-http404 .pic-404__child[data-v-c095f994]{position:absolute}.wscn-http404 .pic-404__child.left[data-v-c095f994]{width:80px;top:17px;left:220px;opacity:0;-webkit-animation-name:cloudLeft-data-v-c095f994;animation-name:cloudLeft-data-v-c095f994;-webkit-animation-duration:2s;animation-duration:2s;-webkit-animation-timing-function:linear;animation-timing-function:linear;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-delay:1s;animation-delay:1s}.wscn-http404 .pic-404__child.mid[data-v-c095f994]{width:46px;top:10px;left:420px;opacity:0;-webkit-animation-name:cloudMid-data-v-c095f994;animation-name:cloudMid-data-v-c095f994;-webkit-animation-duration:2s;animation-duration:2s;-webkit-animation-timing-function:linear;animation-timing-function:linear;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-delay:1.2s;animation-delay:1.2s}.wscn-http404 .pic-404__child.right[data-v-c095f994]{width:62px;top:100px;left:500px;opacity:0;-webkit-animation-name:cloudRight-data-v-c095f994;animation-name:cloudRight-data-v-c095f994;-webkit-animation-duration:2s;animation-duration:2s;-webkit-animation-timing-function:linear;animation-timing-function:linear;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards;-webkit-animation-delay:1s;animation-delay:1s}@-webkit-keyframes cloudLeft-data-v-c095f994{0%{top:17px;left:220px;opacity:0}20%{top:33px;left:188px;opacity:1}80%{top:81px;left:92px;opacity:1}to{top:97px;left:60px;opacity:0}}@keyframes cloudLeft-data-v-c095f994{0%{top:17px;left:220px;opacity:0}20%{top:33px;left:188px;opacity:1}80%{top:81px;left:92px;opacity:1}to{top:97px;left:60px;opacity:0}}@-webkit-keyframes cloudMid-data-v-c095f994{0%{top:10px;left:420px;opacity:0}20%{top:40px;left:360px;opacity:1}70%{top:130px;left:180px;opacity:1}to{top:160px;left:120px;opacity:0}}@keyframes cloudMid-data-v-c095f994{0%{top:10px;left:420px;opacity:0}20%{top:40px;left:360px;opacity:1}70%{top:130px;left:180px;opacity:1}to{top:160px;left:120px;opacity:0}}@-webkit-keyframes cloudRight-data-v-c095f994{0%{top:100px;left:500px;opacity:0}20%{top:120px;left:460px;opacity:1}80%{top:180px;left:340px;opacity:1}to{top:200px;left:300px;opacity:0}}@keyframes cloudRight-data-v-c095f994{0%{top:100px;left:500px;opacity:0}20%{top:120px;left:460px;opacity:1}80%{top:180px;left:340px;opacity:1}to{top:200px;left:300px;opacity:0}}.wscn-http404 .bullshit[data-v-c095f994]{position:relative;float:left;width:300px;padding:30px 0;overflow:hidden}.wscn-http404 .bullshit__oops[data-v-c095f994]{font-size:32px;line-height:40px;color:#1482f0;margin-bottom:20px;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}.wscn-http404 .bullshit__headline[data-v-c095f994],.wscn-http404 .bullshit__oops[data-v-c095f994]{font-weight:700;opacity:0;-webkit-animation-name:slideUp-data-v-c095f994;animation-name:slideUp-data-v-c095f994;-webkit-animation-duration:.5s;animation-duration:.5s}.wscn-http404 .bullshit__headline[data-v-c095f994]{font-size:20px;line-height:24px;color:#222;margin-bottom:10px;-webkit-animation-delay:.1s;animation-delay:.1s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}.wscn-http404 .bullshit__info[data-v-c095f994]{font-size:13px;line-height:21px;color:grey;margin-bottom:30px;-webkit-animation-delay:.2s;animation-delay:.2s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}.wscn-http404 .bullshit__info[data-v-c095f994],.wscn-http404 .bullshit__return-home[data-v-c095f994]{opacity:0;-webkit-animation-name:slideUp-data-v-c095f994;animation-name:slideUp-data-v-c095f994;-webkit-animation-duration:.5s;animation-duration:.5s}.wscn-http404 .bullshit__return-home[data-v-c095f994]{display:block;float:left;width:110px;height:36px;background:#1482f0;border-radius:100px;text-align:center;color:#fff;font-size:14px;line-height:36px;cursor:pointer;-webkit-animation-delay:.3s;animation-delay:.3s;-webkit-animation-fill-mode:forwards;animation-fill-mode:forwards}@-webkit-keyframes slideUp-data-v-c095f994{0%{-webkit-transform:translateY(60px);transform:translateY(60px);opacity:0}to{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}}@keyframes slideUp-data-v-c095f994{0%{-webkit-transform:translateY(60px);transform:translateY(60px);opacity:0}to{-webkit-transform:translateY(0);transform:translateY(0);opacity:1}}

View File

@ -0,0 +1 @@
.line[data-v-0778e87e]{text-align:center}

View File

@ -0,0 +1 @@
.line[data-v-1b3e544c]{text-align:center}

View File

@ -0,0 +1 @@
.dashboard-container[data-v-3e145b52]{margin:30px}.dashboard-text[data-v-3e145b52]{font-size:30px;line-height:46px}

View File

@ -0,0 +1 @@
.line[data-v-56d84331]{text-align:center}

View File

@ -0,0 +1 @@
.app-container[data-v-43f4ac84]{padding:20px}.filter-row[data-v-43f4ac84]{margin-bottom:20px}.el-form-item[data-v-43f4ac84]{margin-bottom:0}.button-row[data-v-43f4ac84]{margin-top:10px;margin-bottom:10px}.el-button[data-v-43f4ac84]{margin-right:10px}

View File

@ -0,0 +1 @@
@supports(-webkit-mask:none) and (not (cater-color:#fff)){.login-container .el-input input{color:#fff}}.login-container .el-input{display:inline-block;height:47px;width:85%}.login-container .el-input input{background:transparent;border:0;-webkit-appearance:none;border-radius:0;padding:12px 5px 12px 15px;color:#fff;height:47px;caret-color:#fff}.login-container .el-input input:-webkit-autofill{-webkit-box-shadow:0 0 0 1000px #283443 inset!important;box-shadow:inset 0 0 0 1000px #283443!important;-webkit-text-fill-color:#fff!important}.login-container .el-form-item{border:1px solid hsla(0,0%,100%,.1);background:rgba(0,0,0,.1);border-radius:5px;color:#454545}.login-container[data-v-384c582a]{min-height:100%;width:100%;background-color:#2d3a4b;overflow:hidden}.login-container .login-form[data-v-384c582a]{position:relative;width:520px;max-width:100%;padding:160px 35px 0;margin:0 auto;overflow:hidden}.login-container .tips[data-v-384c582a]{font-size:14px;color:#fff;margin-bottom:10px}.login-container .tips span[data-v-384c582a]:first-of-type{margin-right:16px}.login-container .svg-container[data-v-384c582a]{padding:6px 5px 6px 15px;color:#889aa4;vertical-align:middle;width:30px;display:inline-block}.login-container .title-container[data-v-384c582a]{position:relative}.login-container .title-container .title[data-v-384c582a]{font-size:26px;color:#eee;margin:0 auto 40px auto;text-align:center;font-weight:700}.login-container .show-pwd[data-v-384c582a]{position:absolute;right:10px;top:7px;font-size:16px;color:#889aa4;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}

View File

@ -0,0 +1 @@
.app-container[data-v-fbf0743a]{padding:20px}.button-container[data-v-fbf0743a]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;margin-bottom:10px}.filter-row[data-v-fbf0743a]{margin-bottom:20px}.el-form-item[data-v-fbf0743a]{margin-bottom:0}

View File

@ -0,0 +1 @@
.app-container[data-v-27336528]{padding:20px}.button-container[data-v-27336528]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;margin-bottom:10px}.filter-row[data-v-27336528]{margin-bottom:20px}.el-form-item[data-v-27336528]{margin-bottom:0}

View File

@ -0,0 +1 @@
.app-container[data-v-d5d75630]{padding:20px}.button-container[data-v-d5d75630]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-pack:end;-ms-flex-pack:end;justify-content:flex-end;margin-bottom:10px}.filter-row[data-v-d5d75630]{margin-bottom:20px}.el-form-item[data-v-d5d75630]{margin-bottom:0}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
.line[data-v-09baedeb]{text-align:center}

View File

@ -0,0 +1 @@
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{-webkit-box-sizing:content-box;box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted}b,strong{font-weight:inherit;font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:.35em .75em .625em}legend{-webkit-box-sizing:border-box;box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{-webkit-box-sizing:border-box;box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}[hidden],template{display:none}#nprogress{pointer-events:none}#nprogress .bar{background:#29d;position:fixed;z-index:1031;top:0;left:0;width:100%;height:2px}#nprogress .peg{display:block;position:absolute;right:0;width:100px;height:100%;-webkit-box-shadow:0 0 10px #29d,0 0 5px #29d;box-shadow:0 0 10px #29d,0 0 5px #29d;opacity:1;-webkit-transform:rotate(3deg) translateY(-4px);transform:rotate(3deg) translateY(-4px)}#nprogress .spinner{display:block;position:fixed;z-index:1031;top:15px;right:15px}#nprogress .spinner-icon{width:18px;height:18px;-webkit-box-sizing:border-box;box-sizing:border-box;border:2px solid transparent;border-top-color:#29d;border-left-color:#29d;border-radius:50%;-webkit-animation:nprogress-spinner .4s linear infinite;animation:nprogress-spinner .4s linear infinite}.nprogress-custom-parent{overflow:hidden;position:relative}.nprogress-custom-parent #nprogress .bar,.nprogress-custom-parent #nprogress .spinner{position:absolute}@-webkit-keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg)}to{-webkit-transform:rotate(1turn)}}@keyframes nprogress-spinner{0%{-webkit-transform:rotate(0deg);transform:rotate(0deg)}to{-webkit-transform:rotate(1turn);transform:rotate(1turn)}}

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-159c7f2c"],{"26fc":function(t,s,a){t.exports=a.p+"static/img/404_cloud.0f4bc32b.png"},"8cdb":function(t,s,a){"use strict";a.r(s);var c=function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"wscn-http404-container"},[a("div",{staticClass:"wscn-http404"},[t._m(0),a("div",{staticClass:"bullshit"},[a("div",{staticClass:"bullshit__oops"},[t._v("OOPS!")]),t._m(1),a("div",{staticClass:"bullshit__headline"},[t._v(t._s(t.message))]),a("div",{staticClass:"bullshit__info"},[t._v("Please check that the URL you entered is correct, or click the button below to return to the homepage.")]),a("a",{staticClass:"bullshit__return-home",attrs:{href:""}},[t._v("Back to home")])])])])},e=[function(){var t=this,s=t.$createElement,c=t._self._c||s;return c("div",{staticClass:"pic-404"},[c("img",{staticClass:"pic-404__parent",attrs:{src:a("a36b"),alt:"404"}}),c("img",{staticClass:"pic-404__child left",attrs:{src:a("26fc"),alt:"404"}}),c("img",{staticClass:"pic-404__child mid",attrs:{src:a("26fc"),alt:"404"}}),c("img",{staticClass:"pic-404__child right",attrs:{src:a("26fc"),alt:"404"}})])},function(){var t=this,s=t.$createElement,a=t._self._c||s;return a("div",{staticClass:"bullshit__info"},[t._v("All rights reserved "),a("a",{staticStyle:{color:"#20a0ff"},attrs:{href:"https://wallstreetcn.com",target:"_blank"}},[t._v("wallstreetcn")])])}],i={name:"Page404",computed:{message:function(){return"The webmaster said that you can not enter this page..."}}},l=i,n=(a("dd53"),a("2877")),r=Object(n["a"])(l,c,e,!1,null,"c095f994",null);s["default"]=r.exports},a36b:function(t,s,a){t.exports=a.p+"static/img/404.a57b6f31.png"},b0a8:function(t,s,a){},dd53:function(t,s,a){"use strict";a("b0a8")}}]);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-4dd98664"],{"385e":function(t,e,n){},"5ee6":function(t,e,n){"use strict";n.r(e);var r=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("el-form",{ref:"form",attrs:{model:t.form,"label-width":"120px"}},[n("el-form-item",{attrs:{label:"科目名称"}},[n("el-input",{staticStyle:{width:"200px"},model:{value:t.form.name,callback:function(e){t.$set(t.form,"name",e)},expression:"form.name"}})],1),n("el-form-item",{attrs:{label:"科目类型"}},[n("el-select",{attrs:{placeholder:"选择类型"},model:{value:t.form.type,callback:function(e){t.$set(t.form,"type",e)},expression:"form.type"}},[n("el-option",{attrs:{label:"必修",value:"1"}}),n("el-option",{attrs:{label:"选修",value:"2"}})],1)],1),n("el-form-item",{attrs:{label:"学分"}},[n("el-input",{staticStyle:{width:"200px"},model:{value:t.form.credit,callback:function(e){t.$set(t.form,"credit",e)},expression:"form.credit"}})],1),n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:t.onSubmit}},[t._v("提交")]),n("el-button",{on:{click:t.onCancel}},[t._v("取消")])],1)],1)],1)},i=[],o=(n("b0c0"),n("c418")),a={props:{id:{type:String,required:!1,default:""}},data:function(){return{form:{id:"",name:"",type:"",credit:""}}},created:function(){var t=this;if(this.id){var e={id:this.id};this.loading=!0,Object(o["c"])(e).then((function(e){var n=e.result,r={1:"必修",2:"选修"};t.form={id:n.id,name:n.name,type:n.type,credit:n.credit},t.form.type=r[n.type]||"",t.loading=!1})).catch((function(){t.loading=!1})),console.log("id is {}",this.id)}},methods:{onSubmit:function(){var t=this;this.loading=!0,this.form.id?Object(o["e"])(this.form).then((function(){t.$message({type:"info",message:"更新成功"}),t.$router.push("/teacher/subject")})):Object(o["a"])(this.form).then((function(){t.$router.push("/teacher/subject"),t.loading=!1})).catch((function(){t.loading=!1}))},onCancel:function(){this.$router.push("/teacher/subject")}}},c=a,u=(n("ff6f"),n("2877")),l=Object(u["a"])(c,r,i,!1,null,"1b3e544c",null);e["default"]=l.exports},c418:function(t,e,n){"use strict";n.d(e,"d",(function(){return i})),n.d(e,"a",(function(){return o})),n.d(e,"e",(function(){return a})),n.d(e,"b",(function(){return c})),n.d(e,"c",(function(){return u}));var r=n("b775");function i(t){return Object(r["a"])({url:"/api/subject/list",method:"get",params:t})}function o(t){return Object(r["a"])({url:"/api/subject/add",method:"post",data:t})}function a(t){return Object(r["a"])({url:"/api/subject/update",method:"post",data:t})}function c(t){return Object(r["a"])({url:"/api/subject/delete",method:"post",data:t})}function u(t){return Object(r["a"])({url:"/api/subject/info",method:"get",params:t})}},ff6f:function(t,e,n){"use strict";n("385e")}}]);

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-630a64ed"],{"30fb":function(t,a,e){"use strict";e("7148")},7148:function(t,a,e){},9406:function(t,a,e){"use strict";e.r(a);var n=function(){var t=this,a=t.$createElement,e=t._self._c||a;return e("div",{staticClass:"dashboard-container"},[e("div",{staticClass:"dashboard-text"},[t._v("name: "+t._s(t.name))])])},s=[],c=e("5530"),i=e("2f62"),o={name:"Dashboard",computed:Object(c["a"])({},Object(i["b"])(["name"]))},r=o,u=(e("30fb"),e("2877")),b=Object(u["a"])(r,n,s,!1,null,"3e145b52",null);a["default"]=b.exports}}]);

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-6bcd7e08"],{"371d":function(e,t,l){"use strict";l.r(t);var o=function(){var e=this,t=e.$createElement,l=e._self._c||t;return l("div",{staticClass:"app-container"},[l("el-form",{ref:"form",attrs:{model:e.form,"label-width":"120px"}},[l("el-form-item",{attrs:{label:"学生姓名"}},[l("el-input",{staticStyle:{width:"200px"},model:{value:e.form.username,callback:function(t){e.$set(e.form,"username",t)},expression:"form.username"}})],1),l("el-form-item",{attrs:{label:"性别"}},[l("el-select",{attrs:{placeholder:"选择性别"},model:{value:e.form.gender,callback:function(t){e.$set(e.form,"gender",t)},expression:"form.gender"}},[l("el-option",{attrs:{label:"男",value:"1"}}),l("el-option",{attrs:{label:"女",value:"2"}})],1)],1),l("el-form-item",{attrs:{label:"出生日期"}},[l("el-col",{attrs:{span:11}},[l("el-date-picker",{staticStyle:{width:"200px"},attrs:{type:"date",placeholder:"选择日期"},model:{value:e.form.birthday,callback:function(t){e.$set(e.form,"birthday",t)},expression:"form.birthday"}})],1)],1),l("el-form-item",{attrs:{label:"联系方式"}},[l("el-input",{staticStyle:{width:"200px"},model:{value:e.form.phone,callback:function(t){e.$set(e.form,"phone",t)},expression:"form.phone"}})],1),l("el-form-item",{attrs:{label:"学院"}},[l("el-select",{attrs:{placeholder:"选择学院"},model:{value:e.form.college,callback:function(t){e.$set(e.form,"college",t)},expression:"form.college"}},[l("el-option",{attrs:{label:"电控",value:"electronic"}}),l("el-option",{attrs:{label:"机械",value:"mechanical"}}),l("el-option",{attrs:{label:"计算机",value:"computer"}})],1)],1),l("el-form-item",{attrs:{label:"班级"}},[l("el-input",{staticStyle:{width:"200px"},model:{value:e.form.classId,callback:function(t){e.$set(e.form,"classId",t)},expression:"form.classId"}})],1),l("el-form-item",[l("el-button",{attrs:{type:"primary"},on:{click:e.onSubmit}},[e._v("提交")]),l("el-button",{on:{click:e.onCancel}},[e._v("取消")])],1)],1)],1)},a=[],r=l("c24f"),n={props:{id:{type:String,required:!1,default:""}},data:function(){return{form:{userId:"",username:"",gender:"",birthday:"",phone:"",college:"",classId:""}}},created:function(){var e=this;if(this.id){var t={id:this.id};this.loading=!0,Object(r["g"])(t).then((function(t){var l=t.result;e.form={userId:l.userId,username:l.username,gender:l.gender,birthday:new Date(l.birthday),phone:l.phone,college:l.college,classId:l.classId},e.loading=!1})).catch((function(){e.loading=!1})),console.log("id is {}",this.id)}},methods:{onSubmit:function(){var e=this;this.loading=!0,this.form.userId?Object(r["f"])(this.form).then((function(){e.$message({type:"info",message:"更新成功"})})):this.$store.dispatch("user/createUser",this.form).then((function(){e.$router.push("/teacher/table"),e.loading=!1})).catch((function(){e.loading=!1}))},onCancel:function(){this.$router.push("/teacher/table")}}},s=n,i=(l("59b6"),l("2877")),c=Object(i["a"])(s,o,a,!1,null,"56d84331",null);t["default"]=c.exports},"59b6":function(e,t,l){"use strict";l("cb36")},cb36:function(e,t,l){}}]);

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-853cd7be"],{"2ebd":function(t,e,n){"use strict";n("bbaa")},"5ba2":function(t,e,n){},"9ed6":function(t,e,n){"use strict";n.r(e);var s=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"login-container"},[n("el-form",{ref:"loginForm",staticClass:"login-form",attrs:{model:t.loginForm,rules:t.loginRules,"auto-complete":"on","label-position":"left"}},[n("div",{staticClass:"title-container"},[n("h3",{staticClass:"title"},[t._v("管理系统")])]),n("el-form-item",{attrs:{prop:"username"}},[n("span",{staticClass:"svg-container"},[n("svg-icon",{attrs:{"icon-class":"user"}})],1),n("el-input",{ref:"username",attrs:{placeholder:"校园账户id",name:"账户ID",type:"number",tabindex:"1","auto-complete":"on"},model:{value:t.loginForm.accountId,callback:function(e){t.$set(t.loginForm,"accountId",e)},expression:"loginForm.accountId"}})],1),n("el-form-item",{attrs:{prop:"password"}},[n("span",{staticClass:"svg-container"},[n("svg-icon",{attrs:{"icon-class":"password"}})],1),n("el-input",{key:t.passwordType,ref:"password",attrs:{type:t.passwordType,placeholder:"密码",name:"password",tabindex:"2","auto-complete":"on"},nativeOn:{keyup:function(e){return!e.type.indexOf("key")&&t._k(e.keyCode,"enter",13,e.key,"Enter")?null:t.handleLogin(e)}},model:{value:t.loginForm.password,callback:function(e){t.$set(t.loginForm,"password",e)},expression:"loginForm.password"}}),n("span",{staticClass:"show-pwd",on:{click:t.showPwd}},[n("svg-icon",{attrs:{"icon-class":"password"===t.passwordType?"eye":"eye-open"}})],1)],1),n("el-button",{staticStyle:{width:"100%","margin-bottom":"30px"},attrs:{loading:t.loading,type:"primary"},nativeOn:{click:function(e){return e.preventDefault(),t.handleLogin(e)}}},[t._v("Login")]),n("div",{staticClass:"tips"},[n("span",{staticStyle:{"margin-right":"20px"}},[t._v("username: admin")]),n("span",[t._v(" password: any")])])],1)],1)},o=[],a={name:"Login",data:function(){var t=function(t,e,n){n()},e=function(t,e,n){e.length<5?n(new Error("The password can not be less than 6 digits")):n()};return{loginForm:{accountId:"1000",password:"admin"},loginRules:{username:[{required:!0,trigger:"blur",validator:t}],password:[{required:!0,trigger:"blur",validator:e}]},loading:!1,passwordType:"password",redirect:void 0}},watch:{$route:{handler:function(t){this.redirect=t.query&&t.query.redirect},immediate:!0}},methods:{showPwd:function(){var t=this;"password"===this.passwordType?this.passwordType="":this.passwordType="password",this.$nextTick((function(){t.$refs.password.focus()}))},handleLogin:function(){var t=this;this.$refs.loginForm.validate((function(e){if(!e)return console.log("error submit!!"),!1;t.loading=!0,t.$store.dispatch("user/login",t.loginForm).then((function(){t.$router.push({path:t.redirect||"/"}),t.loading=!1})).catch((function(){t.loading=!1}))}))}}},r=a,i=(n("a6c8"),n("2ebd"),n("2877")),l=Object(i["a"])(r,s,o,!1,null,"384c582a",null);e["default"]=l.exports},a6c8:function(t,e,n){"use strict";n("5ba2")},bbaa:function(t,e,n){}}]);

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-8f958bfe"],{"217d":function(t,e,n){"use strict";n("8bee")},"8bee":function(t,e,n){},aede:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("el-form",{attrs:{"label-width":"120px"}},[n("el-row",{staticClass:"filter-row",attrs:{type:"flex",justify:"start"}},[n("el-col",{attrs:{span:6}},[n("el-form-item",{attrs:{label:"科目id"}},[n("el-input",{attrs:{placeholder:"请输入科目id"},model:{value:t.filter.id,callback:function(e){t.$set(t.filter,"id",e)},expression:"filter.id"}})],1)],1),n("el-col",{attrs:{span:6}},[n("el-form-item",{attrs:{label:"科目名称"}},[n("el-input",{attrs:{placeholder:"请输入科目名称"},model:{value:t.filter.name,callback:function(e){t.$set(t.filter,"name",e)},expression:"filter.name"}})],1)],1),n("el-col",{attrs:{span:6}},[n("el-form-item",{attrs:{label:"类型"}},[n("el-select",{attrs:{placeholder:"选择类型",clearable:""},model:{value:t.filter.type,callback:function(e){t.$set(t.filter,"type",e)},expression:"filter.type"}},[n("el-option",{attrs:{label:"必修",value:"1"}}),n("el-option",{attrs:{label:"选修",value:"2"}})],1)],1)],1),n("el-col",{attrs:{span:4,offset:"0"}},[n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:t.onFilter}},[t._v("筛选")])],1)],1),n("el-col",{attrs:{span:4,offset:"0"}},[n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:t.handleAdd}},[t._v("新增")])],1)],1)],1)],1),n("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.list,"element-loading-text":"Loading",border:"",fit:"","highlight-current-row":""}},[n("el-table-column",{attrs:{align:"center",label:"科目id"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(" "+t._s(e.row.id)+" ")]}}])}),n("el-table-column",{attrs:{label:"科目名称"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(" "+t._s(e.row.name)+" ")]}}])}),n("el-table-column",{attrs:{label:"科目类型",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s("1"==e.row.type?"必修":"选修"))])]}}])}),n("el-table-column",{attrs:{label:"学分",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s(e.row.credit))])]}}])}),n("el-table-column",{attrs:{label:"操作",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("el-button",{attrs:{type:"text"},on:{click:function(n){return t.handleEdit(e.row)}}},[t._v("修改")]),n("el-button",{attrs:{type:"text"},on:{click:function(n){return t.handleDelete(e.row.id)}}},[t._v("删除")])]}}])})],1)],1)},l=[],i=(n("4de4"),n("d3b7"),n("0643"),n("2382"),n("c418")),r={filters:{statusFilter:function(t){var e={published:"success",draft:"gray",deleted:"danger"};return e[t]}},data:function(){return{list:null,listLoading:!0,filter:{id:"",name:"",type:""}}},created:function(){this.fetchData()},methods:{fetchData:function(){var t=this;this.listLoading=!0,Object(i["d"])().then((function(e){t.list=e.result,t.listLoading=!1})).catch((function(){t.listLoading=!1}))},handleAdd:function(){this.$router.push("/form/subject")},handleEdit:function(t){this.$router.push({path:"/form/subject",query:{id:t.id}})},onFilter:function(){var t=this;this.listLoading=!0,Object(i["d"])(this.filter).then((function(e){t.list=e.result,t.listLoading=!1})).catch((function(){t.listLoading=!1}))},handleDelete:function(t){var e=this;this.$confirm("确认删除该班级吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){var n={id:t};Object(i["b"])(n).then((function(){e.$message({type:"success",message:"删除成功!"}),e.fetchData()})).catch((function(){e.$message({type:"error",message:"删除失败, 请重试!"})}))})).catch((function(){e.$message({type:"info",message:"已取消删除"})}))}}},s=r,o=(n("217d"),n("2877")),c=Object(o["a"])(s,a,l,!1,null,"fbf0743a",null);e["default"]=c.exports},c418:function(t,e,n){"use strict";n.d(e,"d",(function(){return l})),n.d(e,"a",(function(){return i})),n.d(e,"e",(function(){return r})),n.d(e,"b",(function(){return s})),n.d(e,"c",(function(){return o}));var a=n("b775");function l(t){return Object(a["a"])({url:"/api/subject/list",method:"get",params:t})}function i(t){return Object(a["a"])({url:"/api/subject/add",method:"post",data:t})}function r(t){return Object(a["a"])({url:"/api/subject/update",method:"post",data:t})}function s(t){return Object(a["a"])({url:"/api/subject/delete",method:"post",data:t})}function o(t){return Object(a["a"])({url:"/api/subject/info",method:"get",params:t})}}}]);

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-abf30690"],{"95ef":function(t,e,n){"use strict";n("a3ac")},a3ac:function(t,e,n){},ad8f:function(t,e,n){"use strict";n.d(e,"b",(function(){return a})),n.d(e,"a",(function(){return s}));var l=n("b775");function a(t){return Object(l["a"])({url:"/api/account/list",method:"get",params:t})}function s(t){return Object(l["a"])({url:"/api/class/list",method:"get",params:t})}},ea99:function(t,e,n){"use strict";n.r(e);var l=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("el-form",{attrs:{"label-width":"120px"}},[n("el-row",{staticClass:"filter-row",attrs:{type:"flex",justify:"start"}},[n("el-col",{attrs:{span:8}},[n("el-form-item",{attrs:{label:"按 UID 筛选"}},[n("el-input",{attrs:{placeholder:"请输入 UID"},model:{value:t.filter.uid,callback:function(e){t.$set(t.filter,"uid",e)},expression:"filter.uid"}})],1)],1),n("el-col",{attrs:{span:8}},[n("el-form-item",{attrs:{label:"按班级筛选"}},[n("el-input",{attrs:{placeholder:"请输入班级"},model:{value:t.filter.classId,callback:function(e){t.$set(t.filter,"classId",e)},expression:"filter.classId"}})],1)],1),n("el-col",{attrs:{span:4}},[n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:t.onFilter}},[t._v("筛选")])],1)],1),n("el-col",{attrs:{span:4}},[n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:t.handleAdd}},[t._v("新增")])],1)],1)],1)],1),n("el-table",{directives:[{name:"loading",rawName:"v-loading",value:t.listLoading,expression:"listLoading"}],staticStyle:{width:"100%"},attrs:{data:t.list,"element-loading-text":"Loading",border:"",fit:"","highlight-current-row":""}},[n("el-table-column",{attrs:{align:"center",label:"校园账户id"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(" "+t._s(e.row.userId)+" ")]}}])}),n("el-table-column",{attrs:{label:"姓名",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[t._v(" "+t._s(e.row.username)+" ")]}}])}),n("el-table-column",{attrs:{label:"班级",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s(e.row.classId))])]}}])}),n("el-table-column",{attrs:{label:"性别",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s(e.row.gender))])]}}])}),n("el-table-column",{attrs:{label:"出生日期",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s(e.row.birthday))])]}}])}),n("el-table-column",{attrs:{label:"联系方式",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s(e.row.phone))])]}}])}),n("el-table-column",{attrs:{label:"学院",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("span",[t._v(t._s(e.row.college))])]}}])}),n("el-table-column",{attrs:{label:"操作",align:"center"},scopedSlots:t._u([{key:"default",fn:function(e){return[n("el-button",{attrs:{type:"text"},on:{click:function(n){return t.handleEdit(e.row.userId)}}},[t._v("修改")]),n("el-button",{attrs:{type:"text"},on:{click:function(n){return t.handleDelete(e.row.userId)}}},[t._v("删除")])]}}])})],1)],1)},a=[],s=(n("4de4"),n("d3b7"),n("0643"),n("2382"),n("ad8f")),r=n("c24f"),i={filters:{statusFilter:function(t){var e={published:"success",draft:"gray",deleted:"danger"};return e[t]}},data:function(){return{list:null,listLoading:!0,filter:{uid:"",classId:""}}},created:function(){this.fetchData()},methods:{fetchData:function(){var t=this;this.listLoading=!0,Object(s["b"])().then((function(e){t.list=e.result,t.listLoading=!1})).catch((function(){t.listLoading=!1}))},handleAdd:function(){this.$router.push("/form/index")},onFilter:function(){var t=this;this.listLoading=!0,Object(s["b"])(this.filter).then((function(e){t.list=e.result,t.listLoading=!1})).catch((function(){t.listLoading=!1}))},handleEdit:function(t){this.$router.push({path:"/form/index",query:{id:t}})},handleDelete:function(t){var e=this;this.$confirm("确认删除该账户吗?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then((function(){console.log(t);var n={id:parseInt(t,10)};console.log(n),Object(r["b"])(n).then((function(){e.$message({type:"success",message:"删除成功!"}),e.fetchData()})).catch((function(){e.$message({type:"error",message:"删除失败, 请重试!"})}))})).catch((function(){e.$message({type:"info",message:"已取消删除"})}))}}},o=i,c=(n("95ef"),n("2877")),u=Object(c["a"])(o,l,a,!1,null,"27336528",null);e["default"]=u.exports}}]);

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-f6ce77f2"],{1968:function(t,e,n){"use strict";n("6d65")},"4ed0":function(t,e,n){"use strict";n.r(e);var o=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("div",{staticClass:"app-container"},[n("el-form",{ref:"form",attrs:{model:t.form,"label-width":"120px"}},[n("el-form-item",{attrs:{label:"入学年份"}},[n("el-input",{staticStyle:{width:"200px"},model:{value:t.form.year,callback:function(e){t.$set(t.form,"year",e)},expression:"form.year"}})],1),n("el-form-item",{attrs:{label:"班级名称"}},[n("el-input",{staticStyle:{width:"200px"},model:{value:t.form.name,callback:function(e){t.$set(t.form,"name",e)},expression:"form.name"}})],1),n("el-form-item",{attrs:{label:"专业"}},[n("el-select",{attrs:{placeholder:"选择专业"},model:{value:t.form.major,callback:function(e){t.$set(t.form,"major",e)},expression:"form.major"}},[n("el-option",{attrs:{label:"软件工程",value:"SoftwareEngineering"}}),n("el-option",{attrs:{label:"网络工程",value:"NetworkEngineering"}}),n("el-option",{attrs:{label:"信息安全",value:"InformationSecurity"}}),n("el-option",{attrs:{label:"人工智能",value:"ArtificialIntelligence"}})],1)],1),n("el-form-item",{attrs:{label:"导员"}},[n("el-select",{attrs:{placeholder:"选择导员"},model:{value:t.form.counselorAccountId,callback:function(e){t.$set(t.form,"counselorAccountId",e)},expression:"form.counselorAccountId"}},t._l(t.counselors,(function(t){return n("el-option",{key:t.userId,attrs:{label:t.username+t.userId,value:t.userId}})})),1)],1),n("el-form-item",{attrs:{label:"学生数量"}},[n("el-input",{staticStyle:{width:"200px"},model:{value:t.form.studentCount,callback:function(e){t.$set(t.form,"studentCount",e)},expression:"form.studentCount"}})],1),n("el-form-item",[n("el-button",{attrs:{type:"primary"},on:{click:t.onSubmit}},[t._v("提交")]),n("el-button",{on:{click:t.onCancel}},[t._v("取消")])],1)],1)],1)},r=[],a=(n("b0c0"),n("c24f")),l=n("50a5"),c={props:{id:{type:String,required:!1,default:""}},data:function(){return{form:{id:"",year:"",name:"",major:"",counselorAccountId:"",studentCount:""},counselors:[]}},created:function(){var t=this;if(Object(a["d"])().then((function(e){t.counselors=e.result})),this.id){var e={id:this.id};this.loading=!0,Object(l["b"])(e).then((function(e){var n=e.result;t.form={id:n.id,year:n.year,name:n.name,major:n.major,counselorAccountId:n.counselorAccountId,studentCount:n.studentCount},t.loading=!1})).catch((function(){t.loading=!1})),console.log("id is {}",this.id)}},methods:{onSubmit:function(){var t=this;this.loading=!0,this.form.id?Object(l["d"])(this.form).then((function(){t.$message({type:"info",message:"更新成功"}),t.$router.push("/teacher/class")})):(Object(l["a"])(this.form).then((function(){t.$router.push("/teacher/class"),t.loading=!1})).catch((function(){t.loading=!1})),this.$router.push("/teacher/class"))},onCancel:function(){this.$router.push("/teacher/class")}}},i=c,s=(n("1968"),n("2877")),u=Object(s["a"])(i,o,r,!1,null,"09baedeb",null);e["default"]=u.exports},"50a5":function(t,e,n){"use strict";n.d(e,"a",(function(){return r})),n.d(e,"d",(function(){return a})),n.d(e,"c",(function(){return l})),n.d(e,"b",(function(){return c}));var o=n("b775");function r(t){return Object(o["a"])({url:"/api/class/add",method:"post",data:t})}function a(t){return Object(o["a"])({url:"/api/class/update",method:"post",data:t})}function l(t){return Object(o["a"])({url:"/api/class/delete",method:"post",data:t})}function c(t){return Object(o["a"])({url:"/api/class/info",method:"get",params:t})}},"6d65":function(t,e,n){}}]);

File diff suppressed because one or more lines are too long