Commit f3d1de2c by shiwenbo

增加根据合同id查询车辆信息接口

parent 2bfc47e5
......@@ -11,4 +11,6 @@ public interface SelfPickupCarDao {
UUID create(KObject kobject);
KObject load(UUID id);
KObject getCarInfoByContractId(UUID contractId);
}
......@@ -2,7 +2,11 @@ package com.xyst.dinas.contract.internal.dao;
import java.util.UUID;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateCallback;
import org.springframework.orm.hibernate5.HibernateOperations;
import org.springframework.stereotype.Repository;
......@@ -27,4 +31,16 @@ public class SelfPickupCarDaoImpl implements SelfPickupCarDao {
public KObject load(UUID id) {
return (KObject) template.get(SelfPickupCarConstant.ENTITY, id);
}
@Override
public KObject getCarInfoByContractId(UUID contractId) {
return (KObject)template.execute(new HibernateCallback<KObject>() {
@Override
public KObject doInHibernate(Session session) throws HibernateException {
Query<KObject> query = session.createQuery("from " + SelfPickupCarConstant.ENTITY + " where (discard is null or discard = 0) and contract.id =:contractId", KObject.class);
query.setParameter("contractId", contractId);
return query.getSingleResult();
}
});
}
}
......@@ -76,4 +76,11 @@ public class SelfPickupCarServiceImpl implements SelfPickupCarService {
return selfPickupCarDao.create(kobject);
}
@Override
public String getCarInfoByContractId(String contractId) {
KObject carInfoKObject = selfPickupCarDao.getCarInfoByContractId(UUID.fromString(contractId));
String carInfo = carInfoKObject.getString("carInfo");
return carInfo;
}
}
......@@ -9,4 +9,6 @@ public interface SelfPickupCarService {
UUID create(KObject kobject);
void update(String param);
String getCarInfoByContractId(String contractId);
}
......@@ -3,6 +3,8 @@ package com.xyst.dinas.contract.web;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
......@@ -11,6 +13,7 @@ import com.beecode.amino.core.Amino;
import com.beecode.bcp.type.KClass;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.inz.basis.team.pojo.ResponseObj;
import com.xyst.dinas.contract.constant.SelfPickupCarConstant;
import com.xyst.dinas.contract.entity.CommonResult;
import com.xyst.dinas.contract.service.SelfPickupCarService;
......@@ -40,4 +43,10 @@ public class SelfPickupCarController {
selfPickupCarService.update(selfPickupCarInfo);
return CommonResult.SUCCESS_RESULT;
}
@GetMapping("/selfPickupCar/getCarInfoByContractId/{contractId}")
public Object getCarInfoByContractId(@PathVariable String contractId) {
String carInfo = selfPickupCarService.getCarInfoByContractId(contractId);
return ResponseObj.success("查询成功", carInfo);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment