# Wuyan-project2 **Repository Path**: xmu714/wuyan-project2 ## Basic Information - **Project Name**: Wuyan-project2 - **Description**: 王道无厌组Java46项目二 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-12-28 - **Last Updated**: 2023-01-03 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # 项目二开发规范 ## 开发红线 首先,以下**强制要求**务必遵守: 1. 尊重他人劳动成果,如非必要请勿改动不在自己开发范围的东西! 2. 完成一个功能接口,先自测至少可运行,再提交! ## 项目结构 ![整体结构](img/2022-12-28_16-14.png) ## 业务相关 1. Controller内的方法上用`@PostMapping`或`@GetMapping`写明是POST还是GET,一来方便生成API文档,二来也是前后端明确请求对接的要求。 2. 业务层次:Controller进行参数校验,Service调用Mapper读写数据库并封装Data,完成主要业务功能,Mapper专注于增删查改。 ## 配置文件 1. 主配置文件`application.yml`用于开启公共配置和私有配置 2. 公共配置`application-common.yml`已包含端口号、日志级别、分页插件,其他配置可后续补充,谨慎修改! 3. 数据库配置`application-db.yml`已被git忽略,请手动创建,内容如下: ```yaml spring: datasource: driver-class-name: com.mysql.jdbc.Driver url: jdbc:mysql://localhost:3306/cskaoyan_market?useSSL=false&useUnicode=true&characterEncoding=utf-8 username: root password: 123456 ``` 4. 静态资源配置`application-static.yml`已被git忽略,请手动创建,内容如下: ```yaml spring: web: resources: static-locations: file:d:img/ ``` ## 测试模板 ```java package com.cskaoyan.app; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; @SpringBootTest class WuyanProject2ApplicationTests { @Test void contextLoads() { } } ``` ## 关于shiro集成相关问题 1. 目前shiro接管了登录、授权和权限控制,Session一致性我已全部做好,不需要另外造轮子; 2. 登录密码采用了加密,所以原有的三个账户需要更改密码,改密sql如下: ```sql update market_admin set `password` = '192023a7bbd73250516f069df18b500' where username = 'admin123'; update market_admin set `password` = '3c63fe4e1023b95042573c6624933274' where username = 'mall123'; update market_admin set `password` = '16a1371371bc2f32b7532baa0e0c6784' where username = 'promotion123'; ``` 小程序端也要改密码,对应sql为: ```sql update market_user set `password` = '6ad14ba9986e3615423dfca256d04e3f' where username = 'user123'; ``` 我给的加密算法比较简单,如果想自己建用户,只需要在网上找`md5生成`,将明文密码转换为对应的十六进制md5字符串即可,开头有0要去掉 3. 登录依赖自建权限表,建表sql在`sql/market_rbac.sql`里,已经包含了数据,不要再更改; 4. 如果发现登录出现login.jsp,请手动清理浏览器cookie数据 5. 小程序里面已经可以获取登录过的用户的userid,获取方法为: ```java Subject subject = SecurityUtils.getSubject(); Integer userid = (Integer) subject.getSession().getAttribute("userid"); ``` 但是session可能过期,因此取值的时候需要适当判空 ## git相关