2023.6.15
1. 修改了部分BUG
This commit is contained in:
parent
0008b39a67
commit
0a85101c5d
@ -4,7 +4,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import com.sdut.labex.entity.TimeOption;
|
||||
import com.sdut.labex.service.TimeOptionService;
|
||||
import com.sdut.labex.utils.ResVo;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@ -15,7 +14,7 @@ import javax.annotation.Resource;
|
||||
* Author: springforest
|
||||
* Description:
|
||||
*/
|
||||
@Controller
|
||||
@RestController
|
||||
@CrossOrigin
|
||||
public class TimeOptionController {
|
||||
|
||||
|
@ -24,11 +24,6 @@ public class UserController {
|
||||
return userService.login(jsonObject.getString("id"), jsonObject.getString("password"));
|
||||
}
|
||||
|
||||
@PostMapping("/register")
|
||||
public ResVo register(@RequestBody JSONObject jsonObject) {
|
||||
return userService.register(jsonObject.toJavaObject(com.sdut.labex.entity.User.class));
|
||||
}
|
||||
|
||||
@PutMapping("/changePassword")
|
||||
public ResVo changePassword(@RequestBody JSONObject jsonObject) {
|
||||
String id = jsonObject.getString("id");
|
||||
|
@ -33,9 +33,9 @@ public class User implements Serializable {
|
||||
private String password;
|
||||
|
||||
/**
|
||||
* 班级ID
|
||||
* 班级
|
||||
*/
|
||||
private String classId;
|
||||
private String className;
|
||||
|
||||
/**
|
||||
* 邮箱
|
||||
|
@ -14,7 +14,13 @@ import com.sdut.labex.utils.ResVo;
|
||||
public interface UserService extends IService<User> {
|
||||
public ResVo login(String id, String password);
|
||||
|
||||
public ResVo register(User user);
|
||||
|
||||
public ResVo changePassword(String id, String oldPassword, String newPassword);
|
||||
|
||||
public ResVo add(User user);
|
||||
|
||||
public ResVo delete(String id);
|
||||
|
||||
public ResVo update(User user);
|
||||
|
||||
public ResVo insertBatch();
|
||||
}
|
||||
|
@ -32,14 +32,14 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
if (user == null) {
|
||||
return ResVo.error("用户不存在");
|
||||
}
|
||||
|
||||
|
||||
//仅测试用
|
||||
//todo:上线后删除||判断
|
||||
if (password.equals(user.getPassword()) || DigestUtils.md5DigestAsHex(password.getBytes()).equals(user.getPassword())) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("id", user.getId());
|
||||
map.put("role", user.getRole());
|
||||
map.put("username", user.getUsername());
|
||||
map.put("classId", user.getClassId());
|
||||
map.put("classId", user.getClassName());
|
||||
map.put("department", user.getDepartment());
|
||||
String token = JWTUtil.getTokenByMap(map);
|
||||
map.put("token", token);
|
||||
@ -49,18 +49,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo register(User user) {
|
||||
try {
|
||||
user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
|
||||
userMapper.insert(user);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return ResVo.error();
|
||||
}
|
||||
return ResVo.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo changePassword(String id, String oldPassword, String newPassword) {
|
||||
User user = userMapper.selectById(id);
|
||||
@ -76,4 +64,40 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User>
|
||||
}
|
||||
return ResVo.ok();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo add(User user) {
|
||||
try {
|
||||
user.setPassword(DigestUtils.md5DigestAsHex(user.getPassword().getBytes()));
|
||||
userMapper.insert(user);
|
||||
} catch (Exception e) {
|
||||
return ResVo.error("添加失败");
|
||||
}
|
||||
return ResVo.ok("添加成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo delete(String id) {
|
||||
try {
|
||||
userMapper.deleteById(id);
|
||||
} catch (Exception e) {
|
||||
return ResVo.error("删除失败");
|
||||
}
|
||||
return ResVo.ok("删除成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo update(User user) {
|
||||
try {
|
||||
userMapper.updateById(user);
|
||||
} catch (Exception e) {
|
||||
return ResVo.error("更新失败");
|
||||
}
|
||||
return ResVo.ok("更新成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResVo insertBatch() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
<id property="id" column="id" jdbcType="VARCHAR"/>
|
||||
<result property="username" column="username" jdbcType="VARCHAR"/>
|
||||
<result property="password" column="password" jdbcType="VARCHAR"/>
|
||||
<result property="classId" column="class_id" jdbcType="VARCHAR"/>
|
||||
<result property="className" column="class_name" jdbcType="VARCHAR"/>
|
||||
<result property="email" column="email" jdbcType="VARCHAR"/>
|
||||
<result property="department" column="department" jdbcType="VARCHAR"/>
|
||||
<result property="role" column="role" jdbcType="VARCHAR"/>
|
||||
|
Loading…
Reference in New Issue
Block a user