Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gs1-office-web-sit
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
吴迪
gs1-office-web-sit
Commits
f8ae5a5c
Commit
f8ae5a5c
authored
Mar 18, 2023
by
吴迪
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
【修改】异常处理
parent
8664e7d7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
21 deletions
+16
-21
RRExceptionHandler.java
...n/java/io/office/common/exception/RRExceptionHandler.java
+2
-5
BarcodeController.java
...o/office/modules/manage/controller/BarcodeController.java
+14
-14
BarcodeGenerationServiceImpl.java
...les/manage/service/impl/BarcodeGenerationServiceImpl.java
+0
-2
No files found.
src/main/java/io/office/common/exception/RRExceptionHandler.java
View file @
f8ae5a5c
...
@@ -58,15 +58,12 @@ public class RRExceptionHandler {
...
@@ -58,15 +58,12 @@ public class RRExceptionHandler {
return
R
.
error
();
return
R
.
error
();
}
}
@ExceptionHandler
(
Exception
.
class
)
@ExceptionHandler
(
Exception
.
class
)
public
R
handleException
(
Exception
e
){
public
R
handleException
(
Exception
e
){
logger
.
error
(
e
.
getMessage
(),
e
);
logger
.
error
(
e
.
getMessage
(),
e
);
return
R
.
error
();
return
R
.
error
();
}
}
@ExceptionHandler
(
IllegalArgumentException
.
class
)
public
R
handleException
(
IllegalArgumentException
e
){
logger
.
error
(
e
.
getMessage
(),
e
);
return
R
.
error
();
}
}
}
src/main/java/io/office/modules/manage/controller/BarcodeController.java
View file @
f8ae5a5c
package
io
.
office
.
modules
.
manage
.
controller
;
package
io
.
office
.
modules
.
manage
.
controller
;
import
com.github.mbhk.barcode4j.Configuration
;
import
com.github.mbhk.barcode4j.Configuration
;
import
io.office.common.exception.RRException
;
import
io.office.modules.app.annotation.Login
;
import
io.office.modules.app.annotation.Login
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.Log
;
import
org.apache.commons.logging.LogFactory
;
import
org.apache.commons.logging.LogFactory
;
import
org.krysalis.barcode4j.BarcodeException
;
import
org.krysalis.barcode4j.BarcodeException
;
...
@@ -33,12 +35,10 @@ import java.util.logging.Logger;
...
@@ -33,12 +35,10 @@ import java.util.logging.Logger;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/barcodegeneration"
)
@RequestMapping
(
"/barcodegeneration"
)
@Slf4j
public
class
BarcodeController
{
public
class
BarcodeController
{
private
final
Log
logger
=
LogFactory
.
getLog
(
getClass
());
public
Log
getLogger
()
{
return
logger
;
}
/** Parameter name for the message */
/** Parameter name for the message */
public
static
final
String
BARCODE_MSG
=
"msg"
;
public
static
final
String
BARCODE_MSG
=
"msg"
;
/** Parameter name for the barcode type */
/** Parameter name for the barcode type */
...
@@ -68,11 +68,11 @@ public class BarcodeController {
...
@@ -68,11 +68,11 @@ public class BarcodeController {
private
static
final
String
ERROR_WHILE_GENERATING_BARCODE
=
"Error while generating barcode"
;
private
static
final
String
ERROR_WHILE_GENERATING_BARCODE
=
"Error while generating barcode"
;
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
BarcodeController
.
class
.
getName
());
@Login
@Login
@GetMapping
(
value
=
"/api/gensvg"
)
@GetMapping
(
value
=
"/api/gensvg"
)
public
void
getBarcode
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
public
void
getBarcode
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
try
{
try
{
System
.
out
.
println
(
"barcode................"
);
System
.
out
.
println
(
"barcode................"
);
final
String
format
=
determineFormat
(
request
);
final
String
format
=
determineFormat
(
request
);
...
@@ -140,17 +140,17 @@ public class BarcodeController {
...
@@ -140,17 +140,17 @@ public class BarcodeController {
response
.
getOutputStream
().
write
(
bout
.
toByteArray
());
response
.
getOutputStream
().
write
(
bout
.
toByteArray
());
response
.
getOutputStream
().
flush
();
response
.
getOutputStream
().
flush
();
}
catch
(
BarcodeException
e
)
{
}
catch
(
BarcodeException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
ERROR_WHILE_GENERATING_BARCODE
,
e
);
log
.
error
(
ERROR_WHILE_GENERATING_BARCODE
,
e
);
throw
new
ServletException
(
e
);
throw
new
RRException
(
e
.
getMessage
()
);
}
catch
(
TransformerException
e
)
{
}
catch
(
TransformerException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
ERROR_WHILE_GENERATING_BARCODE
,
e
);
log
.
error
(
ERROR_WHILE_GENERATING_BARCODE
,
e
);
throw
new
ServletException
(
e
);
throw
new
RRException
(
e
.
getMessage
()
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
ERROR_WHILE_GENERATING_BARCODE
,
e
);
log
.
error
(
ERROR_WHILE_GENERATING_BARCODE
,
e
);
throw
new
ServletException
(
e
);
throw
new
RRException
(
e
.
getMessage
()
);
}
catch
(
IllegalArgumentException
e
)
{
}
catch
(
IllegalArgumentException
e
)
{
LOGGER
.
log
(
Level
.
SEVERE
,
ERROR_WHILE_GENERATING_BARCODE
,
e
);
log
.
error
(
ERROR_WHILE_GENERATING_BARCODE
,
e
);
throw
new
ServletException
(
e
);
throw
new
RRException
(
e
.
getMessage
()
);
}
}
}
}
...
...
src/main/java/io/office/modules/manage/service/impl/BarcodeGenerationServiceImpl.java
View file @
f8ae5a5c
...
@@ -63,8 +63,6 @@ public class BarcodeGenerationServiceImpl implements BarcodeGenerationService {
...
@@ -63,8 +63,6 @@ public class BarcodeGenerationServiceImpl implements BarcodeGenerationService {
}
else
if
(
content
.
length
()>
48
){
}
else
if
(
content
.
length
()>
48
){
throw
new
RRException
(
"总长度不能超过48位"
);
throw
new
RRException
(
"总长度不能超过48位"
);
}
}
String
url
=
""
;
String
url
=
""
;
if
(
content
.
length
()
>
50
)
{
if
(
content
.
length
()
>
50
)
{
throw
new
RRException
(
"最大50位!"
);
throw
new
RRException
(
"最大50位!"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment