Commit f8f0c93f by 高晓磊

Merge branch 'feature/dinas_type' into develop

parents e8c61f88 ae9021c2
......@@ -14,6 +14,7 @@ import org.hibernate.query.NativeQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate5.HibernateTemplate;
import java.math.BigInteger;
import java.util.Date;
import java.util.List;
import java.util.UUID;
......@@ -24,7 +25,6 @@ public class DinasTypeDaoImpl extends AbstractBaseDao implements DinasTypeDao, D
@Autowired
private HibernateTemplate template;
private String insertOrUpdateDinasTypeStationHql=" inz_kunlun01.xyst_dinas_biz_station_dinas_type " +
"set station_id = :stationId , dinas_type_id =:dinasTypeId ";
......@@ -102,10 +102,10 @@ public class DinasTypeDaoImpl extends AbstractBaseDao implements DinasTypeDao, D
@Override
public boolean checkedStation(UUID dinasTypeId, UUID stationId) {
Boolean hasCount = getHasCount(dinasTypeId, stationId);
if(hasCount){
if(!hasCount){
return template.executeWithNativeSession(session -> {
NativeQuery<Integer> nativeQuery = session.createNativeQuery(
"insert into " + insertOrUpdateDinasTypeStationHql, Integer.class);
NativeQuery nativeQuery = session.createNativeQuery(
"insert into " + insertOrUpdateDinasTypeStationHql);
nativeQuery.setParameter("stationId", stationId);
nativeQuery.setParameter("dinasTypeId", dinasTypeId);
int count = nativeQuery.executeUpdate();
......@@ -122,8 +122,8 @@ public class DinasTypeDaoImpl extends AbstractBaseDao implements DinasTypeDao, D
if(hasCount){
return template.executeWithNativeSession(session -> {
NativeQuery<Integer> nativeQuery = session.createNativeQuery(
"delete " + deleteOrSelectDinasTypeStationHql, Integer.class);
NativeQuery nativeQuery = session.createNativeQuery(
"delete " + deleteOrSelectDinasTypeStationHql);
nativeQuery.setParameter("stationId", stationId);
nativeQuery.setParameter("dinasTypeId", dinasTypeId);
int count = nativeQuery.executeUpdate();
......@@ -135,12 +135,12 @@ public class DinasTypeDaoImpl extends AbstractBaseDao implements DinasTypeDao, D
private Boolean getHasCount(UUID dinasTypeId, UUID stationId) {
return template.executeWithNativeSession(session -> {
NativeQuery<Integer> nativeQuery = session.createNativeQuery(
"select count(1) "+deleteOrSelectDinasTypeStationHql, Integer.class);
NativeQuery nativeQuery = session.createNativeQuery(
"select count(1) "+deleteOrSelectDinasTypeStationHql);
nativeQuery.setParameter("stationId", stationId);
nativeQuery.setParameter("dinasTypeId", dinasTypeId);
Integer singleResult = nativeQuery.getSingleResult();
return singleResult != null && singleResult == 0;
Integer singleResult = Integer.valueOf(nativeQuery.getSingleResult().toString());
return singleResult==1;
});
}
......
......@@ -6,10 +6,11 @@ import com.xyst.dinas.biz.dao.DinasTypeDao;
import com.xyst.dinas.biz.service.DinasTypeService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.UUID;
@Transactional(rollbackFor = Exception.class)
public class DinasTypeServiceImpl implements DinasTypeService {
@Autowired
......
......@@ -59,7 +59,7 @@ public class DinasTypeController {
public ResponseObj update(@RequestBody String body){
KObject kobject = JSONObjectUtils.toObject(body,Amino.getApplicationMetadataContext().getBean(DinasTypeConstant.ENTITY, KClass.class));
if(StringUtils.isEmpty(kobject.getString("stationName"))){
if(StringUtils.isEmpty(kobject.getString("dinasTypeName"))){
return ResponseObj.error(400,"砂石种类名称不能为空");
}
if(kobject.getUuid("id") == null){
......
......@@ -41,14 +41,14 @@ public class StationController {
@RequestMapping(value = "list/page", method = RequestMethod.GET)
public Page<KObject> getStaffByRole(
public ResponseObj getStaffByRole(
@RequestParam(name = "pageNo", required = false) Integer pageNo,
@RequestParam(name = "pageSize", required = false) Integer pageSize) throws Exception {
Page<KObject> objectPage = new Page<>();
objectPage.setPageNo(pageNo);
objectPage.setPageSize(pageSize);
return stationService.queryByPaging(objectPage);
return ResponseObj.success("查询成功",stationService.queryByPaging(objectPage));
}
......
......@@ -80,19 +80,6 @@
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>com.beecode.bap.biztrait.datamodel.SubTableAnnotation</m:type>
</m:annotation>
</m:annotations>
<m:id>726e8dac-46c8-429f-94db-9922840c5998</m:id>
<m:name>dinasTypes</m:name>
<m:title>售卖的砂石</m:title>
<m:type>com.xyst.dinas.biz.datamodel.DinasType[]</m:type>
<m:description></m:description>
<m:default></m:default>
</m:attribute>
<m:attribute>
<m:annotations/>
<m:id>b4211477-b5b7-4036-9814-7e5affff7ea0</m:id>
<m:name>openingDate</m:name>
......
......@@ -3,7 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.hibernate.org/xsd/hibernate-mapping
http://www.hibernate.org/xsd/hibernate-mapping/hibernate-mapping-4.0.xsd">
<class entity-name="com.xyst.dinas.biz.datamodel.DinasType" table="xyst_dinas_biz_dinas_type" optimistic-lock="version">
<class entity-name="com.xyst.dinas.biz.datamodel.DinasType" table="xyst_dinas_biz_dinas_type" optimistic-lock="version"
>
<tuplizer entity-mode="dynamic-map" class="com.beecode.bcp.store.hibernate.KObjectEntityTuplizer"/>
<id name="id" type="uuid-binary" column="id" length="16">
<generator class="assigned" />
......@@ -43,9 +44,9 @@
<comment>砂石是否售卖,0不售卖 1还售卖</comment>
</column>
</property>
<bag name="stations" cascade="none" table="xyst_dinas_biz_station_dinas_type">
<bag name="stations" cascade="none" table="xyst_dinas_biz_station_dinas_type" lazy="extra">
<key column="dinas_type_id" not-null="true" />
<many-to-many class="com.xyst.dinas.biz.datamodel.Station" column="station_id" fetch="join"/>
<many-to-many class="com.xyst.dinas.biz.datamodel.Station" column="station_id"/>
</bag>
<property name="reason" type="nstring" not-null="false">
<column name="reason" length="300" >
......
......@@ -80,15 +80,10 @@
<comment>备注</comment>
</column>
</property>
<property name="sortOrder" type="int" not-null="true" unique="true" update="false" insert="false" index="station_sort_index" >
<property name="sortOrder" type="int" not-null="true" unique="true" index="station_sort_index" >
<column name="sort_order" length="10">
<comment >排序</comment>
</column>
</property>
<bag name="dinasTypes" cascade="none" inverse="true" table="xyst_dinas_biz_station_dinas_type">
<key column="station_id" not-null="true"/>
<many-to-many class="com.xyst.dinas.biz.datamodel.DinasType" column="dinas_type_id" />
</bag>
</class>
</hibernate-mapping>
\ No newline at end of file
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