|
@@ -3,7 +3,6 @@ package com.gihon.security.controller;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.gihon.common.http.HttpResult;
|
|
|
import com.gihon.security.encoder.MyPasswordEncoder;
|
|
|
-import com.gihon.security.mapper.UserMapper;
|
|
|
import com.gihon.security.pojo.User;
|
|
|
import com.gihon.security.service.UserService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -11,7 +10,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
@@ -21,8 +19,6 @@ import java.util.List;
|
|
|
@RestController
|
|
|
@RequestMapping("/user")
|
|
|
public class UserController {
|
|
|
- @Resource
|
|
|
- private UserMapper userMapper;
|
|
|
@Autowired
|
|
|
private UserService userService;
|
|
|
|
|
@@ -90,12 +86,9 @@ public class UserController {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@GetMapping(value = "/deleteUser")
|
|
|
public HttpResult deleteUser(@RequestParam Long id) {
|
|
|
-
|
|
|
-
|
|
|
- int update = userMapper.deleteById(id);
|
|
|
-
|
|
|
+ boolean b = userService.removeById(id);
|
|
|
//添加数据失败
|
|
|
- if (update == 0) {
|
|
|
+ if (!b) {
|
|
|
return HttpResult.error("删除用户失败");
|
|
|
}
|
|
|
return HttpResult.ok();
|
|
@@ -122,11 +115,15 @@ public class UserController {
|
|
|
User user = User.builder().username(username).build();
|
|
|
user.setPassword(encoder.encode(password));
|
|
|
//根据用户名
|
|
|
- int update1 = userMapper.update(user, new QueryWrapper<User>()
|
|
|
+ boolean update = userService.update(user, new QueryWrapper<User>()
|
|
|
.eq("username", user.getUsername())
|
|
|
- );
|
|
|
+ );
|
|
|
+ //userService.lambdaUpdate().eq(User::getId,1)
|
|
|
+ // .set(User::getId,1)
|
|
|
+ // .set(User::getUsername,"213")
|
|
|
+ // .update();
|
|
|
//修改结果
|
|
|
- if (update1 != 1) {
|
|
|
+ if (!update) {
|
|
|
return HttpResult.error("修改密码访问数据库失败");
|
|
|
}
|
|
|
return HttpResult.ok();
|