新增用户修改接口
This commit is contained in:
@@ -24,4 +24,8 @@ public class CourseController {
|
|||||||
public ResultVo getCourseResources() {
|
public ResultVo getCourseResources() {
|
||||||
return ResultVo.Success("", courseService.getCourseResources());
|
return ResultVo.Success("", courseService.getCourseResources());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户上传课程资源
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.backend.webbackend.Controller;
|
package com.backend.webbackend.Controller;
|
||||||
|
|
||||||
import com.backend.webbackend.Service.userService;
|
import com.backend.webbackend.Service.userService;
|
||||||
|
import com.backend.webbackend.Tools.Tools;
|
||||||
import com.backend.webbackend.Vo.ResultVo;
|
import com.backend.webbackend.Vo.ResultVo;
|
||||||
import com.backend.webbackend.domain.User;
|
import com.backend.webbackend.domain.User;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
@@ -12,15 +13,16 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
public class userController {
|
public class userController {
|
||||||
@Autowired
|
@Autowired
|
||||||
userService userService;
|
userService userService;
|
||||||
|
@Autowired
|
||||||
|
private Tools tools;
|
||||||
|
|
||||||
|
|
||||||
//返回所有部门信息
|
//返回所有部门信息:用于用户注册时选择部门
|
||||||
@GetMapping("dept")
|
@GetMapping("dept")
|
||||||
public ResultVo getAllDept(){
|
public ResultVo getAllDept(){
|
||||||
return ResultVo.Success("",userService.getAlldept());
|
return ResultVo.Success("",userService.getAlldept());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//用户注册
|
//用户注册
|
||||||
@PostMapping("register")
|
@PostMapping("register")
|
||||||
public ResultVo register(@RequestBody User user){
|
public ResultVo register(@RequestBody User user){
|
||||||
@@ -32,6 +34,7 @@ public class userController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户登录
|
||||||
@PostMapping("login")
|
@PostMapping("login")
|
||||||
public ResultVo login(@RequestBody User user) {
|
public ResultVo login(@RequestBody User user) {
|
||||||
if(!userService.login(user.getUsername(),user.getPassword())){
|
if(!userService.login(user.getUsername(),user.getPassword())){
|
||||||
@@ -40,4 +43,19 @@ public class userController {
|
|||||||
return ResultVo.Success("","登陆成功");
|
return ResultVo.Success("","登陆成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//用户信息修改
|
||||||
|
@PostMapping("update")
|
||||||
|
public ResultVo updateUserInfo(@RequestBody User user){
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//密码加密
|
||||||
|
user.setPassword(tools.encryptPassword(user.getPassword()));
|
||||||
|
userService.updateUserInfo(user);
|
||||||
|
return ResultVo.Success("","用户信息修改成功");
|
||||||
|
}
|
||||||
|
catch (Exception e){
|
||||||
|
throw new RuntimeException("用户信息修改失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,8 +73,14 @@ public class userServiceImpl implements userService {
|
|||||||
return userMapper.updateById(user)==1;
|
return userMapper.updateById(user)==1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//返回部门列表
|
||||||
@Override
|
@Override
|
||||||
public List<Dept> getAlldept() {
|
public List<Dept> getAlldept() {
|
||||||
return deptMapper.selectAllDept();
|
return deptMapper.selectAllDept();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateUserInfo(User user){
|
||||||
|
return userMapper.updateByName(user);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,5 @@ public interface userService {
|
|||||||
boolean register(User user);
|
boolean register(User user);
|
||||||
boolean login(String username, String password);
|
boolean login(String username, String password);
|
||||||
List<Dept> getAlldept();
|
List<Dept> getAlldept();
|
||||||
|
int updateUserInfo(User user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,4 +28,6 @@ public interface UserMapper {
|
|||||||
int countByUsername(@Param("username") String username);
|
int countByUsername(@Param("username") String username);
|
||||||
|
|
||||||
int updateById(User user);
|
int updateById(User user);
|
||||||
|
|
||||||
|
int updateByName(User user);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,4 +125,29 @@
|
|||||||
last_login_time = #{lastLoginTime}
|
last_login_time = #{lastLoginTime}
|
||||||
where id = #{id}
|
where id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="updateByName">
|
||||||
|
update user
|
||||||
|
<set>
|
||||||
|
<if test="password != null">
|
||||||
|
password = #{password},
|
||||||
|
</if>
|
||||||
|
<if test="realName != null">
|
||||||
|
real_name = #{realName},
|
||||||
|
</if>
|
||||||
|
<if test="phone != null">
|
||||||
|
phone = #{phone},
|
||||||
|
</if>
|
||||||
|
<if test="deptId != null">
|
||||||
|
dept_id = #{deptId},
|
||||||
|
</if>
|
||||||
|
<if test="role != null">
|
||||||
|
role = #{role},
|
||||||
|
</if>
|
||||||
|
<if test="status != null">
|
||||||
|
status = #{status},
|
||||||
|
</if>
|
||||||
|
</set>
|
||||||
|
where username = #{username}
|
||||||
|
</update>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user