|
|
@ -4,12 +4,15 @@ import com.alibaba.fastjson2.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.iflytop.nuclear.model.Account; |
|
|
|
import com.iflytop.nuclear.service.AccountService; |
|
|
|
import com.iflytop.nuclear.utils.JwtTokenUtils; |
|
|
|
import com.iflytop.nuclear.utils.ResponseData; |
|
|
|
import com.iflytop.nuclear.vo.TaskVO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.security.access.prepost.PreAuthorize; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
@ -26,6 +29,8 @@ public class AccountController { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
AccountService accountService; |
|
|
|
@Autowired |
|
|
|
HttpServletRequest request; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询用户列表 |
|
|
@ -75,6 +80,15 @@ public class AccountController { |
|
|
|
|
|
|
|
@PostMapping("/delete") |
|
|
|
public ResponseData delete(@RequestBody Map<String,String> userInfo){ |
|
|
|
// 不能删除当前登陆的账号 |
|
|
|
String token = request.getHeader("Authorization"); |
|
|
|
if (token.length() > 0){ |
|
|
|
String[] s = token.split(" "); |
|
|
|
String username = JwtTokenUtils.getUsername(s[1]); |
|
|
|
if (username.equals(userInfo.get("username"))) { |
|
|
|
return ResponseData.fail("不能删除当前登陆的账号"); |
|
|
|
} |
|
|
|
} |
|
|
|
boolean b = accountService.deleteByUsername(userInfo.get("username")); |
|
|
|
JSONObject res = new JSONObject(); |
|
|
|
res.put("result", b); |
|
|
|