diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java index 7c6b530a..42389a79 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/domain/TbProductVo.java @@ -210,4 +210,6 @@ public class TbProductVo { private String selectSpec; private String specTableHeaders; + + private String skuSnap; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java index 1885c962..8b2bbd53 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/product/service/impl/TbProductServiceImpl.java @@ -26,6 +26,8 @@ import me.zhengjie.modules.productInfo.product.service.TbProductService; import me.zhengjie.modules.productInfo.product.service.dto.TbProductDto; import me.zhengjie.modules.productInfo.product.service.dto.TbProductQueryCriteria; import me.zhengjie.modules.productInfo.product.service.mapstruct.TbProductMapper; +import me.zhengjie.modules.productInfo.productSkuResult.domain.TbProductSkuResult; +import me.zhengjie.modules.productInfo.productSkuResult.repository.TbProductSkuResultRepository; import me.zhengjie.modules.productInfo.productSpec.domain.TbProductSpec; import me.zhengjie.modules.productInfo.productSpec.repository.TbProductSpecRepository; import me.zhengjie.modules.productInfo.productSku.domain.TbProductSku; @@ -62,6 +64,7 @@ public class TbProductServiceImpl implements TbProductService { private final TbProductSkuRepository tbProductSkuRepository; private final TbShopUnitRepository tbShopUnitRepository; private final TbProductSpecRepository tbProductSpecRepository; + private final TbProductSkuResultRepository tbProductSkuResultRepository; @Override @@ -219,6 +222,9 @@ public class TbProductServiceImpl implements TbProductService { TbProduct product = new TbProduct(); //组装 BeanUtil.copyProperties(resources,product, CopyOptions.create().setIgnoreNullValue(true)); + if (resources.getCategoryId() == null){ + throw new BadRequestException("必填内容未填写"); + } product.setCategoryId(String.valueOf(resources.getCategoryId())); product.setIsDel(0); product.setIsDelete(0); @@ -236,7 +242,6 @@ public class TbProductServiceImpl implements TbProductService { if (!resources.getGroupSnap().isEmpty()){ product.setGroupSnap(ListUtil.JSONArrayChangeString(resources.getGroupSnap())); } - TbProduct save = tbProductRepository.save(product); if (save.getId() == null){ @@ -254,6 +259,15 @@ public class TbProductServiceImpl implements TbProductService { } tbProductSkuRepository.saveAll(skuList); } + //保存到sku_result + if ("sku".equals(resources.getTypeEnum())){ + TbProductSkuResult productSkuResult = new TbProductSkuResult(); + productSkuResult.setCreatedAt(Instant.now().toEpochMilli()); + productSkuResult.setUpdatedAt(Instant.now().toEpochMilli()); + productSkuResult.setTagSnap(resources.getSkuSnap()); + productSkuResult.setId(Integer.valueOf(save.getShopId())); + tbProductSkuResultRepository.save(productSkuResult); + } return resources; } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/domain/TbProductSkuResult.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/domain/TbProductSkuResult.java new file mode 100644 index 00000000..d5dab17b --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/domain/TbProductSkuResult.java @@ -0,0 +1,65 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-08 +**/ +@Entity +@Data +@Table(name="tb_product_sku_result") +public class TbProductSkuResult implements Serializable { + + @Id + @Column(name = "`id`") + @ApiModelProperty(value = "商品Id") + private Integer id; + + @Column(name = "`merchant_id`") + @ApiModelProperty(value = "商户Id") + private String merchantId; + + @Column(name = "`spec_id`") + @ApiModelProperty(value = "规格id") + private Long specId; + + @Column(name = "`tag_snap`") + @ApiModelProperty(value = "标签列表,包括名称,显示") + private String tagSnap; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + public void copy(TbProductSkuResult source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/repository/TbProductSkuResultRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/repository/TbProductSkuResultRepository.java new file mode 100644 index 00000000..7eee149e --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/repository/TbProductSkuResultRepository.java @@ -0,0 +1,28 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.repository; + +import me.zhengjie.modules.productInfo.productSkuResult.domain.TbProductSkuResult; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +public interface TbProductSkuResultRepository extends JpaRepository, JpaSpecificationExecutor { +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/rest/TbProductSkuResultController.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/rest/TbProductSkuResultController.java new file mode 100644 index 00000000..0fc5c64a --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/rest/TbProductSkuResultController.java @@ -0,0 +1,87 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.productInfo.productSkuResult.domain.TbProductSkuResult; +import me.zhengjie.modules.productInfo.productSkuResult.service.TbProductSkuResultService; +import me.zhengjie.modules.productInfo.productSkuResult.service.dto.TbProductSkuResultQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "/skuResult管理") +@RequestMapping("/api/tbProductSkuResult") +public class TbProductSkuResultController { + + private final TbProductSkuResultService tbProductSkuResultService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbProductSkuResult:list')") + public void exportTbProductSkuResult(HttpServletResponse response, TbProductSkuResultQueryCriteria criteria) throws IOException { + tbProductSkuResultService.download(tbProductSkuResultService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询/skuResult") + @ApiOperation("查询/skuResult") + @PreAuthorize("@el.check('tbProductSkuResult:list')") + public ResponseEntity queryTbProductSkuResult(TbProductSkuResultQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbProductSkuResultService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @PostMapping + @Log("新增/skuResult") + @ApiOperation("新增/skuResult") + @PreAuthorize("@el.check('tbProductSkuResult:add')") + public ResponseEntity createTbProductSkuResult(@Validated @RequestBody TbProductSkuResult resources){ + return new ResponseEntity<>(tbProductSkuResultService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改/skuResult") + @ApiOperation("修改/skuResult") + @PreAuthorize("@el.check('tbProductSkuResult:edit')") + public ResponseEntity updateTbProductSkuResult(@Validated @RequestBody TbProductSkuResult resources){ + tbProductSkuResultService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除/skuResult") + @ApiOperation("删除/skuResult") + @PreAuthorize("@el.check('tbProductSkuResult:del')") + public ResponseEntity deleteTbProductSkuResult(@RequestBody Integer[] ids) { + tbProductSkuResultService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/TbProductSkuResultService.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/TbProductSkuResultService.java new file mode 100644 index 00000000..2c7b7c56 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/TbProductSkuResultService.java @@ -0,0 +1,83 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.service; + +import me.zhengjie.modules.productInfo.productSkuResult.domain.TbProductSkuResult; +import me.zhengjie.modules.productInfo.productSkuResult.service.dto.TbProductSkuResultDto; +import me.zhengjie.modules.productInfo.productSkuResult.service.dto.TbProductSkuResultQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @description 服务接口 +* @author lyf +* @date 2024-02-08 +**/ +public interface TbProductSkuResultService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbProductSkuResultQueryCriteria criteria, Pageable pageable); + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbProductSkuResultQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbProductSkuResultDto + */ + TbProductSkuResultDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbProductSkuResultDto + */ + TbProductSkuResultDto create(TbProductSkuResult resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbProductSkuResult resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Integer[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/dto/TbProductSkuResultDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/dto/TbProductSkuResultDto.java new file mode 100644 index 00000000..5ffec2a1 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/dto/TbProductSkuResultDto.java @@ -0,0 +1,45 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-08 +**/ +@Data +public class TbProductSkuResultDto implements Serializable { + + /** 商品Id */ + private Integer id; + + /** 商户Id */ + private String merchantId; + + /** 规格id */ + private Long specId; + + /** 标签列表,包括名称,显示 */ + private String tagSnap; + + private Long createdAt; + + private Long updatedAt; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/dto/TbProductSkuResultQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/dto/TbProductSkuResultQueryCriteria.java new file mode 100644 index 00000000..ee0ccaf8 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/dto/TbProductSkuResultQueryCriteria.java @@ -0,0 +1,33 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +@Data +public class TbProductSkuResultQueryCriteria{ + + /** 精确 */ + @Query + private Integer id; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/impl/TbProductSkuResultServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/impl/TbProductSkuResultServiceImpl.java new file mode 100644 index 00000000..46795893 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/impl/TbProductSkuResultServiceImpl.java @@ -0,0 +1,108 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.service.impl; + +import me.zhengjie.modules.productInfo.productSkuResult.domain.TbProductSkuResult; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.productInfo.productSkuResult.repository.TbProductSkuResultRepository; +import me.zhengjie.modules.productInfo.productSkuResult.service.TbProductSkuResultService; +import me.zhengjie.modules.productInfo.productSkuResult.service.dto.TbProductSkuResultDto; +import me.zhengjie.modules.productInfo.productSkuResult.service.dto.TbProductSkuResultQueryCriteria; +import me.zhengjie.modules.productInfo.productSkuResult.service.mapstruct.TbProductSkuResultMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://eladmin.vip +* @description 服务实现 +* @author lyf +* @date 2024-02-08 +**/ +@Service +@RequiredArgsConstructor +public class TbProductSkuResultServiceImpl implements TbProductSkuResultService { + + private final TbProductSkuResultRepository tbProductSkuResultRepository; + private final TbProductSkuResultMapper tbProductSkuResultMapper; + + @Override + public Map queryAll(TbProductSkuResultQueryCriteria criteria, Pageable pageable){ + Page page = tbProductSkuResultRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbProductSkuResultMapper::toDto)); + } + + @Override + public List queryAll(TbProductSkuResultQueryCriteria criteria){ + return tbProductSkuResultMapper.toDto(tbProductSkuResultRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbProductSkuResultDto findById(Integer id) { + TbProductSkuResult tbProductSkuResult = tbProductSkuResultRepository.findById(id).orElseGet(TbProductSkuResult::new); + ValidationUtil.isNull(tbProductSkuResult.getId(),"TbProductSkuResult","id",id); + return tbProductSkuResultMapper.toDto(tbProductSkuResult); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbProductSkuResultDto create(TbProductSkuResult resources) { + return tbProductSkuResultMapper.toDto(tbProductSkuResultRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbProductSkuResult resources) { + TbProductSkuResult tbProductSkuResult = tbProductSkuResultRepository.findById(resources.getId()).orElseGet(TbProductSkuResult::new); + ValidationUtil.isNull( tbProductSkuResult.getId(),"TbProductSkuResult","id",resources.getId()); + tbProductSkuResult.copy(resources); + tbProductSkuResultRepository.save(tbProductSkuResult); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbProductSkuResultRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbProductSkuResultDto tbProductSkuResult : all) { + Map map = new LinkedHashMap<>(); + map.put("商户Id", tbProductSkuResult.getMerchantId()); + map.put("规格id", tbProductSkuResult.getSpecId()); + map.put("标签列表,包括名称,显示", tbProductSkuResult.getTagSnap()); + map.put(" createdAt", tbProductSkuResult.getCreatedAt()); + map.put(" updatedAt", tbProductSkuResult.getUpdatedAt()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/mapstruct/TbProductSkuResultMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/mapstruct/TbProductSkuResultMapper.java new file mode 100644 index 00000000..ebaf6efd --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/productInfo/productSkuResult/service/mapstruct/TbProductSkuResultMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.productInfo.productSkuResult.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.productInfo.productSkuResult.domain.TbProductSkuResult; +import me.zhengjie.modules.productInfo.productSkuResult.service.dto.TbProductSkuResultDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-08 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbProductSkuResultMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SpringSecurityConfig.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SpringSecurityConfig.java index ad886f31..61a8027e 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SpringSecurityConfig.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/config/SpringSecurityConfig.java @@ -132,6 +132,7 @@ public class SpringSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers(HttpMethod.DELETE, anonymousUrls.get(RequestMethodEnum.DELETE.getType()).toArray(new String[0])).permitAll() // 所有类型的接口都放行 .antMatchers(anonymousUrls.get(RequestMethodEnum.ALL.getType()).toArray(new String[0])).permitAll() + .antMatchers("/auth/appletsLogin").permitAll() // 所有请求都需要认证 .anyRequest().authenticated() .and().apply(securityConfigurerAdapter()); diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java index 12ef47ce..2f54c21d 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/security/rest/AuthorizationController.java @@ -119,6 +119,44 @@ public class AuthorizationController { return ResponseEntity.ok(authInfo); } + /** + * 小程序登录 + * @param authUser + * @param request + * @return + * @throws Exception + */ + @PostMapping(value = "/appletsLogin") + public ResponseEntity appletsLogin(@RequestBody AuthUserDto authUser,HttpServletRequest request)throws Exception{ + // 密码解密 + String password = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, authUser.getPassword()); + + UsernamePasswordAuthenticationToken authenticationToken = + new UsernamePasswordAuthenticationToken(authUser.getUsername(), password); + Authentication authentication = authenticationManagerBuilder.getObject().authenticate(authenticationToken); + SecurityContextHolder.getContext().setAuthentication(authentication); + // 生成令牌与第三方系统获取令牌方式 + String token = tokenProvider.createToken(authentication); + final JwtUserDto jwtUserDto = (JwtUserDto) authentication.getPrincipal(); + // 保存在线信息 + onlineUserService.save(jwtUserDto, token,request); + // 返回 token 与 用户信息 + TbShopInfo byAccount = tbShopInfoRepository.findByAccount(jwtUserDto.getUsername()); + Map authInfo = new HashMap(2) {{ + put("token", properties.getTokenStartWith() + token); + put("user", jwtUserDto); + if (byAccount!= null){ + put("shopId",byAccount.getId()); + } + + }}; + if (loginProperties.isSingleLogin()) { + //踢掉之前已经登录的token + onlineUserService.checkLoginOnUser(authUser.getUsername(), token); + } + return ResponseEntity.ok(authInfo); + } + @ApiOperation("获取用户信息") @GetMapping(value = "/info") public ResponseEntity getUserInfo() { diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java index 537965c2..946fe10c 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shop/service/impl/TbShopInfoServiceImpl.java @@ -15,6 +15,7 @@ */ package me.zhengjie.modules.shopInfo.shop.service.impl; +import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.shopInfo.shop.domain.TbShopInfo; import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.FileUtil; @@ -54,6 +55,9 @@ public class TbShopInfoServiceImpl implements TbShopInfoService { @Override public Map queryAll(TbShopInfoQueryCriteria criteria, Pageable pageable){ +// if (!"admin".equals(criteria.getAccount())){ +// throw new BadRequestException("登录账号有误"); +// } Page page = tbShopInfoRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); return PageUtil.toPage(page.map(tbShopInfoMapper::toDto)); } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/domain/TbMerchantThirdApply.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/domain/TbMerchantThirdApply.java new file mode 100644 index 00000000..cabc2780 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/domain/TbMerchantThirdApply.java @@ -0,0 +1,78 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.domain; + +import lombok.Data; +import cn.hutool.core.bean.BeanUtil; +import io.swagger.annotations.ApiModelProperty; +import cn.hutool.core.bean.copier.CopyOptions; +import javax.persistence.*; +import javax.validation.constraints.*; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-02 +**/ +@Entity +@Data +@Table(name="tb_merchant_third_apply") +public class TbMerchantThirdApply implements Serializable { + + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "`id`") + @ApiModelProperty(value = "自增id") + private Integer id; + + @Column(name = "`type`") + @ApiModelProperty(value = "type") + private String type; + + @Column(name = "`app_id`",unique = true) + @ApiModelProperty(value = "商户应用") + private String appId; + + @Column(name = "`app_token`") + @ApiModelProperty(value = "商户token") + private String appToken; + + @Column(name = "`status`") + @ApiModelProperty(value = "审核详情-1未提交,0已提交(不可修改) 1审核通过") + private Integer status; + + @Column(name = "`pay_password`") + @ApiModelProperty(value = "支付密码") + private String payPassword; + + @Column(name = "`created_at`") + @ApiModelProperty(value = "createdAt") + private Long createdAt; + + @Column(name = "`updated_at`") + @ApiModelProperty(value = "updatedAt") + private Long updatedAt; + + @Column(name = "`shop_id`") + @ApiModelProperty(value = "shopId") + private Integer shopId; + + public void copy(TbMerchantThirdApply source){ + BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); + } +} diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/repository/TbMerchantThirdApplyRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/repository/TbMerchantThirdApplyRepository.java new file mode 100644 index 00000000..d1ec52fb --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/repository/TbMerchantThirdApplyRepository.java @@ -0,0 +1,39 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.repository; + +import me.zhengjie.modules.shopInfo.shopThirdApply.domain.TbMerchantThirdApply; +import org.apache.ibatis.annotations.Param; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-02 +**/ +public interface TbMerchantThirdApplyRepository extends JpaRepository, JpaSpecificationExecutor { + /** + * 根据 AppId 查询 + * @param app_id / + * @return / + */ + TbMerchantThirdApply findByAppId(String app_id); + + @Query("select thirdApply from TbMerchantThirdApply thirdApply where thirdApply.shopId = :shopId") + TbMerchantThirdApply findByShopId(@Param("shopId") Integer shopId); +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/rest/TbMerchantThirdApplyController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/rest/TbMerchantThirdApplyController.java new file mode 100644 index 00000000..457daab5 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/rest/TbMerchantThirdApplyController.java @@ -0,0 +1,97 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.rest; + +import me.zhengjie.annotation.Log; +import me.zhengjie.modules.shopInfo.shopThirdApply.domain.TbMerchantThirdApply; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.TbMerchantThirdApplyService; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyDto; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyQueryCriteria; +import org.springframework.data.domain.Pageable; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import io.swagger.annotations.*; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-02 +**/ +@RestController +@RequiredArgsConstructor +@Api(tags = "/shop/thirdApply管理") +@RequestMapping("/api/tbMerchantThirdApply") +public class TbMerchantThirdApplyController { + + private final TbMerchantThirdApplyService tbMerchantThirdApplyService; + + @Log("导出数据") + @ApiOperation("导出数据") + @GetMapping(value = "/download") + @PreAuthorize("@el.check('tbMerchantThirdApply:list')") + public void exportTbMerchantThirdApply(HttpServletResponse response, TbMerchantThirdApplyQueryCriteria criteria) throws IOException { + tbMerchantThirdApplyService.download(tbMerchantThirdApplyService.queryAll(criteria), response); + } + + @GetMapping + @Log("查询/shop/thirdApply") + @ApiOperation("查询/shop/thirdApply") + @PreAuthorize("@el.check('tbMerchantThirdApply:list')") + public ResponseEntity queryTbMerchantThirdApply(TbMerchantThirdApplyQueryCriteria criteria, Pageable pageable){ + return new ResponseEntity<>(tbMerchantThirdApplyService.queryAll(criteria,pageable),HttpStatus.OK); + } + + @GetMapping("/{shopId}") + public ResponseEntity queryTbMerchantThirdApply(@PathVariable Integer shopId){ + TbMerchantThirdApplyDto byShopId = tbMerchantThirdApplyService.findByShopId(shopId); + if (byShopId == null){ + return new ResponseEntity<>(new TbMerchantThirdApplyDto(),HttpStatus.OK); + } + return new ResponseEntity<>(byShopId,HttpStatus.OK); + } + + @PostMapping + @Log("新增/shop/thirdApply") + @ApiOperation("新增/shop/thirdApply") + @PreAuthorize("@el.check('tbMerchantThirdApply:add')") + public ResponseEntity createTbMerchantThirdApply(@Validated @RequestBody TbMerchantThirdApply resources){ + return new ResponseEntity<>(tbMerchantThirdApplyService.create(resources),HttpStatus.CREATED); + } + + @PutMapping + @Log("修改/shop/thirdApply") + @ApiOperation("修改/shop/thirdApply") + @PreAuthorize("@el.check('tbMerchantThirdApply:edit')") + public ResponseEntity updateTbMerchantThirdApply(@Validated @RequestBody TbMerchantThirdApply resources){ + tbMerchantThirdApplyService.update(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + + @DeleteMapping + @Log("删除/shop/thirdApply") + @ApiOperation("删除/shop/thirdApply") + @PreAuthorize("@el.check('tbMerchantThirdApply:del')") + public ResponseEntity deleteTbMerchantThirdApply(@RequestBody Integer[] ids) { + tbMerchantThirdApplyService.deleteAll(ids); + return new ResponseEntity<>(HttpStatus.OK); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/TbMerchantThirdApplyService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/TbMerchantThirdApplyService.java new file mode 100644 index 00000000..ce1a013e --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/TbMerchantThirdApplyService.java @@ -0,0 +1,86 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.service; + +import me.zhengjie.modules.shopInfo.shopThirdApply.domain.TbMerchantThirdApply; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyDto; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyQueryCriteria; +import org.springframework.data.domain.Pageable; +import java.util.Map; +import java.util.List; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; + +/** +* @website https://eladmin.vip +* @description 服务接口 +* @author lyf +* @date 2024-02-02 +**/ +public interface TbMerchantThirdApplyService { + + /** + * 查询数据分页 + * @param criteria 条件 + * @param pageable 分页参数 + * @return Map + */ + Map queryAll(TbMerchantThirdApplyQueryCriteria criteria, Pageable pageable); + + TbMerchantThirdApplyDto findByShopId(Integer shopId); + + + /** + * 查询所有数据不分页 + * @param criteria 条件参数 + * @return List + */ + List queryAll(TbMerchantThirdApplyQueryCriteria criteria); + + /** + * 根据ID查询 + * @param id ID + * @return TbMerchantThirdApplyDto + */ + TbMerchantThirdApplyDto findById(Integer id); + + /** + * 创建 + * @param resources / + * @return TbMerchantThirdApplyDto + */ + TbMerchantThirdApplyDto create(TbMerchantThirdApply resources); + + /** + * 编辑 + * @param resources / + */ + void update(TbMerchantThirdApply resources); + + /** + * 多选删除 + * @param ids / + */ + void deleteAll(Integer[] ids); + + /** + * 导出数据 + * @param all 待导出的数据 + * @param response / + * @throws IOException / + */ + void download(List all, HttpServletResponse response) throws IOException; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/dto/TbMerchantThirdApplyDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/dto/TbMerchantThirdApplyDto.java new file mode 100644 index 00000000..2d24d8b4 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/dto/TbMerchantThirdApplyDto.java @@ -0,0 +1,53 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.service.dto; + +import lombok.Data; +import java.io.Serializable; + +/** +* @website https://eladmin.vip +* @description / +* @author lyf +* @date 2024-02-02 +**/ +@Data +public class TbMerchantThirdApplyDto implements Serializable { + + /** 自增id */ + private Integer id; + + private String type; + + /** 商户应用 */ + private String appId=""; + + /** 商户token */ + private String appToken=""; + + /** 审核详情-1未提交,0已提交(不可修改) 1审核通过 */ + private Integer status=1; + + /** 支付密码 */ + private String payPassword=""; + + private Long createdAt; + + private Long updatedAt; + + /** shopId */ + private Integer shopId; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/dto/TbMerchantThirdApplyQueryCriteria.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/dto/TbMerchantThirdApplyQueryCriteria.java new file mode 100644 index 00000000..a38ed61f --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/dto/TbMerchantThirdApplyQueryCriteria.java @@ -0,0 +1,33 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.service.dto; + +import lombok.Data; +import java.util.List; +import me.zhengjie.annotation.Query; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-02 +**/ +@Data +public class TbMerchantThirdApplyQueryCriteria{ + + /** 精确 */ + @Query + private Integer shopId; +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/impl/TbMerchantThirdApplyServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/impl/TbMerchantThirdApplyServiceImpl.java new file mode 100644 index 00000000..5c10a087 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/impl/TbMerchantThirdApplyServiceImpl.java @@ -0,0 +1,125 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.service.impl; + +import me.zhengjie.modules.shopInfo.shopThirdApply.domain.TbMerchantThirdApply; +import me.zhengjie.utils.ValidationUtil; +import me.zhengjie.utils.FileUtil; +import lombok.RequiredArgsConstructor; +import me.zhengjie.modules.shopInfo.shopThirdApply.repository.TbMerchantThirdApplyRepository; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.TbMerchantThirdApplyService; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyDto; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyQueryCriteria; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.mapstruct.TbMerchantThirdApplyMapper; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.Pageable; +import me.zhengjie.utils.PageUtil; +import me.zhengjie.utils.QueryHelp; +import java.util.List; +import java.util.Map; +import java.io.IOException; +import javax.servlet.http.HttpServletResponse; +import java.util.ArrayList; +import java.util.LinkedHashMap; + +/** +* @website https://eladmin.vip +* @description 服务实现 +* @author lyf +* @date 2024-02-02 +**/ +@Service +@RequiredArgsConstructor +public class TbMerchantThirdApplyServiceImpl implements TbMerchantThirdApplyService { + + private final TbMerchantThirdApplyRepository tbMerchantThirdApplyRepository; + private final TbMerchantThirdApplyMapper tbMerchantThirdApplyMapper; + + @Override + public Map queryAll(TbMerchantThirdApplyQueryCriteria criteria, Pageable pageable){ + Page page = tbMerchantThirdApplyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + return PageUtil.toPage(page.map(tbMerchantThirdApplyMapper::toDto)); + } + + @Override + public TbMerchantThirdApplyDto findByShopId(Integer shopId) { + TbMerchantThirdApply byShopId = tbMerchantThirdApplyRepository.findByShopId(shopId); + return tbMerchantThirdApplyMapper.toDto(byShopId); + } + + + @Override + public List queryAll(TbMerchantThirdApplyQueryCriteria criteria){ + return tbMerchantThirdApplyMapper.toDto(tbMerchantThirdApplyRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); + } + + @Override + @Transactional + public TbMerchantThirdApplyDto findById(Integer id) { + TbMerchantThirdApply tbMerchantThirdApply = tbMerchantThirdApplyRepository.findById(id).orElseGet(TbMerchantThirdApply::new); + ValidationUtil.isNull(tbMerchantThirdApply.getId(),"TbMerchantThirdApply","id",id); + return tbMerchantThirdApplyMapper.toDto(tbMerchantThirdApply); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public TbMerchantThirdApplyDto create(TbMerchantThirdApply resources) { +// if(tbMerchantThirdApplyRepository.findByAppId(resources.getAppId()) != null){ +// throw new EntityExistException(TbMerchantThirdApply.class,"app_id",resources.getAppId()); +// } + return tbMerchantThirdApplyMapper.toDto(tbMerchantThirdApplyRepository.save(resources)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(TbMerchantThirdApply resources) { + TbMerchantThirdApply tbMerchantThirdApply = tbMerchantThirdApplyRepository.findById(resources.getId()).orElseGet(TbMerchantThirdApply::new); + ValidationUtil.isNull( tbMerchantThirdApply.getId(),"TbMerchantThirdApply","id",resources.getId()); +// tbMerchantThirdApply1 = tbMerchantThirdApplyRepository.findByAppId(resources.getAppId()); +// if(tbMerchantThirdApply1 != null && !tbMerchantThirdApply1.getId().equals(tbMerchantThirdApply.getId())){ +// throw new EntityExistException(TbMerchantThirdApply.class,"app_id",resources.getAppId()); +// } + tbMerchantThirdApply.copy(resources); + tbMerchantThirdApplyRepository.save(tbMerchantThirdApply); + } + + @Override + public void deleteAll(Integer[] ids) { + for (Integer id : ids) { + tbMerchantThirdApplyRepository.deleteById(id); + } + } + + @Override + public void download(List all, HttpServletResponse response) throws IOException { + List> list = new ArrayList<>(); + for (TbMerchantThirdApplyDto tbMerchantThirdApply : all) { + Map map = new LinkedHashMap<>(); + map.put(" type", tbMerchantThirdApply.getType()); + map.put("商户应用", tbMerchantThirdApply.getAppId()); + map.put("商户token", tbMerchantThirdApply.getAppToken()); + map.put("审核详情-1未提交,0已提交(不可修改) 1审核通过", tbMerchantThirdApply.getStatus()); + map.put("支付密码", tbMerchantThirdApply.getPayPassword()); + map.put(" createdAt", tbMerchantThirdApply.getCreatedAt()); + map.put(" updatedAt", tbMerchantThirdApply.getUpdatedAt()); + map.put("shopId", tbMerchantThirdApply.getShopId()); + list.add(map); + } + FileUtil.downloadExcel(list, response); + } +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/mapstruct/TbMerchantThirdApplyMapper.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/mapstruct/TbMerchantThirdApplyMapper.java new file mode 100644 index 00000000..2d7780d3 --- /dev/null +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/shopThirdApply/service/mapstruct/TbMerchantThirdApplyMapper.java @@ -0,0 +1,32 @@ +/* +* Copyright 2019-2020 Zheng Jie +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +package me.zhengjie.modules.shopInfo.shopThirdApply.service.mapstruct; + +import me.zhengjie.base.BaseMapper; +import me.zhengjie.modules.shopInfo.shopThirdApply.domain.TbMerchantThirdApply; +import me.zhengjie.modules.shopInfo.shopThirdApply.service.dto.TbMerchantThirdApplyDto; +import org.mapstruct.Mapper; +import org.mapstruct.ReportingPolicy; + +/** +* @website https://eladmin.vip +* @author lyf +* @date 2024-02-02 +**/ +@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) +public interface TbMerchantThirdApplyMapper extends BaseMapper { + +} \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java index 235d2d84..4f3c9056 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/domain/TbShopTable.java @@ -100,7 +100,12 @@ public class TbShopTable implements Serializable { @ApiModelProperty(value = "updatedAt") private Long updatedAt; + @Column(name = "`qrcode`") + @ApiModelProperty(value = "二维码") + private String qrcode = ""; + public void copy(TbShopTable source){ BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); } + } diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/repository/TbShopTableRepository.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/repository/TbShopTableRepository.java index 890b63c0..cc6a342a 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/repository/TbShopTableRepository.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/repository/TbShopTableRepository.java @@ -16,8 +16,12 @@ package me.zhengjie.modules.shopInfo.table.repository; import me.zhengjie.modules.shopInfo.table.domain.TbShopTable; +import org.apache.ibatis.annotations.Param; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; +import org.springframework.data.jpa.repository.Query; + +import java.util.List; /** * @website https://eladmin.vip @@ -25,4 +29,10 @@ import org.springframework.data.jpa.repository.JpaSpecificationExecutor; * @date 2024-01-18 **/ public interface TbShopTableRepository extends JpaRepository, JpaSpecificationExecutor { + + @Query("select table from TbShopTable table where table.qrcode = :qrcode") + TbShopTable findByQrcode(@Param("qrcode") String qrcode); + +// @Query("select table from TbShopTable table where table.shopId = :qrcode") +// List findByQrcode(@Param("qrcode") Integer shopId); } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java index 2bef09c5..acaa2208 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/rest/TbShopTableController.java @@ -67,6 +67,12 @@ public class TbShopTableController { return new ResponseEntity<>(tbShopTableService.create(resources),HttpStatus.CREATED); } + @PostMapping("/qrcode") + public ResponseEntity bindingQRcode(@RequestBody TbShopTable resources){ + tbShopTableService.binding(resources); + return new ResponseEntity<>(HttpStatus.NO_CONTENT); + } + @PutMapping @Log("修改/shop/table") @ApiOperation("修改/shop/table") diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/TbShopTableService.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/TbShopTableService.java index 35f8f007..b3fcb496 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/TbShopTableService.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/TbShopTableService.java @@ -54,6 +54,8 @@ public interface TbShopTableService { */ TbShopTableDto findById(Integer id); + + void binding(TbShopTable resources); /** * 创建 * diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/dto/TbShopTableDto.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/dto/TbShopTableDto.java index d30be2d8..eb914f41 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/dto/TbShopTableDto.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/dto/TbShopTableDto.java @@ -68,4 +68,6 @@ public class TbShopTableDto implements Serializable { private Long createdAt; private Long updatedAt; + + private String qrcode; } \ No newline at end of file diff --git a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java index 8a840a19..497754a3 100644 --- a/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java +++ b/eladmin-system/src/main/java/me/zhengjie/modules/shopInfo/table/service/impl/TbShopTableServiceImpl.java @@ -15,6 +15,8 @@ */ package me.zhengjie.modules.shopInfo.table.service.impl; +import lombok.Value; +import me.zhengjie.exception.BadRequestException; import me.zhengjie.modules.shopInfo.table.domain.TbShopTable; import me.zhengjie.utils.ValidationUtil; import me.zhengjie.utils.FileUtil; @@ -48,12 +50,22 @@ public class TbShopTableServiceImpl implements TbShopTableService { private final TbShopTableRepository tbShopTableRepository; private final TbShopTableMapper tbShopTableMapper; + /** + *桌码前缀 + */ + private final String QRCODE = "https://kysh.sxczgkj.cn/codeplate?code="; + @Override public Map queryAll(TbShopTableQueryCriteria criteria, Pageable pageable){ if (criteria.getAreaId() == 0){ criteria.setAreaId(null); } Page page = tbShopTableRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); + for (TbShopTable date : page.getContent()) { + if (!"".equals(date.getQrcode())){ + date.setQrcode(QRCODE+date.getQrcode().trim()); + } + } HashMap map = new HashMap<>(); map.put("content",page.getContent()); map.put("totalElements",page.getTotalElements()); @@ -73,11 +85,28 @@ public class TbShopTableServiceImpl implements TbShopTableService { return tbShopTableMapper.toDto(tbShopTable); } + @Override + public void binding(TbShopTable resources) { + //判是否绑定过 + TbShopTable byQrcode = tbShopTableRepository.findByQrcode(resources.getQrcode()); + if (byQrcode != null){ + throw new BadRequestException("已绑定"); + } + TbShopTable tbShopTable = tbShopTableRepository.findById(resources.getId()).orElseGet(TbShopTable::new); + if (tbShopTable.getId() == null){ + throw new BadRequestException("找不到台桌"); + } + ValidationUtil.isNull( tbShopTable.getId(),"TbShopTable","id",resources.getId()); + tbShopTable.copy(resources); + tbShopTableRepository.save(tbShopTable); + } + @Override @Transactional(rollbackFor = Exception.class) public TbShopTable create(TbShopTable resources) { resources.setCreatedAt(Instant.now().toEpochMilli()); resources.setUpdatedAt(Instant.now().toEpochMilli()); + resources.setQrcode(""); return tbShopTableRepository.save(resources); } diff --git a/eladmin-system/src/main/resources/config/application-dev.yml b/eladmin-system/src/main/resources/config/application-dev.yml index a673a2f6..094180db 100644 --- a/eladmin-system/src/main/resources/config/application-dev.yml +++ b/eladmin-system/src/main/resources/config/application-dev.yml @@ -3,10 +3,14 @@ spring: datasource: druid: db-type: com.alibaba.druid.pool.DruidDataSource - driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy - url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:fycashier}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false - username: ${DB_USER:root} - password: ${DB_PWD:123456789} + #driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy +# url: jdbc:log4jdbc:mysql://${DB_HOST:localhost}:${DB_PORT:3306}/${DB_NAME:fycashier}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false +# username: ${DB_USER:root} +# password: ${DB_PWD:123456789} + url: jdbc:mysql://121.40.128.145:3306/fycashier?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: mysqlroot@123 + driver-class-name: com.mysql.cj.jdbc.Driver # 初始连接数 initial-size: 5 # 最小连接数 diff --git a/eladmin-system/src/main/resources/config/application.yml b/eladmin-system/src/main/resources/config/application.yml index f59bbee6..3fd8cb65 100644 --- a/eladmin-system/src/main/resources/config/application.yml +++ b/eladmin-system/src/main/resources/config/application.yml @@ -57,4 +57,6 @@ code: #密码加密传输,前端公钥加密,后端私钥解密 rsa: - private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== \ No newline at end of file + private_key: MIIBUwIBADANBgkqhkiG9w0BAQEFAASCAT0wggE5AgEAAkEA0vfvyTdGJkdbHkB8mp0f3FE0GYP3AYPaJF7jUd1M0XxFSE2ceK3k2kw20YvQ09NJKk+OMjWQl9WitG9pB6tSCQIDAQABAkA2SimBrWC2/wvauBuYqjCFwLvYiRYqZKThUS3MZlebXJiLB+Ue/gUifAAKIg1avttUZsHBHrop4qfJCwAI0+YRAiEA+W3NK/RaXtnRqmoUUkb59zsZUBLpvZgQPfj1MhyHDz0CIQDYhsAhPJ3mgS64NbUZmGWuuNKp5coY2GIj/zYDMJp6vQIgUueLFXv/eZ1ekgz2Oi67MNCk5jeTF2BurZqNLR3MSmUCIFT3Q6uHMtsB9Eha4u7hS31tj1UWE+D+ADzp59MGnoftAiBeHT7gDMuqeJHPL4b+kC+gzV4FGTfhR9q3tTbklZkD2A== + +qrcode: https://kysh.sxczgkj.cn/codeplate?code=