修改相关bug

1 个父辈 a333d522
......@@ -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,
@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, "系统繁忙");
......
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
......@@ -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);
......
......@@ -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);
......
......@@ -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 到此讨论。请谨慎行事。
请先完成此消息的编辑!