Commit 1ac7ad26 authored by Quxl's avatar Quxl

x

parent 9d88281a
package com.egolm.sso.config; package com.egolm.sso.config;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.aspectj.lang.annotation.AfterThrowing; import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@Aspect @Aspect
@Component @Component
public class ExceptionAspect { public class ExceptionAspect {
@AfterThrowing(throwing="ex", pointcut="execution(public * com.egolm.sso.services.*.*.execute(..))") private static final String execution = "execution(public * com.egolm.sso.services.*.*.execute(..))";
Log logger = LogFactory.getLog(ExceptionAspect.class);
@Before(value = execution)
public void before(Throwable ex) {
}
@AfterThrowing(throwing = "ex", pointcut = execution)
public void afterThrowing(Throwable ex) { public void afterThrowing(Throwable ex) {
} }
......
...@@ -18,7 +18,7 @@ public class CommonService { ...@@ -18,7 +18,7 @@ public class CommonService {
public Long getNextval(String sName) { public Long getNextval(String sName) {
try { try {
Map<String, Object> seqMap = jdbcTemplate.queryForMap("select * from sequence where name = ?", sName); Map<String, Object> seqMap = jdbcTemplate.queryForMap("select * from x_sequence where name = ?", sName);
Integer id = (Integer)seqMap.get("id"); Integer id = (Integer)seqMap.get("id");
Long step = (Long)seqMap.get("step"); Long step = (Long)seqMap.get("step");
Long max = (Long)seqMap.get("max"); Long max = (Long)seqMap.get("max");
...@@ -29,7 +29,7 @@ public class CommonService { ...@@ -29,7 +29,7 @@ public class CommonService {
if(value > max || value < min) { if(value > max || value < min) {
throw new XRException(MessageFormat.format("序列已超出许可范围[{0}]", sName)); throw new XRException(MessageFormat.format("序列已超出许可范围[{0}]", sName));
} else { } else {
String sql = "update sequence set value = ? where id = ? and value < ?"; String sql = "update x_sequence set value = ? where id = ? and value < ?";
int count = jdbcTemplate.update(sql, nextValue, id, nextValue); int count = jdbcTemplate.update(sql, nextValue, id, nextValue);
if(count == 1) { if(count == 1) {
return value; return value;
...@@ -40,7 +40,7 @@ public class CommonService { ...@@ -40,7 +40,7 @@ public class CommonService {
} }
} }
} catch (EmptyResultDataAccessException e) { } catch (EmptyResultDataAccessException e) {
String sql = "insert into sequence (name, max, min, step, value) values (?, ?, ?, ?, ?)"; String sql = "insert into x_sequence (name, max, min, step, value) values (?, ?, ?, ?, ?)";
jdbcTemplate.update(sql, sName, Long.MAX_VALUE, 1L, 1L, 1L); jdbcTemplate.update(sql, sName, Long.MAX_VALUE, 1L, 1L, 1L);
return this.getNextval(sName); return this.getNextval(sName);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment