提交 47eeb636 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 fb3a8026
......@@ -8,28 +8,42 @@
type="date"
:transfer="true"
:format="valFormat"
:placeholder="$t('components.appRangeEditor.placeholder')"
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="onValueChange">
@on-change="(value,type)=>{onValueChange(item,value)}">
</date-picker>
<time-picker
:key="index"
v-else-if="editorType.startsWith('DATEPICKEREX')"
:transfer="true"
:format="valFormat"
:placeholder="$t('components.appRangeEditor.placeholder')"
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="onValueChange">
@on-change="(value)=>{onValueChange(item,value)}">
</time-picker>
<i-input
:key="index"
v-else
v-else-if="Object.is(editorType, 'NUMBER')"
type="number"
:value="getValue(item)"
:disabled="disabled"
:placeholder="$t('components.appRangeEditor.input')"
:placeholder="$t('info.input')"
@on-change="setValue">
</i-input>
<app-span
:key="index"
v-else-if="Object.is(editorType, 'SPAN')"
:value="activeData[item]"
:disabled="disabled">
</app-span>
<i-input
:key="index"
v-else
:value="getValue(item)"
:disabled="disabled"
:placeholder="$t('info.input')"
@on-change="setValue">
</i-input>
</template>
......
......@@ -3,7 +3,7 @@
text-overflow: ellipsis;
word-break: break-all;
overflow: hidden;
text-align: center;
text-align: left;
.file-item{
color: #606266;
display: inline-block;
......
......@@ -747,7 +747,7 @@ export default class MainBase extends Vue implements ControlInterface {
const importDataModel:any ={
}
if(Object.keys(importDataModel).length == 0){
this.$Notice.warning({ title: this.$t("app.utilview.warning"), desc: this.$t("app.utilview.info") });
this.$Notice.warning({ 'title': (this.$t("app.utilview.warning") as string), 'desc': (this.$t("app.utilview.info") as string) });
return;
}
const view:any ={
......
......@@ -817,7 +817,7 @@ export default class MainBase extends Vue implements ControlInterface {
const importDataModel:any ={
}
if(Object.keys(importDataModel).length == 0){
this.$Notice.warning({ title: this.$t("app.utilview.warning"), desc: this.$t("app.utilview.info") });
this.$Notice.warning({ 'title': (this.$t("app.utilview.warning") as string), 'desc': (this.$t("app.utilview.info") as string) });
return;
}
const view:any ={
......
......@@ -20,23 +20,23 @@ import lombok.Data;
import org.springframework.data.annotation.Transient;
import com.baomidou.mybatisplus.annotation.*;
import cn.ibizlab.util.domain.EntityMP;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
/**
* 实体[数据字典]
* 大数据 [数据字典] 对象
*/
@Data
@TableName(value = "IBZDICT",resultMap = "IBZDictResultMap")
public class IBZDict extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L;
@Document(collection = "ibzdict")
public class IBZDict extends EntityBase implements Serializable {
/**
* 字典标识
*/
@Id()
@DEField(isKeyField=true)
@TableId(value= "ibzdictid",type=IdType.UUID)
@JSONField(name = "dictid")
@JsonProperty("dictid")
private String dictid;
......@@ -44,57 +44,56 @@ public class IBZDict extends EntityMP implements Serializable {
/**
* 字典名称
*/
@TableField(value = "ibzdictname")
@JSONField(name = "dictname")
@JsonProperty("dictname")
@Field(name = "ibzdictname")
private String dictname;
/**
* 逻辑有效标志
*/
@DEField(preType = DEPredefinedFieldType.LOGICVALID, logicval = "1" , logicdelval="0")
@TableLogic(value= "1",delval="0")
@TableField(value = "enable")
@JSONField(name = "enable")
@JsonProperty("enable")
@Field(name = "enable")
private Integer enable;
/**
* 建立时间
*/
@DEField(preType = DEPredefinedFieldType.CREATEDATE)
@TableField(value = "createdate" , fill = FieldFill.INSERT)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "createdate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
@Field(name = "createdate")
private Timestamp createdate;
/**
* 更新时间
*/
@DEField(preType = DEPredefinedFieldType.UPDATEDATE)
@TableField(value = "updatedate")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
@Field(name = "updatedate")
private Timestamp updatedate;
/**
* 建立人
*/
@DEField(preType = DEPredefinedFieldType.CREATEMAN)
@TableField(value = "createman" , fill = FieldFill.INSERT)
@JSONField(name = "createman")
@JsonProperty("createman")
@Field(name = "createman")
private String createman;
/**
* 更新人
*/
@DEField(preType = DEPredefinedFieldType.UPDATEMAN)
@TableField(value = "updateman")
@JSONField(name = "updateman")
@JsonProperty("updateman")
@Field(name = "updateman")
private String updateman;
......@@ -102,26 +101,12 @@ public class IBZDict extends EntityMP implements Serializable {
/**
* 字典项目
*/
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
@JSONField(name = "items")
@JsonProperty("items")
@Field(name = "items")
private List<cn.ibizlab.core.dict.domain.IBZDictItem> items;
/**
* 设置 [字典项目]
*/
public void setItems(List<cn.ibizlab.core.dict.domain.IBZDictItem> items){
this.items = items ;
this.modify("items",(items!=null)?items:(new ArrayList()));
}
/**
* 设置 [字典名称]
*/
public void setDictname(String dictname){
this.dictname = dictname ;
this.modify("ibzdictname",dictname);
}
}
......@@ -129,3 +114,4 @@ public class IBZDict extends EntityMP implements Serializable {
......@@ -20,23 +20,23 @@ import lombok.Data;
import org.springframework.data.annotation.Transient;
import com.baomidou.mybatisplus.annotation.*;
import cn.ibizlab.util.domain.EntityMP;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import org.springframework.data.mongodb.core.mapping.FieldType;
/**
* 实体[字典项目]
* 大数据 [字典项目] 对象
*/
@Data
@TableName(value = "IBZDICTITEM",resultMap = "IBZDictItemResultMap")
public class IBZDictItem extends EntityMP implements Serializable {
private static final long serialVersionUID = 1L;
@Document(collection = "ibzdictitem")
public class IBZDictItem extends EntityBase implements Serializable {
/**
* 字典项目标识
*/
@Id()
@DEField(isKeyField=true)
@TableId(value= "ibzdictitemid",type=IdType.UUID)
@JSONField(name = "itemid")
@JsonProperty("itemid")
private String itemid;
......@@ -44,105 +44,105 @@ public class IBZDictItem extends EntityMP implements Serializable {
/**
* 栏目显示值
*/
@TableField(value = "ibzdictitemname")
@JSONField(name = "itemname")
@JsonProperty("itemname")
@Field(name = "ibzdictitemname")
private String itemname;
/**
* 栏目值
*/
@TableField(value = "dictitemval")
@JSONField(name = "itemval")
@JsonProperty("itemval")
@Field(name = "dictitemval")
private String itemval;
/**
* 字典标识
*/
@TableField(value = "dictid")
@JSONField(name = "dictid")
@JsonProperty("dictid")
@Field(name = "dictid")
private String dictid;
/**
* 父栏目值
*/
@TableField(value = "pitemval")
@JSONField(name = "pitemval")
@JsonProperty("pitemval")
@Field(name = "pitemval")
private String pitemval;
/**
* 过滤项
*/
@TableField(value = "itemfilter")
@JSONField(name = "itemfilter")
@JsonProperty("itemfilter")
@Field(name = "itemfilter")
private String itemfilter;
/**
* 栏目样式
*/
@DEField(defaultValue = "itemcls" , defaultValueType = DEFieldDefaultValueType.PARAM)
@TableField(value = "itemcls")
@JSONField(name = "itemcls")
@JsonProperty("itemcls")
@Field(name = "itemcls")
private String itemcls;
/**
* 图标
*/
@DEField(defaultValue = "no,png")
@TableField(value = "itemicon")
@JSONField(name = "itemicon")
@JsonProperty("itemicon")
@Field(name = "itemicon")
private String itemicon;
/**
* 排序
*/
@TableField(value = "showorder")
@JSONField(name = "showorder")
@JsonProperty("showorder")
@Field(name = "showorder")
private Integer showorder;
/**
* 建立时间
*/
@DEField(preType = DEPredefinedFieldType.CREATEDATE)
@TableField(value = "createdate" , fill = FieldFill.INSERT)
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "createdate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("createdate")
@Field(name = "createdate")
private Timestamp createdate;
/**
* 更新时间
*/
@DEField(defaultValueType = DEFieldDefaultValueType.CURTIME , preType = DEPredefinedFieldType.UPDATEDATE)
@TableField(value = "updatedate")
@JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", locale = "zh" , timezone="GMT+8")
@JSONField(name = "updatedate" , format="yyyy-MM-dd HH:mm:ss")
@JsonProperty("updatedate")
@Field(name = "updatedate")
private Timestamp updatedate;
/**
* 建立人
*/
@DEField(preType = DEPredefinedFieldType.CREATEMAN)
@TableField(value = "createman" , fill = FieldFill.INSERT)
@JSONField(name = "createman")
@JsonProperty("createman")
@Field(name = "createman")
private String createman;
/**
* 更新人
*/
@DEField(defaultValue = "SRFPERSONID" , defaultValueType = DEFieldDefaultValueType.SESSION , preType = DEPredefinedFieldType.UPDATEMAN)
@TableField(value = "updateman")
@JSONField(name = "updateman")
@JsonProperty("updateman")
@Field(name = "updateman")
private String updateman;
......@@ -151,67 +151,11 @@ public class IBZDictItem extends EntityMP implements Serializable {
*/
@JsonIgnore
@JSONField(serialize = false)
@TableField(exist = false)
@Transient
private cn.ibizlab.core.dict.domain.IBZDict dict;
/**
* 设置 [栏目显示值]
*/
public void setItemname(String itemname){
this.itemname = itemname ;
this.modify("ibzdictitemname",itemname);
}
/**
* 设置 [栏目值]
*/
public void setItemval(String itemval){
this.itemval = itemval ;
this.modify("dictitemval",itemval);
}
/**
* 设置 [字典标识]
*/
public void setDictid(String dictid){
this.dictid = dictid ;
this.modify("dictid",dictid);
}
/**
* 设置 [父栏目值]
*/
public void setPitemval(String pitemval){
this.pitemval = pitemval ;
this.modify("pitemval",pitemval);
}
/**
* 设置 [过滤项]
*/
public void setItemfilter(String itemfilter){
this.itemfilter = itemfilter ;
this.modify("itemfilter",itemfilter);
}
/**
* 设置 [栏目样式]
*/
public void setItemcls(String itemcls){
this.itemcls = itemcls ;
this.modify("itemcls",itemcls);
}
/**
* 设置 [图标]
*/
public void setItemicon(String itemicon){
this.itemicon = itemicon ;
this.modify("itemicon",itemicon);
}
/**
* 设置 [排序]
*/
public void setShoworder(Integer showorder){
this.showorder = showorder ;
this.modify("showorder",showorder);
}
}
......@@ -219,3 +163,4 @@ public class IBZDictItem extends EntityMP implements Serializable {
......@@ -15,35 +15,39 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.ibizlab.util.filter.QueryBuildContext;
import cn.ibizlab.core.dict.domain.IBZDictItem;
import java.util.regex.Pattern;
import com.mongodb.BasicDBObject;
/**
* 关系型数据实体[IBZDictItem] 查询条件对象
* NoSQL数据实体[IBZDictItem] 查询条件对象
*/
@Slf4j
@Data
public class IBZDictItemSearchContext extends QueryWrapperContext<IBZDictItem> {
public class IBZDictItemSearchContext extends QueryBuildContext {
private String n_ibzdictitemname_like;//[栏目显示值]
public void setN_ibzdictitemname_like(String n_ibzdictitemname_like) {
this.n_ibzdictitemname_like = n_ibzdictitemname_like;
if(!ObjectUtils.isEmpty(this.n_ibzdictitemname_like)){
this.getSelectCond().like("ibzdictitemname", n_ibzdictitemname_like);
Pattern pattern = Pattern.compile("^.*" + n_ibzdictitemname_like + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("ibzdictitemname").regex(pattern);
}
}
private String n_dictitemval_like;//[栏目值]
public void setN_dictitemval_like(String n_dictitemval_like) {
this.n_dictitemval_like = n_dictitemval_like;
if(!ObjectUtils.isEmpty(this.n_dictitemval_like)){
this.getSelectCond().like("dictitemval", n_dictitemval_like);
Pattern pattern = Pattern.compile("^.*" + n_dictitemval_like + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("dictitemval").regex(pattern);
}
}
private String n_dictid_eq;//[字典标识]
public void setN_dictid_eq(String n_dictid_eq) {
this.n_dictid_eq = n_dictid_eq;
if(!ObjectUtils.isEmpty(this.n_dictid_eq)){
this.getSelectCond().eq("dictid", n_dictid_eq);
this.getSelectCond().and("dictid").is(n_dictid_eq);
}
}
......@@ -54,11 +58,11 @@ public class IBZDictItemSearchContext extends QueryWrapperContext<IBZDictItem> {
{
this.query=query;
if(!StringUtils.isEmpty(query)){
this.getSelectCond().or().like("ibzdictitemname",query);
Pattern pattern = Pattern.compile("^.*" + query + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().or(new BasicDBObject("ibzdictitemname",pattern));
}
}
}
......@@ -15,28 +15,32 @@ import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
import cn.ibizlab.util.filter.QueryWrapperContext;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.ibizlab.util.filter.QueryBuildContext;
import cn.ibizlab.core.dict.domain.IBZDict;
import java.util.regex.Pattern;
import com.mongodb.BasicDBObject;
/**
* 关系型数据实体[IBZDict] 查询条件对象
* NoSQL数据实体[IBZDict] 查询条件对象
*/
@Slf4j
@Data
public class IBZDictSearchContext extends QueryWrapperContext<IBZDict> {
public class IBZDictSearchContext extends QueryBuildContext {
private String n_ibzdictid_like;//[字典标识]
public void setN_ibzdictid_like(String n_ibzdictid_like) {
this.n_ibzdictid_like = n_ibzdictid_like;
if(!ObjectUtils.isEmpty(this.n_ibzdictid_like)){
this.getSelectCond().like("ibzdictid", n_ibzdictid_like);
Pattern pattern = Pattern.compile("^.*" + n_ibzdictid_like + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("ibzdictid").regex(pattern);
}
}
private String n_ibzdictname_like;//[字典名称]
public void setN_ibzdictname_like(String n_ibzdictname_like) {
this.n_ibzdictname_like = n_ibzdictname_like;
if(!ObjectUtils.isEmpty(this.n_ibzdictname_like)){
this.getSelectCond().like("ibzdictname", n_ibzdictname_like);
Pattern pattern = Pattern.compile("^.*" + n_ibzdictname_like + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().and("ibzdictname").regex(pattern);
}
}
......@@ -47,11 +51,11 @@ public class IBZDictSearchContext extends QueryWrapperContext<IBZDict> {
{
this.query=query;
if(!StringUtils.isEmpty(query)){
this.getSelectCond().or().like("ibzdictname",query);
Pattern pattern = Pattern.compile("^.*" + query + ".*$", Pattern.CASE_INSENSITIVE);
this.getSelectCond().or(new BasicDBObject("ibzdictname",pattern));
}
}
}
package cn.ibizlab.core.dict.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import cn.ibizlab.core.dict.domain.IBZDictItem;
import org.springframework.stereotype.Repository;
@Repository
public interface IBZDictItemRepository extends MongoRepository<IBZDictItem, String>{
}
package cn.ibizlab.core.dict.repository;
import org.springframework.data.mongodb.repository.MongoRepository;
import cn.ibizlab.core.dict.domain.IBZDict;
import org.springframework.stereotype.Repository;
@Repository
public interface IBZDictRepository extends MongoRepository<IBZDict, String>{
}
......@@ -16,12 +16,10 @@ import cn.ibizlab.core.dict.domain.IBZDictItem;
import cn.ibizlab.core.dict.filter.IBZDictItemSearchContext;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[IBZDictItem] 服务对象接口
*/
public interface IIBZDictItemService extends IService<IBZDictItem>{
public interface IIBZDictItemService{
IBZDictItem get(String key) ;
IBZDictItem getDraft(IBZDictItem et) ;
......@@ -37,11 +35,12 @@ public interface IIBZDictItemService extends IService<IBZDictItem>{
Page<IBZDictItem> searchDefault(IBZDictItemSearchContext context) ;
List<IBZDictItem> selectByDictid(String dictid) ;
void saveByDictid(String dictid,List<IBZDictItem> list) ;
void removeByDictid(String dictid) ;
void saveByDictid(String dictid,List<IBZDictItem> list) ;
}
......@@ -16,12 +16,10 @@ import cn.ibizlab.core.dict.domain.IBZDict;
import cn.ibizlab.core.dict.filter.IBZDictSearchContext;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* 实体[IBZDict] 服务对象接口
*/
public interface IIBZDictService extends IService<IBZDict>{
public interface IIBZDictService{
IBZDict get(String key) ;
boolean create(IBZDict et) ;
......@@ -41,3 +39,4 @@ public interface IIBZDictService extends IService<IBZDict>{
}
......@@ -27,31 +27,32 @@ import cn.ibizlab.util.helper.CachedBeanCopier;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ibizlab.core.dict.mapper.IBZDictItemMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import cn.ibizlab.core.dict.repository.IBZDictItemRepository;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Query;
import javax.annotation.Resource;
/**
* 实体[字典项目] 服务对象接口实现
*/
@Slf4j
@Service
public class IBZDictItemServiceImpl extends ServiceImpl<IBZDictItemMapper, IBZDictItem> implements IIBZDictItemService {
private int batchSize = 500;
public class IBZDictItemServiceImpl implements IIBZDictItemService {
@Autowired
private IBZDictItemRepository repository;
@Override
@Transactional
public IBZDictItem get(String key) {
IBZDictItem et = getById(key);
if(et==null){
et=new IBZDictItem();
Optional<IBZDictItem> result = repository.findById(key);
if(!result.isPresent()){
IBZDictItem et=new IBZDictItem();
et.setItemid(key);
return et;
}
return et;
else
return result.get();
}
@Override
......@@ -62,75 +63,75 @@ public class IBZDictItemServiceImpl extends ServiceImpl<IBZDictItemMapper, IBZDi
@Override
@Transactional
public boolean save(IBZDictItem et) {
return saveOrUpdate(et) ;
repository.save(et);
return true ;
}
@Override
@Transactional(
rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(IBZDictItem et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
public void saveBatch(List<IBZDictItem> list) {
saveOrUpdateBatch(list,batchSize);
repository.saveAll(list);
}
@Override
public boolean checkKey(IBZDictItem et) {
return (!ObjectUtils.isEmpty(et.getItemid()))&&(!Objects.isNull(this.getById(et.getItemid())));
return repository.findById(et.getItemid()).isPresent();
}
@Override
@Transactional
public boolean remove(String key) {
if(!removeById(key)) return false;
repository.deleteById(key);
return true ;
}
@Override
public void removeBatch(Collection<String> idList) {
removeByIds(idList);
repository.deleteAll(repository.findAllById(idList));
}
@Override
@Transactional
public boolean create(IBZDictItem et) {
if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getItemid()),et);
repository.insert(et);
return true ;
}
@Override
public void createBatch(List<IBZDictItem> list) {
saveBatch(list,batchSize);
repository.insert(list);
}
@Override
@Transactional
public boolean update(IBZDictItem et) {
if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("ibzdictitemid",et.getItemid())))
return false;
CachedBeanCopier.copy(get(et.getItemid()),et);
repository.save(et);
return true ;
}
@Override
public void updateBatch(List<IBZDictItem> list) {
updateBatchById(list,batchSize);
repository.saveAll(list);
}
@Override
public List<IBZDictItem> selectByDictid(String dictid) {
return baseMapper.selectByDictid(dictid);
IBZDictItemSearchContext context=new IBZDictItemSearchContext();
context.setN_dictid_eq(dictid);
Query query = new BasicQuery(context.getSelectCond().get().toString());
return mongoTemplate.find(query,IBZDictItem.class);
}
@Override
public void removeByDictid(String dictid) {
Set<String> delIds=new HashSet<String>();
for(IBZDictItem before:selectByDictid(dictid)){
delIds.add(before.getItemid());
}
if(delIds.size()>0)
this.removeBatch(delIds);
}
@Override
......@@ -162,22 +163,25 @@ public class IBZDictItemServiceImpl extends ServiceImpl<IBZDictItemMapper, IBZDi
this.removeBatch(delIds);
}
@Override
public void removeByDictid(String dictid) {
this.remove(new QueryWrapper<IBZDictItem>().eq("ibzdictid",dictid));
}
@Resource
private MongoTemplate mongoTemplate;
/**
* 查询集合 DEFAULT
*/
@Override
public Page<IBZDictItem> searchDefault(IBZDictItemSearchContext context) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<IBZDictItem> pages=baseMapper.searchDefault(context.getPage(),context,context.getSelectCond());
return new PageImpl<IBZDictItem>(pages.getRecords(), context.getPageable(), pages.getTotal());
Query query = new BasicQuery(context.getSelectCond().get().toString());
long total = mongoTemplate.count(query, IBZDictItem.class);
List<IBZDictItem> list=mongoTemplate.find(query.with(context.getPageable()),IBZDictItem.class);
return new PageImpl<IBZDictItem>(list,context.getPageable(),total);
}
}
......@@ -27,52 +27,49 @@ import cn.ibizlab.util.helper.CachedBeanCopier;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import cn.ibizlab.core.dict.mapper.IBZDictMapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import cn.ibizlab.core.dict.repository.IBZDictRepository;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.BasicQuery;
import org.springframework.data.mongodb.core.query.Query;
import javax.annotation.Resource;
/**
* 实体[数据字典] 服务对象接口实现
*/
@Slf4j
@Service
public class IBZDictServiceImpl extends ServiceImpl<IBZDictMapper, IBZDict> implements IIBZDictService {
public class IBZDictServiceImpl implements IIBZDictService {
@Autowired
private cn.ibizlab.core.dict.service.IIBZDictItemService ibzdictitemService;
private int batchSize = 500;
private IBZDictRepository repository;
@Override
@Transactional
public IBZDict get(String key) {
IBZDict et = getById(key);
if(et==null){
et=new IBZDict();
Optional<IBZDict> result = repository.findById(key);
if(!result.isPresent()){
IBZDict et=new IBZDict();
et.setDictid(key);
return et;
}
return et;
else
return result.get();
}
@Override
@Transactional
public boolean create(IBZDict et) {
if(!this.retBool(this.baseMapper.insert(et)))
return false;
CachedBeanCopier.copy(get(et.getDictid()),et);
repository.insert(et);
return true ;
}
@Override
public void createBatch(List<IBZDict> list) {
saveBatch(list,batchSize);
repository.insert(list);
}
@Override
public boolean checkKey(IBZDict et) {
return (!ObjectUtils.isEmpty(et.getDictid()))&&(!Objects.isNull(this.getById(et.getDictid())));
return repository.findById(et.getDictid()).isPresent();
}
@Override
......@@ -83,65 +80,61 @@ public class IBZDictServiceImpl extends ServiceImpl<IBZDictMapper, IBZDict> impl
@Override
@Transactional
public boolean update(IBZDict et) {
if(!update(et,(Wrapper) et.getUpdateWrapper(true).eq("ibzdictid",et.getDictid())))
return false;
CachedBeanCopier.copy(get(et.getDictid()),et);
repository.save(et);
return true ;
}
@Override
public void updateBatch(List<IBZDict> list) {
updateBatchById(list,batchSize);
repository.saveAll(list);
}
@Override
@Transactional
public boolean remove(String key) {
ibzdictitemService.removeByDictid(key) ;
if(!removeById(key)) return false;
repository.deleteById(key);
return true ;
}
@Override
public void removeBatch(Collection<String> idList) {
removeByIds(idList);
repository.deleteAll(repository.findAllById(idList));
}
@Override
@Transactional
public boolean save(IBZDict et) {
return saveOrUpdate(et) ;
repository.save(et);
return true ;
}
@Override
@Transactional(
rollbackFor = {Exception.class}
)
public boolean saveOrUpdate(IBZDict et) {
if (null == et) {
return false;
} else {
return checkKey(et) ? this.update(et) : this.create(et);
}
}
@Override
public void saveBatch(List<IBZDict> list) {
saveOrUpdateBatch(list,batchSize);
repository.saveAll(list);
}
@Resource
private MongoTemplate mongoTemplate;
/**
* 查询集合 DEFAULT
*/
@Override
public Page<IBZDict> searchDefault(IBZDictSearchContext context) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page<IBZDict> pages=baseMapper.searchDefault(context.getPage(),context,context.getSelectCond());
return new PageImpl<IBZDict>(pages.getRecords(), context.getPageable(), pages.getTotal());
Query query = new BasicQuery(context.getSelectCond().get().toString());
long total = mongoTemplate.count(query, IBZDict.class);
List<IBZDict> list=mongoTemplate.find(query.with(context.getPageable()),IBZDict.class);
return new PageImpl<IBZDict>(list,context.getPageable(),total);
}
}
......@@ -27,13 +27,13 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
*/
@JsonIgnore
@JSONField(serialize = false)
public Page getPage(){
public Page getPages(){
Page page;
List<String> asc_fieldList = new ArrayList<>();
List<String> desc_fieldList = new ArrayList<>();
int currentPage=pageable.getPageNumber();
int pageSize=pageable.getPageSize();
int currentPage=getPageable().getPageNumber();
int pageSize=getPageable().getPageSize();
//构造mybatis-plus分页
if(StringUtils.isEmpty(currentPage) || StringUtils.isEmpty(pageSize))
......@@ -42,7 +42,7 @@ public class QueryWrapperContext<T> extends SearchContextBase implements ISearch
page=new Page(currentPage+1,pageSize);
//构造mybatis-plus排序
Sort sort = pageable.getSort();
Sort sort = getPageable().getSort();
Iterator<Sort.Order> it_sort = sort.iterator();
if(ObjectUtils.isEmpty(it_sort))
......
......@@ -8,6 +8,8 @@ import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.StringUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -36,15 +38,55 @@ public class SearchContextBase implements ISearchContext{
* 数据查询
*/
public List dataQueryList;
/**
* 当前页数
*/
public int page=0;
/**
* 每页显示条数
*/
public int size=20;
/**
* 排序
*/
public String sort;
/**
* 排序对象
*/
public Sort pageSort;
/**
* 获取分页参数
* @return
*/
public Pageable getPageable() {
Pageable pageable = PageRequest.of(page,size,pageSort);
return pageable;
}
/**
* 设置排序值
* @param strSort
*/
public void setSort(String strSort) {
this.sort=strSort;
if(!StringUtils.isEmpty(strSort)){
String arrSort[]=strSort.split(",");
String field=arrSort[0];
String order=arrSort[1];
if(order.equalsIgnoreCase("asc")){
this.pageSort=Sort.by(Sort.Direction.ASC,field);
}
else if(order.equalsIgnoreCase("desc")){
this.pageSort=Sort.by(Sort.Direction.DESC,field);
}
}
}
/**
* 上下文参数
*/
Map<String,Object> params = new HashMap<String,Object>() ;
@JsonIgnore
Pageable pageable = PageRequest.of(0, 20);
/**
* 获取数据上下文
* @return
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册