| | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.io.File; |
| | | import java.lang.reflect.Field; |
| | | import java.lang.reflect.Method; |
| | | import java.math.BigDecimal; |
| | |
| | | queryWrapper.orderByAsc(sortData.getProperty()); |
| | | } |
| | | } |
| | | return PageData.from(baseDataMapper.selectPage(page, queryWrapper)); |
| | | IPage<BaseData> result =baseDataMapper.selectPage(page, queryWrapper); |
| | | if(result!=null && result.getRecords()!=null){ |
| | | for(BaseData data :result.getRecords()){ |
| | | //多图,英文逗号隔开 |
| | | if(StringUtils.isNotBlank(data.getBgImg())){ |
| | | String tImg = data.getBgImg().replace(",", ",").replace(".avif", ""); |
| | | String[] imgs =tImg.split(","); |
| | | data.setBgImgs(imgs); |
| | | |
| | | } |
| | | } |
| | | } |
| | | return PageData.from(result); |
| | | } |
| | | |
| | | @Override |
| | |
| | | public static boolean IS_RUNNING = false; |
| | | @Override |
| | | @Transactional |
| | | @Async |
| | | public void dealBaseData() { |
| | | if(IS_RUNNING){ |
| | | return; |
| | |
| | | int i =0; |
| | | //多图,英文逗号隔开 |
| | | if(StringUtils.isNotBlank(data.getBgImg())){ |
| | | String tImg = data.getBgImg().replace(",", ","); |
| | | String tImg = data.getBgImg().replace(",", ",").replace(".avif", ""); |
| | | String[] imgs =tImg.split(","); |
| | | for (int j = 0; j < imgs.length; j++) { |
| | | if(StringUtils.isNotBlank(imgs[j])){ |
| | |
| | | return 0; |
| | | } |
| | | |
| | | private OssModel initOssModel() { |
| | | @Override |
| | | public OssModel initOssModel() { |
| | | OssModel model = new OssModel(); |
| | | model.setUrl(systemDictDataBiz.queryByCode(Constants.OSS, Constants.RESOURCE_PATH).getCode()); |
| | | model.setEndpoint(systemDictDataBiz.queryByCode(Constants.OSS, Constants.ENDPOINT).getCode()); |
| | |
| | | return model; |
| | | } |
| | | |
| | | private String getOssImgurl(OssModel ossModel, String folder,String img) { |
| | | @Override |
| | | public String getOssImgurl(OssModel ossModel, String folder,String img) { |
| | | if(StringUtils.isBlank(img)){ |
| | | return null; |
| | | } |
| | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public String getOssImgurl(OssModel ossModel, String folder, File f) { |
| | | if(f == null || !f.isFile()){ |
| | | return null; |
| | | } |
| | | try { |
| | | String img = f.getPath(); |
| | | String nowDate = DateUtil.getNowShortDate();// 当前时间(年月日) |
| | | String nfix = img.lastIndexOf(".")>0?img.substring(img.lastIndexOf(".")):null; |
| | | nfix = StringUtils.defaultString(nfix,".jpg"); |
| | | String fileName = UUID.randomUUID() + nfix; |
| | | String tempFileName = nowDate + "/" + fileName; |
| | | String key =folder+ tempFileName;// 文件名 |
| | | |
| | | ALiYunUtil obs = new ALiYunUtil(ossModel.getEndpoint(), ossModel.getAccessId(), ossModel.getAccessKey()); |
| | | if (obs.uploadFile(ossModel.getBucket(), key,f,null)) { |
| | | return tempFileName; |
| | | } |
| | | }catch (Exception e){ |
| | | |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |