Giter VIP home page Giter VIP logo

loc-framework's People

Contributors

dragontree101 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loc-framework's Issues

请教些问题

1.Ioc-samples 中依赖的loc-framework-config-sample 中没有这个config-starter
2.mybatis中的配置文件
image中的readDemo等的连接数据库属性在
image中没有定义和解析,请问是怎么能够设置连接的,若设置的是默认的数据库,那请问是怎么去设置的呢?
3.

关于跨域访问的这个地方代码是不是手误

`@Configuration
@ConditionalOnWebApplication(type = Type.SERVLET)
@EnableConfigurationProperties(LocSpringMvcCorsProperties.class)
public class LocSpringMvcAutoConfiguration {

@bean
@ConditionalOnClass(CorsFilter.class)
@ConditionalOnProperty(value = "loc.web.springmvc.cors.enabled")
public Filter corsFilter(LocSpringMvcCorsProperties locSpringMvcCorsProperties) {
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration(
Optional.ofNullable(locSpringMvcCorsProperties.getPath()).orElse("/**"),
buildConfig(locSpringMvcCorsProperties));
return new CorsFilter(source);
}

private CorsConfiguration buildConfig(LocSpringMvcCorsProperties locSpringMvcCorsProperties) {
CorsConfiguration corsConfiguration = new CorsConfiguration();
Optional.ofNullable(locSpringMvcCorsProperties.getAllowOrigins())
.ifPresent(origins -> origins.forEach(corsConfiguration::addAllowedOrigin));
Optional.ofNullable(locSpringMvcCorsProperties.getAllowHeaders())
.ifPresent(headers -> headers.forEach(corsConfiguration::addAllowedHeader));
Optional.ofNullable(locSpringMvcCorsProperties.getAllowOrigins())
.ifPresent(methods -> methods.forEach(corsConfiguration::addAllowedMethod));
Optional.ofNullable(locSpringMvcCorsProperties.getAllowExposeHeaders())
.ifPresent(headers -> headers.forEach(corsConfiguration::addExposedHeader));
return corsConfiguration;
}`
两次使用了locSpringMvcCorsProperties.getAllowOrigins(),最后一次应该是locSpringMvcCorsProperties.getAllowMethods()

关于problemUtil的封装

问题1:class和interface封装工具类除了代码默认简写外还有其他区别吗?因为interface没有private,所以还是喜欢用class写。
问题2:前后端分离后,数据用map封装放data好还是这样自定义好?

public class ProblemUtil {

    public static Problem createProblem(Object... datas) {
        ProblemBuilder builder = Problem.builder().withDetail("success").with("code", 0);
            for(Object obj:datas){
                String  name = getName(obj);
                builder.with(name,obj);
            }
        return builder.build();
    }

    public static Problem createProblem(String detail, Object... datas) {
        ProblemBuilder builder = Problem.builder().withDetail(detail).with("code", 0);
            for(Object obj:datas){
                String  name = getName(obj);
                builder.with(name,obj);
            }
        return builder.build();
    }

    public  static Problem createProblem(String detail, int code, Object... datas) {
        ProblemBuilder builder = Problem.builder().withDetail(detail).with("code", code);
            for(Object obj:datas){
                String  name = getName(obj);
                builder.with(name,obj);
            }
        return builder.build();
    }
    private static String getName(Object obj){
        String name = null;
        if(obj instanceof List){
            name = ((List) obj).get(0).getClass().getName()+"s";

        }else {
            name  = obj.getClass().getName();
        }
        return tolowFirstCase(name.substring(name.lastIndexOf(".")+1));
    }
    private static String tolowFirstCase(String str) {
        char[] c = str.toCharArray();
        c[0] = (char) (c[0]-(32)); //ASCII
        return c.toString();
    }

}

关于多数据源事务的问题

`@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class,DataSourceTransactionManagerAutoConfiguration.class })
@EnableTransactionManagement
public class SampleMybatisApplication {

public static void main(String[] args) throws Exception {
	SpringApplication app = new SpringApplication(
			SampleMybatisApplication.class);
	app.run(args);
}

@Autowired
private HotMapper hotMapper;
@Autowired
private SecondHotMapper secondHotMapper;

@Transactional("firstTransactionManager")
@RequestMapping(value = "/transactional1", method = RequestMethod.GET)
public String transactional1() {
	hotMapper.deleteById(10);
	return "";
}

@Transactional("secondTransactionManager")
@RequestMapping(value = "/transactional2", method = RequestMethod.GET)
public String transactional2() {
	secondHotMapper.deleteById(10);
	return "";
}

}`

我的HotMapper 和 SecondHotMapper 是对应两个数据源的mapper,如果想添加事务的时候就必须像上面代码一样指定Transactional的名字,请问大神有什么好的办法,不需要业务层去关心当前使用的哪个事务么?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.