提交 553251a5 authored 作者: Whispa's avatar Whispa

Merge remote-tracking branch 'origin/master'

......@@ -508,6 +508,7 @@ public class AuthController extends Controller {
private void fillUserNecessayInfo(TbCfUserInfo tbCfUserInfoVo) {
if (tbCfUserInfoVo.getAvatar() == null) tbCfUserInfoVo.setAvatar(domainProperties.getProperty("user.avatar"));
tbCfUserInfoVo.setNick(tbCfUserInfoVo.getAccount());
tbCfUserInfoVo.setUserNo(IdUtil.createIdByDate());
tbCfUserInfoVo.setPhoneFlag(StateConstant.INVALID);
tbCfUserInfoVo.setLoginCount(0);
......
......@@ -8,8 +8,8 @@ import com.example.afrishop_v3.repository.TbCfToicouponRepository;
import com.example.afrishop_v3.security.services.AuthenticationUser;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedHashMap;
import java.util.List;
import java.math.BigDecimal;
import java.util.*;
@RestController
@RequestMapping("/coupon")
......@@ -24,36 +24,36 @@ public class CouponController {
@GetMapping
public Result getUserCoupons(){
public Result getUserCoupons() {
return queryCouponByUserId(user.userId());
}
@GetMapping("queryCouponByUserId")
public Result queryCouponByUserId(@RequestParam("userId") String userId){
public Result queryCouponByUserId(@RequestParam("userId") String userId) {
List<TbCfToicoupon> availableCoupons = repository.queryUserAvailableCoupon(userId);
List<TbCfToicoupon> expiredCoupons = repository.queryUserExpiredCoupon(userId);
List<TbCfToicoupon> usedCoupons = repository.queryUserUsedCoupon(userId);
LinkedHashMap<String, Object> hashMap = new LinkedHashMap<>();
hashMap.put("validCouponList",availableCoupons);
hashMap.put("usedCouponList",usedCoupons);
hashMap.put("expiredCouponList",expiredCoupons);
hashMap.put("validCouponList", availableCoupons);
hashMap.put("usedCouponList", usedCoupons);
hashMap.put("expiredCouponList", expiredCoupons);
return new Result<>(hashMap);
}
@GetMapping("{couponId}")
public Result queryCouponDetails(@PathVariable("couponId") String couponId){
public Result queryCouponDetails(@PathVariable("couponId") String couponId) {
return new Result<>(repository.findById(couponId));
}
@GetMapping("take/{couponId}")
public Result couponTake(@PathVariable("couponId") String couponId){
public Result couponTake(@PathVariable("couponId") String couponId) {
// TODO
//TbCfCouponEntity tbCfCouponEntity=grabCoupon(couponId);
// if(tbCfCouponEntity!=null) {
......@@ -63,6 +63,31 @@ public class CouponController {
// //result.setMessage("Successfully received");
// } else {
// }
return new Result(ResultCodeEnum.ERROR.getCode(),"The coupon has been snapped up");
return new Result(ResultCodeEnum.ERROR.getCode(), "The coupon has been snapped up");
}
/**
* 查询用户未使用的优惠券,可用的排在顶部
*/
@GetMapping("/selectCoupon")
public Result queryUserAvailableCoupons(@RequestParam("orderPrice") BigDecimal orderPrice) {
Map<String, Object> couponMap = new HashMap<>();
//可使用的优惠券
LinkedList<TbCfToicoupon> availableCoupon = new LinkedList();
//不可使用的优惠券
LinkedList<TbCfToicoupon> unAvailableCoupon = new LinkedList();
List<TbCfToicoupon> couponList = repository.queryUserAvailableCoupon(user.userId());
couponList.forEach(coupon -> {
boolean available = orderPrice.compareTo(coupon.withAmount()) >= 0;
if (available) {
availableCoupon.add(coupon);
} else {
unAvailableCoupon.add(coupon);
}
});
couponMap.put("availableCoupon", availableCoupon);
couponMap.put("unAvailableCoupon", unAvailableCoupon);
return new Result(couponMap);
}
}
......@@ -56,7 +56,7 @@ public class ItemController {
@RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize,
@RequestParam(value = "order", required = false) String order) {
return new Result<>(repository.findAllByItemCategorytwo(typeTwoId, PageRequest.of(pageNum,pageSize,sort(order))));
return new Result<>(repository.findAllByItemCategorytwoOrderByCreateTimeDesc(typeTwoId, PageRequest.of(pageNum,pageSize,sort(order))));
}
@GetMapping("/queryCategoryTwoByCid/{categoryId}")
......@@ -133,7 +133,7 @@ public class ItemController {
@RequestParam(value = "pageNum", defaultValue = "0") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "6") Integer pageSize,
@RequestParam(value = "order", required = false) String order) {
return new Result<>(repository.findAllByItemDescritionId(typeThreeId, PageRequest.of(pageNum,pageSize,sort(order))));
return new Result<>(repository.findAllByItemDescritionIdOrderByCreateTimeDesc(typeThreeId, PageRequest.of(pageNum,pageSize,sort(order))));
}
private Sort sort(String order){
......
......@@ -12,9 +12,9 @@ import org.springframework.data.repository.query.Param;
import java.util.List;
public interface TbCfStationItemRepository extends PagingAndSortingRepository<TbCfStationItem, String> {
Page<TbCfStationItem> findAllByItemCategorytwo(String category, Pageable pageable);
Page<TbCfStationItem> findAllByItemCategorytwoOrderByCreateTimeDesc(String category, Pageable pageable);
Page<TbCfStationItem> findAllByItemDescritionId(String description, Pageable pageable);
Page<TbCfStationItem> findAllByItemDescritionIdOrderByCreateTimeDesc(String description, Pageable pageable);
Page<TbCfStationItem> findAllByItemLabelContaining(String label, Pageable pageable);
......@@ -42,4 +42,6 @@ public interface TbCfStationItemRepository extends PagingAndSortingRepository<Tb
@Query(value = "select i from #{#entityName} i inner join AdvertisementItem a on i.itemId=a.itemId where a.adId=?1")
Page<TbCfStationItem> getAdvertisementItem2(String adId, Pageable pageable);
List<TbCfStationItem> findTop4ByItemCategoryOrderByCreateTime(String category);
}
......@@ -48,7 +48,6 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
}
@Bean
@Override
public AuthenticationManager authenticationManagerBean() throws Exception {
......@@ -65,7 +64,9 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
http.cors().and().csrf().disable()
.exceptionHandling().authenticationEntryPoint(unauthorizedHandler).and()
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS).and()
.authorizeRequests().antMatchers("/api/auth/**","/search/image/**", "/itemStation/**", "/startPage/**", "/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**","/version/**","/flutterwave/notify/**","/dpo/notify/**","/advertisement/**").permitAll()
.authorizeRequests().antMatchers("/api/auth/**", "/search/image/**", "/itemStation/**", "/startPage/**",
"/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**", "/version/**",
"/flutterwave/notify/**", "/dpo/notify/**", "/advertisement/**", "/website/**").permitAll()
.antMatchers("/api/test/**").permitAll()
.anyRequest().authenticated();
......
package com.example.afrishop_v3.vo;
import com.example.afrishop_v3.models.TbCfStationItem;
import java.util.List;
public class StationToGoodsType {
private String CategoryId;
private String Goodstypetitle;
private String GoodstypeUrl;
private List<TbCfStationItem> stationlist;
public String getCategoryId() {
return CategoryId;
}
public String getGoodstypetitle() {
return Goodstypetitle;
}
public List<TbCfStationItem> getStationlist() {
return stationlist;
}
public void setCategoryId(String categoryId) {
CategoryId = categoryId;
}
public void setGoodstypetitle(String goodstypetitle) {
Goodstypetitle = goodstypetitle;
}
public void setStationlist(List<TbCfStationItem> stationlist) {
this.stationlist = stationlist;
}
public String getGoodstypeUrl() {
return GoodstypeUrl;
}
public void setGoodstypeUrl(String goodstypeUrl) {
GoodstypeUrl = goodstypeUrl;
}
}
......@@ -4,10 +4,14 @@ package com.example.afrishop_v3.website.controller;
import com.example.afrishop_v3.base.Result;
import com.example.afrishop_v3.models.TbCfDescripiton;
import com.example.afrishop_v3.models.TbCfGoodstwotype;
import com.example.afrishop_v3.models.TbCfGoodstype;
import com.example.afrishop_v3.models.TbCfStationItem;
import com.example.afrishop_v3.repository.TbCfDescripitonRepository;
import com.example.afrishop_v3.repository.TbCfGoodstwotypeRepository;
import com.example.afrishop_v3.repository.TbCfGoodstypeRepository;
import com.example.afrishop_v3.repository.TbCfStationItemRepository;
import com.example.afrishop_v3.vo.Category;
import com.example.afrishop_v3.vo.StationToGoodsType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -18,10 +22,10 @@ import java.util.*;
/**
* @Auther: wudepeng
* @Date: 2020/11/23
* @Description:PC官网首页商品分类管理
* @Description:PC官网首页内容管理
*/
@RestController
@RequestMapping(value = "/website/column")
@RequestMapping(value = "/website")
public class ColumnController {
private final TbCfGoodstypeRepository repository;
......@@ -30,17 +34,19 @@ public class ColumnController {
private final TbCfDescripitonRepository tertiaryRepository;
public ColumnController(TbCfGoodstypeRepository repository, TbCfGoodstwotypeRepository secondaryRepository, TbCfDescripitonRepository tertiaryRepository) {
private final TbCfStationItemRepository itemRepository;
public ColumnController(TbCfGoodstypeRepository repository, TbCfGoodstwotypeRepository secondaryRepository, TbCfDescripitonRepository tertiaryRepository, TbCfStationItemRepository itemRepository) {
this.repository = repository;
this.secondaryRepository = secondaryRepository;
this.tertiaryRepository = tertiaryRepository;
this.itemRepository = itemRepository;
}
/**
* 查询所有一级分类
*/
@GetMapping
@GetMapping("/column")
public Result findTopCategory() {
return new Result(repository.findAll());
......@@ -49,7 +55,7 @@ public class ColumnController {
/**
* 查询一级分类的子分类
*/
@GetMapping("/{id}")
@GetMapping("/column/{id}")
public Result findCategoryChildrens(@PathVariable("id") String id) {
LinkedList<Category> categoryList = new LinkedList();
......@@ -69,4 +75,25 @@ public class ColumnController {
return new Result(categoryList);
}
/**
* 首页商品分类商品展示(每个分类展示4个)
*/
@GetMapping("/findItemByCategory")
public Result findItemByCategory() {
List<StationToGoodsType> listStation = new ArrayList<>();
Iterable<TbCfGoodstype> list = repository.findAll();
for (TbCfGoodstype goods : list) {
StationToGoodsType goodsType = new StationToGoodsType();
goodsType.setCategoryId(goods.getGoodstypeId());
goodsType.setGoodstypetitle(goods.getGoodstypeTitle());
goodsType.setGoodstypeUrl(goods.getGoodstypeUrl());
List<TbCfStationItem> station = itemRepository.findTop4ByItemCategoryOrderByCreateTime(goods.getGoodstypeId());
goodsType.setStationlist(station);
listStation.add(goodsType);
}
return new Result(listStation);
}
}
server:
servlet:
context-path: /afrishop
port: 8099
spring:
datasource:
url: jdbc:mysql://47.106.242.175:3306/afrishop_test?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
url: jdbc:mysql://159.138.48.71:3306/chinafrica_ref?useUnicode=true&connectionCollation=utf8mb4_general_ci&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
username: root
driver-class-name: com.mysql.cj.jdbc.Driver
password: diaoyun666
password: Diaoyunnuli.8
redis:
#Redis数据库分片索引(默认为0)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论