Skip to content

Commit

Permalink
Merge pull request #1 from yu199195/master
Browse files Browse the repository at this point in the history
更新
  • Loading branch information
ylh23y committed Jul 22, 2018
2 parents 95ad241 + e70d187 commit 1ec88d2
Show file tree
Hide file tree
Showing 180 changed files with 2,153 additions and 3,668 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ myth

# Features

* ##### 天然无缝集成 spring-boot-starter 。

* ##### RPC框架支持 : dubbo,motan,springcloud。

* ##### 消息中间件支持 : jms(activimq),amqp(rabbitmq),kafka,roceketmq。
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*
*/

package com.github.myth.admin;

import org.springframework.boot.SpringApplication;
Expand All @@ -23,14 +24,18 @@
import org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration;

/**
* MythAdminApplication.
* @author xiaoyu
*/
@SpringBootApplication(exclude = {MongoAutoConfiguration.class, MongoDataAutoConfiguration.class})
public class MythAdminApplication {
public static void main(String[] args) {

/**
* myth admin start.
* @param args args
*/
public static void main(final String[] args) {
SpringApplication.run(MythAdminApplication.class, args);
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,18 @@
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;


/**
* <p>Description: .</p>
*
* Permission.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/23 20:10
* @since JDK 1.8
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Permission {

/**
* 是否登录
* is login.
*
* @return true 需要 false 不需要
* @return true
*/
boolean isLogin() default true;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* along with this distribution; if not, see <http://www.gnu.org/licenses/>.
*
*/

package com.github.myth.admin.configuration;

import com.github.myth.admin.interceptor.AuthInterceptor;
Expand All @@ -35,54 +36,44 @@
import java.util.stream.StreamSupport;

/**
* <p>Description: .</p>
*
* AdminConfiguration.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/23 21:08
* @since JDK 1.8
*/
@Configuration
public class AdminConfiguration {


@Bean
public WebMvcConfigurer corsConfigurer() {
return new WebMvcConfigurerAdapter() {
@Override
public void addInterceptors(InterceptorRegistry registry) {
public void addInterceptors(final InterceptorRegistry registry) {
registry.addInterceptor(new AuthInterceptor()).addPathPatterns("/**");
}
};
}


@Configuration
static class SerializerConfiguration {

private final Environment env;

@Autowired
public SerializerConfiguration(Environment env) {
SerializerConfiguration(final Environment env) {
this.env = env;
}


@Bean
public ObjectSerializer objectSerializer() {

final SerializeEnum serializeEnum =
SerializeEnum.acquire(env.getProperty("myth.serializer.support"));
final ServiceLoader<ObjectSerializer> objectSerializers =
ServiceBootstrap.loadAll(ObjectSerializer.class);

return StreamSupport.stream(objectSerializers.spliterator(), false)
.filter(objectSerializer ->
Objects.equals(objectSerializer.getScheme(),
serializeEnum.getSerialize())).findFirst()
.orElse(new KryoSerializer());

}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import static com.google.common.collect.Lists.newArrayList;

/**
* SwaggerConfig.
* @author xiaoyu
*/
@Configuration
Expand All @@ -46,7 +47,7 @@ public class SwaggerConfig {

private static final String VERSION = "1.0.0";

ApiInfo apiInfo() {
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Swagger API")
.description("myth-admin 平台接口测试")
Expand All @@ -58,11 +59,9 @@ ApiInfo apiInfo() {
.build();
}

// swagger
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
// .paths(paths())
.build().pathMapping("/").directModelSubstitute(LocalDate.class, String.class)
.genericModelSubstitutes(ResponseEntity.class).useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, newArrayList(new ResponseMessageBuilder().code(500).message("500 message")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,27 +27,21 @@
import org.springframework.web.bind.annotation.RestController;

/**
* <p>Description: .</p>
*
* LoginController.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/20 10:11
* @since JDK 1.8
*/
@RestController
public class LoginController {


private final LoginService loginService;

@Autowired
public LoginController(LoginService loginService) {
public LoginController(final LoginService loginService) {
this.loginService = loginService;
}


@PostMapping("/login")
public AjaxResponse login(@RequestBody UserDTO userDTO) {
public AjaxResponse login(@RequestBody final UserDTO userDTO) {
final Boolean login = loginService.login(userDTO.getUserName(), userDTO.getPassword());
return AjaxResponse.success(login);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@

import com.github.myth.admin.annotation.Permission;
import com.github.myth.admin.dto.TransactionLogDTO;
import com.github.myth.admin.page.CommonPager;
import com.github.myth.admin.query.ConditionQuery;
import com.github.myth.admin.service.ApplicationNameService;
import com.github.myth.admin.service.AppNameService;
import com.github.myth.admin.service.LogService;
import com.github.myth.admin.vo.LogVO;
import com.github.myth.common.utils.httpclient.AjaxResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -36,53 +34,44 @@
import java.util.List;

/**
* <p>Description: .</p>
* 事务恢复controller
*
* TransactionLogController.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/18 10:31
* @since JDK 1.8
*/
@RestController
@RequestMapping("/log")
public class TransactionLogController {


private final LogService logService;

private final ApplicationNameService applicationNameService;
private final AppNameService appNameService;

@Value("${myth.retry.max}")
private Integer recoverRetryMax;

@Autowired
public TransactionLogController(LogService logService, ApplicationNameService applicationNameService) {
public TransactionLogController(final LogService logService,
final AppNameService appNameService) {
this.logService = logService;
this.applicationNameService = applicationNameService;
this.appNameService = appNameService;
}

@Permission
@PostMapping(value = "/listPage")
public AjaxResponse listPage(@RequestBody ConditionQuery recoverQuery) {
final CommonPager<LogVO> pager =
logService.listByPage(recoverQuery);
return AjaxResponse.success(pager);
public AjaxResponse listPage(@RequestBody final ConditionQuery recoverQuery) {
return AjaxResponse.success(logService.listByPage(recoverQuery));
}


@PostMapping(value = "/batchRemove")
@Permission
public AjaxResponse batchRemove(@RequestBody TransactionLogDTO transactionLogDTO) {

public AjaxResponse batchRemove(@RequestBody final TransactionLogDTO transactionLogDTO) {
final Boolean success = logService.batchRemove(transactionLogDTO.getIds(), transactionLogDTO.getApplicationName());
return AjaxResponse.success(success);

}

@PostMapping(value = "/update")
@Permission
public AjaxResponse update(@RequestBody TransactionLogDTO transactionLogDTO) {
public AjaxResponse update(@RequestBody final TransactionLogDTO transactionLogDTO) {
final Boolean success = logService.updateRetry(transactionLogDTO.getId(),
transactionLogDTO.getRetry(), transactionLogDTO.getApplicationName());
return AjaxResponse.success(success);
Expand All @@ -92,9 +81,8 @@ public AjaxResponse update(@RequestBody TransactionLogDTO transactionLogDTO) {
@PostMapping(value = "/listAppName")
@Permission
public AjaxResponse listAppName() {
final List<String> list = applicationNameService.list();
final List<String> list = appNameService.list();
return AjaxResponse.success(list);
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,14 @@
import java.util.List;

/**
* <p>Description: .</p>
*
* TransactionLogDTO.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/24 16:24
* @since JDK 1.8
*/
@Data
public class TransactionLogDTO implements Serializable {

private static final long serialVersionUID = 6905402148490426011L;

private String applicationName;

private List<String> ids;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,14 @@
import java.io.Serializable;

/**
* <p>Description: .</p>
*
* UserDTO.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/23 18:18
* @since JDK 1.8
*/
@Data
public class UserDTO implements Serializable {

private static final long serialVersionUID = -3479973014221253748L;

private String userName;

private String password;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*
*/


package com.github.myth.admin.filter;

import org.springframework.stereotype.Component;
Expand All @@ -31,33 +30,28 @@
import java.io.IOException;

/**
* <p>Description: .</p>
*
* CorsFilter.
* @author xiaoyu(Myth)
* @version 1.0
* @date 2017/10/23 17:57
* @since JDK 1.8
*//*
*/
*/
@Component
public class CorsFilter implements Filter {


@Override
public void init(FilterConfig filterConfig) throws ServletException {
public void init(final FilterConfig filterConfig) {

}

@Override
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
public void doFilter(final ServletRequest req,
final ServletResponse res,
final FilterChain chain) throws IOException, ServletException {
HttpServletResponse response = (HttpServletResponse) res;
response.setHeader("Access-Control-Allow-Origin","*");
response.setHeader("Access-Control-Allow-Origin", "*");
response.setHeader("Access-Control-Allow-Credentials", "true");
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
response.setHeader("Access-Control-Max-Age", "7200");
response.setHeader("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
response.setHeader("Access-Control-Request-Headers","content-type");
response.setHeader("Access-Control-Request-Headers", "content-type");
chain.doFilter(req, res);
}

Expand All @@ -66,6 +60,5 @@ public void destroy() {

}


}

Loading

0 comments on commit 1ec88d2

Please sign in to comment.