merge
This commit is contained in:
@@ -2,7 +2,6 @@ package com.xwbing.service;
|
||||
|
||||
import com.xwbing.util.RestMessage;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -13,21 +12,25 @@ import java.util.Objects;
|
||||
* 创建时间: 2017/5/5 16:44
|
||||
* 作者: xiangwb
|
||||
*/
|
||||
@Service
|
||||
public class BaseService<T> {
|
||||
private JpaRepository<T,String> jpaRepository;
|
||||
private JpaRepository<T, String> jpaRepository;
|
||||
|
||||
public BaseService(JpaRepository<T, String> jpaRepository) {
|
||||
this.jpaRepository = jpaRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 增
|
||||
*
|
||||
* @param t
|
||||
* @return
|
||||
*/
|
||||
public RestMessage saveOrUpdate(T t){
|
||||
RestMessage result=new RestMessage();
|
||||
t=jpaRepository.save(t);
|
||||
if(Objects.isNull(t)){
|
||||
public RestMessage saveOrUpdate(T t) {
|
||||
RestMessage result = new RestMessage();
|
||||
t = jpaRepository.save(t);
|
||||
if (Objects.isNull(t)) {
|
||||
result.setMessage("保存数据失败");
|
||||
}else {
|
||||
} else {
|
||||
result.setSuccess(true);
|
||||
result.setMessage("保存数据成功");
|
||||
}
|
||||
@@ -36,11 +39,12 @@ public class BaseService<T> {
|
||||
|
||||
/**
|
||||
* 删
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public RestMessage removeById(String id){
|
||||
RestMessage result=new RestMessage();
|
||||
public RestMessage removeById(String id) {
|
||||
RestMessage result = new RestMessage();
|
||||
jpaRepository.delete(id);
|
||||
result.setSuccess(true);
|
||||
result.setMessage("删除数据成功");
|
||||
@@ -49,20 +53,20 @@ public class BaseService<T> {
|
||||
|
||||
/**
|
||||
* 单个查找
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public T findById(String id){
|
||||
T t=jpaRepository.findOne(id);
|
||||
return t;
|
||||
public T findById(String id) {
|
||||
return jpaRepository.findOne(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表超找
|
||||
* 列表查找
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public List<T> findList(){
|
||||
List<T> list=jpaRepository.findAll();
|
||||
return list;
|
||||
public List<T> findList() {
|
||||
return jpaRepository.findAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public class SysConfigControl {
|
||||
|
||||
@ApiOperation(value = "删除", notes = "根据code删除系统配置信息")
|
||||
@ApiImplicitParam(name = "code", value = "配置项的code", paramType = "query", required = true, dataType = "string")
|
||||
@GetMapping("removeByCode/{code}")
|
||||
public JSONObject removeByCode(@PathVariable String code) {
|
||||
@GetMapping("removeByCode")
|
||||
public JSONObject removeByCode(@RequestParam String code) {
|
||||
String logMsg = "删除系统配置信息";
|
||||
logger.info(logMsg + " code:{}", code);
|
||||
if (StringUtils.isEmpty(code)) {
|
||||
@@ -67,7 +67,7 @@ public class SysConfigControl {
|
||||
@ApiImplicitParam(name = "enable", value = "是否启用,格式为Y|N", paramType = "query", required = true, dataType = "string"),
|
||||
})
|
||||
@PostMapping("update")
|
||||
public JSONObject update(@RequestBody SysConfig sysConfig) {
|
||||
public JSONObject update(SysConfig sysConfig) {
|
||||
String logMsg = "修改系统配置信息";
|
||||
logger.info(logMsg);
|
||||
if (StringUtils.isEmpty(sysConfig.getCode()))
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.xwbing.service.SysUserService;
|
||||
import com.xwbing.util.JSONObjResult;
|
||||
import com.xwbing.util.RestMessage;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
@@ -28,6 +30,7 @@ public class SysUserControl {
|
||||
private SysUserService sysUserService;
|
||||
@Resource
|
||||
private SysUserLoginInOutService loginInOutService;
|
||||
private final Logger logger = LoggerFactory.getLogger(SysUserControl.class);
|
||||
|
||||
@LogInfo("添加用户")
|
||||
@PostMapping("save")
|
||||
|
||||
@@ -33,7 +33,6 @@ public class GlobalExceptionHandler {
|
||||
/**
|
||||
* 自定义业务异常
|
||||
*
|
||||
* @param request
|
||||
* @param ex
|
||||
* @return
|
||||
*/
|
||||
@@ -42,7 +41,7 @@ public class GlobalExceptionHandler {
|
||||
// 返回给页面200状态码
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
@ResponseBody
|
||||
public JSONObject handlerGuideException(HttpServletRequest request, Exception ex) {
|
||||
public JSONObject handlerGuideException(Exception ex) {
|
||||
logger.error(ex.getMessage());
|
||||
return JSONObjResult.toJSONObj(ex.getMessage());
|
||||
}
|
||||
|
||||
@@ -64,6 +64,8 @@
|
||||
<!-- Root Logger -->
|
||||
<root level="debug">
|
||||
<appender-ref ref="Console"/>
|
||||
<appender-ref ref="info_appender"/>
|
||||
<appender-ref ref="error_appender"/>
|
||||
</root>
|
||||
<!-- 3rdparty Loggers -->
|
||||
<logger name="org.springframework.core" level="info"/>
|
||||
@@ -74,11 +76,13 @@
|
||||
<logger name="org.apache.http" level="warn"/>
|
||||
<!-- 默认为root。匹配该name下的所有子类,由于这个logger也是满足root的,additivity为true,该logger和root都会打印。
|
||||
additivity为false,匹配该logger的信息只会在该logger下打印,不会在root下打印 -->
|
||||
<!--
|
||||
<logger name="com.xwbing.handler.WebLogAspect" level="INFO" additivity="true">
|
||||
<appender-ref ref="info_appender"/>
|
||||
</logger>
|
||||
<logger name="com.xwbing.handler.GlobalExceptionHandler" level="ERROR" additivity="true">
|
||||
<appender-ref ref="error_appender"/>
|
||||
</logger>
|
||||
-->
|
||||
</Loggers>
|
||||
</Configuration>
|
||||
Reference in New Issue
Block a user