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.
72 lines
2.4 KiB
72 lines
2.4 KiB
package cn.redrock.assetmanage.service.impl;
|
|
|
|
import cn.redrock.assetmanage.dto.PublicAsset;
|
|
import cn.redrock.assetmanage.entity.AmPublicAsset;
|
|
import cn.redrock.assetmanage.mapper.AmPublicAssetMapper;
|
|
import cn.redrock.assetmanage.service.PublicAssetService;
|
|
import cn.redrock.assetmanage.utils.BeanUtilsExt;
|
|
import com.github.pagehelper.PageHelper;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import java.util.Date;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* @ Author : lihua
|
|
* @ Date :
|
|
* @ Description : 2019/7/23 10:03
|
|
* @ Modified by :
|
|
* @ Version : 1.0
|
|
*/
|
|
@Slf4j
|
|
@Service
|
|
@Transactional
|
|
public class PublicAssetServiceImpl implements PublicAssetService {
|
|
@Autowired
|
|
private AmPublicAssetMapper publicAssetMapper;
|
|
|
|
@Override
|
|
public boolean add(PublicAsset publicAsset) {
|
|
AmPublicAsset asset = publicAssetMapper.findByKey(publicAsset.getCode());
|
|
if(asset != null){
|
|
log.info("public asset {} already exists",publicAsset.getCode());
|
|
return false;
|
|
}
|
|
AmPublicAsset amPublicAsset = new AmPublicAsset();
|
|
BeanUtils.copyProperties(publicAsset,amPublicAsset);
|
|
amPublicAsset.setCreateTime(new Date());
|
|
if(publicAssetMapper.insertSelective(amPublicAsset)> 0){
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
@Override
|
|
public List<AmPublicAsset> search(String field, String content, Integer pageNum, Integer pageSize) {
|
|
if(pageNum != null && pageSize != null){
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
}
|
|
return publicAssetMapper.search(field,content);
|
|
}
|
|
|
|
@Override
|
|
public boolean update(PublicAsset publicAsset) {
|
|
AmPublicAsset asset = publicAssetMapper.findByKey(publicAsset.getCode());
|
|
if(asset == null){
|
|
log.info("public asset {} not exists",publicAsset.getCode());
|
|
return false;
|
|
}
|
|
BeanUtilsExt.copyPropertiesIgnoreNull(publicAsset,asset);
|
|
asset.setUpdateTime(new Date());
|
|
return publicAssetMapper.updateByPrimaryKeySelective(asset) > 0;
|
|
}
|
|
|
|
@Override
|
|
public boolean delete(String code) {
|
|
return publicAssetMapper.deleteByPrimaryKey(code) > 0;
|
|
}
|
|
}
|
|
|