Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
T
tongmeng-app
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
林海冰
tongmeng-app
Commits
4daf6959
提交
4daf6959
authored
1月 17, 2019
作者:
林海冰
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加logo二维码工具,店铺信息相关注册接口
上级
f8a3c8ff
全部展开
显示空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
977 行增加
和
100 行删除
+977
-100
pom.xml
pom.xml
+16
-5
StoreApiController.java
...main/java/com/mall/controller/api/StoreApiController.java
+196
-32
ValidateManager.java
...n/java/com/mall/service/mengbeng/api/ValidateManager.java
+69
-0
ValidateService.java
...a/com/mall/service/mengbeng/api/impl/ValidateService.java
+99
-0
StoreManager.java
...in/java/com/mall/service/mengbeng/store/StoreManager.java
+6
-1
StoreService.java
...va/com/mall/service/mengbeng/store/impl/StoreService.java
+7
-2
DateUtil.java
src/main/java/com/mall/util/DateUtil.java
+111
-5
SMSUtil.java
src/main/java/com/mall/util/SMSUtil.java
+4
-3
DecodeImgZxing.java
src/main/java/com/mall/util/tongmeng/DecodeImgZxing.java
+65
-0
EncodeImgZingLogo.java
src/main/java/com/mall/util/tongmeng/EncodeImgZingLogo.java
+103
-0
EncodeImgZingLogoTest.java
...in/java/com/mall/util/tongmeng/EncodeImgZingLogoTest.java
+37
-0
EncodeImgZxing.java
src/main/java/com/mall/util/tongmeng/EncodeImgZxing.java
+109
-0
StoreManager.xml
src/main/resources/mybatis1/tongmeng/StoreManager.xml
+19
-1
ValidateMapper.xml
src/main/resources/mybatis1/tongmeng/ValidateMapper.xml
+126
-0
store_list.jsp
src/main/webapp/WEB-INF/jsp/tongmeng/store/store_list.jsp
+10
-51
没有找到文件。
pom.xml
浏览文件 @
4daf6959
...
...
@@ -752,6 +752,17 @@
<artifactId>
jdom
</artifactId>
<version>
1.1
</version>
</dependency>
<!-- 二维码生成工具 -->
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
core
</artifactId>
<version>
3.3.2
</version>
</dependency>
<dependency>
<groupId>
com.google.zxing
</groupId>
<artifactId>
javase
</artifactId>
<version>
3.3.1
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/mall/controller/api/StoreApiController.java
浏览文件 @
4daf6959
差异被折叠。
点击展开。
src/main/java/com/mall/service/mengbeng/api/ValidateManager.java
0 → 100644
浏览文件 @
4daf6959
package
com
.
mall
.
service
.
mengbeng
.
api
;
import
java.util.List
;
import
com.mall.entity.Page
;
import
com.mall.util.PageData
;
/**
* 说明: 快递员注册验证码存储表接口
* 创建时间:2018-10-09
* @version
*/
public
interface
ValidateManager
{
/**新增
* @param pd
* @throws Exception
*/
public
void
save
(
PageData
pd
)
throws
Exception
;
/**删除
* @param pd
* @throws Exception
*/
public
void
delete
(
PageData
pd
)
throws
Exception
;
/**修改
* @param pd
* @throws Exception
*/
public
void
edit
(
PageData
pd
)
throws
Exception
;
/**列表
* @param page
* @throws Exception
*/
public
List
<
PageData
>
list
(
Page
page
)
throws
Exception
;
/**列表(全部)
* @param pd
* @throws Exception
*/
public
List
<
PageData
>
listAll
(
PageData
pd
)
throws
Exception
;
/**通过id获取数据
* @param pd
* @throws Exception
*/
public
PageData
findById
(
PageData
pd
)
throws
Exception
;
/**批量删除
* @param ArrayDATA_IDS
* @throws Exception
*/
public
void
deleteAll
(
String
[]
ArrayDATA_IDS
)
throws
Exception
;
/**
* 通过手机号查找对象
* @param phone
* @return
* @throws Exception
*/
public
PageData
findByPhone
(
String
phone
,
String
code_from
)
throws
Exception
;
/**
* 通过手机号删除元组
*/
public
Object
deleteByPhone
(
String
phone
)
throws
Exception
;
}
src/main/java/com/mall/service/mengbeng/api/impl/ValidateService.java
0 → 100644
浏览文件 @
4daf6959
package
com
.
mall
.
service
.
mengbeng
.
api
.
impl
;
import
java.util.List
;
import
javax.annotation.Resource
;
import
org.springframework.stereotype.Service
;
import
com.mall.dao.DaoSupport
;
import
com.mall.entity.Page
;
import
com.mall.service.mengbeng.api.ValidateManager
;
import
com.mall.util.PageData
;
/**
* 说明: 快递员注册验证码存储表
* 创建时间:2018-10-09
* @version
*/
@Service
(
"validateService"
)
public
class
ValidateService
implements
ValidateManager
{
@Resource
(
name
=
"daoSupport"
)
private
DaoSupport
dao
;
/**新增
* @param pd
* @throws Exception
*/
public
void
save
(
PageData
pd
)
throws
Exception
{
dao
.
save
(
"ValidateMapper.save"
,
pd
);
}
/**删除
* @param pd
* @throws Exception
*/
public
void
delete
(
PageData
pd
)
throws
Exception
{
dao
.
delete
(
"ValidateMapper.delete"
,
pd
);
}
/**修改
* @param pd
* @throws Exception
*/
public
void
edit
(
PageData
pd
)
throws
Exception
{
dao
.
update
(
"ValidateMapper.edit"
,
pd
);
}
/**列表
* @param page
* @throws Exception
*/
@SuppressWarnings
(
"unchecked"
)
public
List
<
PageData
>
list
(
Page
page
)
throws
Exception
{
return
(
List
<
PageData
>)
dao
.
findForList
(
"ValidateMapper.datalistPage"
,
page
);
}
/**列表(全部)
* @param pd
* @throws Exception
*/
@SuppressWarnings
(
"unchecked"
)
public
List
<
PageData
>
listAll
(
PageData
pd
)
throws
Exception
{
return
(
List
<
PageData
>)
dao
.
findForList
(
"ValidateMapper.listAll"
,
pd
);
}
/**通过id获取数据
* @param pd
* @throws Exception
*/
public
PageData
findById
(
PageData
pd
)
throws
Exception
{
return
(
PageData
)
dao
.
findForObject
(
"ValidateMapper.findById"
,
pd
);
}
/**批量删除
* @param ArrayDATA_IDS
* @throws Exception
*/
public
void
deleteAll
(
String
[]
ArrayDATA_IDS
)
throws
Exception
{
dao
.
delete
(
"ValidateMapper.deleteAll"
,
ArrayDATA_IDS
);
}
@Override
public
PageData
findByPhone
(
String
phone
,
String
code_from
)
throws
Exception
{
PageData
pd
=
new
PageData
();
pd
.
put
(
"phone"
,
phone
);
pd
.
put
(
"code_from"
,
code_from
);
return
(
PageData
)
dao
.
findForObject
(
"ValidateMapper.findByPhone"
,
pd
);
}
@Override
public
Object
deleteByPhone
(
String
phone
)
throws
Exception
{
return
dao
.
findForObject
(
"ValidateMapper.deleteByPhone"
,
phone
);
}
}
src/main/java/com/mall/service/mengbeng/store/StoreManager.java
浏览文件 @
4daf6959
...
...
@@ -59,10 +59,15 @@ public interface StoreManager{
* @param pd
* @return
*/
public
int
findByPhone
(
PageData
pd
)
throws
Exception
;
public
PageData
findByPhone
(
String
phone
)
throws
Exception
;
public
void
viewStore
(
PageData
pd
)
throws
Exception
;
public
PageData
findByStore
(
String
storeName
)
throws
Exception
;
}
src/main/java/com/mall/service/mengbeng/store/impl/StoreService.java
浏览文件 @
4daf6959
...
...
@@ -92,8 +92,8 @@ public class StoreService implements StoreManager{
* @return
*/
@Override
public
int
findByPhone
(
PageData
pd
)
throws
Exception
{
return
(
int
)
dao
.
findForObject
(
"StoreManager.findByPhone"
,
pd
);
public
PageData
findByPhone
(
String
phone
)
throws
Exception
{
return
(
PageData
)
dao
.
findForObject
(
"StoreManager.findByPhone"
,
phone
);
}
@Override
...
...
@@ -115,5 +115,10 @@ public class StoreService implements StoreManager{
viewedStore
.
put
(
"store_view_number"
,
store_view_number
);
}
@Override
public
PageData
findByStore
(
String
storeName
)
throws
Exception
{
return
(
PageData
)
dao
.
findForObject
(
"StoreManager.findByStore"
,
storeName
);
}
}
src/main/java/com/mall/util/DateUtil.java
浏览文件 @
4daf6959
...
...
@@ -179,11 +179,11 @@ public class DateUtil {
String
dateStr
=
sdf
.
format
(
date
);
return
dateStr
;
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
getTime
());
System
.
out
.
println
(
getAfterDayWeek
(
"3"
));
}
//
//
public static void main(String[] args) {
//
System.out.println(getTime());
//
System.out.println(getAfterDayWeek("3"));
//
}
/**
...
...
@@ -266,4 +266,110 @@ public class DateUtil {
return
simpleDateFormat
.
format
(
dates
);
}
}
/**
* 对时间进行操作分钟数加减 ysl
* @throws ParseException
*/
public
static
String
timeplus
(
int
num
)
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Calendar
afterTime
=
Calendar
.
getInstance
();
afterTime
.
add
(
Calendar
.
MINUTE
,
num
);
// 当前分钟+5 负号为剪
Date
afterDate
=
(
Date
)
afterTime
.
getTime
();
String
time
=
dateFormat
.
format
(
afterDate
);
System
.
out
.
println
(
"修改后的 时间"
+
time
);
return
time
;
}
/**
* 对传入的时间分钟数加减
* ysl
*/
public
static
String
timeplus
(
int
num
,
Date
date
)
throws
ParseException
{
SimpleDateFormat
dateFormat
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Calendar
afterTime
=
Calendar
.
getInstance
();
afterTime
.
setTime
(
date
);
afterTime
.
add
(
Calendar
.
MINUTE
,
num
);
// 当前分钟+5 负号为剪
Date
afterDate
=
(
Date
)
afterTime
.
getTime
();
String
time
=
dateFormat
.
format
(
afterDate
);
System
.
out
.
println
(
"修改后的 时间"
+
time
);
return
time
;
}
/**
* 传入的时间与系统当前时间相减,得到天数差,小时差,分钟差
* @param
* @throws ParseException
* wuyulun
*/
public
static
long
minuteDifference
(
String
createTime
)
throws
ParseException
{
Date
date3
=
new
Date
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
date2
=
df
.
parse
(
createTime
);
long
diff
=
date3
.
getTime
()
-
date2
.
getTime
();
// 这样得到的差值是微秒级别
long
days
=
diff
/
(
1000
*
60
*
60
*
24
);
long
hours
=
(
diff
-
days
*
(
1000
*
60
*
60
*
24
))
/
(
1000
*
60
*
60
);
long
minutes
=
(
diff
-
days
*
(
1000
*
60
*
60
*
24
)
-
hours
*
(
1000
*
60
*
60
))
/
(
1000
*
60
);
return
minutes
;
}
/**
* 传入的时间与系统当前时间相减,得到天数差,小时差,分钟差
* @param
* @throws ParseException
* wuyulun
*/
public
static
long
hourDifference
(
String
createTime
)
{
Date
date3
=
new
Date
();
SimpleDateFormat
df
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
Date
date2
=
null
;
try
{
date2
=
df
.
parse
(
createTime
);
}
catch
(
ParseException
e
)
{
e
.
printStackTrace
();
}
long
diff
=
date3
.
getTime
()
-
date2
.
getTime
();
// 这样得到的差值是微秒级别
long
days
=
diff
/
(
1000
*
60
*
60
*
24
);
long
hours
=
(
diff
-
days
*
(
1000
*
60
*
60
*
24
))
/
(
1000
*
60
*
60
);
return
hours
;
}
public
static
void
main
(
String
[]
args
)
throws
ParseException
{
/*System.out.println(getTime());
System.out.println(getAfterDayWeek("3"));*/
// String time = timeplus(5,new Date());
String
time
=
DateUtil
.
getTime
();
System
.
out
.
println
(
time
);
String
setTime
=
"2018-10-18 1:00:00"
;
long
hourDifference
=
DateUtil
.
hourDifference
(
setTime
);
System
.
out
.
println
(
hourDifference
);
}
/**
* 通过时间秒毫秒数判断两个时间的间隔
* @param date1 时间小
* @param date2 时间大
* @return
*/
public
static
int
differentDaysByMillisecond
(
Date
date1
,
Date
date2
)
{
int
days
=
(
int
)
((
date2
.
getTime
()
-
date1
.
getTime
())
/
(
1000
*
3600
*
24
));
return
days
;
}
/**
*
* @param time yyyy-MM-dd
* @return String yyyy
*/
public
static
String
getYearByStringTime
(
String
time
)
{
try
{
Date
date
=
sdfDay
.
parse
(
time
);
String
year
=
sdfYear
.
format
(
date
);
return
year
;
}
catch
(
ParseException
e
){
e
.
getErrorOffset
();
}
return
null
;
}
}
src/main/java/com/mall/util/SMSUtil.java
浏览文件 @
4daf6959
...
...
@@ -95,7 +95,7 @@ public class SMSUtil {
* @return
* @throws IOException
*/
public
String
yzCode
(
String
phone
)
throws
IOException
{
public
String
yzCode
(
String
phone
,
String
name
)
throws
IOException
{
if
(
phone
.
equals
(
null
)){
return
"error"
;
...
...
@@ -108,7 +108,8 @@ public class SMSUtil {
String
tpl_value
=
URLEncoder
.
encode
(
"#code#"
,
ENCODING
)
+
"="
+
URLEncoder
.
encode
(
code
,
ENCODING
)
+
"&"
+
URLEncoder
.
encode
(
"#company#"
,
ENCODING
)
+
"="
+
URLEncoder
.
encode
(
"正品2020"
,
ENCODING
);
// + URLEncoder.encode("正品2020",ENCODING);
+
URLEncoder
.
encode
(
name
,
ENCODING
);
System
.
out
.
println
(
tpl_value
);
System
.
out
.
println
(
SMSUtil
.
tplSendSms
(
apikey
,
tpl_id
,
tpl_value
,
phone
));
return
code
;
...
...
@@ -135,7 +136,7 @@ public class SMSUtil {
public
static
void
main
(
String
[]
args
)
throws
IOException
{
SMSUtil
smsUtil
=
new
SMSUtil
();
smsUtil
.
yzCode
(
"15913115046"
);
smsUtil
.
yzCode
(
"15913115046"
,
"ok"
);
}
}
src/main/java/com/mall/util/tongmeng/DecodeImgZxing.java
0 → 100644
浏览文件 @
4daf6959
package
com
.
mall
.
util
.
tongmeng
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.EnumMap
;
import
javax.imageio.ImageIO
;
import
com.google.zxing.Binarizer
;
import
com.google.zxing.BinaryBitmap
;
import
com.google.zxing.DecodeHintType
;
import
com.google.zxing.LuminanceSource
;
import
com.google.zxing.MultiFormatReader
;
import
com.google.zxing.NotFoundException
;
import
com.google.zxing.Result
;
import
com.google.zxing.client.j2se.BufferedImageLuminanceSource
;
import
com.google.zxing.common.HybridBinarizer
;
/**
* @ClassName DecodeImgZxing
* @Description 通过google的zxing解析二维码 注:此代码,不能解析:L纠错级别带logo和H级别的解析
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 二维码解析
*/
public
class
DecodeImgZxing
{
//二维码格式参数
private
static
final
EnumMap
<
DecodeHintType
,
Object
>
hints
=
new
EnumMap
<
DecodeHintType
,
Object
>(
DecodeHintType
.
class
);
static
{
hints
.
put
(
DecodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
}
/**
* 解析二维码,使用google的zxing
* @param imgPath 二维码路径
* @return content 二维码内容
* */
public
static
String
decodeImg
(
File
imgFile
){
String
content
=
null
;
if
(!
imgFile
.
isFile
()){
System
.
out
.
println
(
"输入非文件"
);
return
null
;
}
try
{
BufferedImage
image
=
ImageIO
.
read
(
imgFile
);
LuminanceSource
source
=
new
BufferedImageLuminanceSource
(
image
);
Binarizer
binarizer
=
new
HybridBinarizer
(
source
);
BinaryBitmap
binaryBitmap
=
new
BinaryBitmap
(
binarizer
);
MultiFormatReader
reader
=
new
MultiFormatReader
();
Result
result
=
reader
.
decode
(
binaryBitmap
,
hints
);
content
=
result
.
getText
();
// System.out.println("二维码结果:"+":"+result.toString()+","+result.getBarcodeFormat()+","+result.getText());
}
catch
(
NotFoundException
e
)
{
System
.
out
.
println
(
"二维码解析NotFoundException"
);
e
.
printStackTrace
();
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"二维码解析IOException"
);
e
.
printStackTrace
();
}
return
content
;
}
}
src/main/java/com/mall/util/tongmeng/EncodeImgZingLogo.java
0 → 100644
浏览文件 @
4daf6959
package
com
.
mall
.
util
.
tongmeng
;
import
java.awt.BasicStroke
;
import
java.awt.Color
;
import
java.awt.Graphics2D
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.OutputStream
;
/**
* ClassName:EncodeImgZingLogo <br/>
* Function: TODO ADD FUNCTION. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2019年1月17日 上午11:56:13 <br/>
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 带logo的二维码生成代码
*/
import
javax.imageio.ImageIO
;
public
class
EncodeImgZingLogo
{
/**
* 二维码绘制logo
* @param twodimensioncodeImg 二维码图片文件
* @param logoImg logo图片文件
* */
public
static
BufferedImage
encodeImgLogo
(
File
twodimensioncodeImg
,
File
logoImg
){
BufferedImage
twodimensioncode
=
null
;
try
{
if
(!
twodimensioncodeImg
.
isFile
()
||
!
logoImg
.
isFile
()){
System
.
out
.
println
(
"输入非图片"
);
return
null
;
}
//读取二维码图片
twodimensioncode
=
ImageIO
.
read
(
twodimensioncodeImg
);
//获取画笔
Graphics2D
g
=
twodimensioncode
.
createGraphics
();
//读取logo图片
BufferedImage
logo
=
ImageIO
.
read
(
logoImg
);
//设置二维码大小,太大,会覆盖二维码,此处20%
int
logoWidth
=
logo
.
getWidth
(
null
)
>
twodimensioncode
.
getWidth
()*
2
/
10
?
(
twodimensioncode
.
getWidth
()*
2
/
10
)
:
logo
.
getWidth
(
null
);
int
logoHeight
=
logo
.
getHeight
(
null
)
>
twodimensioncode
.
getHeight
()*
2
/
10
?
(
twodimensioncode
.
getHeight
()*
2
/
10
)
:
logo
.
getHeight
(
null
);
//设置logo图片放置位置
//中心
int
x
=
(
twodimensioncode
.
getWidth
()
-
logoWidth
)
/
2
;
int
y
=
(
twodimensioncode
.
getHeight
()
-
logoHeight
)
/
2
;
//右下角,15为调整值
// int x = twodimensioncode.getWidth() - logoWidth-15;
// int y = twodimensioncode.getHeight() - logoHeight-15;
//开始合并绘制图片
g
.
drawImage
(
logo
,
x
,
y
,
logoWidth
,
logoHeight
,
null
);
g
.
drawRoundRect
(
x
,
y
,
logoWidth
,
logoHeight
,
15
,
15
);
//logo边框大小
g
.
setStroke
(
new
BasicStroke
(
2
));
//logo边框颜色
g
.
setColor
(
Color
.
WHITE
);
g
.
drawRect
(
x
,
y
,
logoWidth
,
logoHeight
);
g
.
dispose
();
logo
.
flush
();
twodimensioncode
.
flush
();
}
catch
(
Exception
e
){
System
.
out
.
println
(
"二维码绘制logo失败"
);
}
return
twodimensioncode
;
}
/**
* 二维码输出到文件
* @param twodimensioncodeImg 二维码图片文件
* @param logoImg logo图片文件
* @param format 图片格式
* @param file 输出文件
* */
public
static
void
writeToFile
(
File
twodimensioncodeImg
,
File
logoImg
,
String
format
,
File
file
)
throws
IOException
{
BufferedImage
image
=
encodeImgLogo
(
twodimensioncodeImg
,
logoImg
);
try
{
ImageIO
.
write
(
image
,
format
,
file
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"二维码写入文件失败"
+
e
.
getMessage
());
}
}
/**
* 二维码流式输出
* @param twodimensioncodeImg 二维码图片文件
* @param logoImg logo图片文件
* @param format 图片格式
* @param stream 输出流
* */
public
static
void
writeToStream
(
File
twodimensioncodeImg
,
File
logoImg
,
String
format
,
OutputStream
stream
){
BufferedImage
image
=
encodeImgLogo
(
twodimensioncodeImg
,
logoImg
);
try
{
ImageIO
.
write
(
image
,
format
,
stream
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"二维码写入流失败"
+
e
.
getMessage
());
}
}
}
src/main/java/com/mall/util/tongmeng/EncodeImgZingLogoTest.java
0 → 100644
浏览文件 @
4daf6959
package
com
.
mall
.
util
.
tongmeng
;
import
java.io.File
;
import
java.io.IOException
;
/**
* ClassName:EncodeImgZingLogoTest <br/>
* Date: 2019年1月17日 下午12:10:14 <br/>
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 二维码生成器工具测试类
*/
public
class
EncodeImgZingLogoTest
{
public
static
void
main
(
String
[]
args
)
throws
IOException
{
String
contents
=
"https://blog.csdn.net/shasiqq/article/details/80307846"
;
String
format
=
"jpg"
;
//***此处如果格式为"gif",则logo图片为黑色,其他格式ok
//生成二维码
File
img
=
new
File
(
"D:"
+
File
.
separator
+
"csdn.jpg"
);
EncodeImgZxing
.
writeToFile
(
contents
,
format
,
img
);
//生成带有logo图片的二维码
File
logoImg
=
new
File
(
"D:"
+
File
.
separator
+
"logo.jpg"
);
File
img1
=
new
File
(
"D:"
+
File
.
separator
+
"csdnAndLogo.jpg"
);
EncodeImgZingLogo
.
writeToFile
(
img
,
logoImg
,
format
,
img1
);
//解析二维码内容
String
content
=
DecodeImgZxing
.
decodeImg
(
img
);
System
.
out
.
println
(
"1:"
+
content
);
//解析二维码带logo内容
String
content1
=
DecodeImgZxing
.
decodeImg
(
img1
);
System
.
out
.
println
(
"2:"
+
content1
);
}
}
src/main/java/com/mall/util/tongmeng/EncodeImgZxing.java
0 → 100644
浏览文件 @
4daf6959
package
com
.
mall
.
util
.
tongmeng
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.util.EnumMap
;
import
javax.imageio.ImageIO
;
import
com.google.zxing.BarcodeFormat
;
import
com.google.zxing.EncodeHintType
;
import
com.google.zxing.MultiFormatWriter
;
import
com.google.zxing.common.BitMatrix
;
import
com.google.zxing.qrcode.decoder.ErrorCorrectionLevel
;
/**
* ClassName:EncodeImgZxing <br/>
* Function: TODO ADD FUNCTION. <br/>
* Reason: TODO ADD REASON. <br/>
* Date: 2019年1月17日 上午11:55:40 <br/>
* @author 林海冰
* @version 广州抵奥云信息科技有限公司
* @since JDK 1.8
* @see 生成二维码准备文件
*/
public
class
EncodeImgZxing
{
//二维码颜色
private
static
final
int
BLACK
=
0xFF000000
;
//0xFFFF0000,红色
//二维码背景色
private
static
final
int
WHITE
=
0xFFFFFFFF
;
//0xFF0000FF,蓝色
//注:二维码颜色色差大,扫描快,但如果"BLACK'设置为黑色外其他颜色,可能无法扫描
//二维码图片宽度
private
static
final
int
width
=
300
;
//二维码图片高度
private
static
final
int
height
=
300
;
//二维码格式参数
private
static
final
EnumMap
<
EncodeHintType
,
Object
>
hints
=
new
EnumMap
<
EncodeHintType
,
Object
>(
EncodeHintType
.
class
);
static
{
/*二维码的纠错级别(排错率),4个级别:
L (7%)、
M (15%)、
Q (25%)、
H (30%)(最高H)
纠错信息同样存储在二维码中,纠错级别越高,纠错信息占用的空间越多,那么能存储的有用讯息就越少;共有四级;
选择M,扫描速度快。
*/
hints
.
put
(
EncodeHintType
.
ERROR_CORRECTION
,
ErrorCorrectionLevel
.
H
);
// 二维码边界空白大小 1,2,3,4 (4为默认,最大)
hints
.
put
(
EncodeHintType
.
MARGIN
,
1
);
hints
.
put
(
EncodeHintType
.
CHARACTER_SET
,
"UTF-8"
);
hints
.
put
(
EncodeHintType
.
MAX_SIZE
,
350
);
hints
.
put
(
EncodeHintType
.
MIN_SIZE
,
150
);
}
/**
* 绘制二维码
* @param contents 二维码内容
* @return image 二维码图片
* */
public
static
BufferedImage
encodeImg
(
String
contents
){
BufferedImage
image
=
null
;
try
{
BitMatrix
matrix
=
new
MultiFormatWriter
().
encode
(
contents
,
BarcodeFormat
.
QR_CODE
,
width
,
height
,
hints
);
image
=
new
BufferedImage
(
width
,
height
,
BufferedImage
.
TYPE_INT_RGB
);
int
width
=
matrix
.
getWidth
();
int
height
=
matrix
.
getHeight
();
for
(
int
x
=
0
;
x
<
width
;
x
++){
for
(
int
y
=
0
;
y
<
height
;
y
++){
image
.
setRGB
(
x
,
y
,
matrix
.
get
(
x
,
y
)
?
BLACK
:
WHITE
);
}
}
}
catch
(
Exception
e
){
System
.
out
.
println
(
"生成二维码失败"
+
e
.
getMessage
());
}
return
image
;
}
/**
* 二维码输出到文件
* @param contents 二维码内容
* @param format 图片格式
* @param file 输出文件
* */
public
static
void
writeToFile
(
String
contents
,
String
format
,
File
file
){
BufferedImage
image
=
encodeImg
(
contents
);
try
{
ImageIO
.
write
(
image
,
format
,
file
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"二维码写入文件失败"
+
e
.
getMessage
());
}
}
/**
* 二维码流式输出
* @param contents 二维码内容
* @param format 图片格式
* @param stream 输出流
* */
public
static
void
writeToStream
(
String
contents
,
String
format
,
OutputStream
stream
){
BufferedImage
image
=
encodeImg
(
contents
);
try
{
ImageIO
.
write
(
image
,
format
,
stream
);
}
catch
(
IOException
e
)
{
System
.
out
.
println
(
"二维码写入流失败"
+
e
.
getMessage
());
}
}
}
src/main/resources/mybatis1/tongmeng/StoreManager.xml
浏览文件 @
4daf6959
...
...
@@ -182,6 +182,15 @@
#{item}
</foreach>
</delete>
<select
id=
"findByPhone"
parameterType=
"pd"
resultType=
"pd"
>
select
<include
refid=
"Field"
></include>
from
<include
refid=
"tableName"
></include>
where mobile = #{phone}
</select>
<!-- 添加访问量 -->
<update
id=
"addStoreViewNumber"
parameterType=
"pd"
>
update
<include
refid=
"tableName"
></include>
...
...
@@ -189,6 +198,7 @@
store_view_number = #{store_view_number}
where store_id = #{store_id}
</update>
<!-- 添加被访问量 -->
<update
id=
"addViewNumber"
parameterType=
"pd"
>
update
<include
refid=
"tableName"
></include>
...
...
@@ -196,6 +206,7 @@
view_number = #{view_number}
where store_id = #{store_id}
</update>
<!-- 改变店铺状态 -->
<update
id=
"updateIsValid"
parameterType=
"pd"
>
update
<include
refid=
"tableName"
></include>
...
...
@@ -203,6 +214,13 @@
is_valid_store = #{is_valid_store}
where store_id = #{store_id}
</update>
<!-- 通过店铺名称获取数据 -->
<select
id=
"findByStore"
parameterType=
"pd"
resultType=
"pd"
>
select
<include
refid=
"Field"
></include>
from
<include
refid=
"tableName"
></include>
where store_name = #{store_name}
</select>
</mapper>
\ No newline at end of file
src/main/resources/mybatis1/tongmeng/ValidateMapper.xml
0 → 100644
浏览文件 @
4daf6959
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"ValidateMapper"
>
<!--表名 -->
<sql
id=
"tableName"
>
t_validate_code
</sql>
<!-- 字段 -->
<sql
id=
"Field"
>
id,
phone,
create_time,
authcode,
code_from
</sql>
<!-- 字段值 -->
<sql
id=
"FieldValue"
>
#{id},
#{phone},
#{create_time},
#{authcode},
#{code_from}
</sql>
<!-- 新增-->
<insert
id=
"save"
parameterType=
"pd"
>
insert into
<include
refid=
"tableName"
></include>
(
<include
refid=
"Field"
></include>
) values (
<include
refid=
"FieldValue"
></include>
)
</insert>
<!-- 删除-->
<delete
id=
"delete"
parameterType=
"pd"
>
delete from
<include
refid=
"tableName"
></include>
where
id = #{id}
</delete>
<!-- 修改 -->
<update
id=
"edit"
parameterType=
"pd"
>
update
<include
refid=
"tableName"
></include>
set
id = #{id},
phone = #{phone},
create_time = #{create_time},
authcode = #{authcode},
code_from =#{code_from}
where
id = #{id}
</update>
<!-- 通过ID获取数据 -->
<select
id=
"findById"
parameterType=
"pd"
resultType=
"pd"
>
select
<include
refid=
"Field"
></include>
from
<include
refid=
"tableName"
></include>
where
id = #{id}
</select>
<!-- 列表 -->
<select
id=
"datalistPage"
parameterType=
"page"
resultType=
"pd"
>
select
<include
refid=
"Field"
></include>
from
<include
refid=
"tableName"
></include>
where 1=1
<if
test=
"pd.keywords!= null and pd.keywords != ''"
>
<!-- 关键词检索 -->
and
(
<!-- 根据需求自己加检索条件
字段1 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
or
字段2 LIKE CONCAT(CONCAT('%', #{pd.keywords}),'%')
-->
)
</if>
</select>
<!-- 列表(全部) -->
<select
id=
"listAll"
parameterType=
"pd"
resultType=
"pd"
>
select
<include
refid=
"Field"
></include>
from
<include
refid=
"tableName"
></include>
</select>
<!-- 通过手机号查找对象 -->
<select
id=
"findByPhone"
parameterType=
"String"
resultType=
"pd"
>
select
*
from
<include
refid=
"tableName"
></include>
where
phone=#{phone}
</select>
<!-- 批量删除 -->
<delete
id=
"deleteAll"
parameterType=
"String"
>
delete from
<include
refid=
"tableName"
></include>
where
id in
<foreach
item=
"item"
index=
"index"
collection=
"array"
open=
"("
separator=
","
close=
")"
>
#{item}
</foreach>
</delete>
<!--通过手机号删除元组-->
<!-- 删除-->
<delete
id=
"deleteByPhone"
parameterType=
"String"
>
delete from
<include
refid=
"tableName"
></include>
where
phone = #{phone}
</delete>
</mapper>
\ No newline at end of file
src/main/webapp/WEB-INF/jsp/tongmeng/store/store_list.jsp
浏览文件 @
4daf6959
...
...
@@ -90,7 +90,7 @@
<c:forEach
items=
"
${
varList
}
"
var=
"var"
varStatus=
"vs"
>
<tr>
<td
class=
'center'
>
<label
class=
"pos-rel"
><input
type=
'checkbox'
name=
'ids'
value=
"${var.
open
id}"
class=
"ace"
/><span
class=
"lbl"
></span></label>
<label
class=
"pos-rel"
><input
type=
'checkbox'
name=
'ids'
value=
"${var.
store_
id}"
class=
"ace"
/><span
class=
"lbl"
></span></label>
</td>
<td
class=
'center'
style=
"width: 30px;"
>
${vs.index+1}
</td>
<td
class=
'center'
><img
src=
"${var.store_logo}"
style=
"height:50px"
></td>
...
...
@@ -131,39 +131,12 @@
</a>
</c:if> --%>
<c:if
test=
"
${
QX
.
del
==
1
}
"
>
<a
class=
"btn btn-xs btn-danger"
onclick=
"del('${var.
open
id}');"
>
<a
class=
"btn btn-xs btn-danger"
onclick=
"del('${var.
store_
id}');"
>
<i
class=
"ace-icon fa fa-trash-o bigger-120"
title=
"删除"
></i>
</a>
</c:if>
</div>
<div
class=
"hidden-md hidden-lg"
>
<div
class=
"inline pos-rel"
>
<button
class=
"btn btn-minier btn-primary dropdown-toggle"
data-toggle=
"dropdown"
data-position=
"auto"
>
<i
class=
"ace-icon fa fa-cog icon-only bigger-110"
></i>
</button>
<ul
class=
"dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close"
>
<c:if
test=
"
${
QX
.
edit
==
1
}
"
>
<li>
<a
style=
"cursor:pointer;"
onclick=
"edit('${var.openid}');"
class=
"tooltip-success"
data-rel=
"tooltip"
title=
"修改"
>
<span
class=
"green"
>
<i
class=
"ace-icon fa fa-pencil-square-o bigger-120"
></i>
</span>
</a>
</li>
</c:if>
<c:if
test=
"
${
QX
.
del
==
1
}
"
>
<li>
<a
style=
"cursor:pointer;"
onclick=
"del('${var.openid}');"
class=
"tooltip-error"
data-rel=
"tooltip"
title=
"删除"
>
<span
class=
"red"
>
<i
class=
"ace-icon fa fa-trash-o bigger-120"
></i>
</span>
</a>
</li>
</c:if>
</ul>
</div>
</div>
</td>
</tr>
</c:forEach>
...
...
@@ -291,7 +264,7 @@
var
diag
=
new
top
.
Dialog
();
diag
.
Drag
=
true
;
diag
.
Title
=
"新增"
;
diag
.
URL
=
'${pageContext.request.contextPath}/
vehicleUser
/goAdd.do'
;
diag
.
URL
=
'${pageContext.request.contextPath}/
store
/goAdd.do'
;
diag
.
Width
=
900
;
diag
.
Height
=
710
;
diag
.
Modal
=
true
;
//有无遮罩窗口
...
...
@@ -315,7 +288,7 @@
bootbox
.
confirm
(
"确定要删除吗?"
,
function
(
result
)
{
if
(
result
)
{
top
.
jzts
();
var
url
=
"${pageContext.request.contextPath}/
vehicleUser/delete.do?open
id="
+
Id
+
"&tm="
+
new
Date
().
getTime
();
var
url
=
"${pageContext.request.contextPath}/
store/delete.do?store_
id="
+
Id
+
"&tm="
+
new
Date
().
getTime
();
$
.
get
(
url
,
function
(
data
){
nextPage
(
$
{
page
.
currentPage
});
});
...
...
@@ -329,7 +302,7 @@
var
diag
=
new
top
.
Dialog
();
diag
.
Drag
=
true
;
diag
.
Title
=
"编辑"
;
diag
.
URL
=
'${pageContext.request.contextPath}/
vehicleUser
/goEdit.do?openid='
+
Id
;
diag
.
URL
=
'${pageContext.request.contextPath}/
store
/goEdit.do?openid='
+
Id
;
diag
.
Width
=
900
;
diag
.
Height
=
710
;
diag
.
Modal
=
true
;
//有无遮罩窗口
...
...
@@ -373,7 +346,7 @@
top
.
jzts
();
$
.
ajax
({
type
:
"POST"
,
url
:
'${pageContext.request.contextPath}/
vehicleUser
/deleteAll.do?tm='
+
new
Date
().
getTime
(),
url
:
'${pageContext.request.contextPath}/
store
/deleteAll.do?tm='
+
new
Date
().
getTime
(),
data
:
{
DATA_IDS
:
str
},
dataType
:
'json'
,
//beforeSend: validateData,
...
...
@@ -392,23 +365,9 @@
//导出excel
function
toExcel
(){
window
.
location
.
href
=
'${pageContext.request.contextPath}/vehicleUser/excel.do'
;
};
//导出省
function
provinceExcel
(){
var
excelType
=
$
(
"#excelType option:selected"
).
val
();
var
excelTime
=
$
(
"#excelTime option:selected"
).
val
();
// alert(excelType+" " +excelTime);
window
.
location
.
href
=
'${pageContext.request.contextPath}/vehicleUser/visit_uv_new_excel.do?excelType='
+
excelType
+
'&excelTime='
+
excelTime
+
'&tm='
+
new
Date
().
getTime
();
};
//导出市
function
cityExcel
(){
var
excelType
=
$
(
"#excelType option:selected"
).
val
();
var
excelTime
=
$
(
"#excelTime option:selected"
).
val
();
var
excelCity
=
$
(
"#excelCity option:selected"
).
val
();
$
(
"#province"
)
window
.
location
.
href
=
'${pageContext.request.contextPath}/vehicleUser/visit_uv_excel.do?excelType='
+
excelType
+
'&excelCityID='
+
excelCity
+
'&tm='
+
new
Date
().
getTime
()
+
'&excelTime='
+
excelTime
;
};
window
.
location
.
href
=
'${pageContext.request.contextPath}/store/excel.do'
;
}
</script>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论