Просмотр исходного кода

Merge branch 'dev' of http://git.izouma.com/xiongzhu/raex_back into dev

wangqifan 3 лет назад
Родитель
Сommit
6a51c81b60

+ 1 - 1
src/main/java/com/izouma/nineth/repo/AssetRepo.java

@@ -79,7 +79,7 @@ public interface AssetRepo extends JpaRepository<Asset, Long>, JpaSpecificationE
     int updateCDN(Long id, String pic, String model3d, String minterAvatar,
                   String ownerAvatar, String detail);
 
-    Page<Asset> findByUserIdAndStatusAndNameLike(Long userId, AssetStatus status, String name, Pageable pageable);
+    Page<Asset> findByUserIdAndStatusAndCompanyIdAndNameLike(Long userId, AssetStatus status, Long companyId, String name, Pageable pageable);
 
     List<Asset> findAllByOasisIdInAndStatusIn(List<Long> oasisIds, List<AssetStatus> assetStatuses);
 

+ 16 - 16
src/main/java/com/izouma/nineth/repo/TagRepo.java

@@ -11,38 +11,38 @@ import javax.transaction.Transactional;
 public interface TagRepo extends JpaRepository<Tag, Long>, JpaSpecificationExecutor<Tag> {
 
     @Query(nativeQuery = true, value = "insert into asset_tag (asset_id, tag_id) " +
-            "select id, ?1 from asset where name like ?2")
+            "select id, ?1 from asset where name like ?2 and company_id = ?3")
     @Transactional
     @Modifying
-    int addTagForAssetEasy(Long id, String pattern);
+    int addTagForAssetEasy(Long id, String pattern, Long companyId);
 
     @Query(nativeQuery = true, value = "insert into collection_tag (collection_id, tag_id) " +
-            "select id, ?1 from collection_info where name like ?2")
+            "select id, ?1 from collection_info where name like ?2 and company_id = ?3")
     @Transactional
     @Modifying
-    int addTagForCollectionEasy(Long id, String pattern);
+    int addTagForCollectionEasy(Long id, String pattern , Long companyId);
 
     @Query(nativeQuery = true, value = "insert into asset_tag (asset_id, tag_id) " +
-            "select id, ?1 from asset where name regexp ?2")
+            "select id, ?1 from asset where name regexp ?2 and company_id = ?3")
     @Transactional
     @Modifying
-    int addTagForAssetRegex(Long id, String pattern);
+    int addTagForAssetRegex(Long id, String pattern , Long companyId);
 
     @Query(nativeQuery = true, value = "insert into collection_tag (collection_id, tag_id) " +
-            "select id, ?1 from collection_info where name regexp ?2")
+            "select id, ?1 from collection_info where name regexp ?2 and company_id = ?3")
     @Transactional
     @Modifying
-    int addTagForCollectionRegex(Long id, String pattern);
+    int addTagForCollectionRegex(Long id, String pattern , Long companyId);
 
-    @Query(nativeQuery = true, value = "select count(id) from asset where name like ?1")
-    long countAssetEasy(String pattern);
+    @Query(nativeQuery = true, value = "select count(id) from asset where name like ?1 and company_id = ?2")
+    long countAssetEasy(String pattern, Long companyId);
 
-    @Query(nativeQuery = true, value = "select count(id) from collection_info where name like ?1")
-    long countCollectionEasy(String pattern);
+    @Query(nativeQuery = true, value = "select count(id) from collection_info where name like ?1 and company_id = ?2")
+    long countCollectionEasy(String pattern, Long companyId);
 
-    @Query(nativeQuery = true, value = "select count(id) from asset where name regexp ?1")
-    long countAssetRegex(String pattern);
+    @Query(nativeQuery = true, value = "select count(id) from asset where name regexp ?1 and company_id = ?2")
+    long countAssetRegex(String pattern, Long companyId);
 
-    @Query(nativeQuery = true, value = "select count(id) from collection_info where name regexp ?1")
-    long countCollectionRegex(String pattern);
+    @Query(nativeQuery = true, value = "select count(id) from collection_info where name regexp ?1 and company_id = ?2")
+    long countCollectionRegex(String pattern, Long companyId);
 }

+ 7 - 6
src/main/java/com/izouma/nineth/service/AssetService.java

@@ -905,17 +905,18 @@ public class AssetService {
     }
 
     //    @Cacheable(cacheNames = "fmaa", key = "#userId+'#'+#mintActivityId+'#'+#pageable.hashCode()")
-    public PageWrapper<Asset> findMintActivityAssetsWrap(Long userId, Long mintActivityId, Pageable pageable) {
-        return PageWrapper.of(findMintActivityAssets(userId, mintActivityId, pageable));
+    public PageWrapper<Asset> findMintActivityAssetsWrap(Long userId, Long mintActivityId, Long companyId, Pageable pageable) {
+        return PageWrapper.of(findMintActivityAssets(userId, mintActivityId, companyId, pageable));
     }
 
-    public Page<Asset> findMintActivityAssets(Long userId, Long mintActivityId, Pageable pageable) {
+    public Page<Asset> findMintActivityAssets(Long userId, Long mintActivityId, Long companyId, Pageable pageable) {
         MintActivity mintActivity = mintActivityRepo.findById(mintActivityId).orElse(null);
         if (mintActivity == null) return new PageImpl<>(Collections.emptyList());
-        return findMintActivityAssetsCommon(userId, new CommonMatchDTO(mintActivity.getRule(), mintActivity.isAudit(), mintActivity.getCollectionName()), pageable);
+        return findMintActivityAssetsCommon(userId, companyId, new CommonMatchDTO(mintActivity.getRule(),
+                mintActivity.isAudit(), mintActivity.getCollectionName()), pageable);
     }
 
-    public Page<Asset> findMintActivityAssetsCommon(Long userId, CommonMatchDTO commonMatchDTO, Pageable pageable) {
+    public Page<Asset> findMintActivityAssetsCommon(Long userId, Long companyId, CommonMatchDTO commonMatchDTO, Pageable pageable) {
         if (!commonMatchDTO.isAudit()) {
             Set<Tag> tags = commonMatchDTO.getRule().getTags();
             if (tags.isEmpty()) return new PageImpl<>(Collections.emptyList());
@@ -933,7 +934,7 @@ public class AssetService {
                                     root.join("tags").get("id").in(tags.stream().map(Tag::getId).toArray()))
                             .getRestriction(), pageable);
         } else {
-            return assetRepo.findByUserIdAndStatusAndNameLike(userId, AssetStatus.NORMAL,
+            return assetRepo.findByUserIdAndStatusAndCompanyIdAndNameLike(userId, AssetStatus.NORMAL, companyId,
                     "%" + commonMatchDTO.getCollectionName() + "%", pageable);
         }
     }

+ 14 - 10
src/main/java/com/izouma/nineth/service/TagService.java

@@ -21,30 +21,34 @@ public class TagService {
         return tagRepo.findAll(JpaUtils.toSpecification(pageQuery, Tag.class), JpaUtils.toPageRequest(pageQuery));
     }
 
-    public Object checkAdd(String addMode, String pattern) {
+    public Object checkAdd(String addMode, String pattern, Long companyId) {
+        if (companyId == null) {
+            companyId = 1L;
+        }
         Map<String, Object> map = new HashMap<>();
         if ("easy".equals(addMode)) {
-            map.put("asset", tagRepo.countAssetEasy("%" + pattern + "%"));
-            map.put("collection", tagRepo.countCollectionEasy("%" + pattern + "%"));
+            map.put("asset", tagRepo.countAssetEasy("%" + pattern + "%", companyId));
+            map.put("collection", tagRepo.countCollectionEasy("%" + pattern + "%", companyId));
         } else if ("regex".equals(addMode)) {
-            map.put("asset", tagRepo.countAssetRegex(pattern));
-            map.put("collection", tagRepo.countCollectionRegex(pattern));
+            map.put("asset", tagRepo.countAssetRegex(pattern, companyId));
+            map.put("collection", tagRepo.countCollectionRegex(pattern, companyId));
         }
         return map;
     }
 
-    public Tag create(String name, String remark, boolean addForExist, String addMode, String pattern) {
+    public Tag create(String name, String remark, boolean addForExist, String addMode, String pattern, Long companyId) {
         Tag tag = tagRepo.saveAndFlush(Tag.builder()
                 .name(name)
                 .remark(remark)
+                .companyId(companyId)
                 .build());
         if (addForExist) {
             if ("easy".equals(addMode)) {
-                tagRepo.addTagForAssetEasy(tag.getId(), "%" + pattern + "%");
-                tagRepo.addTagForCollectionEasy(tag.getId(), "%" + pattern + "%");
+                tagRepo.addTagForAssetEasy(tag.getId(), "%" + pattern + "%", companyId);
+                tagRepo.addTagForCollectionEasy(tag.getId(), "%" + pattern + "%", companyId);
             } else if ("regex".equals(addMode)) {
-                tagRepo.addTagForAssetRegex(tag.getId(), pattern);
-                tagRepo.addTagForCollectionRegex(tag.getId(), pattern);
+                tagRepo.addTagForAssetRegex(tag.getId(), pattern, companyId);
+                tagRepo.addTagForCollectionRegex(tag.getId(), pattern, companyId);
             }
         }
         return tag;

+ 3 - 3
src/main/java/com/izouma/nineth/web/AssetController.java

@@ -49,7 +49,7 @@ public class AssetController extends BaseController {
     private OrderRepo               orderRepo;
     private CacheService            cacheService;
     private UserAssetSummaryService userAssetSummaryService;
-    private CollectionRepo collectionRepo;
+    private CollectionRepo          collectionRepo;
 
     //@PreAuthorize("hasRole('ADMIN')")
 //    @PostMapping("/save")
@@ -187,12 +187,12 @@ public class AssetController extends BaseController {
 
     @GetMapping("/assetsForMint")
     @JsonView(Asset.View.Basic.class)
-    public Page<Asset> assetsForMint(@RequestParam Long mintActivityId, Boolean refresh, Pageable pageable) {
+    public Page<Asset> assetsForMint(@RequestParam Long mintActivityId, @RequestParam(defaultValue = "1") Long companyId, Boolean refresh, Pageable pageable) {
         if (Objects.equals(refresh, true)) {
             cacheService.clearFmaa();
         }
         return assetService.findMintActivityAssetsWrap(SecurityUtils.getAuthenticatedUser().getId(),
-                mintActivityId, pageable).toPage();
+                mintActivityId, companyId, pageable).toPage();
     }
 
     @GetMapping("/byTag")

+ 4 - 3
src/main/java/com/izouma/nineth/web/MetaDestroyActivityController.java

@@ -27,7 +27,7 @@ import java.util.Objects;
 @AllArgsConstructor
 public class MetaDestroyActivityController extends BaseController {
     private MetaDestroyActivityService metaDestroyActivityService;
-    private MetaDestroyActivityRepo metaDestroyActivityRepo;
+    private MetaDestroyActivityRepo    metaDestroyActivityRepo;
 
     private AssetService assetService;
 
@@ -82,7 +82,7 @@ public class MetaDestroyActivityController extends BaseController {
     }
 
     @GetMapping("/queryAsset")
-    public MetaRestResult<Page<Asset>> queryAsset(@RequestParam Long id, Pageable pageable) {
+    public MetaRestResult<Page<Asset>> queryAsset(@RequestParam Long id, @RequestParam(defaultValue = "1") Long companyId, Pageable pageable) {
         MetaDestroyActivity metaDestroyActivity = metaDestroyActivityRepo.findById(id).orElse(null);
         if (Objects.isNull(metaDestroyActivity)) {
             return MetaRestResult.returnError("查询不到配置");
@@ -93,7 +93,8 @@ public class MetaDestroyActivityController extends BaseController {
         if (!metaDestroyActivity.isPublish()) {
             return MetaRestResult.returnError("该配置还未发布");
         }
-        return MetaRestResult.returnSuccess(assetService.findMintActivityAssetsCommon(SecurityUtils.getAuthenticatedUser().getId(), new CommonMatchDTO(metaDestroyActivity.getRule(), metaDestroyActivity.isAudit(), metaDestroyActivity.getCollectionName()), pageable));
+        return MetaRestResult.returnSuccess(assetService.findMintActivityAssetsCommon(SecurityUtils.getAuthenticatedUser().getId(), companyId,
+                new CommonMatchDTO(metaDestroyActivity.getRule(), metaDestroyActivity.isAudit(), metaDestroyActivity.getCollectionName()), pageable));
     }
 
 }

+ 2 - 2
src/main/java/com/izouma/nineth/web/MintActivityController.java

@@ -24,7 +24,7 @@ public class MintActivityController extends BaseController {
     private MintActivityService mintActivityService;
     private MintActivityRepo    mintActivityRepo;
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/save")
     public MintActivity save(@RequestBody MintActivity record) {
         if (record.getRule() != null) mintActivityService.checkRule(record.getRule());
@@ -74,7 +74,7 @@ public class MintActivityController extends BaseController {
         return mintActivityRepo.findById(id).orElseThrow(new BusinessException("无记录"));
     }
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/del/{id}")
     public void del(@PathVariable Long id) {
         mintActivityRepo.softDelete(id);

+ 6 - 6
src/main/java/com/izouma/nineth/web/MintOrderController.java

@@ -34,7 +34,7 @@ public class MintOrderController extends BaseController {
     private MintActivityRepo mintActivityRepo;
     private MintMaterialRepo mintMaterialRepo;
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/save")
     public MintOrder save(@RequestBody MintOrder record) {
         if (record.getId() != null) {
@@ -76,7 +76,7 @@ public class MintOrderController extends BaseController {
         return mintOrder;
     }
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/del/{id}")
     public void del(@PathVariable Long id) {
         mintOrderRepo.softDelete(id);
@@ -96,7 +96,7 @@ public class MintOrderController extends BaseController {
         return mintOrderService.create(SecurityUtils.getAuthenticatedUser(), assetIds, mintActivityId, addressId);
     }
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @ApiOperation("导出")
     @PostMapping("/excelPhone")
     public void excelPhone(HttpServletResponse response, @RequestBody PageQuery pageQuery) throws IOException {
@@ -104,7 +104,7 @@ public class MintOrderController extends BaseController {
         ExcelUtils.export(response, data);
     }
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @ApiOperation("订单完成")
     @GetMapping("/finish/{id}")
     public void finish(@PathVariable Long id) {
@@ -125,13 +125,13 @@ public class MintOrderController extends BaseController {
         }};
     }
 
-    @PreAuthorize("hasAnyRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/pass")
     public void audit(@RequestParam Long id) {
         mintOrderService.orderAudit(id, true);
     }
 
-    @PreAuthorize("hasAnyRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/deny")
     public void deny(@RequestParam Long id) {
         mintOrderService.orderAudit(id, false);

+ 8 - 8
src/main/java/com/izouma/nineth/web/TagController.java

@@ -23,7 +23,7 @@ public class TagController extends BaseController {
     private TagService tagService;
     private TagRepo    tagRepo;
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/save")
     public Tag save(@RequestBody Tag record) {
         if (record.getId() == null) {
@@ -34,10 +34,10 @@ public class TagController extends BaseController {
         return tagRepo.save(orig);
     }
 
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     @PostMapping("/create")
-    public Tag create(@RequestParam String name, String remark, boolean addForExist, String addMode, String pattern) {
-        return tagService.create(name, remark, addForExist, addMode, pattern);
+    public Tag create(@RequestParam String name, String remark, boolean addForExist, String addMode, String pattern, @RequestParam(defaultValue = "1") Long companyId) {
+        return tagService.create(name, remark, addForExist, addMode, pattern, companyId);
     }
 
 
@@ -53,7 +53,7 @@ public class TagController extends BaseController {
     }
 
     @PostMapping("/del/{id}")
-    @PreAuthorize("hasRole('ADMIN')")
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
     public void del(@PathVariable Long id) {
         tagRepo.deleteById(id);
     }
@@ -66,9 +66,9 @@ public class TagController extends BaseController {
     }
 
     @GetMapping("/checkAdd")
-    @PreAuthorize("hasRole('ADMIN')")
-    public Object checkAdd(String addMode, String pattern) {
-        return tagService.checkAdd(addMode, pattern);
+    @PreAuthorize("hasAnyRole('ADMIN','SAAS')")
+    public Object checkAdd(String addMode, String pattern, Long companyId) {
+        return tagService.checkAdd(addMode, pattern, companyId);
     }
 }
 

+ 8 - 2
src/main/vue/src/views/company/CompanyTheme.vue

@@ -51,6 +51,9 @@
                             <el-form-item prop="bgImg" label="背景图">
                                 <single-upload v-model="formData.bgImg"></single-upload>
                             </el-form-item>
+                            <el-form-item prop="bgColor" label="开屏页">
+                                <single-upload v-model="formData.bgColor"></single-upload>
+                            </el-form-item>
 
                             <el-form-item class="form-submit">
                                 <el-button @click="onSave" :loading="saving" type="primary"> 保存 </el-button>
@@ -116,6 +119,7 @@ export default {
                 this.formData.theme = res.theme;
                 this.formData.logo = res.logo;
                 this.formData.bgImg = res.bgImg;
+                this.formData.bgColor = res.bgColor;
             }
         });
     },
@@ -125,7 +129,8 @@ export default {
             formData: {
                 theme: 'theme1',
                 logo: '',
-                bgImg: ''
+                bgImg: '',
+                bgColor: ''
             },
             rules: {},
             themeOptions: [
@@ -157,7 +162,8 @@ export default {
                         id: this.companyId,
                         theme: this.formData.theme,
                         logo: this.formData.logo,
-                        bgImg: this.formData.bgImg
+                        bgImg: this.formData.bgImg,
+                        bgColor: this.formData.bgColor
                     },
                     { body: 'json' }
                 )