Skip to content
切换导航面板
项目
群组
代码片段
帮助
zhangtai
/
zzhnc
当前项目
正在载入...
登录
切换导航面板
转到一个项目
项目
版本库
问题
0
合并请求
0
流水线
维基
设置
活动
图像
图表
创建新的问题
作业
提交
问题看板
文件
提交
分支
标签
贡献者
图像
比较
图表
Commit ec3e3a9b
由
zxt@theyeasy.com
编写于
Dec 29, 2017
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改相关bug
1 个父辈
a333d522
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
62 行增加
和
19 行删除
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
src/com/w1hd/zzhnc/model/Goods.java
src/com/w1hd/zzhnc/service/ActivityService.java
src/com/w1hd/zzhnc/service/FansService.java
src/com/w1hd/zzhnc/service/GoodsService.java
src/com/w1hd/zzhnc/controller/wx/WxMiniController.java
查看文件 @
ec3e3a9
...
...
@@ -95,7 +95,7 @@ public class WxMiniController extends BaseController {
}
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
POS
T
)
// 购房助手登录 double lng,double lat
@RequestMapping
(
value
=
"/login"
,
method
=
RequestMethod
.
GE
T
)
// 购房助手登录 double lng,double lat
public
@ResponseBody
Vo_msg
login
(
@RequestParam
(
value
=
"code"
)
String
code
,
@RequestParam
(
value
=
"shareId"
)
Integer
shareId
,
@RequestParam
(
value
=
"nickname"
)
String
nickname
,
@RequestParam
(
value
=
"logo"
)
String
logo
,
@RequestParam
(
value
=
"lng"
)
double
lng
,
...
...
@@ -284,8 +284,7 @@ public class WxMiniController extends BaseController {
PageResults
<
Goods
>
seacrh
=
goodsService
.
seacrh
(
null
,
key
,
null
,
page
,
size
);
List
<
Goods
>
rows
=
seacrh
.
getRows
();
result
.
put
(
"banner"
,
bannerList
);
List
<
MiniHomeVO
>
data
=
MiniHomeVO
.
getData
(
null
,
rows
);
result
.
put
(
"data"
,
data
);
result
.
put
(
"data"
,
rows
);
return
new
Vo_msg
(
0
,
result
);
}
catch
(
Exception
e
)
{
return
new
Vo_msg
(-
1
,
"系统繁忙"
);
...
...
src/com/w1hd/zzhnc/model/Goods.java
查看文件 @
ec3e3a9
package
com
.
w1hd
.
zzhnc
.
model
;
import
java.io.Serializable
;
import
java.math.BigDecimal
;
import
java.util.Date
;
import
javax.persistence.Id
;
public
class
Goods
{
public
class
Goods
implements
Serializable
{
/**
*
*/
private
static
final
long
serialVersionUID
=
7056374928150393961L
;
@Id
private
Integer
id
;
private
Integer
sellerId
;
...
...
@@ -46,7 +52,7 @@ public class Goods {
public
String
getDescription
()
{
return
description
;
}
public
String
getCategoryName
()
{
return
categoryName
;
}
...
...
@@ -275,6 +281,8 @@ public class Goods {
}
public
Integer
getShareCount
()
{
if
(
shareCount
==
null
)
return
1
;
return
shareCount
;
}
...
...
@@ -283,12 +291,13 @@ public class Goods {
}
public
Integer
getPageViews
()
{
if
(
pageViews
==
null
)
return
1
;
return
pageViews
;
}
public
void
setPageViews
(
Integer
pageViews
)
{
this
.
pageViews
=
pageViews
;
}
}
\ No newline at end of file
src/com/w1hd/zzhnc/service/ActivityService.java
查看文件 @
ec3e3a9
...
...
@@ -78,10 +78,11 @@ public class ActivityService {
public
String
clearActivity
()
{
Activity
activity
=
getActivitySetting
();
activity
.
setTurn
(
activity
.
getTurn
()+
1
);
activity
.
setP1
(
null
);
activity
.
setP2
(
null
);
activity
.
setP3
(
null
);
activity
.
setP4
(
null
);
Prize
prize
=
new
Prize
();
activity
.
setP1
(
prize
);
activity
.
setP2
(
prize
);
activity
.
setP3
(
prize
);
activity
.
setP4
(
prize
);
activity
.
setPlanMny
(
new
BigDecimal
(
0
));
activity
.
setStatus
(
0
);
updateActivity
(
activity
);
...
...
src/com/w1hd/zzhnc/service/FansService.java
查看文件 @
ec3e3a9
...
...
@@ -15,6 +15,7 @@ import com.w1hd.zzhnc.model.Fans;
import
com.w1hd.zzhnc.util.CommonUtil
;
import
com.w1hd.zzhnc.util.PageResults
;
import
jodd.util.URLDecoder
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.entity.Example.Criteria
;
...
...
@@ -34,7 +35,7 @@ public class FansService {
public
PageResults
<
Fans
>
getFansList
(
Integer
page
,
String
keyword
)
{
Example
ex
=
new
Example
(
Fans
.
class
);
Criteria
criteria
=
ex
.
createCriteria
();
if
(
Strings
.
isNullOrEmpty
(
keyword
))
{
if
(
!
Strings
.
isNullOrEmpty
(
keyword
))
{
criteria
.
andCondition
(
" ( nickname like \"%"
+
keyword
+
"%\")"
);
}
RowBounds
row
=
new
RowBounds
((
page
-
1
)
*
10
,
10
);
...
...
src/com/w1hd/zzhnc/service/GoodsService.java
查看文件 @
ec3e3a9
...
...
@@ -5,12 +5,15 @@ import java.util.List;
import
org.apache.ibatis.session.RowBounds
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.stereotype.Service
;
import
org.testng.util.Strings
;
import
com.google.common.collect.Lists
;
import
com.w1hd.zzhnc.dao.GoodsDao
;
import
com.w1hd.zzhnc.model.Goods
;
import
com.w1hd.zzhnc.util.PageResults
;
import
com.w1hd.zzhnc.util.RedisUtil
;
import
tk.mybatis.mapper.entity.Example
;
import
tk.mybatis.mapper.entity.Example.Criteria
;
...
...
@@ -21,6 +24,8 @@ public class GoodsService {
@Autowired
GoodsDao
goodsDao
;
final
String
GOODSID_
=
RedisUtil
.
PROJECTNAME
.
concat
(
"_"
).
concat
(
"goods"
);
// 娲诲姩璁剧疆淇濆瓨key
public
List
<
Goods
>
getHomeData
()
{
Example
ex
=
new
Example
(
Goods
.
class
);
ex
.
createCriteria
().
andEqualTo
(
"deleted"
,
false
).
andEqualTo
(
"isHome"
,
true
);
...
...
@@ -28,6 +33,7 @@ public class GoodsService {
return
goodsDao
.
selectByExampleAndRowBounds
(
ex
,
r
);
}
@SuppressWarnings
(
"unchecked"
)
public
Goods
update
(
Goods
goods
)
{
goods
.
setUpdateTime
(
new
Date
(
System
.
currentTimeMillis
()));
if
(
goods
.
getId
()
==
null
||
goods
.
getId
()
==
0
)
{
...
...
@@ -35,23 +41,36 @@ public class GoodsService {
goods
.
setDeleted
(
false
);
goodsDao
.
insert
(
goods
);
}
else
{
if
(
goods
.
getCreatetime
()
==
null
)
{
if
(
goods
.
getCreatetime
()
==
null
)
{
goods
.
setCreatetime
(
new
java
.
util
.
Date
());
}
goods
.
setDeleted
(
false
);
Goods
old
=
goods
(
goods
.
getId
()).
getRows
().
get
(
0
);
if
(
old
!=
null
)
{
goods
.
setPageViews
(
old
.
getPageViews
()
+
1
);
}
redisTemplate
.
delete
(
GOODSID_
+
goods
.
getId
());
goodsDao
.
updateByPrimaryKey
(
goods
);
}
return
goods
;
}
@Autowired
RedisTemplate
redisTemplate
;
public
PageResults
<
Goods
>
seacrh
(
Integer
id
,
String
key
,
Integer
sellerId
,
Integer
page
,
Integer
size
)
{
Example
ex
=
new
Example
(
Goods
.
class
);
Criteria
c
=
ex
.
createCriteria
();
if
(
id
!=
null
&&
id
>
0
)
{
c
.
andEqualTo
(
"id"
,
id
);
return
goods
(
id
);
}
else
{
if
(!
Strings
.
isNullOrEmpty
(
key
))
{
c
.
andCondition
(
" (description like \"%"
+
key
+
"%\" or name like \"%"
+
key
+
"%\")"
);
if
(
"副食"
.
equals
(
key
)
||
"小商品"
.
equals
(
key
)
||
"服装"
.
equals
(
key
)
||
"汽摩配件"
.
equals
(
key
))
{
c
.
andEqualTo
(
"categoryName"
,
key
);
}
else
{
c
.
andCondition
(
" (description like \"%"
+
key
+
"%\" or name like \"%"
+
key
+
"%\")"
);
}
}
if
(
sellerId
!=
null
&&
sellerId
>
0
)
{
c
.
andEqualTo
(
"sellerId"
,
sellerId
);
...
...
@@ -61,11 +80,7 @@ public class GoodsService {
c
.
andEqualTo
(
"deleted"
,
false
);
RowBounds
row
=
new
RowBounds
((
page
-
1
)
*
size
,
size
);
List
<
Goods
>
list
=
goodsDao
.
selectByExampleAndRowBounds
(
ex
,
row
);
int
count
=
1
;
if
(
id
!=
null
&&
id
>
0
)
{
}
else
{
count
=
goodsDao
.
selectCountByExample
(
ex
);
}
int
count
=
goodsDao
.
selectCountByExample
(
ex
);
PageResults
<
Goods
>
pageResults
=
new
PageResults
<>();
pageResults
.
setTotal
(
count
);
pageResults
.
setPage
(
page
);
...
...
@@ -74,6 +89,24 @@ public class GoodsService {
return
pageResults
;
}
@SuppressWarnings
(
"unchecked"
)
public
PageResults
<
Goods
>
goods
(
Integer
id
)
{
PageResults
<
Goods
>
pageResults
=
new
PageResults
<>();
pageResults
.
setTotal
(
1
);
pageResults
.
setPage
(
1
);
pageResults
.
setPageSize
(
10
);
List
<
Goods
>
list
=
Lists
.
newArrayList
();
Goods
goods
=
(
Goods
)
redisTemplate
.
opsForValue
().
get
(
GOODSID_
+
id
);
if
(
goods
==
null
)
{
goods
=
goodsDao
.
selectByPrimaryKey
(
id
);
}
goods
.
setPageViews
(
goods
.
getPageViews
()
+
1
);
redisTemplate
.
opsForValue
().
set
(
GOODSID_
+
id
,
goods
);
list
.
add
(
goods
);
pageResults
.
setRows
(
list
);
return
pageResults
;
}
public
Object
delete
(
Integer
id
)
{
return
goodsDao
.
deleteByPrimaryKey
(
id
)
>
0
;
}
...
...
编写
预览
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
请先完成此消息的编辑!
取消
请
注册
或
登录
后发表评论