Browse Source

test: 测试制品库

wanghongkai 6 năm trước cách đây
mục cha
commit
a282bad903

+ 0 - 2
src/main/java/com/moekr/moocoder/data/dao/UserDAO.java

@@ -13,8 +13,6 @@ public interface UserDAO extends JpaRepository<User, Integer> {
 
 
 	User findByEmail(String email);
 	User findByEmail(String email);
 
 
-	User findByPhone(String phone);
-
 	Page<User> findAllByUsernameLike(String search, Pageable pageable);
 	Page<User> findAllByUsernameLike(String search, Pageable pageable);
 
 
 	Integer countByRole(UserRole role);
 	Integer countByRole(UserRole role);

+ 0 - 3
src/main/java/com/moekr/moocoder/data/entity/User.java

@@ -49,9 +49,6 @@ public class User {
 	@Column(name = "role", nullable = false)
 	@Column(name = "role", nullable = false)
 	private UserRole role;
 	private UserRole role;
 
 
-	@Enumerated(EnumType.STRING)
-	@Column(name = "phone")
-	private String phone;
 
 
 	@Basic
 	@Basic
 	@Column(name = "created_at", nullable = false)
 	@Column(name = "created_at", nullable = false)

+ 1 - 3
src/main/java/com/moekr/moocoder/logic/service/UserService.java

@@ -16,11 +16,9 @@ public interface UserService {
 
 
 	void delete(int userId) throws ServiceException;
 	void delete(int userId) throws ServiceException;
 
 
-	UserVO register(RegisterForm form) throws ServiceException;
+	void register(RegisterForm form) throws ServiceException;
 
 
 	void changePassword(int userId, ChangePasswordForm form) throws ServiceException;
 	void changePassword(int userId, ChangePasswordForm form) throws ServiceException;
 
 
 	void resetPassword(int userId) throws ServiceException;
 	void resetPassword(int userId) throws ServiceException;
-
-	UserVO login(String username, String password) throws ServiceException;
 }
 }

+ 5 - 20
src/main/java/com/moekr/moocoder/logic/service/impl/UserServiceImpl.java

@@ -31,8 +31,6 @@ import org.springframework.ui.ModelMap;
 import org.springframework.util.Assert;
 import org.springframework.util.Assert;
 import org.springframework.web.servlet.ModelAndView;
 import org.springframework.web.servlet.ModelAndView;
 
 
-import java.time.LocalDateTime;
-
 @Service
 @Service
 public class UserServiceImpl implements UserService {
 public class UserServiceImpl implements UserService {
 	private static final Sort PAGE_SORT = Sort.by(Sort.Direction.ASC, "id");
 	private static final Sort PAGE_SORT = Sort.by(Sort.Direction.ASC, "id");
@@ -53,7 +51,7 @@ public class UserServiceImpl implements UserService {
 	@Override
 	@Override
 	@Transactional
 	@Transactional
 	public UserVO create(UserDTO userDTO) throws ServiceException {
 	public UserVO create(UserDTO userDTO) throws ServiceException {
-		return register(userDTO.getUsername(), userDTO.getEmail(), null,userDTO.getPhone(), userDTO.getRole());
+		return register(userDTO.getUsername(), userDTO.getEmail(), null, userDTO.getRole());
 	}
 	}
 
 
 	@Override
 	@Override
@@ -100,11 +98,11 @@ public class UserServiceImpl implements UserService {
 
 
 	@Override
 	@Override
 	@Transactional
 	@Transactional
-	public UserVO register(RegisterForm form) throws ServiceException {
-		return register(form.getUsername(), form.getEmail(), form.getPassword(),form.getPhone(), UserRole.STUDENT);
+	public void register(RegisterForm form) throws ServiceException {
+		register(form.getUsername(), form.getEmail(), form.getPassword(), UserRole.STUDENT);
 	}
 	}
 
 
-	private UserVO register(String username, String email, String password, String phone,UserRole role) throws ServiceException {
+	private UserVO register(String username, String email, String password, UserRole role) throws ServiceException {
 		User user = userDAO.findByUsername(username);
 		User user = userDAO.findByUsername(username);
 		Asserts.isNull(user, "用户名已被使用!");
 		Asserts.isNull(user, "用户名已被使用!");
 		user = userDAO.findByEmail(email);
 		user = userDAO.findByEmail(email);
@@ -121,16 +119,14 @@ public class UserServiceImpl implements UserService {
 		user.setUsername(username);
 		user.setUsername(username);
 		user.setEmail(email);
 		user.setEmail(email);
 		user.setPassword(DigestUtils.sha256Hex(realPassword));
 		user.setPassword(DigestUtils.sha256Hex(realPassword));
-		user.setPhone(phone);
 		user.setRole(role);
 		user.setRole(role);
-		user.setCreatedAt(LocalDateTime.now());
 		ModelMap model = new ModelMap();
 		ModelMap model = new ModelMap();
 		model.addAttribute("username", username);
 		model.addAttribute("username", username);
 		if (password == null) {
 		if (password == null) {
 			model.addAttribute("password", realPassword);
 			model.addAttribute("password", realPassword);
 		}
 		}
 		model.addAttribute("role", role);
 		model.addAttribute("role", role);
-//		mailService.send(email, username, "注册成功 | MOOCODER", new ModelAndView("mail/register", model));
+		mailService.send(email, username, "注册成功 | MOOCODER", new ModelAndView("mail/register", model));
 		return new UserVO(userDAO.save(user));
 		return new UserVO(userDAO.save(user));
 	}
 	}
 
 
@@ -151,17 +147,6 @@ public class UserServiceImpl implements UserService {
 		changePassword(user, password, true);
 		changePassword(user, password, true);
 	}
 	}
 
 
-	@Override
-	public UserVO login(String username, String password) throws ServiceException{
-		User user=userDAO.findByUsername(username);
-		if (user.getPassword().equals(DigestUtils.sha256Hex(password))){
-			return new UserVO(user);
-		}
-		else {
-			throw new ServiceException();
-		}
-	}
-
 	private void changePassword(User user, String password, boolean reset) throws ServiceException {
 	private void changePassword(User user, String password, boolean reset) throws ServiceException {
 		try {
 		try {
 			gitlabApi.changePassword(user.getId(), password);
 			gitlabApi.changePassword(user.getId(), password);

+ 0 - 1
src/main/java/com/moekr/moocoder/logic/vo/UserVO.java

@@ -15,7 +15,6 @@ public class UserVO {
 	private Integer id;
 	private Integer id;
 	private String username;
 	private String username;
 	private String email;
 	private String email;
-	private String phone;
 	private UserRole role;
 	private UserRole role;
 	@JsonProperty("created_at")
 	@JsonProperty("created_at")
 	@JsonSerialize(using = TimestampLocalDateTimeSerializer.class)
 	@JsonSerialize(using = TimestampLocalDateTimeSerializer.class)

+ 0 - 19
src/main/java/com/moekr/moocoder/web/controller/api/UserController.java

@@ -5,8 +5,6 @@ import com.moekr.moocoder.logic.vo.UserVO;
 import com.moekr.moocoder.util.exceptions.ServiceException;
 import com.moekr.moocoder.util.exceptions.ServiceException;
 import com.moekr.moocoder.web.dto.UserDTO;
 import com.moekr.moocoder.web.dto.UserDTO;
 import com.moekr.moocoder.web.dto.form.ChangePasswordForm;
 import com.moekr.moocoder.web.dto.form.ChangePasswordForm;
-import com.moekr.moocoder.web.dto.form.LoginForm;
-import com.moekr.moocoder.web.dto.form.RegisterForm;
 import com.moekr.moocoder.web.response.EmptyResponse;
 import com.moekr.moocoder.web.response.EmptyResponse;
 import com.moekr.moocoder.web.response.PageResourceResponse;
 import com.moekr.moocoder.web.response.PageResourceResponse;
 import com.moekr.moocoder.web.response.ResourceResponse;
 import com.moekr.moocoder.web.response.ResourceResponse;
@@ -40,7 +38,6 @@ public class UserController extends AbstractApiController {
 		return new ResourceResponse(userService.create(userDTO));
 		return new ResourceResponse(userService.create(userDTO));
 	}
 	}
 
 
-
 	@GetMapping("/user")
 	@GetMapping("/user")
 	@RolesAllowed(ADMIN_ROLE)
 	@RolesAllowed(ADMIN_ROLE)
 	public Response retrievePage(@RequestParam(defaultValue = "1") int page,
 	public Response retrievePage(@RequestParam(defaultValue = "1") int page,
@@ -70,22 +67,6 @@ public class UserController extends AbstractApiController {
 		return new EmptyResponse();
 		return new EmptyResponse();
 	}
 	}
 
 
-	@PostMapping("/user/register")
-	@RolesAllowed(STUDENT_ROLE)
-	public Response register(@RequestBody @Valid RegisterForm form) throws ServiceException{
-		try {
-			return new ResourceResponse(userService.register(form));
-		}catch (ServiceException e){
-			return new EmptyResponse();
-		}
-	}
-
-	@PostMapping("/user/login")
-	@RolesAllowed({STUDENT_ROLE,TEACHER_ROLE})
-	public  Response login(@RequestBody @Valid LoginForm form) throws  ServiceException{
-		return new ResourceResponse(userService.login(form.getUsername(),form.getPassword()));
-	}
-
 	@PostMapping("/user/password/change")
 	@PostMapping("/user/password/change")
 	@RolesAllowed({STUDENT_ROLE, TEACHER_ROLE})
 	@RolesAllowed({STUDENT_ROLE, TEACHER_ROLE})
 	public Response changePassword(@AuthenticationPrincipal CustomUserDetails userDetails,
 	public Response changePassword(@AuthenticationPrincipal CustomUserDetails userDetails,

+ 0 - 1
src/main/java/com/moekr/moocoder/web/controller/view/RegisterController.java

@@ -44,7 +44,6 @@ public class RegisterController extends AbstractViewController {
 		} catch (ServiceException e) {
 		} catch (ServiceException e) {
 			attributes.addFlashAttribute("username", form.getUsername());
 			attributes.addFlashAttribute("username", form.getUsername());
 			attributes.addFlashAttribute("email", form.getEmail());
 			attributes.addFlashAttribute("email", form.getEmail());
-			attributes.addFlashAttribute("phone", form.getPhone());
 			attributes.addFlashAttribute("error", e.getMessage());
 			attributes.addFlashAttribute("error", e.getMessage());
 			return "redirect:/register.html";
 			return "redirect:/register.html";
 		}
 		}

+ 0 - 4
src/main/java/com/moekr/moocoder/web/dto/UserDTO.java

@@ -1,7 +1,6 @@
 package com.moekr.moocoder.web.dto;
 package com.moekr.moocoder.web.dto;
 
 
 import com.moekr.moocoder.util.enums.UserRole;
 import com.moekr.moocoder.util.enums.UserRole;
-import javafx.geometry.Pos;
 import lombok.Data;
 import lombok.Data;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.PutMapping;
 import org.springframework.web.bind.annotation.PutMapping;
@@ -20,7 +19,4 @@ public class UserDTO {
 	private String email;
 	private String email;
 	@NotNull(message = "请选择用户角色!", groups = PostMapping.class)
 	@NotNull(message = "请选择用户角色!", groups = PostMapping.class)
 	private UserRole role;
 	private UserRole role;
-	@Pattern(regexp = "[0-9]{11}", message = "请输入11位手机号码!")
-	@NotNull(message = "请输入手机号!",groups = {PostMapping.class, PutMapping.class})
-	private String phone;
 }
 }

+ 0 - 3
src/main/java/com/moekr/moocoder/web/dto/form/RegisterForm.java

@@ -20,7 +20,4 @@ public class RegisterForm {
 	@NotNull(message = "请填写密码!")
 	@NotNull(message = "请填写密码!")
 	private String password;
 	private String password;
 	private String confirm;
 	private String confirm;
-	@Pattern(regexp = "[0-9]{11}", message = "请输入11位手机号码!")
-	@NotNull(message = "请填写手机号!")
-	private String phone;
 }
 }

+ 1 - 1
src/main/resources/templates/index.html

@@ -5,7 +5,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1"/>
     <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1"/>
     <meta name="theme-color" content="#C8C8C8"/>
     <meta name="theme-color" content="#C8C8C8"/>
     <title>MOOCODER</title>
     <title>MOOCODER</title>
-    <link rel="stylesheet" type="text/css" th:href="@{/webjars/SEEC-I-Frontend/0.1.5/css/app.css}">
+    <link rel="stylesheet" type="text/css" th:href="@{/webjars/SEEC-I-Frontend/0.1.6/css/app.css}">
     <style>
     <style>
         html, body {
         html, body {
             margin: 0;
             margin: 0;