目录
序配置中心完善后,自动导入了Mybatis以后
一、admin-service管理员后台的搭建
1、环境测试
添加启动类和bootstrap.yml
bootstrap.yml
spring:
application:
name: admin-service
cloud:
nacos:
server-addr: nacos-server:8848
config:
file-extension: yaml
profiles:
active: dev
# 拉取的配置文件的dataID=admin-service-dev.yaml
nacos映射配置
server:
port: 8080
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql-server:3307/coin-exchange?serverTimezone=UTC%2B8
username: root
password: WXL1214??
redis:
host: redis-server
port: 6380
password: WXL1214??
cloud:
sentinel:
transport:
dashboard: sentinel-dashboard:8858
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
mapper-locations: classpath:/mappers/*Mapper.xml
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
local:
default:
type: linkedhashmap
keyConvertor: fastjson
remote:
default:
type: redis
keyConvertor: fastjson
valueEncoder: kryo
valueDecoder: kryo
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
host: ${spring.redis.host}
port: ${spring.redis.port}
password: ${spring.redis.password}
swagger2:
basePackage: com.dragonwu.controller
name: liangtiandong
url: www.liangtiandong.com
email: liangtiandong@live.com
title: 后台管理系统API接口
description: 后台管理系统API接口演示
version: 1.0
termsOfServiceUrl: www.dragonwu.com
添加测试类
package com.dragonwu.controller;
import com.dragonwu.domain.SysUser;
import com.dragonwu.model.R;
import com.dragonwu.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(tags = "后台管理系统的测试接口")
public class TestController {
@Autowired
private SysUserService sysUserService;
@ApiOperation(value = "查询用户详情")
@GetMapping("/user/info/{id}")
@ApiImplicitParams({
@ApiImplicitParam(name = "id",value = "用户的ID")
})
public R<SysUser> getSysUserInfo(@PathVariable("id")Long id){
SysUser sysUser=sysUserService.getById(id);
return R.ok(sysUser);
}
}
运行测试,接口没问题
2、登录功能的实现
见我的另一篇博客:微服务 管理员登录功能实现案例_Dragon Wu的博客-CSDN博客
3、权限数据的CRUD
微服务 后台 权限数据的CRUD 案例_Dragon Wu的博客-CSDN博客
4、员工查询操作
微服务项目 员工的查询操作_Dragon Wu的博客-CSDN博客
5、后台管理员权限配置
微服务项目 后台管理员角色管理 权限管理 案例_Dragon Wu的博客-CSDN博客