package com.whyc.service;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.whyc.dto.Response;
|
import com.whyc.mapper.ProductHistoryMapper;
|
import com.whyc.pojo.ProductHistory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
@Service
|
public class ProductHistoryService {
|
@Autowired(required = false)
|
private ProductHistoryMapper mapper;
|
|
|
//产品详情查看版本信息
|
public Response getProductVersion(String parentModel,String customCode) {
|
QueryWrapper wrapper=new QueryWrapper();
|
wrapper.eq("parent_model",parentModel);
|
wrapper.eq("custom_code",customCode);
|
List<ProductHistory> list=mapper.selectList(wrapper);
|
return new Response().setII(1,list.size()>0?true:false,list,"返回产品版信息");
|
}
|
|
/**新增追加的版本并将原先的版本的启用设置为未启用*/
|
public void insertAndUpdateEnabled(ProductHistory productHistory) {
|
UpdateWrapper<ProductHistory> update = Wrappers.update();
|
update.set("enabled",0).eq("parent_code",productHistory.getParentCode())
|
.eq("custom_code",productHistory.getCustomCode()).eq("enabled",1);
|
mapper.update(null,update);
|
|
mapper.insert(productHistory);
|
}
|
|
public void updateEnabledStatus(String parentCode, String customCode, int status) {
|
int anotherStatus = 0;
|
if(status==0){
|
anotherStatus=1;
|
}else{
|
anotherStatus=0;
|
}
|
UpdateWrapper<ProductHistory> update = Wrappers.update();
|
update.set("enabled",status).eq("parent_code",parentCode)
|
.eq("custom_code",customCode).eq("enabled",anotherStatus);
|
mapper.update(null,update);
|
}
|
}
|