提交 08d8bf91 authored 作者: 吴德鹏's avatar 吴德鹏

商品列表排序

上级 5e66ece8
......@@ -67,7 +67,7 @@ public class ItemController {
Map<String, Object> map = new HashMap<>();
Optional<TbCfGoodstype> byId = goodstypeRepository.findById(categoryId);
List<TbCfGoodstwotype> allByGoodstypeId = goodstwotypeRepository.findAllByGoodstypeId(categoryId);
List<TbCfGoodstwotype> allByGoodstypeId = goodstwotypeRepository.findAllByGoodstypeIdOrderBySort(categoryId);
map.put("category", byId.orElse(null));
map.put("categoryTwoList", allByGoodstypeId);
return new Result<>(map);
......@@ -78,7 +78,7 @@ public class ItemController {
public Result queryDescriptionByCTwoId(@PathVariable("categoryTwoId") String categoryTwoId) {
Map<String, Object> map = new HashMap<>();
Optional<TbCfGoodstwotype> byId = goodstwotypeRepository.findById(categoryTwoId);
List<TbCfDescripiton> allByGoodstwotypeId = descriptionRepository.findAllByGoodstwotypeId(categoryTwoId);
List<TbCfDescripiton> allByGoodstwotypeId = descriptionRepository.findAllByGoodstwotypeIdOrderBySort(categoryTwoId);
map.put("category", byId.orElse(null));
map.put("descriptionList", allByGoodstwotypeId);
return new Result<>(map);
......
......@@ -5,10 +5,7 @@ import com.example.afrishop_v3.models.TbCfVisit;
import com.example.afrishop_v3.repository.TbCfVisitRepository;
import com.example.afrishop_v3.security.services.AuthenticationUser;
import com.example.afrishop_v3.util.IdUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
......@@ -24,16 +21,16 @@ public class VisitController extends Controller {
private final HttpServletRequest request; //自动注入request
private final TbCfVisitRepository visitRepository;
private final AuthenticationUser user;
// private final AuthenticationUser user;
public VisitController(HttpServletRequest request, TbCfVisitRepository visitRepository, AuthenticationUser user) {
public VisitController(HttpServletRequest request, TbCfVisitRepository visitRepository) {
this.request = request;
this.visitRepository = visitRepository;
this.user = user;
}
@GetMapping("/getVisitCount")
@PostMapping("/getVisitCount")
public Result getVisitCount(@RequestBody TbCfVisit visit) {
String ip = getRealIpAddress(request);
......
......@@ -63,6 +63,16 @@ public class TbCfDescripiton{
*/
private String twoType;
private Integer sort;
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getType() {
return type;
}
......
......@@ -44,10 +44,19 @@ public class TbCfGoodstwotype{
@Transient
private boolean autoLoad = false;
private Integer sort;
@OneToMany(mappedBy = "goodstwotypeId")
private List<TbCfDescripiton> categoryList = new ArrayList<>();
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
/**
* 设置:商品二级分类Id
*/
......
......@@ -7,5 +7,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface TbCfDescripitonRepository extends PagingAndSortingRepository<TbCfDescripiton,String> {
List<TbCfDescripiton> findAllByGoodstwotypeId(String categoryTwo);
List<TbCfDescripiton> findAllByGoodstwotypeIdOrderBySort(String categoryTwo);
}
......@@ -6,5 +6,5 @@ import org.springframework.data.repository.PagingAndSortingRepository;
import java.util.List;
public interface TbCfGoodstwotypeRepository extends PagingAndSortingRepository<TbCfGoodstwotype,String> {
List<TbCfGoodstwotype> findAllByGoodstypeId(String id);
List<TbCfGoodstwotype> findAllByGoodstypeIdOrderBySort(String id);
}
......@@ -70,7 +70,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
.authorizeRequests().antMatchers("/api/auth/**", "/search/image/**", "/itemStation/**", "/startPage/**",
"/goodsType/**", "/home/**", "/spider/**", "/store/**", "/shopify/**", "/community/**", "/version/**",
"/flutterwave/notify/**", "/dpo/notify/**", "/advertisement/**", "/website/**", "/paypal/**", "/discover/bonus/**",
"/problem/**", "/cube/**", "/activity/**", "/attributes/**", "/stripe/**", "/coupon/**", "/logistics/freeShippingThreshold").permitAll()
"/problem/**", "/cube/**", "/activity/**", "/attributes/**", "/stripe/**", "/coupon/**", "/logistics/freeShippingThreshold","/visit/**").permitAll()
.antMatchers("/api/test/**").permitAll()
.anyRequest().authenticated();
......
......@@ -305,9 +305,18 @@ public class HttpsUtil {
params.put("lang", "zh-CN");
String result = HttpClientUtil.createConnection(url, params, "utf-8");
JSONObject jsonObject = JSONObject.parseObject(result);
String country = jsonObject.getString("country");
System.out.println("result:"+result);
System.out.println("country:" + country);
return country;
String status = jsonObject.getString("status");
if ("success".equals(status)) {
String country = jsonObject.getString("country");
String city = jsonObject.getString("city");
if (!city.equals(country)) {
country = country + "-" + city;
}
System.out.println("result:" + result);
System.out.println("country:" + country);
return country;
}
return null;
}
}
......@@ -33,7 +33,7 @@ public class Column2Controller {
@GetMapping("/{id}")
public Result getColumnChildren(@PathVariable String id) {
List<TbCfGoodstwotype> list = goodstwotypeRepository.findAllByGoodstypeId(id);
List<TbCfGoodstwotype> list = goodstwotypeRepository.findAllByGoodstypeIdOrderBySort(id);
list.forEach(TbCfGoodstwotype::enableAutoLoad);
return new Result<>(list);
}
......
......@@ -60,11 +60,11 @@ public class ColumnController {
LinkedList<Category> categoryList = new LinkedList<>();
//二级分类
List<TbCfGoodstwotype> secondaryCategory = secondaryRepository.findAllByGoodstypeId(id);
List<TbCfGoodstwotype> secondaryCategory = secondaryRepository.findAllByGoodstypeIdOrderBySort(id);
secondaryCategory.forEach(category -> {
//三级分类
List<TbCfDescripiton> tertiaryCategory = tertiaryRepository.findAllByGoodstwotypeId(category.getGoodstwotypeId());
List<TbCfDescripiton> tertiaryCategory = tertiaryRepository.findAllByGoodstwotypeIdOrderBySort(category.getGoodstwotypeId());
Category c = new Category();
c.setId(category.getGoodstwotypeId());
c.setCategory(category.getGoodstwotypeTitle());
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论