Commit 93c4cfc3 authored by zengtianlai3's avatar zengtianlai3

添加日志注解

parent 3e1aa57b
......@@ -28,7 +28,6 @@ public class BalanceManager {
String serverIp = server.getServerIp();
allServers.put(serverIp, server);
}
}
public Server getBalanceServer() {
......
......@@ -20,8 +20,10 @@ public abstract class BaseSwaggerConfig {
Docket docket = new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo(swaggerProperties))
.select()
.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getApiBasePackage()))
//.apis(RequestHandlerSelectors.basePackage(swaggerProperties.getApiBasePackage()))
.paths(PathSelectors.any())
//这里指定Controller扫描包路径
.apis(RequestHandlerSelectors.basePackage("iot.sixiang.license.controller"))
.build();
if (swaggerProperties.isEnableSecurity()) {
docket.securitySchemes(securitySchemes()).securityContexts(securityContexts());
......
package iot.sixiang.license.config.swagger;
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
......@@ -10,6 +11,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
*/
@Configuration
@EnableSwagger2WebMvc
@EnableKnife4j
public class SwaggerConfig extends BaseSwaggerConfig {
@Override
public SwaggerProperties swaggerProperties() {
......
......@@ -4,6 +4,8 @@ package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.jwt.UserUtils;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.vo.AlarmVo;
import iot.sixiang.license.service.AlarmService;
......@@ -32,6 +34,7 @@ public class AlarmController {
@ApiOperation(value = "获取告警列表接口", notes = "用于获取告警列表")
@GetMapping("list")
@MyLog(title = "获取告警列表", businessType = BusinessType.SELECT)
public ResResult getAlarmList() {
String userId = UserUtils.getLoginUserId();
int Id = Integer.valueOf(userId);
......
......@@ -3,6 +3,8 @@ package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.service.AlarmReadService;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -28,6 +30,7 @@ public class AlarmReadController {
@ApiOperation(value = "告警已读接口", notes = "将告警信息状态设为已读")
@PostMapping("read")
@MyLog(title = "将告警信息状态设为已读", businessType = BusinessType.OTHER)
public BaseResult readAlarm(){
// int userId = jsonObject.getIntValue("userId");
int userId = 2147483647;
......
......@@ -9,6 +9,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.PageResult;
......@@ -42,6 +44,7 @@ public class ApplyController {
*/
@ApiOperation(value = "应用添加接口", notes = "用于添加应用")
@PostMapping("add")
@MyLog(title = "添加应用", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "appName",value = "应用名",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "appKey",value = "应用key",required = true,dataTypeClass = String.class),
......@@ -67,6 +70,7 @@ public class ApplyController {
*/
@ApiOperation(value = "获取应用列表接口", notes = "用于获取应用列表")
@GetMapping("list")
@MyLog(title = "获取应用列表", optParam = "#{pageNo},#{pageSize},#{appName}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true, dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int"),
......
......@@ -9,6 +9,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.PageResult;
......@@ -46,6 +48,7 @@ public class DeviceController {
@DynamicParameter(name = "appId",value = "应用Id",required = true,dataTypeClass = Integer.class),
@DynamicParameter(name = "count",value = "需要创建的设备数量",required = true,dataTypeClass = Integer.class),
}))
@MyLog(title = "添加设备", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
public BaseResult addDevice(@RequestBody JSONObject jsonObject) {
int appId = jsonObject.getIntValue("appId");
int count = jsonObject.getIntValue("count");
......@@ -67,6 +70,7 @@ public class DeviceController {
*/
@ApiOperation(value = "获取设备列表接口", notes = "用于获取设备列表")
@GetMapping("list")
@MyLog(title = "获取设备列表", optParam = "#{pageNo},#{pageSize},#{appName},#{userName}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true, dataType="int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType="int"),
......
......@@ -6,6 +6,8 @@ import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.jwt.JwtUtil;
import iot.sixiang.license.jwt.LoginUser;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.ResResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -38,13 +40,13 @@ public class LoginController {
*/
@ApiOperation(value = "登录接口", notes = "登录接口")
@GetMapping("login")
@MyLog(title = "登录", optParam = "#{userName},#{password}", businessType = BusinessType.OTHER)
@ApiImplicitParams({
@ApiImplicitParam(name = "userName",value = "用户名",required = true),
@ApiImplicitParam(name = "password",value = "密码",required = true)
})
public ResResult login(@RequestParam("userName") String userName, @RequestParam("password") String password) {
for (LoginUser dbUser : userMap.values()) {
if (dbUser.getUserName().equals(userName) && dbUser.getPassword().equals(password)) {
log.info("登录成功!生成token!");
......@@ -60,6 +62,7 @@ public class LoginController {
@ApiOperation(value = "注销接口", notes = "注销接口")
@GetMapping("logout")
@MyLog(title = "注销", optParam = "#{userName},#{password}", businessType = BusinessType.OTHER)
@ApiImplicitParams({
@ApiImplicitParam(name = "userName",value = "用户名",required = true),
@ApiImplicitParam(name = "password",value = "密码",required = true)
......
......@@ -3,6 +3,8 @@ package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.operate.OperateManager;
......@@ -27,6 +29,7 @@ public class OperateController {
@ApiOperation(value = "服务接口", notes = "用于获取服务列表")
@GetMapping("monitor/server")
@MyLog(title = "获取服务列表", businessType = BusinessType.SELECT)
public ResResult getDeviceTypes() {
List<SamMonitor> records = operateManager.getSamMonitorList();
return ResResult.success().record(records);
......@@ -35,12 +38,14 @@ public class OperateController {
@ApiOperation(value = "在线数量添加接口", notes = "用于添加当前在线数量")
@PostMapping("monitor/add")
@MyLog(title = "添加当前服务器在线数量", businessType = BusinessType.INSERT)
public boolean addMonitor() {
return monitorService.addMonitor(20);
}
@ApiOperation(value = "获取并发量接口", notes = "用于获取并发量")
@GetMapping("monitor/qps")
@MyLog(title = "获取并发量", optParam = "#{type}", businessType = BusinessType.SELECT)
@ApiImplicitParam(name = "type",value = "类型:0:今天 1:昨天 2:七天前 3:三十天前",required = true, dataType = "int")
public ResResult getQps(@RequestParam("type") int type) {
HashMap<String, List<Integer>> monitorList = monitorService.getMonitorList(type);
......
......@@ -3,6 +3,8 @@ package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.resource.ResourceManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -24,6 +26,7 @@ public class ResourceContrller {
@ApiOperation(value = "资源下载接口", notes = "用于下载资源")
@GetMapping("/download")
@MyLog(title = "下载资源", optParam = "#{userId}", businessType = BusinessType.OTHER)
@ApiImplicitParam(name = "userId",value = "用户Id",required = true, dataType = "int")
public void downloadWorkHourRecordTemplate(HttpServletResponse response, @RequestParam(value = "userId") int userId) {
......
......@@ -2,6 +2,8 @@ package iot.sixiang.license.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.model.SamMonitor;
import iot.sixiang.license.operate.OperateManager;
......@@ -28,6 +30,7 @@ public class SamMapController {
@ApiOperation(value = "统计sam总数接口", notes = "用于统计sam的总数和总在线数量")
@GetMapping("count")
@MyLog(title = "统计sam总数", businessType = BusinessType.SELECT)
public ResResult getSamTotalCount() {
Map<String, SamMonitor> samMonitorMap = operateManager.getSamMonitorMap();
Map<String,Integer> map = new HashMap<>();
......
......@@ -10,6 +10,8 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.entity.Server;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.ResResult;
import iot.sixiang.license.service.ServerService;
......@@ -41,6 +43,7 @@ public class ServerController {
*/
@ApiOperation(value = "添加服务接口", notes = "用于添加服务")
@PostMapping("add")
@MyLog(title = "添加服务", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class)
......@@ -61,6 +64,7 @@ public class ServerController {
* @param serverIp
* @return
*/
@MyLog(title = "删除服务", optParam = "#{serverIp}", businessType = BusinessType.DELETE)
@ApiOperation(value = "删除服务接口", notes = "删除服务")
@PostMapping("delete")
public BaseResult deleteServer(@RequestParam("serverIp") String serverIp) {
......@@ -79,6 +83,7 @@ public class ServerController {
*/
@ApiOperation(value = "修改服务接口", notes = "修改服务")
@PostMapping("update")
@MyLog(title = "修改服务", optParam = "#{serverIp},#{port}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "serverIp",value = "服务Ip",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "port",value = "端口",required = true,dataTypeClass = Integer.class)
......@@ -103,6 +108,7 @@ public class ServerController {
*/
@ApiOperation(value = "获取服务列表接口", notes = "用于获取服务列表")
@GetMapping("list")
@MyLog(title = "获取服务列表", optParam = "#{pageNo},#{pageSize}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int")
......
package iot.sixiang.license.controller;
import com.alibaba.fastjson.JSONObject;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.service.SysOperLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
@RestController
@RequestMapping("/iot_license/sys_oper_log")
public class SysOperLogController {
@Autowired
SysOperLogService sysOperLogService;
@GetMapping("get/test/{id}")
@MyLog(title = "get方式日志测试", optParam = "#{id},#{pageNo}", businessType = BusinessType.OTHER)
public BaseResult getTest(@PathVariable Long id, @RequestParam("pageNo") int pageNo) {
return BaseResult.success();
}
@PostMapping("post/test/{id}")
@MyLog(title = "post方式操作日志测试", optParam = "#{jsonObject}", businessType = BusinessType.OTHER)
public BaseResult postTest(@PathVariable Long id, @RequestBody JSONObject jsonObject) {
return BaseResult.success();
}
}
......@@ -9,6 +9,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import iot.sixiang.license.log.BusinessType;
import iot.sixiang.license.log.MyLog;
import iot.sixiang.license.model.BaseResult;
import iot.sixiang.license.model.PageInfoModel;
import iot.sixiang.license.model.PageResult;
......@@ -43,6 +45,7 @@ public class UserController {
*/
@ApiOperation(value = "用户添加接口", notes = "用于添加用户")
@PostMapping("add")
@MyLog(title = "添加用户", optParam = "#{jsonObject}", businessType = BusinessType.INSERT)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "userName",value = "账户名",required = true,dataTypeClass = String.class),
@DynamicParameter(name = "company",value = "公司名",required = true,dataTypeClass = String.class)
......@@ -66,6 +69,7 @@ public class UserController {
*/
@ApiOperation(value = "用户删除接口", notes = "删除用户")
@PostMapping("delete")
@MyLog(title = "删除用户", optParam = "#{userId}", businessType = BusinessType.DELETE)
public BaseResult deleteUser(@RequestParam("userId") int userId) {
boolean res = userService.deleteUser(userId);
if (res) {
......@@ -82,6 +86,7 @@ public class UserController {
*/
@ApiOperation(value = "用户修改接口", notes = "修改用户")
@PostMapping("update")
@MyLog(title = "修改用户", optParam = "#{userId},#{password}", businessType = BusinessType.UPDATE)
@ApiOperationSupport(params = @DynamicParameters(name = "jsonObject",properties = {
@DynamicParameter(name = "userId",value = "用户Id",required = true,dataTypeClass = Integer.class),
@DynamicParameter(name = "password",value = "密码",required = true,dataTypeClass = String.class)
......@@ -106,6 +111,7 @@ public class UserController {
*/
@ApiOperation(value = "获取用户列表接口", notes = "用于获取用户列表")
@GetMapping("list")
@MyLog(title = "获取用户列表", optParam = "#{pageNo},#{pageSize},#{userName},#{company}", businessType = BusinessType.SELECT)
@ApiImplicitParams({
@ApiImplicitParam(name = "pageNo",value = "当前在第几页", required = true,dataType = "int"),
@ApiImplicitParam(name = "pageSize",value = "每页显示多少页", required = true, dataType = "int"),
......
......@@ -6,6 +6,11 @@ public enum BusinessType {
*/
OTHER,
/**
* 查找
*/
SELECT,
/**
* 新增
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment