diff --git a/.idea/data_source_mapping.xml b/.idea/data_source_mapping.xml new file mode 100644 index 0000000..ae49cd1 --- /dev/null +++ b/.idea/data_source_mapping.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..be940c2 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,18 @@ + + + + \ No newline at end of file diff --git a/.idea/jsLibraryMappings.xml b/.idea/jsLibraryMappings.xml new file mode 100644 index 0000000..fcf6671 --- /dev/null +++ b/.idea/jsLibraryMappings.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 9451b82..461b7f8 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/.idea/webContexts.xml b/.idea/webContexts.xml new file mode 100644 index 0000000..86260cc --- /dev/null +++ b/.idea/webContexts.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/me/mofun/config/LocalFileSystemConfig.java b/src/main/java/me/mofun/config/LocalFileSystemConfig.java new file mode 100644 index 0000000..6d16fdd --- /dev/null +++ b/src/main/java/me/mofun/config/LocalFileSystemConfig.java @@ -0,0 +1,41 @@ +package me.mofun.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +@Configuration +public class LocalFileSystemConfig implements WebMvcConfigurer { + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + // 获取操作系统信息 + String os = System.getProperty("os.name").toLowerCase(); + + // 根据不同操作系统设置不同的基础路径 + String basePath; + if (os.contains("win")) { + // Windows系统路径 + basePath = "file:D:/work/code/ipdz/src/main/webapp/"; + } else { + // Linux/Unix系统路径 + basePath = "file:/home/user/work/code/ipdz/src/main/webapp/"; + } + + // 映射productImg目录 + registry.addResourceHandler("/productImg/**") + .addResourceLocations(basePath + "productImg/"); + + // 映射Images目录 + registry.addResourceHandler("/Images/**") + .addResourceLocations(basePath + "Images/"); + + // 映射uploads目录 + registry.addResourceHandler("/uploads/**") + .addResourceLocations(basePath + "uploads/"); + + System.out.println("操作系统: " + os); + System.out.println("基础路径: " + basePath); + System.out.println("静态资源映射配置完成"); + } +} \ No newline at end of file diff --git a/src/main/java/me/mofun/config/UserSessionConfig.java b/src/main/java/me/mofun/config/UserSessionConfig.java deleted file mode 100644 index b580fbc..0000000 --- a/src/main/java/me/mofun/config/UserSessionConfig.java +++ /dev/null @@ -1,42 +0,0 @@ -package me.mofun.config; - -import org.springframework.context.annotation.Configuration; -import org.springframework.web.servlet.config.annotation.InterceptorRegistry; -import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; -import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; - -import javax.annotation.Resource; - -/** - * 用户状态拦截器注册 - * - * @author xuao - */ -@Configuration -public class UserSessionConfig implements WebMvcConfigurer { - - @Resource - private UserSessionInterceptor usInterceptor; - - - @Override - public void addInterceptors(InterceptorRegistry registry) { - //拦截了所有的请求 登录请求放过去 - registry.addInterceptor(usInterceptor) - .addPathPatterns("/**") - .excludePathPatterns("/userManagement/login", "/user/role", "/static/file/**", "/clock/getWXPhone", "/applet/getOpenId", "/applet/getPhone", - "/applet/login", "/swagger-resources/**", "/webjars/**", "/v2/**", - "/swagger-ui.html/**", "/doc.html/**", "/druid/login.html", "/car/test", "/car/getCourseCarInfo", "/constantDrivingTrack/constantDriving", "/vehicleWarning/earlyWarningOfKeyVehicles", "/tBayonetDetail/test", "/keyVehicles/checkKeyVehicles"); - } - - /** - * 添加静态资源文件,外部可以直接访问地址 - * - * @param registry - */ - @Override - public void addResourceHandlers(ResourceHandlerRegistry registry) { - System.out.println("file:" + Global.getProfile()); - registry.addResourceHandler("/static/file/**").addResourceLocations("file:" + Global.getProfile() + "/"); - } -} diff --git a/src/main/java/me/mofun/controller/IndexController.java b/src/main/java/me/mofun/controller/IndexController.java index d7926ef..8efd721 100644 --- a/src/main/java/me/mofun/controller/IndexController.java +++ b/src/main/java/me/mofun/controller/IndexController.java @@ -2,6 +2,7 @@ package me.mofun.controller; import me.mofun.entity.*; import me.mofun.entity.dto.ProductSpellbuyproductDTO; +import me.mofun.entity.dto.SpellbuyrecordDTO; import me.mofun.entity.pojo.BuyHistoryJSON; import me.mofun.entity.pojo.ProductJSON; import me.mofun.entity.pojo.UserJSON; @@ -10,7 +11,6 @@ import me.mofun.service.*; import me.mofun.util.ApplicationListenerImpl; import me.mofun.util.MemCachedClientHelp; import me.mofun.util.UserNameUtil; -import me.mofun.utils.ViewUtils; import net.sf.json.JSONArray; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -90,30 +90,30 @@ public class IndexController { this.userService = userService; } - @Autowired - private ViewUtils viewUtils; - private final String module = "index"; - /** * 首页 */ @GetMapping("/") - public String index(Model model) { + public ModelAndView index() { + ModelAndView mav = new ModelAndView(); + // 检查系统授权 if (!ApplicationListenerImpl.sysConfigureAuth) { - model.addAttribute("errorMsg", "该系统授权已过期,请联系管理员重新授权!谢谢合作。"); - return "error/authorization"; + mav.addObject("errorMsg", "该系统授权已过期,请联系管理员重新授权!谢谢合作。"); + mav.setViewName("/WEB-INF/template/error/authorization"); + return mav; } - + // 初始化首页数据 - initNewProductList(model); - initLatestLotteryList(model); - initRecommendProduct(model); - initNewsList(model); - initIndexImgList(model); -// initUpcomingProducts(model); - - return "WEB-INF/template/my/index/index-new"; + initNewProductList(mav); + initLatestLotteryList(mav); + initRecommendProduct(mav); + initNewsList(mav); + initIndexImgList(mav); +// initUpcomingProducts(mav); + + mav.setViewName("/WEB-INF/template/my/index/index-new"); + return mav; } /** @@ -208,8 +208,8 @@ public class IndexController { if (isCacheExpired(beginDateByNowBuyProduct, nowDateByNowBuyProduct)) { beginDateByNowBuyProduct = System.currentTimeMillis(); Pagination page = spellbuyrecordService.getNowBuyList(0, PAGE_SIZE_XXLARGE); - List nowBuyList = (List) page.getList(); - nowBuyProductList = convertToNowBuyProductList(nowBuyList); + List nowBuyList = (List) page.getList(); + nowBuyProductList = convertToNowBuyProductUserList(nowBuyList); } return nowBuyProductList; } @@ -227,26 +227,32 @@ public class IndexController { * 邀请授权页 */ @GetMapping("/referAuth") - public String referAuth(HttpServletRequest request, Model model) { + public ModelAndView referAuth(HttpServletRequest request) { + ModelAndView mav = new ModelAndView(); String uid = getUidFromCookie(request.getCookies()); - model.addAttribute("uid", uid); - return "referAuthLogin"; + mav.addObject("uid", uid); + mav.setViewName("/WEB-INF/template/my/referAuth/referAuthLogin"); + return mav; } /** * 地图模式页 */ @GetMapping("/map") - public String map() { - return "map"; + public ModelAndView map() { + ModelAndView mav = new ModelAndView(); + mav.setViewName("/WEB-INF/template/index/map"); + return mav; } /** * 诚信页 */ @GetMapping("/sincerity") - public String sincerity() { - return "sincerity"; + public ModelAndView sincerity() { + ModelAndView mav = new ModelAndView(); + mav.setViewName("/WEB-INF/template/index/sincerity"); + return mav; } /** @@ -297,12 +303,14 @@ public class IndexController { * 最新100条拍购记录页 */ @GetMapping("/getNewRecord") - public String getNewRecord(Model model) { + public ModelAndView getNewRecord() { + ModelAndView mav = new ModelAndView(); Pagination page = spellbuyrecordService.getNowBuyList(0, PAGE_SIZE_XXLARGE); - List nowBuyList = (List) page.getList(); + List nowBuyList = (List) page.getList(); List productList = convertToNewRecordProductList(nowBuyList); - model.addAttribute("productList", productList); - return "newRecord"; + mav.addObject("productList", productList); + mav.setViewName("/WEB-INF/template/index/newRecord"); + return mav; } /** @@ -315,7 +323,7 @@ public class IndexController { if (isCacheExpired(beginDateByNewRecord, nowDateByNewRecord)) { beginDateByNewRecord = System.currentTimeMillis(); Pagination page = spellbuyrecordService.getNowBuyAjaxList(0, PAGE_SIZE_XXLARGE, Integer.parseInt(id)); - List nowBuyList = (List) page.getList(); + List nowBuyList = (List) page.getList(); newRecordList = convertToNewRecordProductList(nowBuyList); } return newRecordList; @@ -325,26 +333,27 @@ public class IndexController { * 全站拍购记录查询(带时间筛选) */ @GetMapping("/getAllBuyRecord") - public String getAllBuyRecord(Model model, - @RequestParam(required = false) String startDate, - @RequestParam(required = false) String endDate, - @RequestParam(defaultValue = "0") int pageNo) { + public ModelAndView getAllBuyRecord(@RequestParam(required = false) String startDate, + @RequestParam(required = false) String endDate, + @RequestParam(defaultValue = "0") int pageNo) { + ModelAndView mav = new ModelAndView(); Pagination datePage = spellbuyrecordService.getAllBuyRecord(startDate, endDate, pageNo, PAGE_SIZE_XXLARGE); - List dataList = (List) datePage.getList(); + List dataList = (List) datePage.getList(); List historyList = convertToBuyHistoryList(dataList); - model.addAttribute("buyHistoryJSONList", historyList); - return "allBuyRecord"; + mav.addObject("buyHistoryJSONList", historyList); + mav.setViewName("/WEB-INF/template/index/allBuyRecord"); + return mav; } @GetMapping("/JPData") public String JPData(@RequestParam String action) { - return "forward:/group/" + action + ".action"; + return "forward:/group/" + action; } /** * 初始化首页新品列表 */ - private void initNewProductList(Model model) { + private void initNewProductList(ModelAndView mav) { Pagination page = spellbuyrecordService.indexNewProductList(0, PAGE_SIZE_SMALL); List newList = (List) page.getList(); List newProductList = new ArrayList<>(); @@ -354,18 +363,18 @@ public class IndexController { newProductList.add(productJSON); } - model.addAttribute("newProductList", newProductList); + mav.addObject("newProductList", newProductList); } /** * 初始化最新揭晓列表 */ - private void initLatestLotteryList(Model model) { + private void initLatestLotteryList(ModelAndView mav) { List objList = latestlotteryService.indexWinningScroll(); List latestlotteryList = new ArrayList<>(); for (Latestlottery lottery : objList) { Latestlottery item = new Latestlottery(); - // 拷贝属性(实际项目建议用BeanUtils) + // 拷贝属性 item.setId(lottery.getId()); item.setSpellbuyProductId(lottery.getSpellbuyProductId()); item.setBuyUser(lottery.getBuyUser()); @@ -379,46 +388,45 @@ public class IndexController { item.setBuyUser(userName); latestlotteryList.add(item); } - model.addAttribute("latestlotteryList", latestlotteryList); + mav.addObject("latestlotteryList", latestlotteryList); } /** * 初始化每日推荐商品 */ - private void initRecommendProduct(Model model) { + private void initRecommendProduct(ModelAndView mav) { List objectList = recommendService.getRecommend(); ProductJSON recommendJSON = null; if (objectList != null && !objectList.isEmpty()) { - // 推荐服务返回的是Object[],不是DTO Product product = (Product) objectList.get(0)[0]; Spellbuyproduct spellbuyproduct = (Spellbuyproduct) objectList.get(0)[1]; recommendJSON = convertToProductJSON(product, spellbuyproduct, false); } - model.addAttribute("recommendJSON", recommendJSON); + mav.addObject("recommendJSON", recommendJSON); } /** * 初始化新闻列表(缓存) */ - private void initNewsList(Model model) { + private void initNewsList(ModelAndView mav) { if (newsList == null) { newsList = newsService.indexNews(10, 3); } - model.addAttribute("newsList", newsList); + mav.addObject("newsList", newsList); } /** * 初始化首页图片列表 */ - private void initIndexImgList(Model model) { + private void initIndexImgList(ModelAndView mav) { List indexImgList = JSONArray.fromObject(ApplicationListenerImpl.indexImgAll); - model.addAttribute("indexImgList", indexImgList); + mav.addObject("indexImgList", indexImgList); } /** * 初始化即将揭晓商品 */ - private void initUpcomingProducts(Model model) { + private void initUpcomingProducts(ModelAndView mav) { Pagination page = spellbuyproductService.upcomingAnnounced(0, PAGE_SIZE_MEDIUM); List upcomingList = (List) page.getList(); List productList = new ArrayList<>(); @@ -428,7 +436,7 @@ public class IndexController { productList.add(productJSON); } - model.addAttribute("productList", productList); + mav.addObject("productList", productList); } /** @@ -455,12 +463,12 @@ public class IndexController { /** * 转换为"正在拍购"商品列表 */ - private List convertToNowBuyProductList(List dtoList) { + private List convertToNowBuyProductUserList(List dtoList) { List result = new ArrayList<>(); if (dtoList == null) { return result; } - for (ProductSpellbuyproductDTO dto : dtoList) { + for (SpellbuyrecordDTO dto : dtoList) { ProductJSON json = new ProductJSON(); json.setBuyer(UserNameUtil.userName(dto.getUser())); json.setUserId(String.valueOf(dto.getUser().getUserId())); @@ -476,12 +484,12 @@ public class IndexController { /** * 转换为最新拍购记录商品列表 */ - private List convertToNewRecordProductList(List dtoList) { + private List convertToNewRecordProductList(List dtoList) { List result = new ArrayList<>(); if (dtoList == null) { return result; } - for (ProductSpellbuyproductDTO dto : dtoList) { + for (SpellbuyrecordDTO dto : dtoList) { ProductJSON json = new ProductJSON(); json.setBuyer(UserNameUtil.userName(dto.getUser())); json.setUserId(String.valueOf(dto.getUser().getUserId())); @@ -492,13 +500,10 @@ public class IndexController { json.setProductName(productName.length() > 35 ? productName.substring(0, 35) + "..." : productName); json.setProductPeriod(dto.getSpellbuyproduct().getProductPeriod()); -// json.setBuyCount(dto.getSpellbuyrecord().getBuyPrice()); - json.setBuyCount(1); + json.setBuyCount(dto.getSpellbuyrecord().getBuyPrice()); json.setProductTitle(dto.getProduct().getProductTitle()); -// json.setBuyDate(dto.getSpellbuyrecord().getBuyDate()); - json.setBuyDate(String.valueOf(new Date())); -// json.setProductStyle(String.valueOf(dto.getSpellbuyrecord().getSpellbuyRecordId())); - json.setProductStyle(String.valueOf(1)); + json.setBuyDate(dto.getSpellbuyrecord().getBuyDate()); + json.setProductStyle(String.valueOf(dto.getSpellbuyrecord().getSpellbuyRecordId())); result.add(json); } return result; @@ -507,18 +512,16 @@ public class IndexController { /** * 转换为购买历史列表 */ - private List convertToBuyHistoryList(List dtoList) { + private List convertToBuyHistoryList(List dtoList) { List result = new ArrayList<>(); if (dtoList == null) { return result; } - for (ProductSpellbuyproductDTO dto : dtoList) { + for (SpellbuyrecordDTO dto : dtoList) { BuyHistoryJSON json = new BuyHistoryJSON(); -// json.setBuyCount(Long.parseLong(String.valueOf(dto.getSpellbuyrecord().getBuyPrice()))); - json.setBuyCount(Long.parseLong(String.valueOf(1))); + json.setBuyCount(Long.parseLong(String.valueOf(dto.getSpellbuyrecord().getBuyPrice()))); json.setBuyStatus(dto.getSpellbuyproduct().getSpStatus()); -// json.setHistoryId(dto.getSpellbuyrecord().getSpellbuyRecordId()); - json.setHistoryId(1); + json.setHistoryId(dto.getSpellbuyrecord().getSpellbuyRecordId()); json.setProductId(dto.getSpellbuyproduct().getSpellbuyProductId()); json.setProductImg(dto.getProduct().getHeadImage()); json.setProductName(dto.getProduct().getProductName()); diff --git a/src/main/java/me/mofun/controller/ListController.java b/src/main/java/me/mofun/controller/ListController.java index 0a5de4a..7f5cdb3 100644 --- a/src/main/java/me/mofun/controller/ListController.java +++ b/src/main/java/me/mofun/controller/ListController.java @@ -255,12 +255,7 @@ public class ListController { } } - public static List getTypeSubList() { - return theProductTypeService.getAllProductTypeTree(); - } - // 仅保留服务类的getter(如果有外部依赖) - public IProducttypeService getTheProductTypeService() { - return theProductTypeService; - } + + } \ No newline at end of file diff --git a/src/main/java/me/mofun/controller/LoginController.java b/src/main/java/me/mofun/controller/LoginController.java index e4877d2..ad57fa4 100644 --- a/src/main/java/me/mofun/controller/LoginController.java +++ b/src/main/java/me/mofun/controller/LoginController.java @@ -6,7 +6,6 @@ import me.mofun.service.IUserService; import me.mofun.util.ApplicationListenerImpl; import me.mofun.util.DateUtil; import me.mofun.utils.StringUtils; -import me.mofun.utils.ViewUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -33,21 +32,13 @@ import java.util.Date; */ @Controller @RequestMapping("/login") -public class LoginController { - @Autowired - private ViewUtils viewUtils; - private final String module = "login"; - +public class LoginController { + @Autowired private IUserService userService; - + private static final HTMLFilter htmlFilter = new HTMLFilter(); - - - - - /** * 登录页面 */ @@ -64,7 +55,7 @@ public class LoginController { response.setContentType("text/html;charset=UTF-8"); PrintWriter out = response.getWriter(); out.println(""); + out.println("window.location.href='" + ApplicationListenerImpl.sysConfigureJson.getWwwUrl() + "/help/openCookie.html';"); out.flush(); return null; } @@ -74,14 +65,21 @@ public class LoginController { if (cookies != null) { for (Cookie cookie : cookies) { if ("userId".equals(cookie.getName()) && StringUtils.isNotBlank(cookie.getValue())) { - return new ModelAndView("index"); // 已登录,跳转到首页 + return new ModelAndView("redirect:/index.html"); // 已登录,跳转到首页 } } } + + // 添加forward参数到Model + ModelAndView mv = new ModelAndView("WEB-INF/template/login/index"); + if (StringUtils.isNotBlank(forward)) { + mv.addObject("forward", forward); + } + return mv; } catch (Exception e) { e.printStackTrace(); + return new ModelAndView("WEB-INF/template/login/index"); } - return viewUtils.create(module,"index"); // 未登录,显示登录页 } /** @@ -167,29 +165,28 @@ public class LoginController { return "success"; // 登录成功 } - @GetMapping("/fastLogin") public ModelAndView fastLogin() { - return viewUtils.create(module, "fastLogin"); + return new ModelAndView("WEB-INF/template/login/fastLogin"); } @GetMapping("/buyCartLogin") public ModelAndView buyCartLogin() { - return viewUtils.create(module, "buyCartLogin"); + return new ModelAndView("WEB-INF/template/login/buyCartLogin"); } @GetMapping("/miniLogin") public ModelAndView miniLogin() { - - return viewUtils.create(module, "miniLogin"); + return new ModelAndView("WEB-INF/template/login/miniLogin"); } @GetMapping("/postCommentLogin") public ModelAndView postCommentLogin() { - - return viewUtils.create(module, "postCommentLogin"); + return new ModelAndView("WEB-INF/template/login/postCommentLogin"); } - - - -} + + @GetMapping("/popLogin") + public ModelAndView popLogin() { + return new ModelAndView("WEB-INF/template/login/popLogin"); + } +} \ No newline at end of file diff --git a/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java b/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java index 74ab90e..7df1efa 100644 --- a/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java +++ b/src/main/java/me/mofun/entity/dto/ProductSpellbuyproductDTO.java @@ -9,5 +9,5 @@ import me.mofun.entity.User; public class ProductSpellbuyproductDTO { private Product product; private Spellbuyproduct spellbuyproduct; - private User user; + } \ No newline at end of file diff --git a/src/main/resources/mapper/SpellbuyproductMapper.xml b/src/main/resources/mapper/SpellbuyproductMapper.xml index aa3c5f8..d723d2d 100644 --- a/src/main/resources/mapper/SpellbuyproductMapper.xml +++ b/src/main/resources/mapper/SpellbuyproductMapper.xml @@ -123,6 +123,12 @@ + + + + + + - SELECT pt.productId as pt_productId, pt.productName as pt_productName, @@ -179,7 +185,7 @@ - SELECT pt.productId as pt_productId, pt.productName as pt_productName, @@ -225,7 +231,7 @@ - SELECT pt.productId as pt_productId, pt.productName as pt_productName, @@ -273,7 +279,7 @@ - SELECT pt.productId as pt_productId, pt.productName as pt_productName, @@ -321,7 +327,7 @@ - SELECT pt.productId as pt_productId, pt.productName as pt_productName, @@ -384,7 +390,7 @@ - SELECT pt.productId as pt_productId, pt.productName as pt_productName,