按照Alibaba Java Coding Guidelines插件扫描结果,修改代码规范

This commit is contained in:
shuzheng 2017-11-08 22:01:11 +08:00
parent ad725a433e
commit 3e330ece74
140 changed files with 815 additions and 543 deletions

View File

@ -6,6 +6,9 @@ package com.zheng.api.common.constant;
*/
public enum ApiResultConstant {
/**
* 成功
*/
SUCCESS(1, "success");
public int code;

View File

@ -6,6 +6,11 @@ package com.zheng.api.rpc.api;
*/
public interface ApiService {
/**
* hello
* @param name
* @return
*/
String hello(String name);
}

View File

@ -9,11 +9,11 @@ import org.slf4j.LoggerFactory;
*/
public class ApiServiceMock implements ApiService {
private static Logger _log = LoggerFactory.getLogger(ApiServiceMock.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ApiServiceMock.class);
@Override
public String hello(String name) {
_log.info("ApiServiceMock => hello");
LOGGER.info("ApiServiceMock => hello");
return null;
}

View File

@ -10,12 +10,11 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class ZhengApiRpcServiceApplication {
private static Logger _log = LoggerFactory.getLogger(ZhengApiRpcServiceApplication.class);
public static void main(String[] args) {
_log.info(">>>>> zheng-api-rpc-service 正在启动 <<<<<");
new ClassPathXmlApplicationContext("classpath:META-INF/spring/*.xml");
_log.info(">>>>> zheng-api-rpc-service 启动完成 <<<<<");
}
private static final Logger LOGGER = LoggerFactory.getLogger(ZhengApiRpcServiceApplication.class);
public static void main(String[] args) {
LOGGER.info(">>>>> zheng-api-rpc-service 正在启动 <<<<<");
new ClassPathXmlApplicationContext("classpath:META-INF/spring/*.xml");
LOGGER.info(">>>>> zheng-api-rpc-service 启动完成 <<<<<");
}
}

View File

@ -1,11 +1,8 @@
package com.zheng.api.rpc.service.impl;
import com.zheng.api.rpc.api.ApiService;
import com.zheng.cms.rpc.api.*;
import com.zheng.upms.rpc.api.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/**
* 实现ApiService接口
@ -13,38 +10,8 @@ import org.springframework.beans.factory.annotation.Autowired;
*/
public class ApiServiceImpl implements ApiService {
private static Logger _log = LoggerFactory.getLogger(ApiServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ApiServiceImpl.class);
// @Autowired
// private UpmsSystemService upmsSystemService;
//
// @Autowired
// private UpmsOrganizationService upmsOrganizationService;
//
// @Autowired
// private UpmsUserService upmsUserService;
//
// @Autowired
// private UpmsRoleService upmsRoleService;
//
// @Autowired
// private UpmsPermissionService upmsPermissionService;
//
// @Autowired
// private UpmsApiService upmsApiService;
//
// @Autowired
// private CmsArticleService cmsArticleService;
//
// @Autowired
// private CmsCategoryService cmsCategoryService;
//
// @Autowired
// private CmsCommentService cmsCommentService;
//
// @Autowired
// private CmsTagService cmsTagService;
//
@Override
public String hello(String name) {
return "hello," + name + "!";

View File

@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Api(value = "test", description = "test")
public class TestController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(TestController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TestController.class);
@Autowired
private ApiService apiService;

View File

@ -15,25 +15,27 @@ import javax.jms.TextMessage;
*/
public class DefaultMessageQueueListener implements MessageListener {
private static Logger _log = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
public void onMessage(final Message message) {
// 使用线程池多线程处理
threadPoolTaskExecutor.execute(new Runnable() {
public void run() {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
_log.info("消费:{}", textMessage.getText());
} catch (Exception e){
e.printStackTrace();
}
}
}
});
}
@Override
public void onMessage(final Message message) {
// 使用线程池多线程处理
threadPoolTaskExecutor.execute(new Runnable() {
@Override
public void run() {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
LOGGER.info("消费:{}", textMessage.getText());
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
}
}

View File

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@Api(value = "后台控制器", description = "后台管理")
public class ManageController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(ManageController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ManageController.class);
/**
* 后台首页

View File

@ -37,7 +37,7 @@ import java.util.Map;
@RequestMapping("/manage/article")
public class CmsArticleController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsArticleController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleController.class);
@Autowired
private CmsArticleService cmsArticleService;
@ -67,7 +67,7 @@ public class CmsArticleController extends BaseController {
}
List<CmsArticle> rows = cmsArticleService.selectByExampleForOffsetPage(cmsArticleExample, offset, limit);
long total = cmsArticleService.countByExample(cmsArticleExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -34,7 +34,7 @@ import java.util.Map;
@RequestMapping("/manage/category")
public class CmsCategoryController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsCategoryController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCategoryController.class);
@Autowired
private CmsCategoryService cmsCategoryService;
@ -61,7 +61,7 @@ public class CmsCategoryController extends BaseController {
}
List<CmsCategory> rows = cmsCategoryService.selectByExampleForOffsetPage(cmsCategoryExample, offset, limit);
long total = cmsCategoryService.countByExample(cmsCategoryExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -30,7 +30,7 @@ import java.util.Map;
@RequestMapping("/manage/comment")
public class CmsCommentController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsCommentController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCommentController.class);
@Autowired
private CmsCommentService cmsCommentService;
@ -57,7 +57,7 @@ public class CmsCommentController extends BaseController {
}
List<CmsComment> rows = cmsCommentService.selectByExampleWithBLOBsForOffsetPage(cmsCommentExample, offset, limit);
long total = cmsCommentService.countByExample(cmsCommentExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -34,7 +34,7 @@ import java.util.Map;
@RequestMapping("/manage/menu")
public class CmsMenuController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsMenuController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsMenuController.class);
@Autowired
private CmsMenuService cmsMenuService;
@ -61,7 +61,7 @@ public class CmsMenuController extends BaseController {
}
List<CmsMenu> rows = cmsMenuService.selectByExampleForOffsetPage(cmsMenuExample, offset, limit);
long total = cmsMenuService.countByExample(cmsMenuExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -34,7 +34,7 @@ import java.util.Map;
@RequestMapping("/manage/page")
public class CmsPageController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsPageController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsPageController.class);
@Autowired
private CmsPageService cmsPageService;
@ -61,7 +61,7 @@ public class CmsPageController extends BaseController {
}
List<CmsPage> rows = cmsPageService.selectByExampleForOffsetPage(cmsPageExample, offset, limit);
long total = cmsPageService.countByExample(cmsPageExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -35,7 +35,7 @@ import java.util.Map;
@RequestMapping("/manage/setting")
public class CmsSettingController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsSettingController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsSettingController.class);
@Autowired
private CmsSettingService cmsSettingService;
@ -62,7 +62,7 @@ public class CmsSettingController extends BaseController {
}
List<CmsSetting> rows = cmsSettingService.selectByExampleForOffsetPage(cmsSettingExample, offset, limit);
long total = cmsSettingService.countByExample(cmsSettingExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -34,7 +34,7 @@ import java.util.Map;
@RequestMapping("/manage/tag")
public class CmsTagController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsTagController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsTagController.class);
@Autowired
private CmsTagService cmsTagService;
@ -61,7 +61,7 @@ public class CmsTagController extends BaseController {
}
List<CmsTag> rows = cmsTagService.selectByExampleForOffsetPage(cmsTagExample, offset, limit);
long total = cmsTagService.countByExample(cmsTagExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -34,7 +34,7 @@ import java.util.Map;
@RequestMapping("/manage/topic")
public class CmsTopicController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(CmsTopicController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsTopicController.class);
@Autowired
private CmsTopicService cmsTopicService;
@ -61,7 +61,7 @@ public class CmsTopicController extends BaseController {
}
List<CmsTopic> rows = cmsTopicService.selectByExampleForOffsetPage(cmsTopicExample, offset, limit);
long total = cmsTopicService.countByExample(cmsTopicExample);
Map<String, Object> result = new HashMap<>();
Map<String, Object> result = new HashMap<>(2);
result.put("rows", rows);
result.put("total", total);
return result;

View File

@ -1,4 +1,4 @@
package com.zheng.cms.admin.Interceptor;
package com.zheng.cms.admin.interceptor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -14,7 +14,7 @@ import javax.servlet.http.HttpServletResponse;
*/
public class ManageInterceptor extends HandlerInterceptorAdapter {
private static Logger _log = LoggerFactory.getLogger(ManageInterceptor.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ManageInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {

View File

@ -15,19 +15,21 @@ import javax.jms.TextMessage;
*/
public class DefaultMessageQueueListener implements MessageListener {
private static Logger _log = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
public void onMessage(final Message message) {
@Override
public void onMessage(final Message message) {
// 使用线程池多线程处理
threadPoolTaskExecutor.execute(new Runnable() {
public void run() {
@Override
public void run() {
if (message instanceof TextMessage) {
TextMessage textMessage = (TextMessage) message;
try {
_log.info("消费消息:{}", textMessage.getText());
LOGGER.info("消费消息:{}", textMessage.getText());
} catch (Exception e){
e.printStackTrace();
}

View File

@ -19,7 +19,7 @@
<!-- 非拦截路径 -->
<mvc:exclude-mapping path="/manage/login"/>
<!-- 拦截器对象 -->
<bean id="manageInterceptor" class="com.zheng.cms.admin.Interceptor.ManageInterceptor"/>
<bean id="manageInterceptor" class="com.zheng.cms.admin.interceptor.ManageInterceptor"/>
</mvc:interceptor>
</mvc:interceptors>

View File

@ -6,11 +6,29 @@ package com.zheng.cms.common.constant;
*/
public enum CmsResultConstant {
/**
* 失败
*/
FAILED(0, "failed"),
/**
* 成功
*/
SUCCESS(1, "success"),
/**
* 文件类型不支持
*/
FILE_TYPE_ERROR(20001, "File type not supported!"),
/**
* 无效长度
*/
INVALID_LENGTH(20002, "Invalid length"),
/**
* 无效参数
*/
INVALID_PARAMETER(20003, "Invalid parameter");
public int code;

View File

@ -15,19 +15,21 @@ import javax.jms.TextMessage;
*/
public class DefaultMessageQueueListener implements MessageListener {
private static Logger _log = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
public void onMessage(final Message message) {
// 使用线程池多线程处理
threadPoolTaskExecutor.execute(new Runnable() {
@Override
public void run() {
TextMessage textMessage = (TextMessage) message;
try {
String text = textMessage.getText();
_log.info("消费:{}", text);
LOGGER.info("消费:{}", text);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -1,8 +1,8 @@
package com.zheng.cms.rpc.api;
import com.zheng.common.base.BaseService;
import com.zheng.cms.dao.model.CmsArticle;
import com.zheng.cms.dao.model.CmsArticleExample;
import com.zheng.common.base.BaseService;
import java.util.List;
@ -12,16 +12,36 @@ import java.util.List;
*/
public interface CmsArticleService extends BaseService<CmsArticle, CmsArticleExample> {
// 根据类目获取文章列表
/**
* 根据类目获取文章列表
* @param categoryId
* @param offset
* @param limit
* @return
*/
List<CmsArticle> selectCmsArticlesByCategoryId(Integer categoryId, Integer offset, Integer limit);
// 根据类目获取文章数量
/**
* 根据类目获取文章数量
* @param categoryId
* @return
*/
long countByCategoryId(Integer categoryId);
// 根据标签获取文章列表
/**
* 根据标签获取文章列表
* @param tagId
* @param offset
* @param limit
* @return
*/
List<CmsArticle> selectCmsArticlesByTagId(Integer tagId, Integer offset, Integer limit);
// 根据标签获取文章数量
/**
* 根据标签获取文章数量
* @param tagId
* @return
*/
long countByTagId(Integer tagId);
}

View File

@ -15,29 +15,29 @@ import java.util.List;
*/
public class CmsArticleServiceMock extends BaseServiceMock<CmsArticleMapper, CmsArticle, CmsArticleExample> implements CmsArticleService {
private static Logger _log = LoggerFactory.getLogger(CmsArticleServiceMock.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleServiceMock.class);
@Override
public List<CmsArticle> selectCmsArticlesByCategoryId(Integer categoryId, Integer offset, Integer limit) {
_log.info("CmsArticleServiceMock => getCmsArticlesByCategoryId");
LOGGER.info("CmsArticleServiceMock => getCmsArticlesByCategoryId");
return null;
}
@Override
public long countByCategoryId(Integer categoryId) {
_log.info("CmsArticleServiceMock => countByCategoryId");
LOGGER.info("CmsArticleServiceMock => countByCategoryId");
return 0;
}
@Override
public List<CmsArticle> selectCmsArticlesByTagId(Integer tagId, Integer offset, Integer limit) {
_log.info("CmsArticleServiceMock => getCmsArticlesByCategoryId");
LOGGER.info("CmsArticleServiceMock => getCmsArticlesByCategoryId");
return null;
}
@Override
public long countByTagId(Integer tagId) {
_log.info("CmsArticleServiceMock => countByTagId");
LOGGER.info("CmsArticleServiceMock => countByTagId");
return 0;
}

View File

@ -10,12 +10,12 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class ZhengCmsRpcServiceApplication {
private static Logger _log = LoggerFactory.getLogger(ZhengCmsRpcServiceApplication.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ZhengCmsRpcServiceApplication.class);
public static void main(String[] args) {
_log.info(">>>>> zheng-cms-rpc-service 正在启动 <<<<<");
LOGGER.info(">>>>> zheng-cms-rpc-service 正在启动 <<<<<");
new ClassPathXmlApplicationContext("classpath:META-INF/spring/*.xml");
_log.info(">>>>> zheng-cms-rpc-service 启动完成 <<<<<");
LOGGER.info(">>>>> zheng-cms-rpc-service 启动完成 <<<<<");
}
}

View File

@ -1,11 +1,11 @@
package com.zheng.cms.rpc.service.impl;
import com.zheng.common.annotation.BaseService;
import com.zheng.common.base.BaseServiceImpl;
import com.zheng.cms.dao.mapper.CmsArticleCategoryMapper;
import com.zheng.cms.dao.model.CmsArticleCategory;
import com.zheng.cms.dao.model.CmsArticleCategoryExample;
import com.zheng.cms.rpc.api.CmsArticleCategoryService;
import com.zheng.common.annotation.BaseService;
import com.zheng.common.base.BaseServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsArticleCategoryServiceImpl extends BaseServiceImpl<CmsArticleCategoryMapper, CmsArticleCategory, CmsArticleCategoryExample> implements CmsArticleCategoryService {
private static Logger _log = LoggerFactory.getLogger(CmsArticleCategoryServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleCategoryServiceImpl.class);
@Autowired
CmsArticleCategoryMapper cmsArticleCategoryMapper;

View File

@ -24,7 +24,7 @@ import java.util.List;
@BaseService
public class CmsArticleServiceImpl extends BaseServiceImpl<CmsArticleMapper, CmsArticle, CmsArticleExample> implements CmsArticleService {
private static Logger _log = LoggerFactory.getLogger(CmsArticleServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleServiceImpl.class);
@Autowired
CmsArticleMapper cmsArticleMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsArticleTagServiceImpl extends BaseServiceImpl<CmsArticleTagMapper, CmsArticleTag, CmsArticleTagExample> implements CmsArticleTagService {
private static Logger _log = LoggerFactory.getLogger(CmsArticleTagServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsArticleTagServiceImpl.class);
@Autowired
CmsArticleTagMapper cmsArticleTagMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsCategoryServiceImpl extends BaseServiceImpl<CmsCategoryMapper, CmsCategory, CmsCategoryExample> implements CmsCategoryService {
private static Logger _log = LoggerFactory.getLogger(CmsCategoryServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCategoryServiceImpl.class);
@Autowired
CmsCategoryMapper cmsCategoryMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsCategoryTagServiceImpl extends BaseServiceImpl<CmsCategoryTagMapper, CmsCategoryTag, CmsCategoryTagExample> implements CmsCategoryTagService {
private static Logger _log = LoggerFactory.getLogger(CmsCategoryTagServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCategoryTagServiceImpl.class);
@Autowired
CmsCategoryTagMapper cmsCategoryTagMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsCommentServiceImpl extends BaseServiceImpl<CmsCommentMapper, CmsComment, CmsCommentExample> implements CmsCommentService {
private static Logger _log = LoggerFactory.getLogger(CmsCommentServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsCommentServiceImpl.class);
@Autowired
CmsCommentMapper cmsCommentMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsMenuServiceImpl extends BaseServiceImpl<CmsMenuMapper, CmsMenu, CmsMenuExample> implements CmsMenuService {
private static Logger _log = LoggerFactory.getLogger(CmsMenuServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsMenuServiceImpl.class);
@Autowired
CmsMenuMapper cmsMenuMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsPageServiceImpl extends BaseServiceImpl<CmsPageMapper, CmsPage, CmsPageExample> implements CmsPageService {
private static Logger _log = LoggerFactory.getLogger(CmsPageServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsPageServiceImpl.class);
@Autowired
CmsPageMapper cmsPageMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsSettingServiceImpl extends BaseServiceImpl<CmsSettingMapper, CmsSetting, CmsSettingExample> implements CmsSettingService {
private static Logger _log = LoggerFactory.getLogger(CmsSettingServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsSettingServiceImpl.class);
@Autowired
CmsSettingMapper cmsSettingMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsSystemServiceImpl extends BaseServiceImpl<CmsSystemMapper, CmsSystem, CmsSystemExample> implements CmsSystemService {
private static Logger _log = LoggerFactory.getLogger(CmsSystemServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsSystemServiceImpl.class);
@Autowired
CmsSystemMapper cmsSystemMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsTagServiceImpl extends BaseServiceImpl<CmsTagMapper, CmsTag, CmsTagExample> implements CmsTagService {
private static Logger _log = LoggerFactory.getLogger(CmsTagServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsTagServiceImpl.class);
@Autowired
CmsTagMapper cmsTagMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class CmsTopicServiceImpl extends BaseServiceImpl<CmsTopicMapper, CmsTopic, CmsTopicExample> implements CmsTopicService {
private static Logger _log = LoggerFactory.getLogger(CmsTopicServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsTopicServiceImpl.class);
@Autowired
CmsTopicMapper cmsTopicMapper;

View File

@ -27,7 +27,7 @@ import java.util.List;
@RequestMapping(value = "/blog")
public class BlogController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(BlogController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(BlogController.class);
private static String CODE = "blog";
private static Integer USERID = 1;

View File

@ -20,7 +20,7 @@ import java.util.List;
@Controller
public class IndexController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(IndexController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(IndexController.class);
@Autowired
private CmsMenuService cmsMenuService;

View File

@ -27,7 +27,7 @@ import java.util.List;
@RequestMapping(value = "/news")
public class NewsController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(NewsController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(NewsController.class);
private static String CODE = "news";
private static Integer USERID = 1;

View File

@ -21,7 +21,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@RequestMapping(value = "/page")
public class PageController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(PageController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(PageController.class);
@Autowired
private CmsPageService cmsPageService;

View File

@ -27,7 +27,7 @@ import java.util.List;
@RequestMapping(value = "/qa")
public class QaController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(QaController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(QaController.class);
private static String CODE = "qa";
private static Integer USERID = 1;

View File

@ -30,7 +30,7 @@ import java.util.List;
@RequestMapping(value = "/search")
public class SearchController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(SearchController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(SearchController.class);
@Autowired
private CmsArticleService cmsArticleService;

View File

@ -26,7 +26,7 @@ import java.util.List;
@RequestMapping(value = "/topic")
public class TopicController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(TopicController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(TopicController.class);
@Autowired
private CmsTopicService cmsTopicService;

View File

@ -20,7 +20,7 @@ import java.util.List;
*/
public class CmsWebInterceptor extends HandlerInterceptorAdapter {
private static Logger _log = LoggerFactory.getLogger(CmsWebInterceptor.class);
private static final Logger LOGGER = LoggerFactory.getLogger(CmsWebInterceptor.class);
@Autowired
private CmsMenuService cmsMenuService;
@ -28,7 +28,7 @@ public class CmsWebInterceptor extends HandlerInterceptorAdapter {
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 过滤ajax
if (null != request.getHeader("X-Requested-With") && request.getHeader("X-Requested-With").equalsIgnoreCase("XMLHttpRequest")) {
if (null != request.getHeader("X-Requested-With") && "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"))) {
return true;
}
// zheng-ui静态资源配置信息

View File

@ -15,19 +15,21 @@ import javax.jms.TextMessage;
*/
public class DefaultMessageQueueListener implements MessageListener {
private static Logger _log = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DefaultMessageQueueListener.class);
@Autowired
ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
public void onMessage(final Message message) {
// 使用线程池多线程处理
threadPoolTaskExecutor.execute(new Runnable() {
@Override
public void run() {
TextMessage textMessage = (TextMessage) message;
try {
String text = textMessage.getText();
_log.info("消费:{}", text);
LOGGER.info("消费:{}", text);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -15,31 +15,32 @@ import java.util.List;
*/
public class Consumer {
public static void main(String[] args){
DefaultMQPushConsumer consumer =
new DefaultMQPushConsumer("PushConsumer");
consumer.setNamesrvAddr("127.0.0.1:9876");
try {
//订阅PushTopic下Tag为push的消息
consumer.subscribe("PushTopic", "push");
//程序第一次启动从消息队列头取数据
consumer.setConsumeFromWhere(
ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
consumer.registerMessageListener(
new MessageListenerConcurrently() {
public ConsumeConcurrentlyStatus consumeMessage(
List<MessageExt> list,
ConsumeConcurrentlyContext Context) {
Message msg = list.get(0);
System.out.println(msg.toString());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}
);
consumer.start();
} catch (Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
DefaultMQPushConsumer consumer =
new DefaultMQPushConsumer("PushConsumer");
consumer.setNamesrvAddr("127.0.0.1:9876");
try {
//订阅PushTopic下Tag为push的消息
consumer.subscribe("PushTopic", "push");
//程序第一次启动从消息队列头取数据
consumer.setConsumeFromWhere(
ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
consumer.registerMessageListener(
new MessageListenerConcurrently() {
@Override
public ConsumeConcurrentlyStatus consumeMessage(
List<MessageExt> list,
ConsumeConcurrentlyContext context) {
Message msg = list.get(0);
System.out.println(msg.toString());
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}
);
consumer.start();
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@ -9,24 +9,27 @@ import com.alibaba.rocketmq.common.message.Message;
*/
public class Producer {
public static void main(String[] args) {
DefaultMQProducer producer = new DefaultMQProducer("Producer");
producer.setNamesrvAddr("127.0.0.1:9876");
try {
producer.start();
long time = System.currentTimeMillis();
System.out.println("开始:" + time);
for (int i = 1; i <= 100000; i ++) {
Message msg = new Message("PushTopic", "push", i + "", "Just for test.".getBytes());
SendResult result = producer.send(msg);
//System.out.println("id:" + result.getMsgId() + " result:" + result.getSendStatus());
}
System.out.println("结束,消耗:" + (System.currentTimeMillis() - time));
} catch (Exception e) {
e.printStackTrace();
} finally {
producer.shutdown();
}
}
public static void main(String[] args) {
DefaultMQProducer producer = new DefaultMQProducer("Producer");
producer.setNamesrvAddr("127.0.0.1:9876");
try {
producer.start();
long time = System.currentTimeMillis();
System.out.println("开始:" + time);
int a = 100000;
for (int i = 1; i <= a; i++) {
Message msg = new Message("PushTopic", "push", i + "", "Just for test.".getBytes());
SendResult result = producer.send(msg);
System.out.println("id:" + result.getMsgId() + " result:" + result.getSendStatus());
}
System.out.println("结束,消耗:" + (System.currentTimeMillis() - time));
} catch (Exception e) {
e.printStackTrace();
} finally {
producer.shutdown();
}
}
}

View File

@ -15,7 +15,7 @@ import java.util.List;
*/
public class LongSchedule implements IScheduleTaskDealSingle<Long> {
private static Logger _log = LoggerFactory.getLogger(LongSchedule.class);
private static final Logger LOGGER = LoggerFactory.getLogger(LongSchedule.class);
/**
* 执行单个任务
@ -25,7 +25,7 @@ public class LongSchedule implements IScheduleTaskDealSingle<Long> {
*/
@Override
public boolean execute(Long item, String ownSign) throws Exception {
_log.info("执行任务:{}", item);
LOGGER.info("执行任务:{}", item);
return true;
}
@ -53,6 +53,7 @@ public class LongSchedule implements IScheduleTaskDealSingle<Long> {
@Override
public Comparator<Long> getComparator() {
return new Comparator<Long>() {
@Override
public int compare(Long o1, Long o2) {
return o1.compareTo(o2);
}

View File

@ -13,7 +13,7 @@ import java.util.*;
*/
public class MapSchedule implements IScheduleTaskDealSingle<Map> {
private static Logger _log = LoggerFactory.getLogger(MapSchedule.class);
private static final Logger LOGGER = LoggerFactory.getLogger(MapSchedule.class);
/**
* 执行单个任务
@ -23,7 +23,7 @@ public class MapSchedule implements IScheduleTaskDealSingle<Map> {
*/
@Override
public boolean execute(Map item, String ownSign) throws Exception {
_log.info("执行任务:{}", item);
LOGGER.info("执行任务:{}", item);
return true;
}
@ -40,7 +40,7 @@ public class MapSchedule implements IScheduleTaskDealSingle<Map> {
@Override
public List<Map> selectTasks(String taskParameter, String ownSign, int taskItemNum, List<TaskItemDefine> taskItemList, int eachFetchDataNum) throws Exception {
List<Map> allDrawList = new ArrayList<>();
Map map = new HashMap();
Map map = new HashMap(1);
map.put("ID", System.currentTimeMillis());
allDrawList.add(map);
return allDrawList;
@ -53,11 +53,14 @@ public class MapSchedule implements IScheduleTaskDealSingle<Map> {
@Override
public Comparator<Map> getComparator() {
return new Comparator<Map>() {
@Override
public int compare(Map o1, Map o2) {
Long l1 = (Long) o1.get("ID");
Long l2 = (Long) o2.get("ID");
return l1.compareTo(l2);
}
@Override
public boolean equals(Object obj) {
return this == obj;
}

View File

@ -15,7 +15,7 @@ import org.slf4j.LoggerFactory;
*/
public class RpcLogAspect {
private static Logger _log = LoggerFactory.getLogger(RpcLogAspect.class);
private static final Logger LOGGER = LoggerFactory.getLogger(RpcLogAspect.class);
// 开始时间
private long startTime = 0L;
@ -24,13 +24,13 @@ public class RpcLogAspect {
@Before("execution(* *..rpc..*.*(..))")
public void doBeforeInServiceLayer(JoinPoint joinPoint) {
_log.debug("doBeforeInServiceLayer");
LOGGER.debug("doBeforeInServiceLayer");
startTime = System.currentTimeMillis();
}
@After("execution(* *..rpc..*.*(..))")
public void doAfterInServiceLayer(JoinPoint joinPoint) {
_log.debug("doAfterInServiceLayer");
LOGGER.debug("doAfterInServiceLayer");
}
@Around("execution(* *..rpc..*.*(..))")
@ -42,7 +42,7 @@ public class RpcLogAspect {
String ip = RpcContext.getContext().getRemoteHost();
// 服务url
String rpcUrl = RpcContext.getContext().getUrl().getParameter("application");
_log.info("consumerSide={}, ip={}, url={}", consumerSide, ip, rpcUrl);
LOGGER.info("consumerSide={}, ip={}, url={}", consumerSide, ip, rpcUrl);
return result;
}

View File

@ -9,7 +9,6 @@ import org.springframework.web.bind.annotation.ExceptionHandler;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
/**
* 控制器基类
@ -17,7 +16,7 @@ import java.io.File;
*/
public abstract class BaseController {
private final static Logger _log = LoggerFactory.getLogger(BaseController.class);
private final static Logger LOGGER = LoggerFactory.getLogger(BaseController.class);
/**
* 统一异常处理
@ -27,9 +26,9 @@ public abstract class BaseController {
*/
@ExceptionHandler
public String exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) {
_log.error("统一异常处理:", exception);
LOGGER.error("统一异常处理:", exception);
request.setAttribute("ex", exception);
if (null != request.getHeader("X-Requested-With") && request.getHeader("X-Requested-With").equalsIgnoreCase("XMLHttpRequest")) {
if (null != request.getHeader("X-Requested-With") && "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"))) {
request.setAttribute("requestHeader", "ajax");
}
// shiro没有权限异常

View File

@ -6,7 +6,9 @@ package com.zheng.common.base;
*/
public interface BaseInterface {
// 系统初始化
/**
* 系统初始化
*/
void init();
}

View File

@ -6,13 +6,19 @@ package com.zheng.common.base;
*/
public class BaseResult {
// 状态码1成功其他为失败
/**
* 状态码1成功其他为失败
*/
public int code;
// 成功为success其他为失败原因
/**
* 成功为success其他为失败原因
*/
public String message;
// 数据结果集
/**
* 数据结果集
*/
public Object data;
public BaseResult(int code, String message, Object data) {

View File

@ -10,48 +10,167 @@ import java.util.List;
*/
public interface BaseService<Record, Example> {
int countByExample(Example example);
/**
* 根据条件查询记录数量
* @param example
* @return
*/
int countByExample(Example example);
int deleteByExample(Example example);
/**
* 根据条件删除记录
* @param example
* @return
*/
int deleteByExample(Example example);
int deleteByPrimaryKey(Integer id);
/**
* 根据主键删除记录
* @param id
* @return
*/
int deleteByPrimaryKey(Integer id);
int insert(Record record);
/**
* 插入记录
* @param record
* @return
*/
int insert(Record record);
int insertSelective(Record record);
/**
* 插入记录有效字段
* @param record
* @return
*/
int insertSelective(Record record);
List<Record> selectByExampleWithBLOBs(Example example);
/**
* 根据条件查询记录附带BLOB字段
* @param example
* @return
*/
List<Record> selectByExampleWithBLOBs(Example example);
List<Record> selectByExample(Example example);
/**
* 根据条件查询记录
* @param example
* @return
*/
List<Record> selectByExample(Example example);
List<Record> selectByExampleWithBLOBsForStartPage(Example example, Integer pageNum, Integer pageSize);
/**
* 根据条件查询记录并按页码分页附带BLOB字段
* @param example 条件
* @param pageNum 页数
* @param pageSize 每页记录数
* @return
*/
List<Record> selectByExampleWithBLOBsForStartPage(Example example, Integer pageNum, Integer pageSize);
List<Record> selectByExampleForStartPage(Example example, Integer pageNum, Integer pageSize);
/**
* 根据条件查询记录并按页码分页
* @param example 条件
* @param pageNum 页数
* @param pageSize 每页记录数
* @return
*/
List<Record> selectByExampleForStartPage(Example example, Integer pageNum, Integer pageSize);
List<Record> selectByExampleWithBLOBsForOffsetPage(Example example, Integer offset, Integer limit);
/**
* 根据条件查询记录并按最后记录数分页附带BLOB字段
* @param example 条件
* @param offset 跳过数量
* @param limit 查询数量
* @return
*/
List<Record> selectByExampleWithBLOBsForOffsetPage(Example example, Integer offset, Integer limit);
List<Record> selectByExampleForOffsetPage(Example example, Integer offset, Integer limit);
/**
* 根据条件查询记录并按最后记录数分页
* @param example 条件
* @param offset 跳过数量
* @param limit 查询数量
* @return
*/
List<Record> selectByExampleForOffsetPage(Example example, Integer offset, Integer limit);
Record selectFirstByExample(Example example);
/**
* 根据条件查询第一条记录
* @param example
* @return
*/
Record selectFirstByExample(Example example);
Record selectFirstByExampleWithBLOBs(Example example);
/**
* 根据条件查询第一条记录附带BLOB字段
* @param example
* @return
*/
Record selectFirstByExampleWithBLOBs(Example example);
Record selectByPrimaryKey(Integer id);
/**
* 根据主键查询记录
* @param id
* @return
*/
Record selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") Record record, @Param("example") Example example);
/**
* 根据条件更新有效字段
* @param record
* @param example
* @return
*/
int updateByExampleSelective(@Param("record") Record record, @Param("example") Example example);
int updateByExampleWithBLOBs(@Param("record") Record record, @Param("example") Example example);
/**
* 根据条件更新记录有效字段附带BLOB字段
* @param record
* @param example
* @return
*/
int updateByExampleWithBLOBs(@Param("record") Record record, @Param("example") Example example);
int updateByExample(@Param("record") Record record, @Param("example") Example example);
/**
* 根据条件更新记录
* @param record
* @param example
* @return
*/
int updateByExample(@Param("record") Record record, @Param("example") Example example);
int updateByPrimaryKeySelective(Record record);
/**
* 根据主键更新记录有效字段
* @param record
* @return
*/
int updateByPrimaryKeySelective(Record record);
int updateByPrimaryKeyWithBLOBs(Record record);
/**
* 根据主键更新记录附带BLOB字段
* @param record
* @return
*/
int updateByPrimaryKeyWithBLOBs(Record record);
int updateByPrimaryKey(Record record);
/**
* 根据主键更新记录
* @param record
* @return
*/
int updateByPrimaryKey(Record record);
int deleteByPrimaryKeys(String ids);
/**
* 根据主键批量删除记录
* @param ids
* @return
*/
int deleteByPrimaryKeys(String ids);
void initMapper();
/**
* 初始化mapper
*/
void initMapper();
}

View File

@ -10,43 +10,45 @@ import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;
*/
public class DynamicDataSource extends AbstractRoutingDataSource {
private final static Logger _log = LoggerFactory.getLogger(DynamicDataSource.class);
private final static Logger LOGGER = LoggerFactory.getLogger(DynamicDataSource.class);
private static final ThreadLocal<String> contextHolder = new ThreadLocal<>();
private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
@Override
protected Object determineCurrentLookupKey() {
String dataSource = getDataSource();
_log.info("当前操作使用的数据源:{}", dataSource);
return dataSource;
}
@Override
protected Object determineCurrentLookupKey() {
String dataSource = getDataSource();
LOGGER.info("当前操作使用的数据源:{}", dataSource);
return dataSource;
}
/**
* 设置数据源
* @param dataSource
*/
public static void setDataSource(String dataSource) {
contextHolder.set(dataSource);
}
/**
* 设置数据源
*
* @param dataSource
*/
public static void setDataSource(String dataSource) {
CONTEXT_HOLDER.set(dataSource);
}
/**
* 获取数据源
* @return
*/
public static String getDataSource() {
String dataSource = contextHolder.get();
// 如果没有指定数据源使用默认数据源
if (null == dataSource) {
DynamicDataSource.setDataSource(DataSourceEnum.MASTER.getDefault());
}
return contextHolder.get();
}
/**
* 获取数据源
*
* @return
*/
public static String getDataSource() {
String dataSource = CONTEXT_HOLDER.get();
// 如果没有指定数据源使用默认数据源
if (null == dataSource) {
DynamicDataSource.setDataSource(DataSourceEnum.MASTER.getDefault());
}
return CONTEXT_HOLDER.get();
}
/**
* 清除数据源
*/
public static void clearDataSource() {
contextHolder.remove();
}
/**
* 清除数据源
*/
public static void clearDataSource() {
CONTEXT_HOLDER.remove();
}
}

View File

@ -16,22 +16,22 @@ import java.util.Map;
*/
public class ApplicationContextListener implements ApplicationListener<ContextRefreshedEvent> {
private static Logger _log = LoggerFactory.getLogger(ApplicationContextListener.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ApplicationContextListener.class);
@Override
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
// root application context
if(null == contextRefreshedEvent.getApplicationContext().getParent()) {
_log.debug(">>>>> spring初始化完毕 <<<<<");
LOGGER.debug(">>>>> spring初始化完毕 <<<<<");
// spring初始化完毕后通过反射调用所有使用BaseService注解的initMapper方法
Map<String, Object> baseServices = contextRefreshedEvent.getApplicationContext().getBeansWithAnnotation(BaseService.class);
for(Object service : baseServices.values()) {
_log.debug(">>>>> {}.initMapper()", service.getClass().getName());
LOGGER.debug(">>>>> {}.initMapper()", service.getClass().getName());
try {
Method initMapper = service.getClass().getMethod("initMapper");
initMapper.invoke(service);
} catch (Exception e) {
_log.error("初始化BaseService的initMapper方法异常", e);
LOGGER.error("初始化BaseService的initMapper方法异常", e);
e.printStackTrace();
}
}
@ -39,12 +39,12 @@ public class ApplicationContextListener implements ApplicationListener<ContextRe
// 系统入口初始化
Map<String, BaseInterface> baseInterfaceBeans = contextRefreshedEvent.getApplicationContext().getBeansOfType(BaseInterface.class);
for(Object service : baseInterfaceBeans.values()) {
_log.debug(">>>>> {}.init()", service.getClass().getName());
LOGGER.debug(">>>>> {}.init()", service.getClass().getName());
try {
Method init = service.getClass().getMethod("init");
init.invoke(service);
} catch (Exception e) {
_log.error("初始化BaseInterface的init方法异常", e);
LOGGER.error("初始化BaseInterface的init方法异常", e);
e.printStackTrace();
}
}

View File

@ -14,7 +14,7 @@ public class CommentGenerator extends DefaultCommentGenerator {
@Override
public void addFieldComment(Field field, IntrospectedTable introspectedTable, IntrospectedColumn introspectedColumn) {
super.addFieldComment(field, introspectedTable, introspectedColumn);
if (introspectedColumn.getRemarks() != null && !introspectedColumn.getRemarks().equals("")) {
if (introspectedColumn.getRemarks() != null && !"".equals(introspectedColumn.getRemarks())) {
field.addJavaDocLine("/**");
field.addJavaDocLine(" * " + introspectedColumn.getRemarks());
addJavadocTag(field, false);

View File

@ -23,7 +23,7 @@ public class EncryptPropertyPlaceholderConfigurer extends PropertyPlaceholderCon
protected String convertProperty(String propertyName, String propertyValue) {
for (String p : propertyNames) {
if (p.equalsIgnoreCase(propertyName)) {
return AESUtil.AESDecode(propertyValue);
return AESUtil.aesDecode(propertyValue);
}
}
return super.convertProperty(propertyName, propertyValue);

View File

@ -20,26 +20,31 @@ public class SerializablePlugin extends PluginAdapter {
public SerializablePlugin() {
}
@Override
public boolean validate(List<String> warnings) {
return true;
}
@Override
public void setProperties(Properties properties) {
super.setProperties(properties);
this.addGWTInterface = Boolean.valueOf(properties.getProperty("addGWTInterface")).booleanValue();
this.suppressJavaInterface = Boolean.valueOf(properties.getProperty("suppressJavaInterface")).booleanValue();
}
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
this.makeSerializable(topLevelClass, introspectedTable);
return true;
}
@Override
public boolean modelPrimaryKeyClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
this.makeSerializable(topLevelClass, introspectedTable);
return true;
}
@Override
public boolean modelRecordWithBLOBsClassGenerated(TopLevelClass topLevelClass, IntrospectedTable introspectedTable) {
this.makeSerializable(topLevelClass, introspectedTable);
return true;

View File

@ -17,7 +17,7 @@ import java.security.SecureRandom;
*/
public class AESUtil {
private static final String encodeRules = "zheng";
private static final String ENCODE_RULES = "zheng";
/**
* 加密
@ -28,19 +28,19 @@ public class AESUtil {
* 5.内容加密
* 6.返回字符串
*/
public static String AESEncode(String content) {
public static String aesEncode(String content) {
try {
//1.构造密钥生成器指定为AES算法,不区分大小写
KeyGenerator keygen = KeyGenerator.getInstance("AES");
KeyGenerator keyGenerator = KeyGenerator.getInstance("AES");
//2.根据ecnodeRules规则初始化密钥生成器
//生成一个128位的随机源,根据传入的字节数组
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
random.setSeed(encodeRules.getBytes());
keygen.init(128, random);
random.setSeed(ENCODE_RULES.getBytes());
keyGenerator.init(128, random);
//3.产生原始对称密钥
SecretKey original_key = keygen.generateKey();
SecretKey originalKey = keyGenerator.generateKey();
//4.获得原始对称密钥的字节数组
byte[] raw = original_key.getEncoded();
byte[] raw = originalKey.getEncoded();
//5.根据字节数组生成AES密钥
SecretKey key = new SecretKeySpec(raw, "AES");
//6.根据指定算法AES自成密码器
@ -48,16 +48,16 @@ public class AESUtil {
//7.初始化密码器第一个参数为加密(Encrypt_mode)或者解密解密(Decrypt_mode)操作第二个参数为使用的KEY
cipher.init(Cipher.ENCRYPT_MODE, key);
//8.获取加密内容的字节数组(这里要设置为utf-8)不然内容中如果有中文和英文混合中文就会解密为乱码
byte[] byte_encode = content.getBytes("utf-8");
byte[] byteEncode = content.getBytes("utf-8");
//9.根据密码器的初始化方式--加密将数据加密
byte[] byte_AES = cipher.doFinal(byte_encode);
byte[] byteAES = cipher.doFinal(byteEncode);
//10.将加密后的数据转换为字符串
//这里用Base64Encoder中会找不到包
//解决办法
//在项目的Build path中先移除JRE System Library再添加库JRE System Library重新编译后就一切正常了
String AES_encode = new String(new BASE64Encoder().encode(byte_AES));
String aesEncode = new String(new BASE64Encoder().encode(byteAES));
//11.将字符串返回
return AES_encode;
return aesEncode;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
@ -82,19 +82,19 @@ public class AESUtil {
* 2.将加密后的字符串反纺成byte[]数组
* 3.将加密内容解密
*/
public static String AESDecode(String content) {
public static String aesDecode(String content) {
try {
//1.构造密钥生成器指定为AES算法,不区分大小写
KeyGenerator keygen = KeyGenerator.getInstance("AES");
//2.根据ecnodeRules规则初始化密钥生成器
//生成一个128位的随机源,根据传入的字节数组
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
random.setSeed(encodeRules.getBytes());
random.setSeed(ENCODE_RULES.getBytes());
keygen.init(128, random);
//3.产生原始对称密钥
SecretKey original_key = keygen.generateKey();
SecretKey originalKey = keygen.generateKey();
//4.获得原始对称密钥的字节数组
byte[] raw = original_key.getEncoded();
byte[] raw = originalKey.getEncoded();
//5.根据字节数组生成AES密钥
SecretKey key = new SecretKeySpec(raw, "AES");
//6.根据指定算法AES自成密码器
@ -102,13 +102,13 @@ public class AESUtil {
//7.初始化密码器第一个参数为加密(Encrypt_mode)或者解密(Decrypt_mode)操作第二个参数为使用的KEY
cipher.init(Cipher.DECRYPT_MODE, key);
//8.将加密并编码后的内容解码成字节数组
byte[] byte_content = new BASE64Decoder().decodeBuffer(content);
byte[] byteContent = new BASE64Decoder().decodeBuffer(content);
/*
* 解密
*/
byte[] byte_decode = cipher.doFinal(byte_content);
String AES_decode = new String(byte_decode, "utf-8");
return AES_decode;
byte[] byteDecode = cipher.doFinal(byteContent);
String aesDecode = new String(byteDecode, "utf-8");
return aesDecode;
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (NoSuchPaddingException e) {
@ -134,9 +134,9 @@ public class AESUtil {
System.out.println("key | AESEncode | AESDecode");
for (String key : keys) {
System.out.print(key + " | ");
String encryptString = AESEncode(key);
String encryptString = aesEncode(key);
System.out.print(encryptString + " | ");
String decryptString = AESDecode(encryptString);
String decryptString = aesDecode(encryptString);
System.out.println(decryptString);
}
}

View File

@ -53,8 +53,10 @@ public class CaptchaUtil {
// 生成图片
private void creatImage() {
int fontWidth = width / codeCount;// 字体的宽度
int fontHeight = height - 5;// 字体的高度
// 字体的宽度
int fontWidth = width / codeCount;
// 字体的高度
int fontHeight = height - 5;
int codeY = height - 8;
// 图像buffer
@ -118,10 +120,12 @@ public class CaptchaUtil {
// 得到随机颜色
private Color getRandColor(int fc, int bc) {// 给定范围获得随机颜色
if (fc > 255)
if (fc > 255) {
fc = 255;
if (bc > 255)
}
if (bc > 255) {
bc = 255;
}
int r = fc + random.nextInt(bc - fc);
int g = fc + random.nextInt(bc - fc);
int b = fc + random.nextInt(bc - fc);
@ -133,7 +137,7 @@ public class CaptchaUtil {
*/
private Font getFont(int size) {
Random random = new Random();
Font font[] = new Font[5];
Font[] font = new Font[5];
font[0] = new Font("Ravie", Font.PLAIN, size);
font[1] = new Font("Antique Olive Compact", Font.PLAIN, size);
font[2] = new Font("Fixedsys", Font.PLAIN, size);

View File

@ -20,7 +20,9 @@ public class CookieUtil {
public static void setCookie(HttpServletResponse response, String name, String value, String path, int maxAge) {
Cookie cookie = new Cookie(name, value);
cookie.setPath(path);
if (maxAge > 0) cookie.setMaxAge(maxAge);
if (maxAge > 0) {
cookie.setMaxAge(maxAge);
}
response.addCookie(cookie);
}
public static void setCookie(HttpServletResponse response, String name, String value, int maxAge) {

View File

@ -58,16 +58,16 @@ public class JdbcUtil {
}
rs = pstmt.executeQuery();
ResultSetMetaData metaData = rs.getMetaData();
int cols_len = metaData.getColumnCount();
int colsLen = metaData.getColumnCount();
while (rs.next()) {
Map map = new HashMap();
for (int i = 0; i < cols_len; i ++) {
String cols_name = metaData.getColumnName(i + 1);
Object cols_value = rs.getObject(cols_name);
if (null == cols_value) {
cols_value = "";
Map map = new HashMap(colsLen);
for (int i = 0; i < colsLen; i ++) {
String columnName = metaData.getColumnName(i + 1);
Object columnValue = rs.getObject(columnName);
if (null == columnValue) {
columnValue = "";
}
map.put(cols_name, cols_value);
map.put(columnName, columnValue);
}
list.add(map);
}
@ -77,9 +77,15 @@ public class JdbcUtil {
// 释放连接
public void release() {
try {
if (null != rs) rs.close();
if (null != pstmt) pstmt.close();
if (null != conn) conn.close();
if (null != rs) {
rs.close();
}
if (null != pstmt) {
pstmt.close();
}
if (null != conn) {
conn.close();
}
} catch (SQLException e) {
e.printStackTrace();
}

View File

@ -20,6 +20,7 @@ public class JmsUtil {
*/
public static void sendMessage(JmsTemplate jmsTemplate, Destination destination, final String textMessage) {
jmsTemplate.send(destination, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createTextMessage(textMessage);
}
@ -34,6 +35,7 @@ public class JmsUtil {
*/
public static void sendMessage(JmsTemplate jmsTemplate, Destination destination, final Serializable objectMessage) {
jmsTemplate.send(destination, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
return session.createObjectMessage(objectMessage);
}
@ -49,6 +51,7 @@ public class JmsUtil {
*/
public static void sendMessageDelay(JmsTemplate jmsTemplate, Destination destination, final Serializable objectMessage, final long delay) {
jmsTemplate.send(destination, new MessageCreator() {
@Override
public Message createMessage(Session session) throws JMSException {
ObjectMessage om = session.createObjectMessage(objectMessage);
om.setLongProperty(ScheduledMessage.AMQ_SCHEDULED_DELAY, delay);

View File

@ -8,9 +8,9 @@ import java.util.UUID;
*/
public class MD5Util {
public final static String MD5(String content) {
public final static String md5(String content) {
//用于加密的字符
char md5String[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
char[] md5String = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'};
try {
//使用平台的默认字符集将此 String 编码为 byte序列并将结果存储到一个新的 byte数组中
@ -27,7 +27,7 @@ public class MD5Util {
// 把密文转换成十六进制的字符串形式
int j = md.length;
char str[] = new char[j * 2];
char[] str = new char[j * 2];
int k = 0;
for (int i = 0; i < j; i++) { // i = 0
byte byte0 = md[i]; //95

View File

@ -30,25 +30,25 @@ public class MybatisGeneratorUtil {
/**
* 根据模板生成generatorConfig.xml文件
* @param jdbc_driver 驱动路径
* @param jdbc_url 链接
* @param jdbc_username 帐号
* @param jdbc_password 密码
* @param jdbcDriver 驱动路径
* @param jdbcUrl 链接
* @param jdbcUsername 帐号
* @param jdbcPassword 密码
* @param module 项目模块
* @param database 数据库
* @param table_prefix 表前缀
* @param package_name 包名
* @param tablePrefix 表前缀
* @param packageName 包名
*/
public static void generator(
String jdbc_driver,
String jdbc_url,
String jdbc_username,
String jdbc_password,
String jdbcDriver,
String jdbcUrl,
String jdbcUsername,
String jdbcPassword,
String module,
String database,
String table_prefix,
String package_name,
Map<String, String> last_insert_id_tables) throws Exception{
String tablePrefix,
String packageName,
Map<String, String> lastInsertIdTables) throws Exception{
String os = System.getProperty("os.name");
if (os.toLowerCase().startsWith("win")) {
@ -65,9 +65,9 @@ public class MybatisGeneratorUtil {
String targetProject = module + "/" + module + "-dao";
String basePath = MybatisGeneratorUtil.class.getResource("/").getPath().replace("/target/classes/", "").replace(targetProject, "").replaceFirst("/", "");
String generatorConfig_xml = MybatisGeneratorUtil.class.getResource("/").getPath().replace("/target/classes/", "") + "/src/main/resources/generatorConfig.xml";
String generatorConfigXml = MybatisGeneratorUtil.class.getResource("/").getPath().replace("/target/classes/", "") + "/src/main/resources/generatorConfig.xml";
targetProject = basePath + targetProject;
String sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" + database + "' AND table_name LIKE '" + table_prefix + "_%';";
String sql = "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema = '" + database + "' AND table_name LIKE '" + tablePrefix + "_%';";
System.out.println("========== 开始生成generatorConfig.xml文件 ==========");
List<Map<String, Object>> tables = new ArrayList<>();
@ -76,31 +76,31 @@ public class MybatisGeneratorUtil {
Map<String, Object> table;
// 查询定制前缀项目的所有表
JdbcUtil jdbcUtil = new JdbcUtil(jdbc_driver, jdbc_url, jdbc_username, AESUtil.AESDecode(jdbc_password));
JdbcUtil jdbcUtil = new JdbcUtil(jdbcDriver, jdbcUrl, jdbcUsername, AESUtil.aesDecode(jdbcPassword));
List<Map> result = jdbcUtil.selectByParams(sql, null);
for (Map map : result) {
System.out.println(map.get("TABLE_NAME"));
table = new HashMap<>();
table = new HashMap<>(2);
table.put("table_name", map.get("TABLE_NAME"));
table.put("model_name", lineToHump(ObjectUtils.toString(map.get("TABLE_NAME"))));
tables.add(table);
}
jdbcUtil.release();
String targetProject_sqlMap = basePath + module + "/" + module + "-rpc-service";
String targetProjectSqlMap = basePath + module + "/" + module + "-rpc-service";
context.put("tables", tables);
context.put("generator_javaModelGenerator_targetPackage", package_name + ".dao.model");
context.put("generator_sqlMapGenerator_targetPackage", package_name + ".dao.mapper");
context.put("generator_javaClientGenerator_targetPackage", package_name + ".dao.mapper");
context.put("generator_javaModelGenerator_targetPackage", packageName + ".dao.model");
context.put("generator_sqlMapGenerator_targetPackage", packageName + ".dao.mapper");
context.put("generator_javaClientGenerator_targetPackage", packageName + ".dao.mapper");
context.put("targetProject", targetProject);
context.put("targetProject_sqlMap", targetProject_sqlMap);
context.put("generator_jdbc_password", AESUtil.AESDecode(jdbc_password));
context.put("last_insert_id_tables", last_insert_id_tables);
VelocityUtil.generate(generatorConfig_vm, generatorConfig_xml, context);
context.put("targetProject_sqlMap", targetProjectSqlMap);
context.put("generator_jdbc_password", AESUtil.aesDecode(jdbcPassword));
context.put("last_insert_id_tables", lastInsertIdTables);
VelocityUtil.generate(generatorConfig_vm, generatorConfigXml, context);
// 删除旧代码
deleteDir(new File(targetProject + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/dao/model"));
deleteDir(new File(targetProject + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/dao/mapper"));
deleteDir(new File(targetProject_sqlMap + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/dao/mapper"));
deleteDir(new File(targetProject + "/src/main/java/" + packageName.replaceAll("\\.", "/") + "/dao/model"));
deleteDir(new File(targetProject + "/src/main/java/" + packageName.replaceAll("\\.", "/") + "/dao/mapper"));
deleteDir(new File(targetProjectSqlMap + "/src/main/java/" + packageName.replaceAll("\\.", "/") + "/dao/mapper"));
} catch (Exception e) {
e.printStackTrace();
}
@ -108,7 +108,7 @@ public class MybatisGeneratorUtil {
System.out.println("========== 开始运行MybatisGenerator ==========");
List<String> warnings = new ArrayList<>();
File configFile = new File(generatorConfig_xml);
File configFile = new File(generatorConfigXml);
ConfigurationParser cp = new ConfigurationParser(warnings);
Configuration config = cp.parseConfiguration(configFile);
DefaultShellCallback callback = new DefaultShellCallback(true);
@ -121,8 +121,8 @@ public class MybatisGeneratorUtil {
System.out.println("========== 开始生成Service ==========");
String ctime = new SimpleDateFormat("yyyy/M/d").format(new Date());
String servicePath = basePath + module + "/" + module + "-rpc-api" + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/rpc/api";
String serviceImplPath = basePath + module + "/" + module + "-rpc-service" + "/src/main/java/" + package_name.replaceAll("\\.", "/") + "/rpc/service/impl";
String servicePath = basePath + module + "/" + module + "-rpc-api" + "/src/main/java/" + packageName.replaceAll("\\.", "/") + "/rpc/api";
String serviceImplPath = basePath + module + "/" + module + "-rpc-service" + "/src/main/java/" + packageName.replaceAll("\\.", "/") + "/rpc/service/impl";
for (int i = 0; i < tables.size(); i++) {
String model = StringUtil.lineToHump(ObjectUtils.toString(tables.get(i).get("table_name")));
String service = servicePath + "/" + model + "Service.java";
@ -132,7 +132,7 @@ public class MybatisGeneratorUtil {
File serviceFile = new File(service);
if (!serviceFile.exists()) {
VelocityContext context = new VelocityContext();
context.put("package_name", package_name);
context.put("package_name", packageName);
context.put("model", model);
context.put("ctime", ctime);
VelocityUtil.generate(service_vm, service, context);
@ -142,7 +142,7 @@ public class MybatisGeneratorUtil {
File serviceMockFile = new File(serviceMock);
if (!serviceMockFile.exists()) {
VelocityContext context = new VelocityContext();
context.put("package_name", package_name);
context.put("package_name", packageName);
context.put("model", model);
context.put("ctime", ctime);
VelocityUtil.generate(serviceMock_vm, serviceMock, context);
@ -152,7 +152,7 @@ public class MybatisGeneratorUtil {
File serviceImplFile = new File(serviceImpl);
if (!serviceImplFile.exists()) {
VelocityContext context = new VelocityContext();
context.put("package_name", package_name);
context.put("package_name", packageName);
context.put("model", model);
context.put("mapper", StringUtil.toLowerCaseFirstOne(model));
context.put("ctime", ctime);

View File

@ -10,14 +10,22 @@ import javax.servlet.http.HttpServletRequest;
*/
public class Paginator {
private long total = 0l; // 总记录数
private int page = 1; // 当前页数
private long totalPage = 1; // 总页数
private int rows = 10; // 每页记录数
private int step = 5; // 最多显示分页页码数
private String param = "page"; // 分页参数名称用于支持一个页面多个分页功能
private String url = ""; // 项目路径
private String query = ""; // 当前页所有参数
// 总记录数
private long total = 0L;
// 当前页数
private int page = 1;
// 总页数
private long totalPage = 1;
// 每页记录数
private int rows = 10;
// 最多显示分页页码数
private int step = 5;
// 分页参数名称用于支持一个页面多个分页功能
private String param = "page";
// 项目路径
private String url = "";
// 当前页所有参数
private String query = "";
public Paginator() {
@ -129,15 +137,18 @@ public class Paginator {
String params = "";
String[] querys = query.split("&");
for (int i = 0; i < querys.length; i++) {
if (querys[i].startsWith(param))
if (querys[i].startsWith(param)) {
continue;
if (params.equals(""))
}
if ("".equals(params)) {
params = querys[i];
else
} else {
params += "&" + querys[i];
}
}
if (!params.equals(""))
if (!"".equals(params)) {
url += "?" + params;
}
}
// 结果html
String pages = "";

View File

@ -40,7 +40,7 @@ public class PropertiesFileUtil {
configMap.put(name, conf);
}
// 判断是否打开的资源文件是否超时1分钟
if ((new Date().getTime() - conf.getLoadTime().getTime()) > TIME_OUT) {
if ((System.currentTimeMillis() - conf.getLoadTime().getTime()) > TIME_OUT) {
conf = new PropertiesFileUtil(name);
configMap.put(name, conf);
}
@ -52,7 +52,7 @@ public class PropertiesFileUtil {
try {
String value = resourceBundle.getString(key);
return value;
}catch (MissingResourceException e) {
} catch (MissingResourceException e) {
return "";
}
}
@ -62,7 +62,7 @@ public class PropertiesFileUtil {
try {
String value = resourceBundle.getString(key);
return Integer.parseInt(value);
}catch (MissingResourceException e) {
} catch (MissingResourceException e) {
return null;
}
}
@ -75,7 +75,7 @@ public class PropertiesFileUtil {
return true;
}
return false;
}catch (MissingResourceException e) {
} catch (MissingResourceException e) {
return false;
}
}

View File

@ -18,7 +18,7 @@ public class RedisUtil {
protected static ReentrantLock lockPool = new ReentrantLock();
protected static ReentrantLock lockJedis = new ReentrantLock();
private static Logger _log = LoggerFactory.getLogger(RedisUtil.class);
private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class);
// Redis服务器IP
private static String IP = PropertiesFileUtil.getInstance("redis").get("master.redis.ip");
@ -27,7 +27,7 @@ public class RedisUtil {
private static int PORT = PropertiesFileUtil.getInstance("redis").getInt("master.redis.port");
// 访问密码
private static String PASSWORD = AESUtil.AESDecode(PropertiesFileUtil.getInstance("redis").get("master.redis.password"));
private static String PASSWORD = AESUtil.aesDecode(PropertiesFileUtil.getInstance("redis").get("master.redis.password"));
// 可用连接实例的最大数目默认值为8
// 如果赋值为-1则表示不限制如果pool已经分配了maxActive个jedis实例则此时pool的状态为exhausted(耗尽)
private static int MAX_ACTIVE = PropertiesFileUtil.getInstance("redis").getInt("master.redis.max_active");
@ -49,9 +49,12 @@ public class RedisUtil {
/**
* redis过期时间,以秒为单位
*/
public final static int EXRP_HOUR = 60 * 60; //一小时
public final static int EXRP_DAY = 60 * 60 * 24; //一天
public final static int EXRP_MONTH = 60 * 60 * 24 * 30; //一个月
// 一小时
public final static int EXRP_HOUR = 60 * 60;
// 一天
public final static int EXRP_DAY = 60 * 60 * 24;
// 一个月
public final static int EXRP_MONTH = 60 * 60 * 24 * 30;
/**
* 初始化Redis连接池
@ -65,7 +68,7 @@ public class RedisUtil {
config.setTestOnBorrow(TEST_ON_BORROW);
jedisPool = new JedisPool(config, IP, PORT, TIMEOUT);
} catch (Exception e) {
_log.error("First create JedisPool error : " + e);
LOGGER.error("First create JedisPool error : " + e);
}
}
@ -96,7 +99,7 @@ public class RedisUtil {
}
}
} catch (Exception e) {
_log.error("Get jedis error : " + e);
LOGGER.error("Get jedis error : " + e);
}
return jedis;
}
@ -113,7 +116,7 @@ public class RedisUtil {
jedis.set(key, value);
jedis.close();
} catch (Exception e) {
_log.error("Set key error : " + e);
LOGGER.error("Set key error : " + e);
}
}
@ -128,7 +131,7 @@ public class RedisUtil {
jedis.set(key, value);
jedis.close();
} catch (Exception e) {
_log.error("Set key error : " + e);
LOGGER.error("Set key error : " + e);
}
}
@ -145,7 +148,7 @@ public class RedisUtil {
jedis.setex(key, seconds, value);
jedis.close();
} catch (Exception e) {
_log.error("Set keyex error : " + e);
LOGGER.error("Set keyex error : " + e);
}
}
@ -162,7 +165,7 @@ public class RedisUtil {
jedis.expire(key, seconds);
jedis.close();
} catch (Exception e) {
_log.error("Set key error : " + e);
LOGGER.error("Set key error : " + e);
}
}
@ -206,7 +209,7 @@ public class RedisUtil {
jedis.del(key);
jedis.close();
} catch (Exception e) {
_log.error("Remove keyex error : " + e);
LOGGER.error("Remove keyex error : " + e);
}
}
@ -220,7 +223,7 @@ public class RedisUtil {
jedis.del(key);
jedis.close();
} catch (Exception e) {
_log.error("Remove keyex error : " + e);
LOGGER.error("Remove keyex error : " + e);
}
}
@ -235,7 +238,7 @@ public class RedisUtil {
jedis.lpush(key, strings);
jedis.close();
} catch (Exception e) {
_log.error("lpush error : " + e);
LOGGER.error("lpush error : " + e);
}
}
@ -251,7 +254,7 @@ public class RedisUtil {
jedis.lrem(key, count, value);
jedis.close();
} catch (Exception e) {
_log.error("lpush error : " + e);
LOGGER.error("lpush error : " + e);
}
}
@ -268,7 +271,7 @@ public class RedisUtil {
jedis.expire(key, seconds);
jedis.close();
} catch (Exception e) {
_log.error("sadd error : " + e);
LOGGER.error("sadd error : " + e);
}
}

View File

@ -25,7 +25,7 @@ public class RequestUtil {
if (key.equals(paramName)) {
continue;
}
if (queryString.equals("")) {
if ("".equals(queryString)) {
queryString = key + "=" + request.getParameter(key);
} else {
queryString += "&" + key + "=" + request.getParameter(key);

View File

@ -13,7 +13,7 @@ import javax.servlet.ServletContext;
*/
public class ZhengAdminUtil implements InitializingBean, ServletContextAware {
private static Logger _log = LoggerFactory.getLogger(ZhengAdminUtil.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ZhengAdminUtil.class);
@Override
public void afterPropertiesSet() throws Exception {
@ -22,15 +22,15 @@ public class ZhengAdminUtil implements InitializingBean, ServletContextAware {
@Override
public void setServletContext(ServletContext servletContext) {
_log.info("===== 开始解压zheng-admin =====");
LOGGER.info("===== 开始解压zheng-admin =====");
String version = PropertiesFileUtil.getInstance("zheng-admin-client").get("zheng.admin.version");
_log.info("zheng-admin.jar 版本: {}", version);
LOGGER.info("zheng-admin.jar 版本: {}", version);
String jarPath = servletContext.getRealPath("/WEB-INF/lib/zheng-admin-" + version + ".jar");
_log.info("zheng-admin.jar 包路径: {}", jarPath);
LOGGER.info("zheng-admin.jar 包路径: {}", jarPath);
String resources = servletContext.getRealPath("/") + "/resources/zheng-admin";
_log.info("zheng-admin.jar 解压到: {}", resources);
LOGGER.info("zheng-admin.jar 解压到: {}", resources);
JarUtil.decompress(jarPath, resources);
_log.info("===== 解压zheng-admin完成 =====");
LOGGER.info("===== 解压zheng-admin完成 =====");
}
}

View File

@ -1,10 +1,7 @@
package com.zheng.common.util.key;
import java.sql.Timestamp;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.concurrent.atomic.AtomicLong;
/**
@ -20,47 +17,50 @@ import java.util.concurrent.atomic.AtomicLong;
* @author lry
*/
public class SystemClock {
private final long period;
private final AtomicLong now;
private final long period;
private final AtomicLong now;
ExecutorService executor = Executors.newSingleThreadExecutor();
private SystemClock(long period) {
this.period = period;
this.now = new AtomicLong(System.currentTimeMillis());
scheduleClockUpdating();
}
private SystemClock(long period) {
this.period = period;
this.now = new AtomicLong(System.currentTimeMillis());
scheduleClockUpdating();
}
private static class InstanceHolder {
public static final SystemClock INSTANCE = new SystemClock(1);
}
private static class InstanceHolder {
public static final SystemClock INSTANCE = new SystemClock(1);
}
private static SystemClock instance() {
return InstanceHolder.INSTANCE;
}
private static SystemClock instance() {
return InstanceHolder.INSTANCE;
}
private void scheduleClockUpdating() {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "System Clock");
thread.setDaemon(true);
return thread;
}
});
scheduler.scheduleAtFixedRate(new Runnable() {
public void run() {
now.set(System.currentTimeMillis());
}
}, period, period, TimeUnit.MILLISECONDS);
}
private void scheduleClockUpdating() {
ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
@Override
public Thread newThread(Runnable runnable) {
Thread thread = new Thread(runnable, "System Clock");
thread.setDaemon(true);
return thread;
}
});
scheduler.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
now.set(System.currentTimeMillis());
}
}, period, period, TimeUnit.MILLISECONDS);
}
private long currentTimeMillis() {
return now.get();
}
private long currentTimeMillis() {
return now.get();
}
public static long now() {
return instance().currentTimeMillis();
}
public static long now() {
return instance().currentTimeMillis();
}
public static String nowDate() {
return new Timestamp(instance().currentTimeMillis()).toString();
}
public static String nowDate() {
return new Timestamp(instance().currentTimeMillis()).toString();
}
}

View File

@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
@Api(value = "${modelname}控制器", description = "${modelname}管理")
public class ${model}Controller extends BaseController {
private static Logger _log = LoggerFactory.getLogger(${model}Controller.class);
private static final Logger LOGGER = LoggerFactory.getLogger(${model}Controller.class);

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class ${model}ServiceImpl extends BaseServiceImpl<${model}Mapper, ${model}, ${model}Example> implements ${model}Service {
private static Logger _log = LoggerFactory.getLogger(${model}ServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(${model}ServiceImpl.class);
@Autowired
${model}Mapper ${mapper}Mapper;

View File

@ -21,7 +21,7 @@ import java.util.List;
@Controller
public class IndexController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(IndexController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(IndexController.class);
@Autowired
private DemoService demoService;
@ -45,12 +45,12 @@ public class IndexController extends BaseController {
model.addAttribute("host", demoService.sayHello("http://www.zhangshuzheng.cn/"));
List<User> users = new ArrayList<>();
User user = new User();
user.setId(1l);
user.setId(1L);
user.setAge(11);
user.setName("zhangsan");
users.add(user);
user = new User();
user.setId(2l);
user.setId(2L);
user.setAge(22);
user.setName("lisi");
users.add(user);

View File

@ -15,12 +15,12 @@ import javax.servlet.http.HttpServletResponse;
*/
public class DemoInterceptor extends HandlerInterceptorAdapter {
private static Logger _log = LoggerFactory.getLogger(DemoInterceptor.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DemoInterceptor.class);
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
// 过滤ajax
if (null != request.getHeader("X-Requested-With") && request.getHeader("X-Requested-With").equalsIgnoreCase("XMLHttpRequest")) {
if (null != request.getHeader("X-Requested-With") && "XMLHttpRequest".equalsIgnoreCase(request.getHeader("X-Requested-With"))) {
return true;
}
String appName = PropertiesFileUtil.getInstance().get("app.name");

View File

@ -6,7 +6,14 @@ package com.zheng.oss.common.constant;
*/
public enum OssResultConstant {
/**
* 失败
*/
FAILED(0, "failed"),
/**
* 成功
*/
SUCCESS(1, "success");
public int code;

View File

@ -12,17 +12,17 @@ import java.io.IOException;
*/
public class QiniuDemo {
//设置好账号的ACCESS_KEY和SECRET_KEY
String ACCESS_KEY = "";
String SECRET_KEY = "";
String accessKey = "";
String secretKey = "";
//要上传的空间
String bucketname = "zheng";
//上传到七牛后保存的文件名
String key = "my-java.png";
//上传文件的路径
String FilePath = "C:\\Users\\admin\\Pictures\\zsz\\20161108161228.png";
String filePath = "C:\\Users\\admin\\Pictures\\zsz\\20161108161228.png";
//密钥配置
Auth auth = Auth.create(ACCESS_KEY, SECRET_KEY);
Auth auth = Auth.create(accessKey, secretKey);
//创建上传对象
UploadManager uploadManager = new UploadManager();
@ -34,7 +34,7 @@ public class QiniuDemo {
public void upload() throws IOException {
try {
//调用put方法上传
Response res = uploadManager.put(FilePath, key, getUpToken());
Response res = uploadManager.put(filePath, key, getUpToken());
//打印返回的信息
System.out.println(res.bodyString());
} catch (QiniuException e) {

View File

@ -22,7 +22,7 @@ import javax.servlet.http.HttpServletRequest;
@RequestMapping("/aliyun/oss")
public class AliyunOssController {
private static Logger _log = LoggerFactory.getLogger(AliyunOssController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(AliyunOssController.class);
@Autowired
private AliyunOssService aliyunOssService;

View File

@ -26,7 +26,7 @@ import java.io.*;
@RequestMapping("/demo")
public class DemoController extends BaseController {
private static Logger _log = LoggerFactory.getLogger(DemoController.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DemoController.class);
@Autowired
private AliyunOssService aliyunOssService;
@ -56,7 +56,9 @@ public class DemoController extends BaseController {
BufferedReader reader = new BufferedReader(new InputStreamReader(content));
while (true) {
String line = reader.readLine();
if (line == null) break;
if (line == null) {
break;
}
result.append("\n" + line);
}
content.close();
@ -72,7 +74,7 @@ public class DemoController extends BaseController {
@GetMapping("/aliyun/upload")
public String upload(Model model) {
JSONObject policy = aliyunOssService.policy();
_log.info("policy={}", policy);
LOGGER.info("policy={}", policy);
model.addAttribute("policy", policy);
return thymeleaf("/aliyun/upload");
}

View File

@ -21,7 +21,7 @@ import java.util.Date;
@Service
public class AliyunOssService {
private static Logger _log = LoggerFactory.getLogger(AliyunOssService.class);
private static final Logger LOGGER = LoggerFactory.getLogger(AliyunOssService.class);
@Autowired
private OSSClient aliyunOssClient;
@ -64,7 +64,7 @@ public class AliyunOssService {
result.put("callback", callbackData);
result.put("action", action);
} catch (Exception e) {
_log.error("签名生成失败", e);
LOGGER.error("签名生成失败", e);
}
return result;
}

View File

@ -6,7 +6,14 @@ package com.zheng.pay.common.constant;
*/
public enum PayResultConstant {
/**
* 失败
*/
FAILED(0, "failed"),
/**
* 成功
*/
SUCCESS(1, "success");
public int code;

View File

@ -10,12 +10,12 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class ZhengPayRpcServiceApplication {
private static Logger _log = LoggerFactory.getLogger(ZhengPayRpcServiceApplication.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ZhengPayRpcServiceApplication.class);
public static void main(String[] args) {
_log.info(">>>>> zheng-pay-rpc-service 正在启动 <<<<<");
LOGGER.info(">>>>> zheng-pay-rpc-service 正在启动 <<<<<");
new ClassPathXmlApplicationContext("classpath:META-INF/spring/*.xml");
_log.info(">>>>> zheng-pay-rpc-service 启动完成 <<<<<");
LOGGER.info(">>>>> zheng-pay-rpc-service 启动完成 <<<<<");
}
}

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayInOrderDetailServiceImpl extends BaseServiceImpl<PayInOrderDetailMapper, PayInOrderDetail, PayInOrderDetailExample> implements PayInOrderDetailService {
private static Logger _log = LoggerFactory.getLogger(PayInOrderDetailServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(PayInOrderDetailServiceImpl.class);
@Autowired
PayInOrderDetailMapper payInOrderDetailMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayInOrderServiceImpl extends BaseServiceImpl<PayInOrderMapper, PayInOrder, PayInOrderExample> implements PayInOrderService {
private static Logger _log = LoggerFactory.getLogger(PayInOrderServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayInOrderServiceImpl.class);
@Autowired
PayInOrderMapper payInOrderMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayMchServiceImpl extends BaseServiceImpl<PayMchMapper, PayMch, PayMchExample> implements PayMchService {
private static Logger _log = LoggerFactory.getLogger(PayMchServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayMchServiceImpl.class);
@Autowired
PayMchMapper payMchMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayOutOrderDetailServiceImpl extends BaseServiceImpl<PayOutOrderDetailMapper, PayOutOrderDetail, PayOutOrderDetailExample> implements PayOutOrderDetailService {
private static Logger _log = LoggerFactory.getLogger(PayOutOrderDetailServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayOutOrderDetailServiceImpl.class);
@Autowired
PayOutOrderDetailMapper payOutOrderDetailMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayOutOrderServiceImpl extends BaseServiceImpl<PayOutOrderMapper, PayOutOrder, PayOutOrderExample> implements PayOutOrderService {
private static Logger _log = LoggerFactory.getLogger(PayOutOrderServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayOutOrderServiceImpl.class);
@Autowired
PayOutOrderMapper payOutOrderMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayPayServiceImpl extends BaseServiceImpl<PayPayMapper, PayPay, PayPayExample> implements PayPayService {
private static Logger _log = LoggerFactory.getLogger(PayPayServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayPayServiceImpl.class);
@Autowired
PayPayMapper payPayMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayTypeServiceImpl extends BaseServiceImpl<PayTypeMapper, PayType, PayTypeExample> implements PayTypeService {
private static Logger _log = LoggerFactory.getLogger(PayTypeServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayTypeServiceImpl.class);
@Autowired
PayTypeMapper payTypeMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayVendorServiceImpl extends BaseServiceImpl<PayVendorMapper, PayVendor, PayVendorExample> implements PayVendorService {
private static Logger _log = LoggerFactory.getLogger(PayVendorServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayVendorServiceImpl.class);
@Autowired
PayVendorMapper payVendorMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class PayVestServiceImpl extends BaseServiceImpl<PayVestMapper, PayVest, PayVestExample> implements PayVestService {
private static Logger _log = LoggerFactory.getLogger(PayVestServiceImpl.class);
private static final Logger log = LoggerFactory.getLogger(PayVestServiceImpl.class);
@Autowired
PayVestMapper payVestMapper;

View File

@ -6,7 +6,14 @@ package com.zheng.ucenter.common.constant;
*/
public enum UcenterResultConstant {
/**
* 失败
*/
FAILED(0, "failed"),
/**
* 成功
*/
SUCCESS(1, "success");
public int code;

View File

@ -9,6 +9,6 @@ import org.slf4j.LoggerFactory;
*/
public class UcenterApiServiceMock implements UcenterApiService {
private static Logger _log = LoggerFactory.getLogger(UcenterApiServiceMock.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UcenterApiServiceMock.class);
}

View File

@ -10,12 +10,12 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
*/
public class ZhengUcenterRpcServiceApplication {
private static Logger _log = LoggerFactory.getLogger(ZhengUcenterRpcServiceApplication.class);
private static final Logger LOGGER = LoggerFactory.getLogger(ZhengUcenterRpcServiceApplication.class);
public static void main(String[] args) {
_log.info(">>>>> zheng-ucenter-rpc-service 正在启动 <<<<<");
LOGGER.info(">>>>> zheng-ucenter-rpc-service 正在启动 <<<<<");
new ClassPathXmlApplicationContext("classpath:META-INF/spring/*.xml");
_log.info(">>>>> zheng-ucenter-rpc-service 启动完成 <<<<<");
LOGGER.info(">>>>> zheng-ucenter-rpc-service 启动完成 <<<<<");
}
}

View File

@ -14,6 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
@Transactional
public class UcenterApiServiceImpl implements UcenterApiService {
private static Logger _log = LoggerFactory.getLogger(UcenterApiServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UcenterApiServiceImpl.class);
}

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class UcenterOauthServiceImpl extends BaseServiceImpl<UcenterOauthMapper, UcenterOauth, UcenterOauthExample> implements UcenterOauthService {
private static Logger _log = LoggerFactory.getLogger(UcenterOauthServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UcenterOauthServiceImpl.class);
@Autowired
UcenterOauthMapper ucenterOauthMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class UcenterUserDetailsServiceImpl extends BaseServiceImpl<UcenterUserDetailsMapper, UcenterUserDetails, UcenterUserDetailsExample> implements UcenterUserDetailsService {
private static Logger _log = LoggerFactory.getLogger(UcenterUserDetailsServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UcenterUserDetailsServiceImpl.class);
@Autowired
UcenterUserDetailsMapper ucenterUserDetailsMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class UcenterUserLogServiceImpl extends BaseServiceImpl<UcenterUserLogMapper, UcenterUserLog, UcenterUserLogExample> implements UcenterUserLogService {
private static Logger _log = LoggerFactory.getLogger(UcenterUserLogServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UcenterUserLogServiceImpl.class);
@Autowired
UcenterUserLogMapper ucenterUserLogMapper;

View File

@ -21,7 +21,7 @@ import org.springframework.transaction.annotation.Transactional;
@BaseService
public class UcenterUserOauthServiceImpl extends BaseServiceImpl<UcenterUserOauthMapper, UcenterUserOauth, UcenterUserOauthExample> implements UcenterUserOauthService {
private static Logger _log = LoggerFactory.getLogger(UcenterUserOauthServiceImpl.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UcenterUserOauthServiceImpl.class);
@Autowired
UcenterUserOauthMapper ucenterUserOauthMapper;

Some files were not shown because too many files have changed in this diff Show More