You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.8 KiB
66 lines
1.8 KiB
package com.demo.service.impl;
|
|
|
|
import com.demo.dao.CustomerMapper;
|
|
import com.demo.dao.ProductMapper;
|
|
import com.demo.dao.ReviewMapper;
|
|
import com.demo.pojo.Customer;
|
|
import com.demo.pojo.Product;
|
|
import com.demo.pojo.Review;
|
|
import com.demo.pojo.ReviewExample;
|
|
import com.demo.service.ReviewService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import java.util.List;
|
|
|
|
@Service
|
|
public class ReviewServiceImpl implements ReviewService {
|
|
|
|
@Autowired
|
|
private ReviewMapper reviewMapper;
|
|
@Autowired
|
|
private CustomerMapper customerMapper;
|
|
@Autowired
|
|
private ProductMapper productMapper;
|
|
|
|
@Override
|
|
public List<Review> list() {
|
|
List<Review> reviews = reviewMapper.selectByExample(null);
|
|
for (Review review:reviews){
|
|
Customer customer = customerMapper.selectByPrimaryKey(review.getCstid());
|
|
Product product = productMapper.selectByPrimaryKey(review.getPid());
|
|
review.setCustomer(customer);
|
|
review.setProduct(product);
|
|
}
|
|
return reviews;
|
|
}
|
|
|
|
@Override
|
|
public List<Review> getReviewListByPid(int id) {
|
|
ReviewExample example = new ReviewExample();
|
|
example.createCriteria().andPidEqualTo(id);
|
|
List<Review> reviews = reviewMapper.selectByExample(example);
|
|
for (Review review:reviews){
|
|
Customer customer = customerMapper.selectByPrimaryKey(review.getCstid());
|
|
review.setCustomer(customer);
|
|
}
|
|
|
|
return reviews;
|
|
}
|
|
|
|
@Override
|
|
public void del(int id) {
|
|
reviewMapper.deleteByPrimaryKey(id);
|
|
}
|
|
|
|
@Override
|
|
public Review get(int id) {
|
|
return reviewMapper.selectByPrimaryKey(id);
|
|
}
|
|
|
|
@Override
|
|
public void save(Review review) {
|
|
reviewMapper.insert(review);
|
|
}
|
|
}
|