# yeb_back
**Repository Path**: johndriver/yeb_back
## Basic Information
- **Project Name**: yeb_back
- **Description**: yeb 后端
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2021-06-07
- **Last Updated**: 2021-07-29
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# 后端
## swagger接口文档
## 验证码
```xml
com.github.axet
kaptcha
0.0.9
```
配置类
```java
@Configuration
public class CaptchaConfig {
@Bean
public DefaultKaptcha defaultKaptcha(){
//验证码生成器
DefaultKaptcha defaultKaptcha=new DefaultKaptcha();
//配置
Properties properties = new Properties();
//是否有边框
properties.setProperty("kaptcha.border", "yes");
//设置边框颜色
properties.setProperty("kaptcha.border.color", "105,179,90");
//边框粗细度,默认为1
// properties.setProperty("kaptcha.border.thickness","1");
//验证码
properties.setProperty("kaptcha.session.key","code");
//验证码文本字符颜色 默认为黑色
properties.setProperty("kaptcha.textproducer.font.color", "blue");
//设置字体样式
properties.setProperty("kaptcha.textproducer.font.names", "宋体,楷体,微软雅黑");
//字体大小,默认40
properties.setProperty("kaptcha.textproducer.font.size", "30");
//验证码文本字符内容范围 默认为abced2345678gfynmnpwx
// properties.setProperty("kaptcha.textproducer.char.string", "");
//字符长度,默认为5
properties.setProperty("kaptcha.textproducer.char.length", "4");
//字符间距 默认为2
properties.setProperty("kaptcha.textproducer.char.space", "4");
//验证码图片宽度 默认为200
properties.setProperty("kaptcha.image.width", "100");
//验证码图片高度 默认为40
properties.setProperty("kaptcha.image.height", "40");
Config config = new Config(properties);
defaultKaptcha.setConfig(config);
return defaultKaptcha;
}
}
```
```java
@RestController
@Slf4j
public class CaptchaController {
@Autowired
private DefaultKaptcha defaultKaptcha;
@ApiOperation(value = "验证码")
@GetMapping(value = "/captcha",produces = "image/jpeg")
public void captcha(HttpServletRequest request, HttpServletResponse response){
//定义输出类型为image/jpeg
response.setDateHeader("Expires",0);
response.setHeader("Cache-Control","no-store,no-cache,must-revalidate");
response.addHeader("Cache-Control","post-check=0,pre-check=0");
response.setHeader("Pragma","no-cache");
response.setContentType("image/jpeg");
//---------生成验证码------------
//文本
String text = defaultKaptcha.createText();
log.info(text);
request.getSession().setAttribute("captcha",text);
//文本生成图形验证码
BufferedImage image = defaultKaptcha.createImage(text);
ServletOutputStream outputStream =null;
try {
outputStream = response.getOutputStream();
//图形写入流中
ImageIO.write(image,"jpg",outputStream);
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(null!=outputStream){
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
```
## Redis优化菜单
配置
```xml
org.springframework.boot
spring-boot-starter-data-redis
org.apache.commons
commons-pool2
```
```yaml
spring:
redis:
host: 192.168.144.129
timeout: 10000ms
port: 6379
database: 0
lettuce:
pool:
min-idle:200
max-active: 1024
max-wait: 10000ms
min-idle: 5
```
使用
```java
@Service
public class MenuServiceImpl extends ServiceImpl implements IMenuService {
@Autowired
private MenuMapper menuMapper;
@Autowired
private RedisTemplate redisTemplate;
@Override
public List