• (免费分享)SpringBoot,Vue的快递物流仓库管理系统


    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

    package com.example.api.controller;
    
    import com.example.api.exception.AccountAndPasswordError;
    import com.example.api.model.dto.LoginDto;
    import com.example.api.model.entity.Admin;
    import com.example.api.model.entity.LoginLog;
    import com.example.api.model.enums.Role;
    import com.example.api.model.support.ResponseResult;
    import com.example.api.repository.AdminRepository;
    import com.example.api.service.AdminService;
    import com.example.api.service.LoginLogService;
    import com.example.api.utils.JwtTokenUtil;
    import lombok.extern.slf4j.Slf4j;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.security.access.prepost.PreAuthorize;
    import org.springframework.web.bind.annotation.*;
    
    import javax.annotation.Resource;
    import javax.servlet.http.HttpServletRequest;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Map;
    @RestController
    @RequestMapping("/api/admin")
    @Slf4j
    public class AdminController {
        //获取日志对象
        Logger logger = LoggerFactory.getLogger(AdminController.class);
    
        @Resource
        private AdminService adminService;
    
        @Resource
        private AdminRepository adminRepository;
    
        @Resource
        private LoginLogService loginLogService;
    
        @GetMapping("hasInit")
        public boolean hasInit() {
            return adminRepository.existsAdminByRoles(Role.ROLE_SUPER_ADMIN.getValue());
        }
    
        @PostMapping("/init")
        public Admin init(@RequestBody Admin admin) throws Exception {
            admin.setRoles(Role.ROLE_SUPER_ADMIN.getValue());
            return adminService.save(admin);
        }
    
        @GetMapping("")
        @PreAuthorize("hasAnyRole('ROLE_SUPER_ADMIN' ,'ROLE_ADMIN')")
        public List<Admin> findAll() {
            return adminService.findAll();
        }
    
        @DeleteMapping("")
        @PreAuthorize("hasAnyRole('ROLE_SUPER_ADMIN' ,'ROLE_ADMIN')")
        public void delete(String id) {
            adminService.delete(id);
        }
    
        @PostMapping("")
        @PreAuthorize("hasAnyRole('ROLE_SUPER_ADMIN' ,'ROLE_ADMIN')")
        public Admin save(@RequestBody Admin admin) throws Exception {
            return adminService.save(admin);
        }
    
        @PostMapping("/login")
        public Map<String, Object> loginByEmail(String type, @RequestBody LoginDto dto, HttpServletRequest request) throws Exception {
            Map<String, Object> map = new HashMap<>();
            Admin admin = null;
            String token = null;
            try {
                admin = type.equals("email") ? adminService.loginByEmail(dto) : adminService.loginByPassword(dto);
                token = adminService.createToken(admin,
                        dto.isRemember() ? JwtTokenUtil.REMEMBER_EXPIRATION_TIME : JwtTokenUtil.EXPIRATION_TIME);
            }catch (Exception e){
                throw new Exception("邮箱或密码错误");
            }finally {
                loginLogService.recordLog(dto,admin,request);
            }
            map.put("admin", admin);
            map.put("token", token);
            return map;
        }
    
        @GetMapping("/sendEmail")
        public ResponseResult sendEmail(String email) throws Exception {
            Boolean flag = adminService.sendEmail(email);
            ResponseResult res = new ResponseResult();
            if (flag){
                res.setMsg("发送成功,请登录邮箱查看");
            }else {
                res.setMsg("发送验证码失败,请检查邮箱服务");
            }
            res.setStatus(flag);
            return res;
        }
    
    }
    
    
    • 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
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102

    获取完整源码:
    大家点赞、收藏、关注、评论啦 、查看 👇🏻 👇🏻 👇🏻微信公众号获取联系 👇🏻 👇🏻 👇🏻
    免费领取下载链接-公众号输入口令:053

  • 相关阅读:
    vue打包优化
    赞不绝口!飞凌嵌入式全新子品牌ElfBoard好评如潮
    前端:下载文件(多种方法)
    【无标题】
    top 修改进程的优先级
    Docker安装MongoDB
    flutter系列之:如何自定义动画路由
    【原创】基于Jsp+Servlet的仓库管理系统
    java校园二手书交易管理系统springboot+Vue
    gif图片裁切、压缩导出无水印图片(保姆级教程,亲测可用)
  • 原文地址:https://blog.csdn.net/weixin_42899150/article/details/134277169