Commit 8eb3e299 authored by xiaozhe.chen's avatar xiaozhe.chen
parents 4299b799 7614df4a
package cn.quantgroup.cashloanflowboss.api.channel.controller; package cn.quantgroup.cashloanflowboss.api.channel.controller;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import cn.quantgroup.cashloanflowboss.api.channel.service.ChannelConfService; import cn.quantgroup.cashloanflowboss.api.channel.service.ChannelConfService;
import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User;
import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.core.base.Result; import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.validation.Valid;
import java.util.Map; import java.util.Map;
/** /**
...@@ -14,7 +20,7 @@ import java.util.Map; ...@@ -14,7 +20,7 @@ import java.util.Map;
* @author suntao * @author suntao
*/ */
@RestController @RestController
@RequestMapping("channel/cfg") @RequestMapping("channel")
public class ChannelConfController { public class ChannelConfController {
...@@ -23,15 +29,16 @@ public class ChannelConfController { ...@@ -23,15 +29,16 @@ public class ChannelConfController {
@GetMapping("/info") @GetMapping("/info")
public Result channelConfInfo(Integer channelId) { public Page<ChannelConfiguration> channelInfo(@RequestParam @Valid Pagination pagination, Integer channelId) {
return channelConfService.getChannelInfo(pagination, channelId);
}
Map<String, Object> channelConf = channelConfService.getChannelConf(channelId);
if (channelConf == null) { @GetMapping("/cfg/info")
return new Result(); public Result channelConfInfo(Integer channelId) {
} else { return channelConfService.getChannelConf(channelId);
// TODO
return null;
}
} }
} }
package cn.quantgroup.cashloanflowboss.api.channel.entity.clf;
import cn.quantgroup.cashloanflowboss.api.channel.model.clf.EncType;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
/**
* Created by wudi on 2016/11/28.
*/
@Data
@Entity
@Table(name = "channel_configuration", catalog = "cash_loan_flow")
public class ChannelConfiguration implements Serializable {
private static final long serialVersionUID = -1L;
@Id
@Column(name = "id")
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "channel_name")
private String channelName;
@Column(name = "channel_code")
private String channelCode;
@Column(name = "registered_from")
private Long registeredFrom;
/**
* 默认有效
*/
@Column(name = "is_active")
private Boolean isActive = Boolean.TRUE;
@Column(name = "created_at")
private Timestamp createdAt = new Timestamp(System.currentTimeMillis());
/**
* 请求是否使用标准api
*/
@Column(name = "is_request_standard")
private Boolean isRequestStandard = Boolean.FALSE;
/**
* 加密类型
*/
@Column(name = "enc_type")
private EncType encType = EncType.AES;
/**
* aes加密key
*/
@Column(name = "aes_key")
private String aesKey;
/**
* md5摘要key
*/
@Column(name = "md5_key")
private String md5Key;
/**
* 授信中心channelCode, 爬虫提交channelCode
*/
@Column(name = "spider_center_channel_code")
private String spiderCenterChannelCode;
/**
* 授信中心商户渠道channelCode,授信授权提交channelCode
*/
@Column(name = "spider_center_merchant_channel_code")
private String spiderCenterMerchantChannelCode;
/**
* 渠道认证选项
*/
@Column(name = "auth_option")
private String authOption;
/**
* 免密登陆跳转url
*/
@Column(name = "login_page_url")
private String loginPageUrl;
}
\ No newline at end of file
package cn.quantgroup.cashloanflowboss.api.channel.model; package cn.quantgroup.cashloanflowboss.api.channel.model.boss;
import lombok.Data; import lombok.Data;
......
package cn.quantgroup.cashloanflowboss.api.channel.model; package cn.quantgroup.cashloanflowboss.api.channel.model.boss;
import lombok.Data; import lombok.Data;
......
package cn.quantgroup.cashloanflowboss.api.channel.model.clf;
/**
* function:
* date: 2019/8/6
*
* @author: suntao
*/
public class ChannelConfigurationPage {
}
package cn.quantgroup.cashloanflowboss.api.channel.model.clf;
/**
* Created by liqing on 2017/4/26 0026.
* 加解密方式
*/
public enum EncType {
AES("AES", "aesStandardCryptoService"),RSA("RSA", "rsaStandardCryptoService"),NONE("NONE", "noneStandardCryptoService");
public String text;
public String serviceClass;
EncType(String text, String serviceClass){
this.text = text;
this.serviceClass = serviceClass;
}
}
package cn.quantgroup.cashloanflowboss.api.channel.repository.boss; package cn.quantgroup.cashloanflowboss.api.channel.repository.boss;
import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf; import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
/** /**
* Created by suntao on 2019/7/22. * Created by suntao on 2019/7/22.
* @author suntao * @author suntao
*/ */
@Repository @Repository
public interface ChannelConfRepository { public interface ChannelConfRepository extends JpaRepository<ChannelConf, Long> {
/** /**
* 获取用户 * 获取用户
......
package cn.quantgroup.cashloanflowboss.api.channel.repository.clf;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface ChannelConfigurationRepository extends PagingAndSortingRepository<ChannelConfiguration, String> {
/**
* 获取用户列表(分页)
*
* @param pageable 分页
* @return
*/
Page<ChannelConfiguration> findAllBy(Pageable pageable);
ChannelConfiguration findByRegisteredFrom(Integer channelId);
}
package cn.quantgroup.cashloanflowboss.api.channel.service; package cn.quantgroup.cashloanflowboss.api.channel.service;
import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf; import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.entity.clf.ChannelConfiguration;
import cn.quantgroup.cashloanflowboss.api.channel.repository.boss.ChannelConfRepository; import cn.quantgroup.cashloanflowboss.api.channel.repository.boss.ChannelConfRepository;
import cn.quantgroup.cashloanflowboss.api.channel.repository.clf.ChannelConfigurationRepository;
import cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil; import cn.quantgroup.cashloanflowboss.api.channel.util.ChannelConfUtil;
import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.core.base.Result;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Map;
/** /**
* function: * function:
* date: 2019/8/2 * date: 2019/8/2
...@@ -18,20 +22,29 @@ import java.util.Map; ...@@ -18,20 +22,29 @@ import java.util.Map;
@Service @Service
public class ChannelConfService { public class ChannelConfService {
// @Autowired @Autowired
// private ChannelConfRepository channelConfRepository; private ChannelConfRepository channelConfRepository;
@Autowired
private ChannelConfigurationRepository clfChannelConfigurationRepository;
public Map<String, Object> getChannelConf(Integer channelId) { public Page<ChannelConfiguration> getChannelInfo(Pagination pagination, Integer channelId) {
if (channelId == null) {
return clfChannelConfigurationRepository.findAllBy(new PageRequest(pagination.getPageNumber(), pagination.getPageSize()));
} else {
ChannelConfiguration channelConfiguration = clfChannelConfigurationRepository.findByRegisteredFrom(channelId);
Page<ChannelConfiguration> result = null;
return null;
}
}
// ChannelConf channelConf = channelConfRepository.getByChannelId(channelId); public Result getChannelConf(Integer channelId) {
// if (channelConf == null) { ChannelConf channelConf = channelConfRepository.getByChannelId(channelId);
// return null; return Result.buildSuccess(ChannelConfUtil.channelConfConvertVOModel(channelConf), "success");
// }
//
// return ChannelConfUtil.channelConfConvertVOModel(channelConf);
return null;
} }
} }
...@@ -2,8 +2,8 @@ package cn.quantgroup.cashloanflowboss.api.channel.util; ...@@ -2,8 +2,8 @@ package cn.quantgroup.cashloanflowboss.api.channel.util;
import java.util.Date; import java.util.Date;
import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf; import cn.quantgroup.cashloanflowboss.api.channel.entity.boss.ChannelConf;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfAddModel; import cn.quantgroup.cashloanflowboss.api.channel.model.boss.ChannelConfAddModel;
import cn.quantgroup.cashloanflowboss.api.channel.model.ChannelConfBaseModel; import cn.quantgroup.cashloanflowboss.api.channel.model.boss.ChannelConfBaseModel;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import java.util.HashMap; import java.util.HashMap;
......
...@@ -2,6 +2,7 @@ package cn.quantgroup.cashloanflowboss.api.log.controller; ...@@ -2,6 +2,7 @@ package cn.quantgroup.cashloanflowboss.api.log.controller;
import cn.quantgroup.cashloanflowboss.api.log.model.LoginFormModel; import cn.quantgroup.cashloanflowboss.api.log.model.LoginFormModel;
import cn.quantgroup.cashloanflowboss.api.log.service.LogService; import cn.quantgroup.cashloanflowboss.api.log.service.LogService;
import cn.quantgroup.cashloanflowboss.component.security.Authority;
import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security; import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security;
import cn.quantgroup.cashloanflowboss.core.base.Result; import cn.quantgroup.cashloanflowboss.core.base.Result;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus; import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
...@@ -38,8 +39,8 @@ public class LogController { ...@@ -38,8 +39,8 @@ public class LogController {
* *
* @return * @return
*/ */
@Security(authorityId = "Log.logout")
@DeleteMapping("/logout") @DeleteMapping("/logout")
@Security(authorityId = "Log.logout", authorities = Authority.READ)
public Result<Boolean> logout() { public Result<Boolean> logout() {
return new Result<>(ApplicationStatus.SUCCESS, this.logService.logout()); return new Result<>(ApplicationStatus.SUCCESS, this.logService.logout());
} }
......
package cn.quantgroup.cashloanflowboss.api.log.service; package cn.quantgroup.cashloanflowboss.api.log.service;
import cn.quantgroup.cashloanflowboss.api.role.entity.Permission;
import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus; import cn.quantgroup.cashloanflowboss.api.user.dictionary.UserStatus;
import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User; import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User;
import cn.quantgroup.cashloanflowboss.api.user.service.UserService; import cn.quantgroup.cashloanflowboss.api.user.service.UserService;
...@@ -15,7 +16,7 @@ import org.springframework.stereotype.Service; ...@@ -15,7 +16,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import java.util.HashMap; import java.util.Arrays;
/** /**
* Created by WeiWei on 2019/7/22. * Created by WeiWei on 2019/7/22.
...@@ -51,9 +52,12 @@ public class LogService { ...@@ -51,9 +52,12 @@ public class LogService {
Assert.isFalse(user.getPassword().equalsIgnoreCase(MD5Tools.md5(password)), ApplicationStatus.USERNAME_OR_PASSWORD_ERROR); Assert.isFalse(user.getPassword().equalsIgnoreCase(MD5Tools.md5(password)), ApplicationStatus.USERNAME_OR_PASSWORD_ERROR);
HttpSession session = this.request.getSession(true); HttpSession session = this.request.getSession(true);
session.setAttribute(ApplicationDictionary.SECURITY_KEY, JSONTools.serialize(new HashMap<String, Authority>() {{
put("Log.logout", Authority.CREATE); Permission permission = new Permission();
}})); permission.setId("Log.logout");
permission.setAuthorities(Arrays.asList(Authority.READ));
session.setAttribute(ApplicationDictionary.SECURITY_KEY, JSONTools.serialize(Arrays.asList(permission)));
return true; return true;
......
...@@ -4,9 +4,6 @@ import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User; ...@@ -4,9 +4,6 @@ import cn.quantgroup.cashloanflowboss.api.user.entity.boss.User;
import cn.quantgroup.cashloanflowboss.api.user.model.Pagination; import cn.quantgroup.cashloanflowboss.api.user.model.Pagination;
import cn.quantgroup.cashloanflowboss.api.user.model.RegisterUserFormModel; import cn.quantgroup.cashloanflowboss.api.user.model.RegisterUserFormModel;
import cn.quantgroup.cashloanflowboss.api.user.service.UserService; import cn.quantgroup.cashloanflowboss.api.user.service.UserService;
import cn.quantgroup.cashloanflowboss.component.security.Power;
import cn.quantgroup.cashloanflowboss.component.security.annotiation.Security;
import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty;
import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty; import cn.quantgroup.cashloanflowboss.component.validator.constraints.NotEmpty;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page; import org.springframework.data.domain.Page;
......
package cn.quantgroup.cashloanflowboss.component.security;
/**
* Created by WeiWei on 2019/7/26.
*/
public enum Power {
/**
* 新建
*/
CREATE,
/**
* 更新
*/
UPDATE,
/**
* 删除
*/
DELETE
}
package cn.quantgroup.cashloanflowboss.core.base; package cn.quantgroup.cashloanflowboss.core.base;
import cn.quantgroup.cashloanflowboss.core.dictionary.ApplicationStatus;
import cn.quantgroup.cashloanflowboss.core.dictionary.Status; import cn.quantgroup.cashloanflowboss.core.dictionary.Status;
import lombok.Data; import lombok.Data;
...@@ -50,4 +51,27 @@ public class Result<T> { ...@@ -50,4 +51,27 @@ public class Result<T> {
} }
@SuppressWarnings("unchecked")
public static<T> Result buildSuccess(T data) {
return new Result(ApplicationStatus.SUCCESS, data);
}
@SuppressWarnings("unchecked")
public static<T> Result buildSuccess(T data, String message) {
return new Result(ApplicationStatus.SUCCESS, data, message);
}
@SuppressWarnings("unchecked")
public static<T> Result buildFial(T data) {
return new Result(ApplicationStatus.FAILURE, data);
}
@SuppressWarnings("unchecked")
public static<T> Result buildFial(T data, String message) {
return new Result(ApplicationStatus.FAILURE, data, message);
}
} }
...@@ -36,7 +36,6 @@ public class ApplicationExceptionConfiguration { ...@@ -36,7 +36,6 @@ public class ApplicationExceptionConfiguration {
*/ */
@ExceptionHandler({ApplicationException.class}) @ExceptionHandler({ApplicationException.class})
public Result applicationExceptionHandler(ApplicationException e) { public Result applicationExceptionHandler(ApplicationException e) {
log.error("程序员开小差了,系统异常信息:{}", e.getMessage());
return new Result<>(e.getStatus(), null, e.getStatus().getMessage()); return new Result<>(e.getStatus(), null, e.getStatus().getMessage());
} }
...@@ -96,19 +95,9 @@ public class ApplicationExceptionConfiguration { ...@@ -96,19 +95,9 @@ public class ApplicationExceptionConfiguration {
@ExceptionHandler({Throwable.class}) @ExceptionHandler({Throwable.class})
public Result generalException(Throwable e) { public Result generalException(Throwable e) {
Throwable cause = e; log.error(e.getMessage(), e);
while ((cause = cause.getCause()) != null) { return new Result<>(ApplicationStatus.INTERNAL_SERVICE_ERROR);
if (ApplicationException.class.isAssignableFrom(cause.getClass())) {
cause = cause.getCause();
break;
}
}
String errorMessage = ApplicationException.class.isAssignableFrom(e.getClass()) ? cause.getMessage() : e.getMessage();
log.error("程序员开小差了,未明确的异常信息:{}", errorMessage);
return new Result<>(ApplicationStatus.INTERNAL_SERVICE_ERROR, ApplicationStatus.INTERNAL_SERVICE_ERROR.getMessage());
} }
......
...@@ -34,7 +34,7 @@ public class ApplicationSecurityConfiguration implements SecurityHandler { ...@@ -34,7 +34,7 @@ public class ApplicationSecurityConfiguration implements SecurityHandler {
HttpSession session = this.request.getSession(false); HttpSession session = this.request.getSession(false);
// 检查是否已登录 // 检查是否已登录
Assert.isNull(session.getAttribute(ApplicationDictionary.SECURITY_KEY), ApplicationStatus.AUTHENTICATION_FAILURE); Assert.isTrue((Objects.isNull(session) || Objects.isNull(session.getAttribute(ApplicationDictionary.SECURITY_KEY))), ApplicationStatus.AUTHENTICATION_FAILURE);
// 读取Session授权内容 // 读取Session授权内容
List<Permission> permissions = JSONTools.deserialize(String.valueOf(session.getAttribute(ApplicationDictionary.SECURITY_KEY)), new TypeReference<List<Permission>>() {}); List<Permission> permissions = JSONTools.deserialize(String.valueOf(session.getAttribute(ApplicationDictionary.SECURITY_KEY)), new TypeReference<List<Permission>>() {});
......
...@@ -65,7 +65,7 @@ public class BossDSConfig { ...@@ -65,7 +65,7 @@ public class BossDSConfig {
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) { public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource()) return builder.dataSource(createDataSource())
.packages("cn.quantgroup.cashloanflowboss.api.user.entity.boss") .packages("cn.quantgroup.cashloanflowboss.api.*.entity.boss")
.persistenceUnit(uniquename) .persistenceUnit(uniquename)
.build(); .build();
} }
......
package cn.quantgroup.cashloanflowboss.core.configuration.data;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.orm.jpa.EntityManagerFactoryBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.orm.jpa.JpaTransactionManager;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.transaction.PlatformTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import javax.persistence.EntityManagerFactory;
import javax.sql.DataSource;
@Configuration
@EntityScan(basePackages = {"cn.quantgroup.cashloanflowboss.api.*.entity.clf"})
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = {"cn.quantgroup.cashloanflowboss.api.*.repository.clf"},
entityManagerFactoryRef = "clfEntityManager",
transactionManagerRef = "clfTransactionManager")
public class ClfDSConfig {
@Value("${data.boss.url}")
private String jdbcUrl;
@Value("${data.boss.password}")
private String password;
@Value("${data.boss.username}")
private String user;
private String uniquename = "bossDS";
@Value("${data.boss.pool-size}")
private Integer poolSize;
@Bean(name = "clfDataSource")
@ConfigurationProperties(prefix = "data.boss")
public DataSource createDataSource() {
DruidDataSource source = DruidDataSourceBuilder.create().build();
source.setMaxActive(200);
source.setMinIdle(10);
source.setInitialSize(10);
source.setMaxWait(500000);
source.setTimeBetweenEvictionRunsMillis(60000);
source.setMinEvictableIdleTimeMillis(300000);
source.setValidationQuery("SELECT 'x'");
source.setTestWhileIdle(true);
source.setTestOnBorrow(false);
source.setTestOnReturn(false);
source.setPoolPreparedStatements(Boolean.FALSE);
return source;
}
@Bean(name = "clfEntityManager")
public LocalContainerEntityManagerFactoryBean entityManager(EntityManagerFactoryBuilder builder) {
return builder.dataSource(createDataSource())
.packages("cn.quantgroup.cashloanflowboss.api.*.entity.clf")
.persistenceUnit(uniquename)
.build();
}
@Bean(name = "clfTransactionManager")
public PlatformTransactionManager transactionManager(@Qualifier("clfEntityManager") EntityManagerFactory entityManagerFactory) {
return new JpaTransactionManager(entityManagerFactory);
}
}
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