Commit de5a43b8 authored by 黎博's avatar 黎博

新增添加登录白名单接口

parent ec21c8e3
package cn.qg.qaplatform.stools.controller;
import cn.qg.qaplatform.stools.service.CommonService;
import cn.qg.qaplatform.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@RequestMapping("/common")
public class CommonController {
@Autowired
CommonService commonService;
@GetMapping("/whitelist")
public JsonResult addLoginWhiteList(String namespace, String key, Integer keyType) {
boolean result = commonService.addLoginWhiteList(namespace, key, keyType);
return JsonResult.success(result);
}
}
package cn.qg.qaplatform.stools.mapper;
public interface CommonMapper {
boolean addLoginWhiteList(String key, Integer keyType);
}
package cn.qg.qaplatform.stools.service;
public interface CommonService {
boolean addLoginWhiteList(String namespace, String key, Integer keyType);
}
package cn.qg.qaplatform.stools.service.impl;
import cn.qg.qaplatform.config.SwitchDataSource;
import cn.qg.qaplatform.stools.mapper.CommonMapper;
import cn.qg.qaplatform.stools.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CommonServiceImpl implements CommonService {
@Autowired
CommonMapper commonMapper;
@Override
public boolean addLoginWhiteList(String namespace, String key, Integer keyType) {
SwitchDataSource.dataSourceSwitch(namespace, "login_risk");
boolean result;
try {
result = commonMapper.addLoginWhiteList(key, keyType);
} catch (Exception e) {
e.printStackTrace();
return false;
}
return result;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.qg.qaplatform.stools.mapper.CommonMapper">
<insert id="addLoginWhiteList">
INSERT INTO `white_list` (`key`, `key_type`, `enable`) VALUE (#{key}, #{keyType}, '1');
</insert>
</mapper>
\ No newline at end of file
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