xiaoyong931011
2022-05-27 5684bf988ca723a054ee83628eac5da5c0a687a7
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package com.xcong.farmer.cms.modules.system.Controller;
 
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import com.alibaba.fastjson.JSONObject;
import com.xcong.farmer.cms.common.contants.AppContants;
import com.xcong.farmer.cms.common.response.Result;
import com.xcong.farmer.cms.common.system.bean.LoginUserBean;
import com.xcong.farmer.cms.common.system.dto.LoginDto;
import com.xcong.farmer.cms.modules.system.dto.AdminLoginDto;
import com.xcong.farmer.cms.modules.system.service.ICommonService;
import com.xcong.farmer.cms.modules.system.service.IUserService;
import com.xcong.farmer.cms.utils.RedisUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
 
@RestController
@RequestMapping(value = "/api/common")
@Slf4j
@Api(value = "登录", tags = "登录")
public class AdminCommonController {
 
    @Resource
    private ICommonService iCommonService;
 
    @ApiOperation(value = "登陆接口", notes = "登陆接口")
    @PostMapping("/login")
    public Result login(@RequestBody AdminLoginDto adminLoginDto) {
 
        String username = adminLoginDto.getUsername();
        if(StrUtil.isEmpty(username)){
            return Result.fail("请输入用户名");
        }
        String password = adminLoginDto.getPassword();
        if(StrUtil.isEmpty(password)){
            return Result.fail("请输入密码");
        }
        return iCommonService.login(adminLoginDto);
    }
 
    /**
     * 用户退出登录
     * @return
     */
    @ApiOperation(value="用户退出登录", notes="用户退出登录")
    @GetMapping(value = "/Logout/{id}")
    public Result  memberLogout(@PathVariable(value = "id") Long id) {
        return iCommonService.memberLogout(id);
    }
 
}