Commit 50618e8e authored by shiyu's avatar shiyu

重构

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