SpringBoot实现汽车配件管理系统

1.技术介绍
SpringBoot+Mybatis+mysql+html+css+js
开发工具:eclipse或IDEA
2.主要功能说明:
登录、配件信息管理、配件类型管理、用户管理、订单管理、公告管理
3.部分代码展示:

/**
 * 后台系统登入控制器
 */
@Api(value = "登入接口API")
@Controller
public class LoginController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    //注入
    @Autowired
    private Producer producer;

    @Autowired
    private AdminUserService adminUserService;

    /**
     * @return
     */
    @ApiOperation(value = "控制登入跳转", notes = "登入控制器跳转")
    @GetMapping("/admin/login")
    public String showLogin() {

        return "admin/login";
    }

    @ApiOperation(value = "登入处理接口", notes = "根据json对象处理登入")
    @PostMapping("/admin/login_do")
    @ResponseBody
    public String loginDo(@RequestBody AdminUser user, HttpServletRequest request) {
        logger.info("登入用户的信息:" + user);
        String vrifyCode = (String) request.getSession().getAttribute("vrifyCode");
        if (user != null) {
            AdminUser adminUser = adminUserService.selectByUser(user.getAusername(), user.getApassword());
            if (adminUser == null) {
                return "passwordError";
            } else if (!vrifyCode.equals(user.getVercode())) {
                return "vrifyCodeErroe";
            }
            request.getSession().setAttribute("loginName", user);
            request.getSession().setAttribute("userId", adminUser.getId());
            return "success";
        } else {
            return "userNull";
        }
    }


    /**
     * 生成验证码
     *
     * @param httpServletRequest
     * @param httpServletResponse
     * @throws Exception
     */
    @ApiOperation(value = "验证码接口API", notes = "用于更新验证码")
    @GetMapping("/defaultKaptcha")
    public void defaultKaptcha(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
            throws Exception {
        byte[] captchaChallengeAsJpeg = null;
        ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
        try {
            //生产验证码字符串并保存到session中
            String createText = producer.createText();
            httpServletRequest.getSession().setAttribute("vrifyCode", createText);
            //使用生产的验证码字符串返回一个BufferedImage对象并转为byte写入到byte数组中
            BufferedImage challenge = producer.createImage(createText);
            ImageIO.write(challenge, "jpg", jpegOutputStream);
        } catch (IllegalArgumentException e) {
            httpServletResponse.sendError(HttpServletResponse.SC_NOT_FOUND);
            return;
        }
        //定义response输出类型为image/jpeg类型,使用response输出流输出图片的byte数组
        captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
        httpServletResponse.setHeader("Cache-Control", "no-store");
        httpServletResponse.setHeader("Pragma", "no-cache");
        httpServletResponse.setDateHeader("Expires", 0);
        httpServletResponse.setContentType("image/jpeg");
        ServletOutputStream responseOutputStream =
                httpServletResponse.getOutputStream();
        responseOutputStream.write(captchaChallengeAsJpeg);
        responseOutputStream.flush();
        responseOutputStream.close();
    }


    @ApiOperation(value = "登出接口", notes = "注销接口")
    @GetMapping("/logout")
    public String logout(HttpSession session) {
        //销毁session
        session.invalidate();
        return "/admin/login";
    }

}

4.系统演示地址:
链接:https://pan.baidu.com/s/1ZIVzCCbK2pbIA2Y88wXPqQ
提取码:g437

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值