forked from jly8866/archer
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
解决SQL查询结果html显示未转义的问题 优化detail详情显示,提升审核体验
- Loading branch information
Showing
13 changed files
with
118 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# -*- coding: UTF-8 -*- | ||
import simplejson as json | ||
|
||
from datetime import datetime, date | ||
from decimal import Decimal | ||
from functools import singledispatch | ||
|
||
|
||
class MyClass: | ||
def __init__(self, value): | ||
self._value = value | ||
|
||
def get_value(self): | ||
return self._value | ||
|
||
|
||
# 创建非内置类型的实例 | ||
mc = MyClass('i am class MyClass ') | ||
dm = Decimal('11.11') | ||
dt = datetime.now() | ||
dat = date.today() | ||
|
||
|
||
@singledispatch | ||
def convert(o): | ||
raise TypeError('can not convert type') | ||
|
||
|
||
@convert.register(datetime) | ||
def _(o): | ||
return o.strftime('%Y-%m-%d %H:%M:%S') | ||
|
||
|
||
@convert.register(date) | ||
def _(o): | ||
return o.strftime('%Y-%m-%d') | ||
|
||
|
||
# @convert.register(Decimal) | ||
# def _(o): | ||
# return float(o) | ||
|
||
|
||
@convert.register(MyClass) | ||
def _(o): | ||
return o.get_value() | ||
|
||
|
||
class ExtendJSONEncoder(json.JSONEncoder): | ||
def default(self, obj): | ||
try: | ||
return convert(obj) | ||
except TypeError: | ||
return super(ExtendJSONEncoder, self).default(obj) | ||
|
||
|
||
data = { | ||
'mc': mc, | ||
'dm': dm, | ||
'dt': dt, | ||
'dat': dat, | ||
'bigint': 988983860501598208 | ||
} | ||
|
||
#print(json.dumps(data, cls=ExtendJSONEncoder, bigint_as_string=True)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# -*- coding: UTF-8 -*- | ||
import json | ||
import simplejson as json | ||
|
||
import time | ||
from threading import Thread | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters