Commit 65dc0459 authored by 董建华's avatar 董建华

增加添加登录白名单的接口

parent a1b39974
......@@ -5,7 +5,6 @@ import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.jdbc.DataSourceBuilder;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
......@@ -21,8 +20,6 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
/**
......
package cn.quantgroup.xyqb.controller.risk;
import cn.quantgroup.xyqb.entity.enums.KeyType;
import cn.quantgroup.xyqb.model.JsonResult;
import cn.quantgroup.xyqb.service.risk.LoginRiskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author :dongjianhua
* @date :Created in 2020/12/14 15:02
* @description:登录白名单控制器
* @modified By:
* @version: 1.0
*/
@Slf4j
@RestController
@RequestMapping("/login/risk")
public class LoginWhiteListController {
@Resource
private LoginRiskService loginRiskService;
@RequestMapping(value = "/login/risk", method = RequestMethod.POST)
public JsonResult addWhiteList(String val, KeyType type) {
log.info("添加用户白名单val:{},type:{}", val, type);
if (null == val || null == type) {
return JsonResult.buildErrorStateResult("参数有误", null);
}
loginRiskService.addWhiteList(val, type);
return JsonResult.buildSuccessResult();
}
}
.
\ No newline at end of file
package cn.quantgroup.xyqb.service.risk;
import cn.quantgroup.xyqb.entity.enums.KeyType;
public interface LoginRiskService {
void addWhiteList(String val, KeyType keyType);
}
package cn.quantgroup.xyqb.service.risk.impl;
import cn.quantgroup.xyqb.entity.enums.KeyType;
import cn.quantgroup.xyqb.risk.entity.WhiteList;
import cn.quantgroup.xyqb.risk.repository.WhiteListRepository;
import cn.quantgroup.xyqb.service.risk.LoginRiskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @author :dongjianhua
* @date :Created in 2020/12/14 15:07
* @description:登录风控实现类
* @modified By:
* @version: 1.0
*/
@Slf4j
@Service
public class LoginRiskServiceImpl implements LoginRiskService {
@Resource
private WhiteListRepository whiteListRepository;
@Override
public void addWhiteList(String val, KeyType keyType) {
log.info("添加用户白名单val:{},keyType:{}", val, keyType);
Long count = whiteListRepository.countByKeyEqualsAndTypeEqualsAndEnableIsTrue(val, keyType);
if (count > 0) {
log.warn("用户白名单已经存在val:{},keyType:{}", val, keyType);
return;
}
WhiteList list = new WhiteList();
list.setEnable(Boolean.TRUE);
list.setKey(val);
list.setType(keyType);
whiteListRepository.save(list);
}
}
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