修改相关bug

1 个父辈 a333d522
...@@ -95,7 +95,7 @@ public class WxMiniController extends BaseController { ...@@ -95,7 +95,7 @@ public class WxMiniController extends BaseController {
} }
@RequestMapping(value="/login",method=RequestMethod.POST) // 购房助手登录 double lng,double lat @RequestMapping(value="/login",method=RequestMethod.GET) // 购房助手登录 double lng,double lat
public @ResponseBody Vo_msg login(@RequestParam(value = "code") String code, public @ResponseBody Vo_msg login(@RequestParam(value = "code") String code,
@RequestParam(value = "shareId") Integer shareId, @RequestParam(value = "nickname") String nickname, @RequestParam(value = "shareId") Integer shareId, @RequestParam(value = "nickname") String nickname,
@RequestParam(value = "logo") String logo, @RequestParam(value = "lng") double lng, @RequestParam(value = "logo") String logo, @RequestParam(value = "lng") double lng,
...@@ -284,8 +284,7 @@ public class WxMiniController extends BaseController { ...@@ -284,8 +284,7 @@ public class WxMiniController extends BaseController {
PageResults<Goods> seacrh = goodsService.seacrh(null, key, null, page, size); PageResults<Goods> seacrh = goodsService.seacrh(null, key, null, page, size);
List<Goods> rows = seacrh.getRows(); List<Goods> rows = seacrh.getRows();
result.put("banner", bannerList); result.put("banner", bannerList);
List<MiniHomeVO> data = MiniHomeVO.getData(null, rows); result.put("data", rows);
result.put("data", data);
return new Vo_msg(0, result); return new Vo_msg(0, result);
} catch (Exception e) { } catch (Exception e) {
return new Vo_msg(-1, "系统繁忙"); return new Vo_msg(-1, "系统繁忙");
......
package com.w1hd.zzhnc.model; package com.w1hd.zzhnc.model;
import java.io.Serializable;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import javax.persistence.Id; import javax.persistence.Id;
public class Goods { public class Goods implements Serializable {
/**
*
*/
private static final long serialVersionUID = 7056374928150393961L;
@Id @Id
private Integer id; private Integer id;
private Integer sellerId; private Integer sellerId;
...@@ -46,7 +52,7 @@ public class Goods { ...@@ -46,7 +52,7 @@ public class Goods {
public String getDescription() { public String getDescription() {
return description; return description;
} }
public String getCategoryName() { public String getCategoryName() {
return categoryName; return categoryName;
} }
...@@ -275,6 +281,8 @@ public class Goods { ...@@ -275,6 +281,8 @@ public class Goods {
} }
public Integer getShareCount() { public Integer getShareCount() {
if (shareCount == null)
return 1;
return shareCount; return shareCount;
} }
...@@ -283,12 +291,13 @@ public class Goods { ...@@ -283,12 +291,13 @@ public class Goods {
} }
public Integer getPageViews() { public Integer getPageViews() {
if (pageViews == null)
return 1;
return pageViews; return pageViews;
} }
public void setPageViews(Integer pageViews) { public void setPageViews(Integer pageViews) {
this.pageViews = pageViews; this.pageViews = pageViews;
} }
} }
\ No newline at end of file \ No newline at end of file
...@@ -78,10 +78,11 @@ public class ActivityService { ...@@ -78,10 +78,11 @@ public class ActivityService {
public String clearActivity() { public String clearActivity() {
Activity activity = getActivitySetting(); Activity activity = getActivitySetting();
activity.setTurn(activity.getTurn()+1); activity.setTurn(activity.getTurn()+1);
activity.setP1(null); Prize prize = new Prize();
activity.setP2(null); activity.setP1(prize);
activity.setP3(null); activity.setP2(prize);
activity.setP4(null); activity.setP3(prize);
activity.setP4(prize);
activity.setPlanMny(new BigDecimal(0)); activity.setPlanMny(new BigDecimal(0));
activity.setStatus(0); activity.setStatus(0);
updateActivity(activity); updateActivity(activity);
......
...@@ -15,6 +15,7 @@ import com.w1hd.zzhnc.model.Fans; ...@@ -15,6 +15,7 @@ import com.w1hd.zzhnc.model.Fans;
import com.w1hd.zzhnc.util.CommonUtil; import com.w1hd.zzhnc.util.CommonUtil;
import com.w1hd.zzhnc.util.PageResults; import com.w1hd.zzhnc.util.PageResults;
import jodd.util.URLDecoder;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria; import tk.mybatis.mapper.entity.Example.Criteria;
...@@ -34,7 +35,7 @@ public class FansService { ...@@ -34,7 +35,7 @@ public class FansService {
public PageResults<Fans> getFansList(Integer page, String keyword) { public PageResults<Fans> getFansList(Integer page, String keyword) {
Example ex = new Example(Fans.class); Example ex = new Example(Fans.class);
Criteria criteria = ex.createCriteria(); Criteria criteria = ex.createCriteria();
if(Strings.isNullOrEmpty(keyword)) { if(!Strings.isNullOrEmpty(keyword)) {
criteria.andCondition(" ( nickname like \"%" + keyword +"%\")"); criteria.andCondition(" ( nickname like \"%" + keyword +"%\")");
} }
RowBounds row = new RowBounds((page - 1) * 10, 10); RowBounds row = new RowBounds((page - 1) * 10, 10);
......
...@@ -5,12 +5,15 @@ import java.util.List; ...@@ -5,12 +5,15 @@ import java.util.List;
import org.apache.ibatis.session.RowBounds; import org.apache.ibatis.session.RowBounds;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.testng.util.Strings; import org.testng.util.Strings;
import com.google.common.collect.Lists;
import com.w1hd.zzhnc.dao.GoodsDao; import com.w1hd.zzhnc.dao.GoodsDao;
import com.w1hd.zzhnc.model.Goods; import com.w1hd.zzhnc.model.Goods;
import com.w1hd.zzhnc.util.PageResults; import com.w1hd.zzhnc.util.PageResults;
import com.w1hd.zzhnc.util.RedisUtil;
import tk.mybatis.mapper.entity.Example; import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.entity.Example.Criteria; import tk.mybatis.mapper.entity.Example.Criteria;
...@@ -21,6 +24,8 @@ public class GoodsService { ...@@ -21,6 +24,8 @@ public class GoodsService {
@Autowired @Autowired
GoodsDao goodsDao; GoodsDao goodsDao;
final String GOODSID_ = RedisUtil.PROJECTNAME.concat("_").concat("goods");// 娲诲姩璁剧疆淇濆瓨key
public List<Goods> getHomeData() { public List<Goods> getHomeData() {
Example ex = new Example(Goods.class); Example ex = new Example(Goods.class);
ex.createCriteria().andEqualTo("deleted", false).andEqualTo("isHome", true); ex.createCriteria().andEqualTo("deleted", false).andEqualTo("isHome", true);
...@@ -28,6 +33,7 @@ public class GoodsService { ...@@ -28,6 +33,7 @@ public class GoodsService {
return goodsDao.selectByExampleAndRowBounds(ex, r); return goodsDao.selectByExampleAndRowBounds(ex, r);
} }
@SuppressWarnings("unchecked")
public Goods update(Goods goods) { public Goods update(Goods goods) {
goods.setUpdateTime(new Date(System.currentTimeMillis())); goods.setUpdateTime(new Date(System.currentTimeMillis()));
if (goods.getId() == null || goods.getId() == 0) { if (goods.getId() == null || goods.getId() == 0) {
...@@ -35,23 +41,36 @@ public class GoodsService { ...@@ -35,23 +41,36 @@ public class GoodsService {
goods.setDeleted(false); goods.setDeleted(false);
goodsDao.insert(goods); goodsDao.insert(goods);
} else { } else {
if(goods.getCreatetime() == null ) { if (goods.getCreatetime() == null) {
goods.setCreatetime(new java.util.Date()); goods.setCreatetime(new java.util.Date());
} }
goods.setDeleted(false); 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); goodsDao.updateByPrimaryKey(goods);
} }
return goods; return goods;
} }
@Autowired
RedisTemplate redisTemplate;
public PageResults<Goods> seacrh(Integer id, String key, Integer sellerId, Integer page, Integer size) { public PageResults<Goods> seacrh(Integer id, String key, Integer sellerId, Integer page, Integer size) {
Example ex = new Example(Goods.class); Example ex = new Example(Goods.class);
Criteria c = ex.createCriteria(); Criteria c = ex.createCriteria();
if (id != null && id > 0) { if (id != null && id > 0) {
c.andEqualTo("id", id); return goods(id);
} else { } else {
if (!Strings.isNullOrEmpty(key)) { 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) { if (sellerId != null && sellerId > 0) {
c.andEqualTo("sellerId", sellerId); c.andEqualTo("sellerId", sellerId);
...@@ -61,11 +80,7 @@ public class GoodsService { ...@@ -61,11 +80,7 @@ public class GoodsService {
c.andEqualTo("deleted", false); c.andEqualTo("deleted", false);
RowBounds row = new RowBounds((page - 1) * size, size); RowBounds row = new RowBounds((page - 1) * size, size);
List<Goods> list = goodsDao.selectByExampleAndRowBounds(ex, row); List<Goods> list = goodsDao.selectByExampleAndRowBounds(ex, row);
int count = 1; int count = goodsDao.selectCountByExample(ex);
if (id != null && id > 0) {
}else {
count = goodsDao.selectCountByExample(ex);
}
PageResults<Goods> pageResults = new PageResults<>(); PageResults<Goods> pageResults = new PageResults<>();
pageResults.setTotal(count); pageResults.setTotal(count);
pageResults.setPage(page); pageResults.setPage(page);
...@@ -74,6 +89,24 @@ public class GoodsService { ...@@ -74,6 +89,24 @@ public class GoodsService {
return pageResults; 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) { public Object delete(Integer id) {
return goodsDao.deleteByPrimaryKey(id) > 0; return goodsDao.deleteByPrimaryKey(id) > 0;
} }
......
Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
请先完成此消息的编辑!