Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
0aeb3678
Commit
0aeb3678
authored
Jul 24, 2018
by
Menethil
Browse files
服务器添加支持微信FormId缓存,用于营销或者非用户操作期间通过模版消息通知用户
parent
5c626152
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/NotifyService.java
View file @
0aeb3678
...
...
@@ -73,19 +73,36 @@ public class NotifyService {
/**
* 微信模版消息通知
*
* @param token 通过wxMAService获取token或者通过url请求token
* @param touser 接收者openId
* @param formId 表单ID或者 prepayId
* @param notifyType 通知类别,通过该枚举值在配置文件中获取相应的模版ID
* @param params 通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
*/
@Async
public
void
notifyWxTemplate
(
String
token
,
String
touser
,
String
formId
,
NotifyType
notifyType
,
String
[]
params
)
{
public
void
notifyWxTemplate
(
String
touser
,
String
formId
,
NotifyType
notifyType
,
String
[]
params
)
{
if
(
wxTemplateSender
==
null
)
return
;
String
templateId
=
getTemplateId
(
notifyType
,
wxTemplate
);
wxTemplateSender
.
sendWechatMsg
(
token
,
touser
,
templateId
,
formId
,
""
,
""
,
params
);
wxTemplateSender
.
sendWechatMsg
(
touser
,
templateId
,
formId
,
""
,
""
,
params
);
}
/**
* 微信模版消息通知
* <p>
* 该方法会尝试从数据库获取缓存的FormId去发送消息
*
* @param touser 接收者openId
* @param notifyType 通知类别,通过该枚举值在配置文件中获取相应的模版ID
* @param params 通知模版内容里的参数,类似"您的验证码为{1}"中{1}的值
*/
@Async
public
void
notifyWxTemplate
(
String
touser
,
NotifyType
notifyType
,
String
[]
params
)
{
if
(
wxTemplateSender
==
null
)
return
;
String
templateId
=
getTemplateId
(
notifyType
,
wxTemplate
);
wxTemplateSender
.
sendWechatMsg
(
touser
,
templateId
,
params
);
}
/**
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/WxTemplateSender.java
View file @
0aeb3678
package
org.linlinjava.litemall.core.notify
;
import
cn.binarywang.wx.miniapp.api.WxMaService
;
import
org.json.JSONObject
;
import
org.linlinjava.litemall.db.domain.LitemallUserFormid
;
import
org.linlinjava.litemall.db.service.LitemallUserFormIdService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
javax.net.ssl.*
;
import
java.io.BufferedReader
;
...
...
@@ -19,6 +21,27 @@ import java.security.cert.X509Certificate;
* 微信模版消息通知
*/
public
class
WxTemplateSender
{
@Autowired
WxMaService
wxMaService
;
@Autowired
LitemallUserFormIdService
formIdService
;
/**
* 发送微信消息(模板消息)
*
* @param touser 用户 OpenID
* @param templatId 模板消息ID
* @param parms 详细内容
*/
public
void
sendWechatMsg
(
String
touser
,
String
templatId
,
String
[]
parms
)
{
LitemallUserFormid
userFormid
=
formIdService
.
queryByOpenId
(
touser
);
if
(
userFormid
==
null
)
return
;
sendWechatMsg
(
touser
,
templatId
,
userFormid
.
getFormid
(),
""
,
""
,
parms
);
formIdService
.
delUserFormid
(
userFormid
.
getId
());
}
/**
* 发送微信消息(模板消息)
...
...
@@ -31,9 +54,9 @@ public class WxTemplateSender {
* @param parms 详细内容
* @return
*/
public
String
sendWechatMsg
(
String
token
,
String
touser
,
String
templatId
,
String
formId
,
String
clickurl
,
String
topcolor
,
String
[]
parms
)
{
public
String
sendWechatMsg
(
String
touser
,
String
templatId
,
String
formId
,
String
clickurl
,
String
topcolor
,
String
[]
parms
)
{
try
{
String
tmpurl
=
"https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="
+
t
oken
;
String
tmpurl
=
"https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token="
+
wxMaService
.
getAccessT
oken
()
;
JSONObject
json
=
new
JSONObject
();
json
.
put
(
"touser"
,
touser
);
json
.
put
(
"template_id"
,
templatId
);
...
...
@@ -57,6 +80,7 @@ public class WxTemplateSender {
/**
* 根据参数生成对应的 json 数据
*
* @param parms
* @return
*/
...
...
@@ -64,7 +88,7 @@ public class WxTemplateSender {
JSONObject
json
=
new
JSONObject
();
for
(
int
i
=
1
;
i
<=
parms
.
length
;
i
++)
{
JSONObject
json2
=
new
JSONObject
();
json2
.
put
(
"value"
,
parms
[
i
-
1
]);
json2
.
put
(
"value"
,
parms
[
i
-
1
]);
json
.
put
(
"keyword"
+
i
,
json2
);
}
...
...
litemall-core/src/test/java/org/linlinjava/litemall/core/WxTemplateTest.java
View file @
0aeb3678
...
...
@@ -21,11 +21,10 @@ public class WxTemplateTest {
@Test
public
void
testPaySucceed
()
{
String
token
=
"xx"
;
String
touser
=
"xx"
;
String
formId
=
""
;
String
[]
params
=
new
String
[]{
"xxx"
};
notifyService
.
notifyWxTemplate
(
token
,
touser
,
formId
,
NotifyType
.
PAY_SUCCEED
,
params
);
notifyService
.
notifyWxTemplate
(
touser
,
formId
,
NotifyType
.
PAY_SUCCEED
,
params
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
...
...
litemall-db/mybatis-generator/generatorConfig.xml
View file @
0aeb3678
...
...
@@ -20,7 +20,7 @@
<!-- 查询单条数据插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectOneByExamplePlugin"
/>
<!-- 查询结果选择性返回插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin"
/>
<plugin
type=
"com.itfsw.mybatis.generator.plugins.SelectSelectivePlugin"
/>
<!-- Example Criteria 增强插件 -->
<plugin
type=
"com.itfsw.mybatis.generator.plugins.ExampleEnhancedPlugin"
/>
<!-- 数据Model属性对应Column获取插件 -->
...
...
@@ -47,77 +47,81 @@
<jdbcConnection
driverClass=
"com.mysql.jdbc.Driver"
connectionURL=
"jdbc:mysql://127.0.0.1:3306/litemall?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC&verifyServerCertificate=false&useSSL=false"
userId=
"litemall"
password=
"litemall123456"
/>
password=
"litemall123456"
/>
<javaModelGenerator
targetPackage=
"org.linlinjava.litemall.db.domain"
targetProject=
"src/main/java"
/>
<sqlMapGenerator
targetPackage=
"org.linlinjava.litemall.db.dao"
targetProject=
"src/main/resources"
/>
<javaClientGenerator
type=
"XMLMAPPER"
targetPackage=
"org.linlinjava.litemall.db.dao"
targetProject=
"src/main/java"
/>
<javaModelGenerator
targetPackage=
"org.linlinjava.litemall.db.domain"
targetProject=
"src/main/java"
/>
<sqlMapGenerator
targetPackage=
"org.linlinjava.litemall.db.dao"
targetProject=
"src/main/resources"
/>
<javaClientGenerator
type=
"XMLMAPPER"
targetPackage=
"org.linlinjava.litemall.db.dao"
targetProject=
"src/main/java"
/>
<!--表名-->
<table
tableName=
"litemall_ad"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"start_time"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"end_time"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_address"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_admin"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"last_login_time"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_brand"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_cart"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"specifications"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"specifications"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_category"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_collect"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_comment"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
<columnOverride
column=
"pic_urls"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<columnOverride
column=
"pic_urls"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
</table>
<table
tableName=
"litemall_footprint"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_goods"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
<columnOverride
column=
"gallery"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<columnOverride
column=
"gallery"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
</table>
<table
tableName=
"litemall_goods_attribute"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_goods_specification"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_issue"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_keyword"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_order"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"pay_time"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"ship_time"
/>
...
...
@@ -125,40 +129,48 @@
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"end_time"
/>
</table>
<table
tableName=
"litemall_order_goods"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"specifications"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"specifications"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_product"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"specifications"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"specifications"
javaType=
"java.lang.String[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonStringArrayTypeHandler"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_region"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"litemall_search_history"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_storage"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"modified"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_topic"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"goods"
javaType=
"java.lang.Integer[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
column=
"goods"
javaType=
"java.lang.Integer[]"
typeHandler=
"org.linlinjava.litemall.db.mybatis.JsonIntegerArrayTypeHandler"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_user"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDate"
column=
"birthday"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"last_login_time"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"add_time"
/>
</table>
<table
tableName=
"litemall_system"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
</table>
<table
tableName=
"litemall_user_formid"
>
<generatedKey
column=
"id"
sqlStatement=
"MySql"
identity=
"true"
/>
<columnOverride
javaType=
"java.time.LocalDateTime"
column=
"expire_time"
/>
</table>
</context>
</generatorConfiguration>
\ No newline at end of file
litemall-db/src/main/java/org/linlinjava/litemall/db/dao/LitemallUserFormidMapper.java
0 → 100644
View file @
0aeb3678
package
org.linlinjava.litemall.db.dao
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
import
org.linlinjava.litemall.db.domain.LitemallUserFormid
;
import
org.linlinjava.litemall.db.domain.LitemallUserFormidExample
;
public
interface
LitemallUserFormidMapper
{
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
long
countByExample
(
LitemallUserFormidExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
deleteByExample
(
LitemallUserFormidExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
deleteByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
insert
(
LitemallUserFormid
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
insertSelective
(
LitemallUserFormid
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallUserFormid
selectOneByExample
(
LitemallUserFormidExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallUserFormid
selectOneByExampleSelective
(
@Param
(
"example"
)
LitemallUserFormidExample
example
,
@Param
(
"selective"
)
LitemallUserFormid
.
Column
...
selective
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
List
<
LitemallUserFormid
>
selectByExampleSelective
(
@Param
(
"example"
)
LitemallUserFormidExample
example
,
@Param
(
"selective"
)
LitemallUserFormid
.
Column
...
selective
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
List
<
LitemallUserFormid
>
selectByExample
(
LitemallUserFormidExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
LitemallUserFormid
selectByPrimaryKeySelective
(
@Param
(
"id"
)
Integer
id
,
@Param
(
"selective"
)
LitemallUserFormid
.
Column
...
selective
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
LitemallUserFormid
selectByPrimaryKey
(
Integer
id
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
updateByExampleSelective
(
@Param
(
"record"
)
LitemallUserFormid
record
,
@Param
(
"example"
)
LitemallUserFormidExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
updateByExample
(
@Param
(
"record"
)
LitemallUserFormid
record
,
@Param
(
"example"
)
LitemallUserFormidExample
example
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
updateByPrimaryKeySelective
(
LitemallUserFormid
record
);
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
int
updateByPrimaryKey
(
LitemallUserFormid
record
);
}
\ No newline at end of file
litemall-db/src/main/java/org/linlinjava/litemall/db/domain/LitemallUserFormid.java
0 → 100644
View file @
0aeb3678
package
org.linlinjava.litemall.db.domain
;
import
java.time.LocalDateTime
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
public
class
LitemallUserFormid
{
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user_formid.id
*
* @mbg.generated
*/
private
Integer
id
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user_formid.formId
*
* @mbg.generated
*/
private
String
formid
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user_formid.isprepay
*
* @mbg.generated
*/
private
Boolean
isprepay
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user_formid.useAmount
*
* @mbg.generated
*/
private
Integer
useamount
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user_formid.expire_time
*
* @mbg.generated
*/
private
LocalDateTime
expireTime
;
/**
*
* This field was generated by MyBatis Generator.
* This field corresponds to the database column litemall_user_formid.openId
*
* @mbg.generated
*/
private
String
openid
;
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user_formid.id
*
* @return the value of litemall_user_formid.id
*
* @mbg.generated
*/
public
Integer
getId
()
{
return
id
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user_formid.id
*
* @param id the value for litemall_user_formid.id
*
* @mbg.generated
*/
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user_formid.formId
*
* @return the value of litemall_user_formid.formId
*
* @mbg.generated
*/
public
String
getFormid
()
{
return
formid
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user_formid.formId
*
* @param formid the value for litemall_user_formid.formId
*
* @mbg.generated
*/
public
void
setFormid
(
String
formid
)
{
this
.
formid
=
formid
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user_formid.isprepay
*
* @return the value of litemall_user_formid.isprepay
*
* @mbg.generated
*/
public
Boolean
getIsprepay
()
{
return
isprepay
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user_formid.isprepay
*
* @param isprepay the value for litemall_user_formid.isprepay
*
* @mbg.generated
*/
public
void
setIsprepay
(
Boolean
isprepay
)
{
this
.
isprepay
=
isprepay
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user_formid.useAmount
*
* @return the value of litemall_user_formid.useAmount
*
* @mbg.generated
*/
public
Integer
getUseamount
()
{
return
useamount
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user_formid.useAmount
*
* @param useamount the value for litemall_user_formid.useAmount
*
* @mbg.generated
*/
public
void
setUseamount
(
Integer
useamount
)
{
this
.
useamount
=
useamount
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user_formid.expire_time
*
* @return the value of litemall_user_formid.expire_time
*
* @mbg.generated
*/
public
LocalDateTime
getExpireTime
()
{
return
expireTime
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user_formid.expire_time
*
* @param expireTime the value for litemall_user_formid.expire_time
*
* @mbg.generated
*/
public
void
setExpireTime
(
LocalDateTime
expireTime
)
{
this
.
expireTime
=
expireTime
;
}
/**
* This method was generated by MyBatis Generator.
* This method returns the value of the database column litemall_user_formid.openId
*
* @return the value of litemall_user_formid.openId
*
* @mbg.generated
*/
public
String
getOpenid
()
{
return
openid
;
}
/**
* This method was generated by MyBatis Generator.
* This method sets the value of the database column litemall_user_formid.openId
*
* @param openid the value for litemall_user_formid.openId
*
* @mbg.generated
*/
public
void
setOpenid
(
String
openid
)
{
this
.
openid
=
openid
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
sb
.
append
(
getClass
().
getSimpleName
());
sb
.
append
(
" ["
);
sb
.
append
(
"Hash = "
).
append
(
hashCode
());
sb
.
append
(
", id="
).
append
(
id
);
sb
.
append
(
", formid="
).
append
(
formid
);
sb
.
append
(
", isprepay="
).
append
(
isprepay
);
sb
.
append
(
", useamount="
).
append
(
useamount
);
sb
.
append
(
", expireTime="
).
append
(
expireTime
);
sb
.
append
(
", openid="
).
append
(
openid
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
@Override
public
boolean
equals
(
Object
that
)
{
if
(
this
==
that
)
{
return
true
;
}
if
(
that
==
null
)
{
return
false
;
}
if
(
getClass
()
!=
that
.
getClass
())
{
return
false
;
}
LitemallUserFormid
other
=
(
LitemallUserFormid
)
that
;
return
(
this
.
getId
()
==
null
?
other
.
getId
()
==
null
:
this
.
getId
().
equals
(
other
.
getId
()))
&&
(
this
.
getFormid
()
==
null
?
other
.
getFormid
()
==
null
:
this
.
getFormid
().
equals
(
other
.
getFormid
()))
&&
(
this
.
getIsprepay
()
==
null
?
other
.
getIsprepay
()
==
null
:
this
.
getIsprepay
().
equals
(
other
.
getIsprepay
()))
&&
(
this
.
getUseamount
()
==
null
?
other
.
getUseamount
()
==
null
:
this
.
getUseamount
().
equals
(
other
.
getUseamount
()))
&&
(
this
.
getExpireTime
()
==
null
?
other
.
getExpireTime
()
==
null
:
this
.
getExpireTime
().
equals
(
other
.
getExpireTime
()))
&&
(
this
.
getOpenid
()
==
null
?
other
.
getOpenid
()
==
null
:
this
.
getOpenid
().
equals
(
other
.
getOpenid
()));
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
*/
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
getId
()
==
null
)
?
0
:
getId
().
hashCode
());
result
=
prime
*
result
+
((
getFormid
()
==
null
)
?
0
:
getFormid
().
hashCode
());
result
=
prime
*
result
+
((
getIsprepay
()
==
null
)
?
0
:
getIsprepay
().
hashCode
());
result
=
prime
*
result
+
((
getUseamount
()
==
null
)
?
0
:
getUseamount
().
hashCode
());
result
=
prime
*
result
+
((
getExpireTime
()
==
null
)
?
0
:
getExpireTime
().
hashCode
());
result
=
prime
*
result
+
((
getOpenid
()
==
null
)
?
0
:
getOpenid
().
hashCode
());
return
result
;
}
/**
* This enum was generated by MyBatis Generator.
* This enum corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
enum
Column
{
id
(
"id"
,
"id"
,
"INTEGER"
),
formid
(
"formId"
,
"formid"
,
"VARCHAR"
),
isprepay
(
"isprepay"
,
"isprepay"
,
"BIT"
),
useamount
(
"useAmount"
,
"useamount"
,
"INTEGER"
),
expireTime
(
"expire_time"
,
"expireTime"
,
"TIMESTAMP"
),
openid
(
"openId"
,
"openid"
,
"VARCHAR"
);
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
String
column
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
String
javaProperty
;
/**
* This field was generated by MyBatis Generator.
* This field corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
private
final
String
jdbcType
;
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
value
()
{
return
this
.
column
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getValue
()
{
return
this
.
column
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getJavaProperty
()
{
return
this
.
javaProperty
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
getJdbcType
()
{
return
this
.
jdbcType
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
Column
(
String
column
,
String
javaProperty
,
String
jdbcType
)
{
this
.
column
=
column
;
this
.
javaProperty
=
javaProperty
;
this
.
jdbcType
=
jdbcType
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
desc
()
{
return
this
.
column
+
" DESC"
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
String
asc
()
{
return
this
.
column
+
" ASC"
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table litemall_user_formid
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
static
Column
[]
excludes
(
Column
...
excludes
)
{
ArrayList
<
Column
>
columns
=
new
ArrayList
<>(
Arrays
.
asList
(
Column
.
values
()));
if
(
excludes
!=
null
&&
excludes
.
length
>
0
)
{
columns
.
removeAll
(
new
ArrayList
<>(
Arrays
.
asList
(
excludes
)));
}
return
columns
.
toArray
(
new
Column
[]{});
}
}
}
\ No newline at end of file
litemall-db/src/main/java/org/linlinjava/litemall/db/domain/LitemallUserFormidExample.java
0 → 100644
View file @
0aeb3678
This diff is collapsed.
Click to expand it.
litemall-db/src/main/java/org/linlinjava/litemall/db/service/LitemallUserFormIdService.java
0 → 100644
View file @
0aeb3678
package
org.linlinjava.litemall.db.service
;
import
org.linlinjava.litemall.db.dao.LitemallUserFormidMapper
;
import
org.linlinjava.litemall.db.domain.LitemallUserFormid
;
import
org.linlinjava.litemall.db.domain.LitemallUserFormidExample
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.time.LocalDateTime
;
@Service
public
class
LitemallUserFormIdService
{
@Resource
private
LitemallUserFormidMapper
formidMapper
;
/**
* 查找是否有可用的FormId
*
* @param openId
* @return
*/
public
LitemallUserFormid
queryByOpenId
(
String
openId
)
{
LitemallUserFormidExample
example
=
new
LitemallUserFormidExample
();
//符合找到该用户记录,且可用次数大于1,且还未过期
example
.
or
().
andOpenidEqualTo
(
openId
).
andExpireTimeGreaterThan
(
LocalDateTime
.
now
());
return
formidMapper
.
selectOneByExample
(
example
);
}
/**
* 添加一个 FormId
*
* @param userFormid
*/
public
void
addUserFormid
(
LitemallUserFormid
userFormid
)
{
formidMapper
.
insertSelective
(
userFormid
);
}
/**
* 删除一个 FormId
*
* @param userFormidId
*/
public
void
delUserFormid
(
Integer
userFormidId
)
{
formidMapper
.
deleteByPrimaryKey
(
userFormidId
);
}
}
litemall-db/src/main/resources/org/linlinjava/litemall/db/dao/LitemallUserFormidMapper.xml
0 → 100644
View file @
0aeb3678
<?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=
"org.linlinjava.litemall.db.dao.LitemallUserFormidMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"org.linlinjava.litemall.db.domain.LitemallUserFormid"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<id
column=
"id"
jdbcType=
"INTEGER"
property=
"id"
/>
<result
column=
"formId"
jdbcType=
"VARCHAR"
property=
"formid"
/>
<result
column=
"isprepay"
jdbcType=
"BIT"
property=
"isprepay"
/>
<result
column=
"useAmount"
jdbcType=
"INTEGER"
property=
"useamount"
/>
<result
column=
"expire_time"
jdbcType=
"TIMESTAMP"
property=
"expireTime"
/>
<result
column=
"openId"
jdbcType=
"VARCHAR"
property=
"openid"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach
collection=
"oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Update_By_Example_Where_Clause"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<where>
<foreach
collection=
"example.oredCriteria"
item=
"criteria"
separator=
"or"
>
<if
test=
"criteria.valid"
>
<trim
prefix=
"("
prefixOverrides=
"and"
suffix=
")"
>
<foreach
collection=
"criteria.criteria"
item=
"criterion"
>
<choose>
<when
test=
"criterion.noValue"
>
and ${criterion.condition}
</when>
<when
test=
"criterion.singleValue"
>
and ${criterion.condition} #{criterion.value}
</when>
<when
test=
"criterion.betweenValue"
>
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when
test=
"criterion.listValue"
>
and ${criterion.condition}
<foreach
close=
")"
collection=
"criterion.value"
item=
"listItem"
open=
"("
separator=
","
>
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql
id=
"Base_Column_List"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
id, formId, isprepay, useAmount, expire_time, openId
</sql>
<select
id=
"selectByExample"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormidExample"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<if
test=
"distinct"
>
distinct
</if>
<include
refid=
"Base_Column_List"
/>
from litemall_user_formid
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
</select>
<select
id=
"selectByExampleSelective"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<if
test=
"example.distinct"
>
distinct
</if>
<choose>
<when
test=
"selective != null and selective.length > 0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.value}
</foreach>
</when>
<otherwise>
id, formId, isprepay, useAmount, expire_time, openId
</otherwise>
</choose>
from litemall_user_formid
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
<if
test=
"example.orderByClause != null"
>
order by ${example.orderByClause}
</if>
</select>
<select
id=
"selectByPrimaryKey"
parameterType=
"java.lang.Integer"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select
<include
refid=
"Base_Column_List"
/>
from litemall_user_formid
where id = #{id,jdbcType=INTEGER}
</select>
<select
id=
"selectByPrimaryKeySelective"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when
test=
"selective != null and selective.length > 0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.value}
</foreach>
</when>
<otherwise>
id, formId, isprepay, useAmount, expire_time, openId
</otherwise>
</choose>
from litemall_user_formid
where id = #{id,jdbcType=INTEGER}
</select>
<delete
id=
"deleteByPrimaryKey"
parameterType=
"java.lang.Integer"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_user_formid
where id = #{id,jdbcType=INTEGER}
</delete>
<delete
id=
"deleteByExample"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormidExample"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
delete from litemall_user_formid
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</delete>
<insert
id=
"insert"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormid"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Integer"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_user_formid (formId, isprepay, useAmount,
expire_time, openId)
values (#{formid,jdbcType=VARCHAR}, #{isprepay,jdbcType=BIT}, #{useamount,jdbcType=INTEGER},
#{expireTime,jdbcType=TIMESTAMP}, #{openid,jdbcType=VARCHAR})
</insert>
<insert
id=
"insertSelective"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormid"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Integer"
>
SELECT LAST_INSERT_ID()
</selectKey>
insert into litemall_user_formid
<trim
prefix=
"("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"formid != null"
>
formId,
</if>
<if
test=
"isprepay != null"
>
isprepay,
</if>
<if
test=
"useamount != null"
>
useAmount,
</if>
<if
test=
"expireTime != null"
>
expire_time,
</if>
<if
test=
"openid != null"
>
openId,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"formid != null"
>
#{formid,jdbcType=VARCHAR},
</if>
<if
test=
"isprepay != null"
>
#{isprepay,jdbcType=BIT},
</if>
<if
test=
"useamount != null"
>
#{useamount,jdbcType=INTEGER},
</if>
<if
test=
"expireTime != null"
>
#{expireTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"openid != null"
>
#{openid,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormidExample"
resultType=
"java.lang.Long"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
select count(*) from litemall_user_formid
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
</select>
<update
id=
"updateByExampleSelective"
parameterType=
"map"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_user_formid
<set>
<if
test=
"record.id != null"
>
id = #{record.id,jdbcType=INTEGER},
</if>
<if
test=
"record.formid != null"
>
formId = #{record.formid,jdbcType=VARCHAR},
</if>
<if
test=
"record.isprepay != null"
>
isprepay = #{record.isprepay,jdbcType=BIT},
</if>
<if
test=
"record.useamount != null"
>
useAmount = #{record.useamount,jdbcType=INTEGER},
</if>
<if
test=
"record.expireTime != null"
>
expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"record.openid != null"
>
openId = #{record.openid,jdbcType=VARCHAR},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByExample"
parameterType=
"map"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_user_formid
set id = #{record.id,jdbcType=INTEGER},
formId = #{record.formid,jdbcType=VARCHAR},
isprepay = #{record.isprepay,jdbcType=BIT},
useAmount = #{record.useamount,jdbcType=INTEGER},
expire_time = #{record.expireTime,jdbcType=TIMESTAMP},
openId = #{record.openid,jdbcType=VARCHAR}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
</update>
<update
id=
"updateByPrimaryKeySelective"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormid"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_user_formid
<set>
<if
test=
"formid != null"
>
formId = #{formid,jdbcType=VARCHAR},
</if>
<if
test=
"isprepay != null"
>
isprepay = #{isprepay,jdbcType=BIT},
</if>
<if
test=
"useamount != null"
>
useAmount = #{useamount,jdbcType=INTEGER},
</if>
<if
test=
"expireTime != null"
>
expire_time = #{expireTime,jdbcType=TIMESTAMP},
</if>
<if
test=
"openid != null"
>
openId = #{openid,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update
id=
"updateByPrimaryKey"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormid"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
-->
update litemall_user_formid
set formId = #{formid,jdbcType=VARCHAR},
isprepay = #{isprepay,jdbcType=BIT},
useAmount = #{useamount,jdbcType=INTEGER},
expire_time = #{expireTime,jdbcType=TIMESTAMP},
openId = #{openid,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select
id=
"selectOneByExample"
parameterType=
"org.linlinjava.litemall.db.domain.LitemallUserFormidExample"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<include
refid=
"Base_Column_List"
/>
from litemall_user_formid
<if
test=
"_parameter != null"
>
<include
refid=
"Example_Where_Clause"
/>
</if>
<if
test=
"orderByClause != null"
>
order by ${orderByClause}
</if>
limit 1
</select>
<select
id=
"selectOneByExampleSelective"
parameterType=
"map"
resultMap=
"BaseResultMap"
>
<!--
WARNING - @mbg.generated
This element is automatically generated by MyBatis Generator, do not modify.
@project https://github.com/itfsw/mybatis-generator-plugin
-->
select
<choose>
<when
test=
"selective != null and selective.length > 0"
>
<foreach
collection=
"selective"
item=
"column"
separator=
","
>
${column.value}
</foreach>
</when>
<otherwise>
id, formId, isprepay, useAmount, expire_time, openId
</otherwise>
</choose>
from litemall_user_formid
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
<if
test=
"example.orderByClause != null"
>
order by ${example.orderByClause}
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/web/WxUserFormId.java
0 → 100644
View file @
0aeb3678
package
org.linlinjava.litemall.wx.web
;
import
org.linlinjava.litemall.core.util.ResponseUtil
;
import
org.linlinjava.litemall.db.domain.LitemallUser
;
import
org.linlinjava.litemall.db.domain.LitemallUserFormid
;
import
org.linlinjava.litemall.db.service.LitemallUserFormIdService
;
import
org.linlinjava.litemall.db.service.LitemallUserService
;
import
org.linlinjava.litemall.wx.annotation.LoginUser
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
java.time.LocalDateTime
;
@RestController
@RequestMapping
(
"/wx/formid"
)
public
class
WxUserFormId
{
@Autowired
LitemallUserService
userService
;
@Autowired
LitemallUserFormIdService
formIdService
;
@GetMapping
(
"create"
)
public
Object
create
(
@LoginUser
Integer
userId
,
String
formId
)
{
if
(
userId
==
null
)
{
return
ResponseUtil
.
unlogin
();
}
if
(
formId
==
null
)
{
return
ResponseUtil
.
badArgument
();
}
LitemallUser
user
=
userService
.
findById
(
userId
);
LitemallUserFormid
userFormid
=
new
LitemallUserFormid
();
userFormid
.
setOpenid
(
user
.
getWeixinOpenid
());
userFormid
.
setFormid
(
formId
);
userFormid
.
setIsprepay
(
false
);
userFormid
.
setUseamount
(
1
);
userFormid
.
setExpireTime
(
LocalDateTime
.
now
().
plusDays
(
7
));
formIdService
.
addUserFormid
(
userFormid
);
return
ResponseUtil
.
ok
();
}
}
Write
Preview
Supports
Markdown
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