Commit 50618e8e authored by shiyu's avatar shiyu

重构

parent 434bf76c
package com.wwdz.ch.wx.service;
import com.wwdz.ch.db.dao.dts.DtsUserDao;
import com.wwdz.ch.wx.dao.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -10,10 +11,10 @@ import com.wwdz.ch.db.domain.User;
@Service
public class UserInfoService {
@Autowired
private DtsUserDao userService;
private DtsUserDao dtsUserDao;
public UserInfo getInfo(Long userId) {
User user = userService.findById(userId);
User user = dtsUserDao.findById(userId);
Assert.state(user != null, "用户不存在");
UserInfo userInfo = new UserInfo();
userInfo.setNickName(user.getNickname());
......
......@@ -7,6 +7,8 @@ import java.util.Map;
import javax.validation.constraints.NotNull;
import com.wwdz.ch.db.dao.ItemDao;
import com.wwdz.ch.db.dao.dts.DtsCollectDao;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.wx.annotation.LoginUser;
import org.apache.commons.lang3.ObjectUtils;
......@@ -36,9 +38,10 @@ public class WxCollectController {
private static final Logger logger = LoggerFactory.getLogger(WxCollectController.class);
@Autowired
private DtsCollectDao collectService;
private DtsCollectDao dtsCollectDao;
@Autowired
private ItemOldDao itemService;
private ItemDao itemDao;
/**
* 用户收藏列表
......@@ -62,8 +65,8 @@ public class WxCollectController {
return ResponseUtil.unlogin();
}
List<CollectObsolete> collectList = collectService.queryByType(userId, type, page, size);
int count = collectService.countByType(userId, type);
List<CollectObsolete> collectList = dtsCollectDao.queryByType(userId, type, page, size);
int count = dtsCollectDao.countByType(userId, type);
int totalPages = (int) Math.ceil((double) count / size);
List<Object> collects = new ArrayList<>(collectList.size());
......@@ -73,7 +76,7 @@ public class WxCollectController {
c.put("type", collect.getType());
c.put("valueId", collect.getValueId());
Item item = itemService.findById(collect.getValueId().longValue());
Item item = itemDao.findById(collect.getValueId().longValue());
c.put("name", item.getName());
c.put("picUrl", item.getImages().split(";")[0]);
c.put("retailPrice", item.getPrice());
......@@ -115,19 +118,19 @@ public class WxCollectController {
return ResponseUtil.badArgument();
}
CollectObsolete collect = collectService.queryByTypeAndValue(userId, type, valueId);
CollectObsolete collect = dtsCollectDao.queryByTypeAndValue(userId, type, valueId);
String handleType = null;
if (collect != null) {
handleType = "delete";
collectService.deleteById(collect.getId());
dtsCollectDao.deleteById(collect.getId());
} else {
handleType = "add";
collect = new CollectObsolete();
collect.setUserId(userId);
collect.setValueId(valueId);
collect.setType(type);
collectService.add(collect);
dtsCollectDao.add(collect);
}
Map<String, Object> data = new HashMap<String, Object>();
......
package com.wwdz.ch.wx.web;
import com.wwdz.ch.db.dao.dts.DtsFeedbackDao;
import com.wwdz.ch.db.dao.dts.DtsUserDao;
import com.wwdz.ch.wx.annotation.LoginUser;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
......@@ -31,9 +33,10 @@ public class WxFeedbackController {
private static final Logger logger = LoggerFactory.getLogger(WxFeedbackController.class);
@Autowired
private DtsFeedbackDao feedbackService;
private DtsFeedbackDao dtsFeedbackDao;
@Autowired
private DtsUserDao userService;
private DtsUserDao dtsUserDao;
private Object validate(Feedback feedback) {
String content = feedback.getContent();
......@@ -84,14 +87,14 @@ public class WxFeedbackController {
return error;
}
User user = userService.findById(userId);
User user = dtsUserDao.findById(userId);
String username = user.getUsername();
feedback.setId(null);
feedback.setUserId(userId);
feedback.setUsername(username);
// 状态默认是0,1表示状态已发生变化
feedback.setStatus(1);
feedbackService.add(feedback);
dtsFeedbackDao.add(feedback);
logger.info("【请求结束】添加意见反馈,响应结果:{}", JSONObject.toJSONString(feedback));
return ResponseUtil.ok();
......
......@@ -5,6 +5,8 @@ import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.JacksonUtil;
import com.wwdz.ch.core.util.ResponseUtil;
import com.wwdz.ch.db.dao.ItemDao;
import com.wwdz.ch.db.dao.dts.DtsFootprintDao;
import com.wwdz.ch.db.domain.Footprint;
import com.wwdz.ch.db.domain.Item;
import com.wwdz.ch.wx.annotation.LoginUser;
......@@ -29,9 +31,11 @@ public class WxFootprintController {
private static final Logger logger = LoggerFactory.getLogger(WxFootprintController.class);
@Autowired
private DtsFootprintDao footprintService;
private DtsFootprintDao dtsFootprintDao;
@Autowired
private ItemOldDao itemService;
private ItemDao itemDao;
@Autowired
private FootPrintService footPrintService;
......@@ -60,7 +64,7 @@ public class WxFootprintController {
if (footprintId == null) {
return ResponseUtil.badArgument();
}
Footprint footprint = footprintService.findById(footprintId);
Footprint footprint = dtsFootprintDao.findById(footprintId);
if (footprint == null) {
return ResponseUtil.badArgumentValue();
......@@ -69,7 +73,7 @@ public class WxFootprintController {
return ResponseUtil.badArgumentValue();
}
footprintService.deleteById(footprintId);
dtsFootprintDao.deleteById(footprintId);
logger.info("【请求结束】删除用户足迹成功!");
return ResponseUtil.ok();
......@@ -94,7 +98,7 @@ public class WxFootprintController {
return ResponseUtil.unlogin();
}
List<Footprint> footprintList = footprintService.queryByAddTime(userId, page, size);
List<Footprint> footprintList = dtsFootprintDao.queryByAddTime(userId, page, size);
long count = PageInfo.of(footprintList).getTotal();
int totalPages = (int) Math.ceil((double) count / size);
......@@ -105,7 +109,7 @@ public class WxFootprintController {
c.put("coinsId", footprint.getItemId());
c.put("addTime", footprint.getAddTime());
Item item = itemService.findById(footprint.getItemId().longValue());
Item item = itemDao.findById(footprint.getItemId().longValue());
c.put("name", item.getName());
c.put("retailPrice", item.getPrice());
c.put("image", item.getImages().split(";")[0]);
......
......@@ -9,6 +9,7 @@ import com.wwdz.ch.core.util.ResponseUtil;
import com.wwdz.ch.core.util.ZincUtil;
import com.wwdz.ch.core.validator.Order;
import com.wwdz.ch.core.validator.Sort;
import com.wwdz.ch.db.dao.ItemDao;
import com.wwdz.ch.db.dao.dts.*;
import com.wwdz.ch.db.impl.CategoryDaoImpl;
import com.wwdz.ch.db.domain.Category;
......@@ -44,7 +45,7 @@ public class WxGoodsController {
private static final Logger logger = LoggerFactory.getLogger(WxGoodsController.class);
@Autowired
private ItemOldDao itemService;
private ItemDao itemDao;
@Autowired
private DtsGoodsProductDao productService;
......@@ -99,7 +100,7 @@ public class WxGoodsController {
logger.info("【请求开始】商品详情,请求参数,userId:{},id:{}", userId, id);
// 商品信息
Item item = itemService.findById(id);
Item item = itemDao.findById(id);
// 用户收藏
int userHasCollect = 0;
......@@ -306,7 +307,7 @@ public class WxGoodsController {
@GetMapping("count")
public Object count() {
logger.info("【请求开始】在售的商品总数...");
Integer goodsCount = itemService.count();
Integer goodsCount = itemDao.count();
Map<String, Object> data = new HashMap<>();
data.put("goodsCount", goodsCount);
......
......@@ -12,6 +12,7 @@ import java.util.concurrent.TimeUnit;
import javax.validation.constraints.NotNull;
import com.wwdz.ch.db.dao.ItemDao;
import com.wwdz.ch.db.impl.CategoryDaoImpl;
import com.wwdz.ch.wx.annotation.LoginUser;
import com.wwdz.ch.wx.service.HomeCacheManager;
......@@ -36,7 +37,7 @@ public class WxHomeController {
private static final Logger logger = LoggerFactory.getLogger(WxHomeController.class);
@Autowired
private ItemOldDao goodsService;
private ItemDao itemDao;
@Autowired
......
......@@ -7,6 +7,8 @@ import java.util.Map;
import javax.validation.constraints.NotEmpty;
import com.wwdz.ch.db.dao.dts.DtsKeywordDao;
import com.wwdz.ch.db.dao.dts.DtsSearchHistoryDao;
import com.wwdz.ch.wx.annotation.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -35,9 +37,10 @@ public class WxSearchController {
private static final Logger logger = LoggerFactory.getLogger(WxSearchController.class);
@Autowired
private DtsKeywordDao keywordsService;
private DtsKeywordDao dtsKeywordDao;
@Autowired
private DtsSearchHistoryDao searchHistoryService;
private DtsSearchHistoryDao dtsSearchHistoryDao;
/**
* 搜索页面信息
......@@ -53,15 +56,15 @@ public class WxSearchController {
logger.info("【请求开始】搜索页面信息展示,请求参数,userId:{}", userId);
// 取出输入框默认的关键词
Keyword defaultKeyword = keywordsService.queryDefault();
Keyword defaultKeyword = dtsKeywordDao.queryDefault();
// 取出热闹关键词
List<Keyword> hotKeywordList = keywordsService.queryHots();
List<Keyword> hotKeywordList = dtsKeywordDao.queryHots();
List<SearchHistory> historyList = null;
if (userId != null) {
// 取出用户历史关键字
historyList = searchHistoryService.queryByUid(userId);
historyList = dtsSearchHistoryDao.queryByUid(userId);
} else {
historyList = new ArrayList<>(0);
}
......@@ -89,7 +92,7 @@ public class WxSearchController {
@RequestParam(defaultValue = "10") Integer size) {
logger.info("【请求开始】关键字提醒,请求参数,keyword:{}", keyword);
List<Keyword> keywordsList = keywordsService.queryByKeyword(keyword, page, size);
List<Keyword> keywordsList = dtsKeywordDao.queryByKeyword(keyword, page, size);
String[] keys = new String[keywordsList.size()];
int index = 0;
for (Keyword key : keywordsList) {
......@@ -114,7 +117,7 @@ public class WxSearchController {
if (userId == null) {
return ResponseUtil.unlogin();
}
searchHistoryService.deleteByUid(userId);
dtsSearchHistoryDao.deleteByUid(userId);
logger.info("【请求结束】清除用户搜索历史,响应结果:{}", "成功");
return ResponseUtil.ok();
......
......@@ -7,6 +7,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.wwdz.ch.db.dao.dts.DtsStorageDao;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
......@@ -45,7 +46,7 @@ public class WxStorageController {
private StorageService storageService;
@Autowired
private DtsStorageDao DtsStorageDao;
private DtsStorageDao dtsStorageDao;
private ExecutorService threadPool = Executors.newFixedThreadPool(20);
......@@ -59,7 +60,7 @@ public class WxStorageController {
do {
key = CharUtil.getRandomString(20) + suffix;
storageInfo = DtsStorageDao.findByKey(key);
storageInfo = dtsStorageDao.findByKey(key);
} while (storageInfo != null);
return key;
......@@ -138,7 +139,7 @@ public class WxStorageController {
public ResponseEntity<Resource> fetch(@PathVariable String key) {
// logger.info("【请求开始】访问存储对象,请求参数,key:{}", key);
Storage DtsStorage = DtsStorageDao.findByKey(key);
Storage DtsStorage = dtsStorageDao.findByKey(key);
if (key == null) {
return ResponseEntity.notFound().build();
}
......@@ -166,7 +167,7 @@ public class WxStorageController {
@GetMapping("/download/{key:.+}")
public ResponseEntity<Resource> download(@PathVariable String key) {
// logger.info("【请求开始】访问存储对象,请求参数,key:{}", key);
Storage DtsStorage = DtsStorageDao.findByKey(key);
Storage DtsStorage = dtsStorageDao.findByKey(key);
if (key == null) {
return ResponseEntity.notFound().build();
}
......
......@@ -4,6 +4,8 @@ import java.time.LocalDateTime;
import javax.validation.constraints.NotNull;
import com.wwdz.ch.db.dao.dts.DtsUserDao;
import com.wwdz.ch.db.dao.dts.DtsUserFormIdDao;
import com.wwdz.ch.wx.annotation.LoginUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -25,10 +27,10 @@ public class WxUserFormId {
private static final Logger logger = LoggerFactory.getLogger(WxUserFormId.class);
@Autowired
private DtsUserDao userService;
private DtsUserDao dtsUserDao;
@Autowired
private DtsUserFormIdDao formIdService;
private DtsUserFormIdDao dtsUserFormIdDao;
/**
* 创建微信访问fromID
......@@ -46,14 +48,14 @@ public class WxUserFormId {
return ResponseUtil.unlogin();
}
User user = userService.findById(userId);
User user = dtsUserDao.findById(userId);
UserFormidObsolete userFormid = new UserFormidObsolete();
userFormid.setOpenid(user.getWeixinOpenid());
userFormid.setFormid(formId);
userFormid.setIsprepay(false);
userFormid.setUseamount(1);
userFormid.setExpireTime(LocalDateTime.now().plusDays(7));
formIdService.addUserFormid(userFormid);
dtsUserFormIdDao.addUserFormid(userFormid);
logger.info("【请求结束】创建微信访问fromID,响应结果:{}", JSONObject.toJSONString(userFormid));
return ResponseUtil.ok();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment