Compare commits

...

No commits in common. 'main' and 'master' have entirely different histories.
main ... master

30
.gitignore vendored

@ -0,0 +1,30 @@
.DS_Store
node_modules/
dist/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
**/*.log
tests/**/coverage/
tests/e2e/reports
selenium-debug.log
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.local
target/
# Created by .ignore support plugin (hsz.mobi)
*.iml
*.iws
# out
**/out/
package-lock.json
yarn.lock

@ -0,0 +1,73 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
(a) You must give any other recipients of the Work or Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License.
You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.

@ -0,0 +1,4 @@
# ba-base
基础框架

@ -0,0 +1,12 @@
@echo off
echo.
echo [信息] 清理工程target生成路径。
echo.
%~d0
cd %~dp0
cd ..
call mvn clean
pause

@ -0,0 +1,12 @@
@echo off
echo.
echo [信息] 打包Web工程生成war/jar包文件。
echo.
%~d0
cd %~dp0
cd ..
call mvn clean package -Dmaven.test.skip=true
pause

@ -0,0 +1,14 @@
@echo off
echo.
echo [信息] 使用Jar命令运行Web工程。
echo.
cd %~dp0
cd ../ruoyi-admin/target
set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m
java -jar %JAVA_OPTS% ruoyi-admin.jar
cd bin
pause

@ -0,0 +1,99 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>my-base</artifactId>
<groupId>com.bs</groupId>
<version>3.8.6</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<artifactId>bs-admin</artifactId>
<description>
web服务入口
</description>
<dependencies>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
</dependency>
<!-- spring-boot-devtools -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <!-- 表示依赖不会传递 -->
</dependency>
<!-- swagger3-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-boot-starter</artifactId>
</dependency>
<!-- 防止进入swagger页面报类型转换错误排除3.0.0中的引用手动增加1.6.2版本 -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.6.2</version>
</dependency>
<!-- Mysql驱动包 -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- 核心模块-->
<dependency>
<groupId>com.bs</groupId>
<artifactId>bs-framework</artifactId>
</dependency>
<!-- 定时任务-->
<dependency>
<groupId>com.bs</groupId>
<artifactId>bs-quartz</artifactId>
</dependency>
<!-- 代码生成-->
<dependency>
<groupId>com.bs</groupId>
<artifactId>bs-generator</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.1.1.RELEASE</version>
<configuration>
<fork>true</fork> <!-- 如果没有该配置devtools不会生效 -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
</plugins>
<finalName>${project.artifactId}</finalName>
</build>
</project>

@ -0,0 +1,23 @@
package com.bs;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
/**
*
*
* @author bs
*/
@SpringBootApplication(exclude = { DataSourceAutoConfiguration.class })
@EnableConfigurationProperties
public class BsApplication
{
public static void main(String[] args)
{
// System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(BsApplication.class, args);
System.out.println("(♥◠‿◠)ノ゙ 启动成功 ლ(´ڡ`ლ)゙ ");
}
}

@ -0,0 +1,18 @@
package com.bs;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
/**
* web
*
* @author bs
*/
public class BsServletInitializer extends SpringBootServletInitializer
{
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application)
{
return application.sources(BsApplication.class);
}
}

@ -0,0 +1,226 @@
package com.bs.cm.controller;
import cn.hutool.core.lang.Validator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.xmlbeans.impl.validator.ValidatorUtil;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author bs
* @date 2024-03-03
*/
@Api(tags = "附件信息")
@RestController
@RequestMapping("/cm/attach")
public class CmAttachController extends BaseController {
@Resource
private ICmAttachService cmAttachService;
/**
*
*/
@ApiOperation("分页查询附件信息列表")
@GetMapping("/pageList")
public TableDataInfo pageList(CmAttach cmAttach) {
startPage();
LambdaQueryWrapper<CmAttach> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, cmAttach);
List<CmAttach> list = cmAttachService.list(queryWrapper);
return getDataTable(list);
}
@PostMapping("/api/file/upload")
@ApiOperation("文件上传")
@Log(title = "文件上传", businessType = BusinessType.OTHER)
// @RepeatSubmit 有点小问题 先注释
public AjaxResult upload(@RequestParam String fileId, CmAttach attach, @RequestParam("files") MultipartFile[] files) {
if (StringUtils.isBlank(fileId) || "null".equals(fileId)) {
return AjaxResult.error("fileId不能为空");
}
if (Validator.isEmpty(files)) {
return AjaxResult.error("上传文件不可为空!");
}
return AjaxResult.success(cmAttachService.uploadFileBatch(files, fileId)) ;
}
/**
*
*/
@ApiOperation("查询附件信息列表")
@GetMapping("/list")
public AjaxResult list(CmAttach cmAttach) {
LambdaQueryWrapper<CmAttach> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, cmAttach);
List<CmAttach> list = cmAttachService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出附件信息列表")
@Log(title = "附件信息导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, CmAttach cmAttach) {
LambdaQueryWrapper<CmAttach> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, cmAttach);
List<CmAttach> list = cmAttachService.list(queryWrapper);
ExcelUtil<CmAttach> util = new ExcelUtil<CmAttach>(CmAttach.class);
util.exportExcel(response, list, "附件信息数据");
}
/**
*
*/
@ApiOperation("获取附件信息详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(cmAttachService.getById(id));
}
/**
*
*/
@ApiOperation("新增附件信息")
@Log(title = "附件信息新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody CmAttach cmAttach) {
return toAjax(cmAttachService.save(cmAttach));
}
/**
*
*/
@ApiOperation("修改附件信息")
@Log(title = "附件信息修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody CmAttach cmAttach) {
return toAjax(cmAttachService.updateById(cmAttach));
}
/**
*
*/
@ApiOperation("删除附件信息")
@Log(title = "附件信息删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(cmAttachService.removeBatchByIds(ids));
}
/**
*
*/
private void condition(LambdaQueryWrapper<CmAttach> queryWrapper, CmAttach cmAttach) {
//用户id
if (Validator.isNotEmpty(cmAttach.getId())) {
queryWrapper.eq(CmAttach::getId, cmAttach.getId());
}
//文件组id
if (Validator.isNotEmpty(cmAttach.getFileId())) {
queryWrapper.eq(CmAttach::getFileId, cmAttach.getFileId());
}
//文件排序
if (Validator.isNotEmpty(cmAttach.getFileSort())) {
queryWrapper.eq(CmAttach::getFileSort, cmAttach.getFileSort());
}
//文件名称(编译后)
if (Validator.isNotEmpty(cmAttach.getAttachName())) {
queryWrapper.eq(CmAttach::getAttachName, cmAttach.getAttachName());
}
//文件类型
if (Validator.isNotEmpty(cmAttach.getAttachFileType())) {
queryWrapper.eq(CmAttach::getAttachFileType, cmAttach.getAttachFileType());
}
//文件编码类型
if (Validator.isNotEmpty(cmAttach.getAttachContentType())) {
queryWrapper.eq(CmAttach::getAttachContentType, cmAttach.getAttachContentType());
}
//文件大小
if (Validator.isNotEmpty(cmAttach.getAttachFileSize())) {
queryWrapper.eq(CmAttach::getAttachFileSize, cmAttach.getAttachFileSize());
}
//文件路径
if (Validator.isNotEmpty(cmAttach.getAttachFileUrl())) {
queryWrapper.eq(CmAttach::getAttachFileUrl, cmAttach.getAttachFileUrl());
}
//文件名(原始)
if (Validator.isNotEmpty(cmAttach.getOldName())) {
queryWrapper.eq(CmAttach::getOldName, cmAttach.getOldName());
}
//文件版本号
if (Validator.isNotEmpty(cmAttach.getVersionNo())) {
queryWrapper.eq(CmAttach::getVersionNo, cmAttach.getVersionNo());
}
//创建部门
if (Validator.isNotEmpty(cmAttach.getCreateDept())) {
queryWrapper.eq(CmAttach::getCreateDept, cmAttach.getCreateDept());
}
//创建人
if (Validator.isNotEmpty(cmAttach.getCreateBy())) {
queryWrapper.eq(CmAttach::getCreateBy, cmAttach.getCreateBy());
}
//创建时间
if (Validator.isNotEmpty(cmAttach.getCreateTime())) {
queryWrapper.eq(CmAttach::getCreateTime, cmAttach.getCreateTime());
}
//修改人
if (Validator.isNotEmpty(cmAttach.getUpdateBy())) {
queryWrapper.eq(CmAttach::getUpdateBy, cmAttach.getUpdateBy());
}
//修改时间
if (Validator.isNotEmpty(cmAttach.getUpdateTime())) {
queryWrapper.eq(CmAttach::getUpdateTime, cmAttach.getUpdateTime());
}
//备注
if (Validator.isNotEmpty(cmAttach.getRemark())) {
queryWrapper.eq(CmAttach::getRemark, cmAttach.getRemark());
}
//删除标志0代表存在 2代表删除
if (Validator.isNotEmpty(cmAttach.getDelFlag())) {
queryWrapper.eq(CmAttach::getDelFlag, cmAttach.getDelFlag());
}
//${column.columnComment}
if (Validator.isNotEmpty(cmAttach.getTenantId())) {
queryWrapper.eq(CmAttach::getTenantId, cmAttach.getTenantId());
}
}
}

@ -0,0 +1,94 @@
package com.bs.cm.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* cm_attach
*
* @author bs
* @date 2024-03-03
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("cm_attach")
@Data
public class CmAttach extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 用户id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
/** 文件组id */
@Excel(name = "文件组id")
@ApiModelProperty(value = "文件组id")
private String fileId;
/** 文件排序 */
@Excel(name = "文件排序")
@ApiModelProperty(value = "文件排序")
private Integer fileSort;
/** 文件名称(编译后) */
@Excel(name = "文件名称", readConverterExp = "编=译后")
@ApiModelProperty(value = "文件名称(编译后)")
private String attachName;
/** 文件类型 */
@Excel(name = "文件类型")
@ApiModelProperty(value = "文件类型")
private String attachFileType;
/** 文件编码类型 */
@Excel(name = "文件编码类型")
@ApiModelProperty(value = "文件编码类型")
private String attachContentType;
/** 文件大小 */
@Excel(name = "文件大小")
@ApiModelProperty(value = "文件大小")
private Long attachFileSize;
/** 文件路径 */
@Excel(name = "文件路径")
@ApiModelProperty(value = "文件路径")
private String attachFileUrl;
/** 文件名(原始) */
@Excel(name = "文件名", readConverterExp = "原=始")
@ApiModelProperty(value = "文件名(原始)")
private String oldName;
/** 文件版本号 */
@Excel(name = "文件版本号")
@ApiModelProperty(value = "文件版本号")
private String versionNo;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
}

@ -0,0 +1,14 @@
package com.bs.cm.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.cm.domain.CmAttach;
/**
* Mapper
*
* @author bs
* @date 2024-03-03
*/
public interface CmAttachMapper extends BaseMapperX<CmAttach> {
}

@ -0,0 +1,18 @@
package com.bs.cm.service;
import com.bs.cm.domain.CmAttach;
import com.github.yulichang.base.MPJBaseService;
import org.springframework.web.multipart.MultipartFile;
import java.util.List;
/**
* Service
*
* @author bs
* @date 2024-03-03
*/
public interface ICmAttachService extends MPJBaseService<CmAttach>{
List<CmAttach> uploadFileBatch(MultipartFile[] files, String fileId);
}

@ -0,0 +1,110 @@
package com.bs.cm.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.bs.cm.mapper.CmAttachMapper;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.constant.Constants;
import com.bs.common.exception.ServiceException;
import com.bs.common.utils.FileUtil;
import com.bs.common.utils.OsInfoUtil;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import java.io.File;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import static cn.hutool.core.date.DateUtil.format;
import static com.bs.common.config.BsConfig.*;
/**
* Service
*
* @author bs
* @date 2024-03-03
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class CmAttachServiceImpl extends MPJBaseServiceImpl<CmAttachMapper, CmAttach> implements ICmAttachService {
@Resource
private ICmAttachService cmAttachService;
public static final String SEPARATOR = "/";
public static final String SUFFIX = Constants.RESOURCE_PREFIX + SEPARATOR;
@Autowired
private Environment env;
@Override
public List<CmAttach> uploadFileBatch(MultipartFile[] files, String fileId) {
List<CmAttach> attachs = new ArrayList<>();
for (MultipartFile file : files) {
//插入附件表
attachs.add(uploadFile(file, fileId));
}
if (attachs.size() == 0) {
return null;
}
// 插入附件中间表
List<CmAttach> attachVos = new ArrayList<>();
cmAttachService.saveBatch(attachs);
// cmAttachService.saveBatch(getAttachRef(attachs,attachVos, fileId, businessUnits));
return attachVos;
}
/**
*
*/
@Transactional
public CmAttach uploadFile(MultipartFile multipartFile, String fileId) {
FileUtil.checkSize(Long.parseLong(env.getProperty("chain.maxSize")), multipartFile.getSize());
String suffix = FileUtil.getExtensionName(multipartFile.getOriginalFilename());
String type = FileUtil.getFileType(suffix);
//新的文件名+后缀
String fileName = FileUtil.fileRenameMos(null, null) + "." + suffix;
//绝对路径+年份+文件类型+文件名
String filePath = format(new Date(), "yyyy") + SEPARATOR +
type + SEPARATOR + fileName;
File file = FileUtil.uploadMos(multipartFile, getFilePath() + SEPARATOR + filePath);
if (ObjectUtil.isNull(file)) {
throw new ServiceException("上传失败");
}
try {
CmAttach attach = new CmAttach();
attach.setFileId(fileId);
// attach.setAttachId(UUIDUtils.generatorUUID());
attach.setAttachName(fileName);
attach.setAttachFileType(type);
attach.setAttachContentType(multipartFile.getContentType());
attach.setAttachFileSize((long) multipartFile.getSize());
attach.setAttachFileUrl(SUFFIX + filePath);
attach.setOldName(multipartFile.getOriginalFilename());
// cmAttachMapper.insert(attach);
return attach;
} catch (Exception e) {
FileUtil.del(file);
throw e;
}
}
/**
*
*
* @return
*/
public static String getFilePath() {
if (OsInfoUtil.isLinux()) {
return getLinuxLocalFilePath();
}
if (OsInfoUtil.isMacOS() || OsInfoUtil.isMacOSX()) {
return getMacLocalFilePath();
}
return getWinLocalFilePath();
}
}

@ -0,0 +1,436 @@
package com.bs.df.controller;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.bs.common.annotation.Anonymous;
import com.bs.common.constant.Constants;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.common.utils.ServletUtils;
import com.bs.df.domain.DfOrder;
import com.bs.df.domain.DfUserBroker;
import com.bs.df.mapper.DfBizClueMapper;
import com.bs.df.service.IDfUserBrokerService;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfBizClue;
import com.bs.df.service.IDfBizClueService;
import javax.annotation.Resource;
/**
* 线Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "业务线索")
@RestController
@RequestMapping("/biz/clue")
public class DfBizClueController extends BaseController {
@Resource
private IDfBizClueService dfBizClueService;
@Resource
private DfBizClueMapper dfBizClueMapper;
@Resource
private ISysUserService userService;
@Resource
private SysUserMapper sysUserMapper;
@Resource
private IDfUserBrokerService dfUserBrokerService;
/**
* 线
*/
@ApiOperation("分页查询业务线索列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfBizClue dfBizClue) {
startPage();
LambdaQueryWrapper<DfBizClue> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBizClue);
queryWrapper.orderByDesc(DfBizClue::getBrowseTime);
boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
if (!admin) {
SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
if (!sysUser.getDeptId().equals(-1L)) {
SysUser byId = userService.getById(SecurityUtils.getUserId());
if ("jj".equals(byId.getUserType())) {
queryWrapper.eq(DfBizClue::getUserId,SecurityUtils.getUserId());
}
}
}
List<DfBizClue> list = dfBizClueService.list(queryWrapper);
for (DfBizClue clue : list) {
if (Validator.isNotEmpty(clue.getUserName())) {
clue.setNickName(clue.getUserName());
}
}
return getDataTable(list);
}
/**
* 线
*/
@ApiOperation("分页查询业务线索数量列表")
@GetMapping("/getVisitsNum")
public TableDataInfo getVisitsNum(DfBizClue dfBizClue) {
// startPage();
//condition(queryWrapper,dfBizClue);
Integer pageNum = ServletUtils.getParameterToInt(Constants.PAGE_NUM);
Integer pageSize = ServletUtils.getParameterToInt(Constants.PAGE_SIZE);
LambdaQueryWrapper<DfBizClue> queryWrapper = new LambdaQueryWrapper();
queryWrapper.eq(DfBizClue::getDataType,dfBizClue.getDataType());
//传入hasOrder参数为1时查询出存在orderId的数据
SysUser sysUser = sysUserMapper.selectById(getUserId());
if (!sysUser.getDeptId().equals(-1L)) {
if (Validator.isNotEmpty(dfBizClue.getHasOrder())) {
queryWrapper.isNotNull(DfBizClue::getOrderId);
if (Validator.isNotEmpty(dfBizClue.getBrokerId())) {
queryWrapper.eq(DfBizClue::getShareUser,dfBizClue.getBrokerId());
} else {
queryWrapper.eq(DfBizClue::getShareUser,SecurityUtils.getUserId());
}
} else {
queryWrapper.eq(DfBizClue::getShareUser,SecurityUtils.getUserId());
}
}
queryWrapper.orderByDesc(DfBizClue::getBrowseTime);
List<DfBizClue> list = dfBizClueService.list(queryWrapper);
Map<String, Integer> visitsNum = new HashMap<>();
for (DfBizClue clue : list) {
String key = clue.getUnionId() + "_" + clue.getDataType();
int count = visitsNum.getOrDefault(key, 0) + 1;
visitsNum.put(key, count);
clue.setVisitsNum(count);
}
Map<String, DfBizClue> latestClues = new HashMap<>();
for (DfBizClue clue : list) {
String key = clue.getUnionId() + "_" + clue.getDataType();
if (!latestClues.containsKey(key) || clue.getBrowseTime().after(latestClues.get(key).getBrowseTime())) {
latestClues.put(key, clue);
}
}
List<DfBizClue> newList = new ArrayList<>(latestClues.values());
for (DfBizClue clue : newList) {
String key = clue.getUnionId() + "_" + clue.getDataType();
int visits = visitsNum.getOrDefault(key, 0);
clue.setVisitsNum(visits);
if (Validator.isNotEmpty(clue.getUserName())) {
clue.setNickName(clue.getUserName());
}
}
List<DfBizClue> sortedList = newList.stream()
.sorted((o1, o2) -> o2.getBrowseTime().compareTo(o1.getBrowseTime())) // 倒序
.collect(Collectors.toList());
Integer start = (pageNum - 1) * pageSize;
List<DfBizClue> result = sortedList.stream()
.skip(start)
.limit(pageSize)
.collect(Collectors.toList());
TableDataInfo data = getDataTable(result);
data.setTotal(sortedList.size());
return data;
// return getDataTable(newList);
}
/**
* 线
*/
@ApiOperation("查询业务线索列表")
@GetMapping("/list")
public AjaxResult list(DfBizClue dfBizClue) {
LambdaQueryWrapper<DfBizClue> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBizClue);
List<DfBizClue> list = dfBizClueService.list(queryWrapper);
for (DfBizClue clue : list) {
if (Validator.isNotEmpty(clue.getUserName())) {
clue.setNickName(clue.getUserName());
}
}
return success(list);
}
/**
* 线
*/
@ApiOperation("查询业务线索列表")
@GetMapping("/listByClassify")
@Anonymous
public AjaxResult listByClassify(DfBizClue dfBizClue) {
LambdaQueryWrapper<DfBizClue> queryWrapper = new LambdaQueryWrapper();
if ("0".equals(dfBizClue.getClassify())) {
queryWrapper.in(DfBizClue::getDataType, "0", "3");
} else if ("1".equals(dfBizClue.getClassify())) {
queryWrapper.in(DfBizClue::getDataType, "2", "4");
} else if ("2".equals(dfBizClue.getClassify())) {
queryWrapper.in(DfBizClue::getDataType, "1");
}
if (Validator.isNotEmpty(dfBizClue.getBusinessLinks())) {
queryWrapper.eq(DfBizClue::getBusinessLinks, dfBizClue.getBusinessLinks());
}
List<DfBizClue> list = dfBizClueService.list(queryWrapper);
for (DfBizClue clue : list) {
if (Validator.isNotEmpty(clue.getUserName())) {
clue.setNickName(clue.getUserName());
}
}
List<DfBizClue> uniqueList = list.stream()
.collect(Collectors.toMap(
DfBizClue::getUserId, // 指定键的抽取函数
dfBizClueVo -> dfBizClueVo, // 指定值的映射函数
(existing, replacement) -> existing // 处理重复键的方式,这里选择保留第一个出现的元素
))
.values()
.stream()
.collect(Collectors.toList());
List<String> avatarLinks = uniqueList.stream()
.map(DfBizClue::getAvatarLink) // 获取每个对象的 avatarLink
.limit(5) // 限制最多只取前 5 个
.collect(Collectors.toList());
DfBizClue dfBizClueByNum = new DfBizClue();
dfBizClueByNum.setAvatarLinks(avatarLinks);
dfBizClueByNum.setUserNum(uniqueList.size());
return success(dfBizClueByNum);
}
/**
* 线
*/
@ApiOperation("导出业务线索列表")
@Log(title = "业务线索导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfBizClue dfBizClue) {
LambdaQueryWrapper<DfBizClue> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBizClue);
List<DfBizClue> list = dfBizClueService.list(queryWrapper);
for (DfBizClue clue : list) {
if (Validator.isNotEmpty(clue.getUserName())) {
clue.setNickName(clue.getUserName());
}
}
ExcelUtil<DfBizClue> util = new ExcelUtil<DfBizClue>(DfBizClue. class);
util.exportExcel(response, list, "业务线索数据");
}
/**
* 线
*/
@ApiOperation("获取业务线索详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
DfBizClue byId = dfBizClueService.getById(id);
List<SysUser> list = userService.list(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserId, byId.getShareUser()));
if (!list.isEmpty()) {
String realName = list.get(0).getRealName();
if (Validator.isEmpty(realName)) {
if (Validator.isNotEmpty(list.get(0).getUserName())) {
list.get(0).setNickName(list.get(0).getUserName());
}
String nickName = list.get(0).getNickName();
if (Validator.isEmpty(nickName)) {
String userName = list.get(0).getUserName();
byId.setRealName(userName);
} else {
byId.setRealName(nickName);
}
} else {
byId.setRealName(realName);
}
}
return success(byId);
}
/**
* 线
*/
@ApiOperation("新增业务线索")
@Log(title = "业务线索新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfBizClue dfBizClue) {
return toAjax(dfBizClueService.save(dfBizClue));
}
/**
* 线
*
*/
@ApiOperation("新增业务线索")
@Log(title = "业务线索新增", businessType = BusinessType.INSERT)
@PostMapping("/addVisitor")
@Anonymous
public AjaxResult addVisitor(DfBizClue dfBizClue) {
Date date = new Date();
dfBizClue.setCreateTimeVo(date);
dfBizClue.setTenantId(0L);
// dfBizClue.setTenantId(SecurityUtils.getTenantId());
return toAjax(dfBizClueMapper.insertClue(dfBizClue));
}
/**
* 线
*/
@ApiOperation("修改业务线索")
@Log(title = "业务线索修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfBizClue dfBizClue) {
return toAjax(dfBizClueService.updateById(dfBizClue));
}
/**
* ID
*/
@ApiOperation("经纪人ID")
@PostMapping("/changeUserId")
public AjaxResult changeUserId(@RequestBody DfBizClue dfBizClue) {
List<DfBizClue> list = dfBizClueService.list(new LambdaQueryWrapper<DfBizClue>()
.eq(DfBizClue::getShareUser, dfBizClue.getOldUserId()));
if (list.size() > 0) {
for (DfBizClue dfBizClueNew : list) {
dfBizClueNew.setShareUser(dfBizClue.getNewUserId());
}
dfBizClueService.updateBatchById(list);
}
List<DfUserBroker> userBrokerList = dfUserBrokerService.list(new LambdaQueryWrapper<DfUserBroker>()
.eq(DfUserBroker::getBrokerId, dfBizClue.getOldUserId()));
if (userBrokerList.size() > 0) {
for (DfUserBroker dfUserBroker : userBrokerList) {
dfUserBroker.setBrokerId(Long.valueOf(dfBizClue.getNewUserId()));
}
dfUserBrokerService.updateBatchById(userBrokerList);
}
return toAjax(true);
}
/**
* 线
*/
@ApiOperation("删除业务线索")
@Log(title = "业务线索删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(dfBizClueService.removeBatchByIds(ids));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfBizClue> queryWrapper,DfBizClue dfBizClue){
//id
if(Validator.isNotEmpty(dfBizClue.getId())){
queryWrapper.eq(DfBizClue::getId,dfBizClue.getId());
}
//数据类型0客户1经纪
if(Validator.isNotEmpty(dfBizClue.getDataType())){
queryWrapper.eq(DfBizClue::getDataType,dfBizClue.getDataType());
}
//线索类型
if(Validator.isNotEmpty(dfBizClue.getClueType())){
queryWrapper.eq(DfBizClue::getClueType,dfBizClue.getClueType());
}
//用户id
if(Validator.isNotEmpty(dfBizClue.getUserId())){
queryWrapper.eq(DfBizClue::getUserId,dfBizClue.getUserId());
}
//用户昵称
if(Validator.isNotEmpty(dfBizClue.getNickName())){
queryWrapper.like(DfBizClue::getNickName,dfBizClue.getNickName());
}
//头像链接
if(Validator.isNotEmpty(dfBizClue.getAvatarLink())){
queryWrapper.eq(DfBizClue::getAvatarLink,dfBizClue.getAvatarLink());
}
//手机号
if(Validator.isNotEmpty(dfBizClue.getPhone())){
queryWrapper.eq(DfBizClue::getPhone,dfBizClue.getPhone());
}
//浏览时间
if(Validator.isNotEmpty(dfBizClue.getBrowseTime())){
queryWrapper.eq(DfBizClue::getBrowseTime,dfBizClue.getBrowseTime());
}
if(Validator.isNotEmpty(dfBizClue.getParams().get("beginTime"))){
queryWrapper.ge(DfBizClue::getBrowseTime,dfBizClue.getParams().get("beginTime"));
}
if(Validator.isNotEmpty(dfBizClue.getParams().get("endTime"))){
queryWrapper.le(DfBizClue::getBrowseTime,dfBizClue.getParams().get("endTime"));
}
//创建部门
if(Validator.isNotEmpty(dfBizClue.getCreateDept())){
queryWrapper.eq(DfBizClue::getCreateDept,dfBizClue.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfBizClue.getCreateBy())){
queryWrapper.eq(DfBizClue::getCreateBy,dfBizClue.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfBizClue.getCreateTime())){
queryWrapper.eq(DfBizClue::getCreateTime,dfBizClue.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfBizClue.getUpdateBy())){
queryWrapper.eq(DfBizClue::getUpdateBy,dfBizClue.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfBizClue.getUpdateTime())){
queryWrapper.eq(DfBizClue::getUpdateTime,dfBizClue.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfBizClue.getDelFlag())){
queryWrapper.eq(DfBizClue::getDelFlag,dfBizClue.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfBizClue.getTenantId())){
queryWrapper.eq(DfBizClue::getTenantId,dfBizClue.getTenantId());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfBizClue.getBusinessLinks())){
queryWrapper.eq(DfBizClue::getBusinessLinks,dfBizClue.getBusinessLinks());
}
}
}

@ -0,0 +1,359 @@
package com.bs.df.controller;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.df.domain.DfProductPoster;
import com.bs.df.mapper.DfBrokerMapper;
import com.bs.df.utils.HtmlUtils;
import com.bs.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfBroker;
import com.bs.df.service.IDfBrokerService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "代理商经纪")
@RestController
@RequestMapping("/broker/broker")
public class DfBrokerController extends BaseController {
@Resource
private IDfBrokerService dfBrokerService;
@Resource
private ISysUserService sysUserService;
@Resource
private DfBrokerMapper dfBrokerMapper;
/**
*
*/
@ApiOperation("分页查询代理商经纪列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfBroker dfBroker) {
// startPage();
LambdaQueryWrapper<DfBroker> queryWrapper = new LambdaQueryWrapper();
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
List<Long> longs = dfBrokerService.filterByUser();
queryWrapper.in(DfBroker::getId, longs);
}
queryWrapper.orderByAsc(DfBroker::getOrderNum);
condition(queryWrapper,dfBroker);
List<DfBroker> list = dfBrokerService.list(queryWrapper);
for (DfBroker broker : list) {
broker.setBrokerDesc(HtmlUtils.stripHtmlTags(broker.getBrokerDesc()));
}
// List<DfBroker> treeList = buildTree(list);
return getDataTable(list);
}
public List<DfBroker> buildTree(List<DfBroker> list) {
List<DfBroker> treeList = new ArrayList<>();
Map<Long, DfBroker> brokerMap = new HashMap<>();
// 遍历列表,将每个节点添加到 Map 中
for (DfBroker broker : list) {
brokerMap.put(broker.getId(), broker);
}
// 构建树形结构
for (DfBroker broker : list) {
if (broker.getParentId() == null) {
treeList.add(findChildren(broker, brokerMap));
}
}
return treeList;
}
private DfBroker findChildren(DfBroker parent, Map<Long, DfBroker> brokerMap) {
for (DfBroker broker : brokerMap.values()) {
if (parent.getId().equals(broker.getParentId())) {
if (parent.getChildren() == null) {
parent.setChildren(new ArrayList<>());
}
parent.getChildren().add(findChildren(broker, brokerMap));
}
}
return parent;
}
/**
*
*/
@ApiOperation("查询代理商经纪列表")
@GetMapping("/list")
public AjaxResult list(DfBroker dfBroker) {
LambdaQueryWrapper<DfBroker> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBroker);
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
List<Long> longs = dfBrokerService.filterByUser();
queryWrapper.in(DfBroker::getId, longs);
}
List<DfBroker> list = dfBrokerService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("查询代理商经纪列表")
@GetMapping("/listByTree")
public AjaxResult listByTree(DfBroker dfBroker) {
LambdaQueryWrapper<DfBroker> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBroker);
List<DfBroker> list = dfBrokerService.list(queryWrapper);
List<DfBroker> treeList = buildTree(list);
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
List<Long> longs = dfBrokerService.filterByUser();
treeList = filterTree(treeList, longs);
// queryWrapper.in(DfBroker::getId, longs);
}
return success(treeList);
}
private List<DfBroker> filterTree(List<DfBroker> treeList, List<Long> idList) {
List<DfBroker> filteredList = new ArrayList<>();
for (DfBroker broker : treeList) {
// 如果当前节点的 ID 在列表中,则将其加入到结果列表中
if (idList.contains(broker.getId())) {
filteredList.add(broker);
}
// 如果当前节点有子节点,则递归调用该方法对其子节点进行过滤
if (broker.getChildren() != null && !broker.getChildren().isEmpty()) {
List<DfBroker> children = filterTree(broker.getChildren(), idList);
// 如果子节点也被过滤掉了,则不加入到结果列表中
if (!children.isEmpty()) {
broker.setChildren(children);
filteredList.add(broker);
}
}
}
return filteredList;
}
/**
*
*/
@ApiOperation("导出代理商经纪列表")
@Log(title = "代理商经纪导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfBroker dfBroker) {
LambdaQueryWrapper<DfBroker> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBroker);
List<DfBroker> list = dfBrokerService.list(queryWrapper);
List<DfBroker> listAll = dfBrokerService.list();
Map<Long, DfBroker> brokerMap = new HashMap<>();
for (DfBroker broker : listAll) {
brokerMap.put(broker.getId(), broker);
}
for (DfBroker broker : list) {
broker.setBrokerDesc(HtmlUtils.stripHtmlTags(broker.getBrokerDesc()));
DfBroker parentBroker = brokerMap.get(broker.getParentId());
if (parentBroker != null) {
broker.setParentName(parentBroker.getBrokerName());
}
}
ExcelUtil<DfBroker> util = new ExcelUtil<DfBroker>(DfBroker. class);
util.exportExcel(response, list, "代理商经纪数据");
}
/**
*
*/
@Log(title = "代理商经纪状态修改", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody DfBroker dfBroker) {
dfBrokerService.updateById(dfBroker);
return toAjax(true);
}
/**
*
*/
@ApiOperation("获取代理商经纪详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(dfBrokerService.getById(id));
}
/**
*
*/
@ApiOperation("新增代理商经纪")
@Log(title = "代理商经纪新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfBroker dfBroker) {
return toAjax(dfBrokerService.save(dfBroker));
}
/**
*
*/
@ApiOperation("修改代理商经纪")
@Log(title = "代理商经纪修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfBroker dfBroker) {
if (null == dfBroker.getParentId()) {
dfBrokerMapper.updateByNull(dfBroker);
}
return toAjax(dfBrokerService.updateById(dfBroker));
}
/**
*
*/
@ApiOperation("删除代理商经纪")
@Log(title = "代理商经纪删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
LambdaQueryWrapper<DfBroker> queryWrapper = new LambdaQueryWrapper();
queryWrapper.in(DfBroker::getParentId,ids);
if(dfBrokerService.list(queryWrapper).size()>0){
return AjaxResult.warn("请先删除子节点");
}
LambdaQueryWrapper<SysUser> queryWrapperByUser = new LambdaQueryWrapper();
queryWrapperByUser.in(SysUser::getDeptId,ids);
queryWrapperByUser.eq(SysUser::getDelFlag,0);
queryWrapperByUser.eq(SysUser::getUserType,"jj");
if(sysUserService.list(queryWrapperByUser).size()>0){
return AjaxResult.warn("请先删除用户");
}
return toAjax(dfBrokerService.removeBatchByIds(ids));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfBroker> queryWrapper,DfBroker dfBroker){
//id
if(Validator.isNotEmpty(dfBroker.getId())){
queryWrapper.eq(DfBroker::getId,dfBroker.getId());
}
//父级id
if(Validator.isNotEmpty(dfBroker.getParentId())){
queryWrapper.eq(DfBroker::getParentId,dfBroker.getParentId());
}
//代理商名称
if(Validator.isNotEmpty(dfBroker.getBrokerName())){
queryWrapper.like(DfBroker::getBrokerName,dfBroker.getBrokerName());
}
//地址
if(Validator.isNotEmpty(dfBroker.getBrokerAddress())){
queryWrapper.eq(DfBroker::getBrokerAddress,dfBroker.getBrokerAddress());
}
//简介
if(Validator.isNotEmpty(dfBroker.getBrokerDesc())){
queryWrapper.eq(DfBroker::getBrokerDesc,dfBroker.getBrokerDesc());
}
//显示顺序
if(Validator.isNotEmpty(dfBroker.getOrderNum())){
queryWrapper.eq(DfBroker::getOrderNum,dfBroker.getOrderNum());
}
//负责人
if(Validator.isNotEmpty(dfBroker.getChargePerson())){
queryWrapper.like(DfBroker::getChargePerson,dfBroker.getChargePerson());
}
//联系电话
if(Validator.isNotEmpty(dfBroker.getContactPhone())){
queryWrapper.like(DfBroker::getContactPhone,dfBroker.getContactPhone());
}
//邮箱
if(Validator.isNotEmpty(dfBroker.getEmail())){
queryWrapper.eq(DfBroker::getEmail,dfBroker.getEmail());
}
//是否机构
if(Validator.isNotEmpty(dfBroker.getIsInstitution())){
queryWrapper.eq(DfBroker::getIsInstitution,dfBroker.getIsInstitution());
}
//状态
if(Validator.isNotEmpty(dfBroker.getStaus())){
queryWrapper.eq(DfBroker::getStaus,dfBroker.getStaus());
}
//备注
if(Validator.isNotEmpty(dfBroker.getRemark())){
queryWrapper.eq(DfBroker::getRemark,dfBroker.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfBroker.getCreateDept())){
queryWrapper.eq(DfBroker::getCreateDept,dfBroker.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfBroker.getCreateBy())){
queryWrapper.eq(DfBroker::getCreateBy,dfBroker.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfBroker.getCreateTime())){
queryWrapper.eq(DfBroker::getCreateTime,dfBroker.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfBroker.getUpdateBy())){
queryWrapper.eq(DfBroker::getUpdateBy,dfBroker.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfBroker.getUpdateTime())){
queryWrapper.eq(DfBroker::getUpdateTime,dfBroker.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfBroker.getDelFlag())){
queryWrapper.eq(DfBroker::getDelFlag,dfBroker.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfBroker.getTenantId())){
queryWrapper.eq(DfBroker::getTenantId,dfBroker.getTenantId());
}
}
}

@ -0,0 +1,184 @@
package com.bs.df.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfBrokerProduct;
import com.bs.df.service.IDfBrokerProductService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "代理产品权限")
@RestController
@RequestMapping("/broker/product")
public class DfBrokerProductController extends BaseController {
@Resource
private IDfBrokerProductService dfBrokerProductService;
/**
*
*/
@ApiOperation("分页查询代理产品权限列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfBrokerProduct dfBrokerProduct) {
startPage();
LambdaQueryWrapper<DfBrokerProduct> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBrokerProduct);
List<DfBrokerProduct> list = dfBrokerProductService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询代理产品权限列表")
@GetMapping("/list")
public AjaxResult list(DfBrokerProduct dfBrokerProduct) {
LambdaQueryWrapper<DfBrokerProduct> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBrokerProduct);
List<DfBrokerProduct> list = dfBrokerProductService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出代理产品权限列表")
@Log(title = "代理产品权限导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfBrokerProduct dfBrokerProduct) {
LambdaQueryWrapper<DfBrokerProduct> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfBrokerProduct);
List<DfBrokerProduct> list = dfBrokerProductService.list(queryWrapper);
ExcelUtil<DfBrokerProduct> util = new ExcelUtil<DfBrokerProduct>(DfBrokerProduct. class);
util.exportExcel(response, list, "代理产品权限数据");
}
/**
*
*/
@ApiOperation("获取代理产品权限详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(dfBrokerProductService.getById(id));
}
/**
*
*/
@ApiOperation("新增代理产品权限")
@Log(title = "代理产品权限新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfBrokerProduct dfBrokerProduct) {
return toAjax(dfBrokerProductService.save(dfBrokerProduct));
}
/**
*
*/
@ApiOperation("修改代理产品权限")
@Log(title = "代理产品权限修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfBrokerProduct dfBrokerProduct) {
return toAjax(dfBrokerProductService.updateById(dfBrokerProduct));
}
/**
*
*/
@ApiOperation("删除代理产品权限")
@Log(title = "代理产品权限删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(dfBrokerProductService.removeBatchByIds(ids));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfBrokerProduct> queryWrapper,DfBrokerProduct dfBrokerProduct){
//id
if(Validator.isNotEmpty(dfBrokerProduct.getId())){
queryWrapper.eq(DfBrokerProduct::getId,dfBrokerProduct.getId());
}
//代理id
if(Validator.isNotEmpty(dfBrokerProduct.getBrokerId())){
queryWrapper.eq(DfBrokerProduct::getBrokerId,dfBrokerProduct.getBrokerId());
}
//产品id
if(Validator.isNotEmpty(dfBrokerProduct.getProductId())){
queryWrapper.eq(DfBrokerProduct::getProductId,dfBrokerProduct.getProductId());
}
//备注
if(Validator.isNotEmpty(dfBrokerProduct.getRemark())){
queryWrapper.eq(DfBrokerProduct::getRemark,dfBrokerProduct.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfBrokerProduct.getCreateDept())){
queryWrapper.eq(DfBrokerProduct::getCreateDept,dfBrokerProduct.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfBrokerProduct.getCreateBy())){
queryWrapper.eq(DfBrokerProduct::getCreateBy,dfBrokerProduct.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfBrokerProduct.getCreateTime())){
queryWrapper.eq(DfBrokerProduct::getCreateTime,dfBrokerProduct.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfBrokerProduct.getUpdateBy())){
queryWrapper.eq(DfBrokerProduct::getUpdateBy,dfBrokerProduct.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfBrokerProduct.getUpdateTime())){
queryWrapper.eq(DfBrokerProduct::getUpdateTime,dfBrokerProduct.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfBrokerProduct.getDelFlag())){
queryWrapper.eq(DfBrokerProduct::getDelFlag,dfBrokerProduct.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfBrokerProduct.getTenantId())){
queryWrapper.eq(DfBrokerProduct::getTenantId,dfBrokerProduct.getTenantId());
}
}
}

@ -0,0 +1,577 @@
package com.bs.df.controller;
import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.baomidou.mybatisplus.annotation.TableField;
import com.bs.common.annotation.Anonymous;
import com.bs.common.constant.Constants;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.common.utils.ServletUtils;
import com.bs.df.domain.DfBizClue;
import com.bs.df.domain.DfBroker;
import com.bs.df.mapper.DfBizClueMapper;
import com.bs.df.mapper.DfOrderMapper;
import com.bs.df.service.IDfBizClueService;
import com.bs.df.service.IDfBrokerService;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfOrder;
import com.bs.df.service.IDfOrderService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "客户订单")
@RestController
@RequestMapping("/order/order")
public class DfOrderController extends BaseController {
@Resource
private IDfOrderService dfOrderService;
@Resource
private IDfBrokerService dfBrokerService;
@Resource
private ISysUserService userService;
@Resource
private DfOrderMapper dfOrderMapper;
@Resource
private IDfBizClueService dfBizClueService;
@Resource
private DfBizClueMapper dfBizClueMapper;
@Autowired
private SysUserMapper sysUserMapper;
/**
*
*/
@ApiOperation("分页查询客户订单列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfOrder dfOrder) {
Integer pageNum = ServletUtils.getParameterToInt(Constants.PAGE_NUM);
Integer pageSize = ServletUtils.getParameterToInt(Constants.PAGE_SIZE);
SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
if (sysUser.getDeptId().equals(-1L)) {
dfOrder.setBrokerId(null);
}
LambdaQueryWrapper<DfOrder> queryWrapper = new LambdaQueryWrapper();
if (Validator.isEmpty(dfOrder.getOrderByColumn())) {
queryWrapper.orderByDesc(DfOrder::getSubmitTime);
}
if (Validator.isNotEmpty(dfOrder.getUserOrProduct())) {
queryWrapper.like(DfOrder::getUserName, dfOrder.getUserOrProduct())
.or()
.like(DfOrder::getProductName, dfOrder.getUserOrProduct());
}
condition(queryWrapper, dfOrder);
boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
if (!admin) {
if (!sysUser.getDeptId().equals(-1L)) {
SysUser byId = userService.getById(SecurityUtils.getUserId());
if ("jj".equals(byId.getUserType())) {
queryWrapper.eq(DfOrder::getBrokerId, SecurityUtils.getUserId());
}
}
}
String orderByColumn = dfOrder.getOrderByColumn();
String isAsc = dfOrder.getIsAsc();
if (StringUtils.isNotEmpty(orderByColumn) && StringUtils.isNotEmpty(isAsc)) {
applyOrderBy(queryWrapper, orderByColumn, isAsc);
}
List<DfOrder> list = dfOrderService.list(queryWrapper);
List<DfOrder> dfOrders = setOrderList(list);
if (StringUtils.isNotEmpty(dfOrder.getBrokerName())) {
dfOrders = dfOrders.stream()
.filter(info -> info.getBrokerName() != null && info.getBrokerName().contains(dfOrder.getBrokerName()))
.collect(Collectors.toList());
}
Integer start = (pageNum - 1) * pageSize;
List<DfOrder> result = dfOrders.stream()
.skip(start)
.limit(pageSize)
.collect(Collectors.toList());
TableDataInfo data = getDataTable(result);
data.setTotal(dfOrders.size());
return data;
}
public void applyOrderBy(LambdaQueryWrapper<DfOrder> queryWrapper, String orderName, String orderType) {
boolean isAsc = "ASC".equalsIgnoreCase(orderType);
switch (orderName) {
case "orderNo":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getOrderNo);
} else {
queryWrapper.orderByDesc(DfOrder::getOrderNo);
}
break;
case "userName":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getUserName);
} else {
queryWrapper.orderByDesc(DfOrder::getUserName);
}
break;
case "productName":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getProductName);
} else {
queryWrapper.orderByDesc(DfOrder::getProductName);
}
break;
case "submitTime":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getSubmitTime);
} else {
queryWrapper.orderByDesc(DfOrder::getSubmitTime);
}
break;
case "applyAmount":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getApplyAmount);
} else {
queryWrapper.orderByDesc(DfOrder::getApplyAmount);
}
break;
case "limitAmount":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getLimitAmount);
} else {
queryWrapper.orderByDesc(DfOrder::getLimitAmount);
}
break;
case "loanAmount":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getLoanAmount);
} else {
queryWrapper.orderByDesc(DfOrder::getLoanAmount);
}
break;
case "loanRate":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getLoanRate);
} else {
queryWrapper.orderByDesc(DfOrder::getLoanRate);
}
break;
case "loadMonth":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getLoadMonth);
} else {
queryWrapper.orderByDesc(DfOrder::getLoadMonth);
}
break;
case "isFirst":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getIsFirst);
} else {
queryWrapper.orderByDesc(DfOrder::getIsFirst);
}
break;
case "settleAmount":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getSettleAmount);
} else {
queryWrapper.orderByDesc(DfOrder::getSettleAmount);
}
break;
case "staus":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getStaus);
} else {
queryWrapper.orderByDesc(DfOrder::getStaus);
}
break;
case "remark":
if (isAsc) {
queryWrapper.orderByAsc(DfOrder::getRemark);
} else {
queryWrapper.orderByDesc(DfOrder::getRemark);
}
break;
default:
queryWrapper.orderByDesc(DfOrder::getSubmitTime);
break;
}
}
private List<DfOrder> setOrderList(List<DfOrder> list) {
List<SysUser> userList = userService.list();
Map<Long, String> userIdToRealNameMapVo = userList.stream()
.filter(user -> user != null && user.getUserId() != null && user.getRealName() != null)
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getRealName));
Map<Long, String> userIdToPhoneMapVo = userList.stream()
.filter(user -> user != null && user.getUserId() != null && user.getPhonenumber() != null)
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getPhonenumber));
Map<Long, String> userIdToNickNameMapVo = userList.stream()
.filter(user -> user != null && user.getUserId() != null && user.getNickName() != null)
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getNickName));
Map<Long, String> userIdToNameMapVo = userList.stream()
.filter(user -> user != null && user.getUserId() != null && user.getUserName() != null)
.collect(Collectors.toMap(SysUser::getUserId, SysUser::getUserName));
list.forEach(order -> {
String realName = userIdToRealNameMapVo.get(order.getBrokerId());
String nickName = userIdToNickNameMapVo.get(order.getBrokerId());
String userName = userIdToNameMapVo.get(order.getBrokerId());
String phone = userIdToPhoneMapVo.get(order.getBrokerId());
if (Validator.isEmpty(realName)) {
if (Validator.isEmpty(nickName)) {
order.setBrokerName(userName);
} else {
order.setBrokerName(nickName);
}
} else {
order.setBrokerName(realName);
}
order.setBrokerPhone(phone);
});
return list;
}
/**
*
*/
@ApiOperation("查询客户订单列表")
@GetMapping("/list")
public AjaxResult list(DfOrder dfOrder) {
LambdaQueryWrapper<DfOrder> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, dfOrder);
queryWrapper.orderByDesc(DfOrder::getCreateTime);
List<DfOrder> list = dfOrderService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出客户订单列表")
@Log(title = "客户订单导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfOrder dfOrder) {
LambdaQueryWrapper<DfOrder> queryWrapper = new LambdaQueryWrapper();
queryWrapper.orderByDesc(DfOrder::getSubmitTime);
condition(queryWrapper, dfOrder);
boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
if (!admin) {
SysUser byId = userService.getById(SecurityUtils.getUserId());
if ("jj".equals(byId.getUserType())) {
queryWrapper.eq(DfOrder::getBrokerId, SecurityUtils.getUserId());
}
}
List<DfOrder> list = dfOrderService.list(queryWrapper);
List<DfOrder> dfOrders = setOrderList(list);
dfOrders.forEach(order -> {
String isFirst = order.getIsFirst();
if (StringUtils.isNotEmpty(isFirst)) {
String isFirstDisplay = isFirst.equals("1") ? "是" : "否";
order.setIsFirst(isFirstDisplay);
}
});
if (StringUtils.isNotEmpty(dfOrder.getUserName())) {
dfOrders = dfOrders.stream()
.filter(info -> info.getUserName() != null && info.getUserName().contains(dfOrder.getUserName()))
.collect(Collectors.toList());
}
if (StringUtils.isNotEmpty(dfOrder.getBrokerName())) {
dfOrders = dfOrders.stream()
.filter(info -> info.getBrokerName() != null && info.getBrokerName().contains(dfOrder.getBrokerName()))
.collect(Collectors.toList());
}
if (StringUtils.isNotEmpty(dfOrder.getPhone())) {
dfOrders = dfOrders.stream()
.filter(info -> info.getPhone() != null && info.getPhone().contains(dfOrder.getPhone()))
.collect(Collectors.toList());
}
ExcelUtil<DfOrder> util = new ExcelUtil<DfOrder>(DfOrder.class);
util.exportExcel(response, dfOrders, "客户订单数据");
}
/**
*
*/
@ApiOperation("获取客户订单详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
DfOrder byId = dfOrderService.getById(id);
List<SysUser> list = userService.list(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserId, byId.getBrokerId()));
if (!list.isEmpty()) {
String realName = list.get(0).getRealName();
if (Validator.isEmpty(realName)) {
String nickName = list.get(0).getNickName();
if (Validator.isEmpty(nickName)) {
String userName = list.get(0).getUserName();
byId.setBrokerName(userName);
} else {
byId.setBrokerName(nickName);
}
} else {
byId.setBrokerName(realName);
}
String phonenumber = list.get(0).getPhonenumber();
byId.setBrokerPhone(phonenumber);
}
return success(byId);
}
/**
*
*/
@PostMapping
public AjaxResult add(@RequestBody DfOrder dfOrder) {
return toAjax(dfOrderService.save(dfOrder));
}
/**
*
*/
@ApiOperation("新增客户订单")
@PostMapping("/visitorAdd")
@Anonymous
public AjaxResult visitorAdd(@RequestBody DfOrder dfOrder) {
// SysUser sysUser = sysUserMapper.selectById(dfOrder.getShareUser());
// if (sysUser == null) {
// return AjaxResult.warn("链接有误");
// }
// List<Long> productIdsByBrokerId = dfBrokerService.getProductIdsByBrokerIdByUserId(Long.valueOf(dfOrder.getShareUser()));
// Long productId = Long.valueOf(dfOrder.getProductId());
// if (!productIdsByBrokerId.contains(productId)) {
// return AjaxResult.warn("链接有误");
// }
Date date = new Date();
dfOrder.setCreateTimeVo(date);
String billNumber = dfOrderService.getBillNumber("RK");
dfOrder.setOrderNo(billNumber);
dfOrder.setTenantId(0L);
dfOrderMapper.insertOrder(dfOrder);
List<DfOrder> dfOrders = dfOrderService.list(new LambdaQueryWrapper<DfOrder>().eq(DfOrder::getOrderNo, billNumber)
.orderByDesc(DfOrder::getCreateTime));
// if (Validator.isNotEmpty(dfOrder.getShareUser())) {
// List<DfBizClue> list = dfBizClueService.list(new LambdaQueryWrapper<DfBizClue>().eq(DfBizClue::getShareUser, dfOrder.getShareUser())
// .isNull(DfBizClue::getOrderId));
// for (DfBizClue clue : list) {
// clue.setOrderId(dfOrders.get(0).getId().toString());
// clue.setPhone(dfOrder.getPhone());
// clue.setNickName(dfOrder.getUserName());
// dfBizClueMapper.updateClue(clue);
// }
// }
if (Validator.isNotEmpty(dfOrder.getUnionId())) {
List<DfBizClue> list = dfBizClueService.list(new LambdaQueryWrapper<DfBizClue>().eq(DfBizClue::getUnionId, dfOrder.getUnionId())
.isNull(DfBizClue::getOrderId));
for (DfBizClue clue : list) {
clue.setOrderId(dfOrders.get(0).getId().toString());
//clue.setNickName(dfOrder.getUserName());
if (Validator.isEmpty(clue.getUserName())) {
clue.setUserName(dfOrder.getUserName());
clue.setPhone(dfOrder.getPhone());
}
dfBizClueMapper.updateClue(clue);
}
}
// dfOrder.setTenantId(SecurityUtils.getTenantId());
// dfOrder.setCreateBy(SecurityUtils.getUserId());
// dfOrder.setCreateDept(SecurityUtils.getDeptId());
return toAjax(true);
}
/**
*
*/
@ApiOperation("修改客户订单")
@Log(title = "客户订单修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfOrder dfOrder) {
return toAjax(dfOrderService.updateById(dfOrder));
}
/**
*
*/
@ApiOperation("删除客户订单")
@Log(title = "客户订单删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(dfOrderService.removeBatchByIds(ids));
}
@ApiOperation("获取单据编号")
@GetMapping("/getBillNo/{billPrefix}")
public AjaxResult getBillNo(@PathVariable("billPrefix") String billPrefix) {
String billNumber = dfOrderService.getBillNumber(billPrefix);
return AjaxResult.success("获取成功", billNumber);
}
/**
*
*/
private void condition(LambdaQueryWrapper<DfOrder> queryWrapper, DfOrder dfOrder) {
//id
if (Validator.isNotEmpty(dfOrder.getId())) {
queryWrapper.eq(DfOrder::getId, dfOrder.getId());
}
//订单号
if (Validator.isNotEmpty(dfOrder.getOrderNo())) {
queryWrapper.like(DfOrder::getOrderNo, dfOrder.getOrderNo());
}
//客户id
if (Validator.isNotEmpty(dfOrder.getUserId())) {
queryWrapper.eq(DfOrder::getUserId, dfOrder.getUserId());
}
//经纪id
if (Validator.isNotEmpty(dfOrder.getBrokerId())) {
queryWrapper.eq(DfOrder::getBrokerId, dfOrder.getBrokerId());
}
//产品id
if (Validator.isNotEmpty(dfOrder.getProductId())) {
queryWrapper.eq(DfOrder::getProductId, dfOrder.getProductId());
}
//产品名称
if (Validator.isNotEmpty(dfOrder.getProductName())) {
queryWrapper.like(DfOrder::getProductName, dfOrder.getProductName());
}
if (Validator.isNotEmpty(dfOrder.getPhone())) {
queryWrapper.like(DfOrder::getPhone, dfOrder.getPhone());
}
if (Validator.isNotEmpty(dfOrder.getUserName())) {
queryWrapper.like(DfOrder::getUserName, dfOrder.getUserName());
}
//提交时间
if (Validator.isNotEmpty(dfOrder.getSubmitTime())) {
queryWrapper.eq(DfOrder::getSubmitTime, dfOrder.getSubmitTime());
}
if (Validator.isNotEmpty(dfOrder.getSubmitTimeBegin())) {
queryWrapper.ge(DfOrder::getSubmitTime, dfOrder.getSubmitTimeBegin());
}
if (Validator.isNotEmpty(dfOrder.getSubmitTimeEnd())) {
queryWrapper.le(DfOrder::getSubmitTime, dfOrder.getSubmitTimeEnd());
}
//申请额(万元)
if (Validator.isNotEmpty(dfOrder.getApplyAmount())) {
queryWrapper.eq(DfOrder::getApplyAmount, dfOrder.getApplyAmount());
}
//授信额(万元)
if (Validator.isNotEmpty(dfOrder.getLimitAmount())) {
queryWrapper.eq(DfOrder::getLimitAmount, dfOrder.getLimitAmount());
}
//放款额(万元)
if (Validator.isNotEmpty(dfOrder.getLoanAmount())) {
queryWrapper.eq(DfOrder::getLoanAmount, dfOrder.getLoanAmount());
}
//放款利率
if (Validator.isNotEmpty(dfOrder.getLoanRate())) {
queryWrapper.eq(DfOrder::getLoanRate, dfOrder.getLoanRate());
}
//贷款期限(月)
if (Validator.isNotEmpty(dfOrder.getLoadMonth())) {
queryWrapper.eq(DfOrder::getLoadMonth, dfOrder.getLoadMonth());
}
//是否首贷
if (Validator.isNotEmpty(dfOrder.getIsFirst())) {
queryWrapper.eq(DfOrder::getIsFirst, dfOrder.getIsFirst());
}
//可结算金额(万元)
if (Validator.isNotEmpty(dfOrder.getSettleAmount())) {
queryWrapper.eq(DfOrder::getSettleAmount, dfOrder.getSettleAmount());
}
//状态
if (Validator.isNotEmpty(dfOrder.getStaus())) {
queryWrapper.eq(DfOrder::getStaus, dfOrder.getStaus());
}
//备注
if (Validator.isNotEmpty(dfOrder.getRemark())) {
queryWrapper.eq(DfOrder::getRemark, dfOrder.getRemark());
}
//创建部门
if (Validator.isNotEmpty(dfOrder.getCreateDept())) {
queryWrapper.eq(DfOrder::getCreateDept, dfOrder.getCreateDept());
}
//创建人员
if (Validator.isNotEmpty(dfOrder.getCreateBy())) {
queryWrapper.eq(DfOrder::getCreateBy, dfOrder.getCreateBy());
}
//创建时间
if (Validator.isNotEmpty(dfOrder.getCreateTime())) {
queryWrapper.eq(DfOrder::getCreateTime, dfOrder.getCreateTime());
}
//修改人员
if (Validator.isNotEmpty(dfOrder.getUpdateBy())) {
queryWrapper.eq(DfOrder::getUpdateBy, dfOrder.getUpdateBy());
}
//修改时间
if (Validator.isNotEmpty(dfOrder.getUpdateTime())) {
queryWrapper.eq(DfOrder::getUpdateTime, dfOrder.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if (Validator.isNotEmpty(dfOrder.getDelFlag())) {
queryWrapper.eq(DfOrder::getDelFlag, dfOrder.getDelFlag());
}
//租户id
if (Validator.isNotEmpty(dfOrder.getTenantId())) {
queryWrapper.eq(DfOrder::getTenantId, dfOrder.getTenantId());
}
}
}

@ -0,0 +1,299 @@
package com.bs.df.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.annotation.Anonymous;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.df.domain.*;
import com.bs.df.utils.HtmlUtils;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.service.IDfProductArticleService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "产品文章")
@RestController
@RequestMapping("/article/article")
public class DfProductArticleController extends BaseController {
@Resource
private IDfProductArticleService dfProductArticleService;
@Resource
private ICmAttachService cmAttachService;
@Resource
private ISysUserService userService;
@Autowired
private SysUserMapper sysUserMapper;
/**
*
*/
@ApiOperation("分页查询产品文章列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfProductArticle dfProductArticle) {
SysUser sysUser = sysUserMapper.selectById(getUserId());
startPage();
String reviewStatus = sysUser.getReviewStatus();
if ("1".equals(reviewStatus)) {
return null;
}
LambdaQueryWrapper<DfProductArticle> queryWrapper = new LambdaQueryWrapper();
boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
if (!admin) {
if (!sysUser.getDeptId().equals(-1L)) {
if ("-99".equals(dfProductArticle.getStatus())) {
} else {
SysUser byId = userService.getById(SecurityUtils.getUserId());
if ("jj".equals(byId.getUserType()) || "kh".equals(byId.getUserType())) {
queryWrapper.eq(DfProductArticle::getStatus, "1");
}
}
}
}
if (Validator.isEmpty(dfProductArticle.getOrderByColumn())) {
queryWrapper.last("ORDER BY CASE WHEN serial_number IS NULL THEN 1 ELSE 0 END, serial_number ASC");
}
condition(queryWrapper,dfProductArticle);
List<DfProductArticle> list = dfProductArticleService.list(queryWrapper);
for (DfProductArticle article : list) {
article.setArticleContent(HtmlUtils.stripHtmlTags(article.getArticleContent()));
}
List<CmAttach> attachVo = cmAttachService.list();
Map<String, List<CmAttach>> attachMap = attachVo.stream()
.filter(cmAttach -> cmAttach.getFileId() != null)
.collect(Collectors.groupingBy(CmAttach::getFileId));
for (DfProductArticle article : list) {
article.setArticleContent(HtmlUtils.stripHtmlTags(article.getArticleContent()));
String id = article.getId();
List<CmAttach> matchingAttachments = attachMap.get(String.valueOf(id));
if (matchingAttachments != null) {
article.setFiles(matchingAttachments);
}
}
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询产品文章列表")
@GetMapping("/list")
public AjaxResult list(DfProductArticle dfProductArticle) {
LambdaQueryWrapper<DfProductArticle> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductArticle);
List<DfProductArticle> list = dfProductArticleService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出产品文章列表")
@Log(title = "产品文章导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfProductArticle dfProductArticle) {
LambdaQueryWrapper<DfProductArticle> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductArticle);
List<DfProductArticle> list = dfProductArticleService.list(queryWrapper);
for (DfProductArticle article : list) {
//去除富文本中的HTML标签
article.setArticleContent(HtmlUtils.stripHtmlTags(article.getArticleContent()));
}
ExcelUtil<DfProductArticle> util = new ExcelUtil<DfProductArticle>(DfProductArticle. class);
util.exportExcel(response, list, "产品文章数据");
}
/**
*
*/
@ApiOperation("获取产品文章详细信息")
@GetMapping(value = "/{id}")
@Anonymous
public AjaxResult getInfo(@PathVariable("id") String id) {
DfProductArticle byId = dfProductArticleService.getById(id);
List<CmAttach> attachVo = cmAttachService.list(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId, id));
byId.setFiles(attachVo);
return success(byId);
}
/**
*
*/
@ApiOperation("新增产品文章")
@Log(title = "产品文章新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfProductArticle dfProductArticle) {
return toAjax(dfProductArticleService.save(dfProductArticle));
}
/**
*
*/
@ApiOperation("修改产品文章")
@Log(title = "产品文章修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfProductArticle dfProductArticle) {
return toAjax(dfProductArticleService.updateById(dfProductArticle));
}
/**
*
*/
@ApiOperation("修改产品文章状态")
@Log(title = "修改产品文章状态", businessType = BusinessType.DELETE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody DfProductArticle dfProductArticle) {
String[] ids = dfProductArticle.getIds();
String status = dfProductArticle.getStatus();
List<DfProductArticle> dfProductArticles = new ArrayList<>();
for (String id : ids) {
DfProductArticle dfProductArticlerNew = new DfProductArticle();
dfProductArticlerNew.setId(id);
dfProductArticlerNew.setStatus(status);
dfProductArticles.add(dfProductArticlerNew);
}
return toAjax(dfProductArticleService.updateBatchById(dfProductArticles));
}
/**
*
*/
@ApiOperation("删除产品文章")
@Log(title = "产品文章删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<String> ids) {
List<DfProductArticle> list = dfProductArticleService.list(new LambdaQueryWrapper<DfProductArticle>()
.in(DfProductArticle::getId, ids));
for (DfProductArticle dfProductArticle : list) {
if ("1".equals(dfProductArticle.getStatus())) {
return AjaxResult.warn("该产品文章已经上架,请先下架再删除");
}
}
return toAjax(dfProductArticleService.removeBatchByIds(ids));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfProductArticle> queryWrapper,DfProductArticle dfProductArticle){
//文章id
if(Validator.isNotEmpty(dfProductArticle.getId())){
queryWrapper.eq(DfProductArticle::getId,dfProductArticle.getId());
}
//文章分类0产品文章1经纪文章
if(Validator.isNotEmpty(dfProductArticle.getArticleType())){
queryWrapper.eq(DfProductArticle::getArticleType,dfProductArticle.getArticleType());
}
//文章类型
if(Validator.isNotEmpty(dfProductArticle.getArticleKind())){
queryWrapper.eq(DfProductArticle::getArticleKind,dfProductArticle.getArticleKind());
}
//文章标题
if(Validator.isNotEmpty(dfProductArticle.getArticleTitle())){
queryWrapper.like(DfProductArticle::getArticleTitle,dfProductArticle.getArticleTitle());
}
//发布时间
if(Validator.isNotEmpty(dfProductArticle.getPublishTime())){
queryWrapper.eq(DfProductArticle::getPublishTime,dfProductArticle.getPublishTime());
}
if(Validator.isNotEmpty(dfProductArticle.getPublishTimeBegin())){
queryWrapper.ge(DfProductArticle::getPublishTime,dfProductArticle.getPublishTimeBegin());
}
if(Validator.isNotEmpty(dfProductArticle.getPublishTimeEnd())){
queryWrapper.le(DfProductArticle::getPublishTime,dfProductArticle.getPublishTimeEnd());
}
//文章正文
if(Validator.isNotEmpty(dfProductArticle.getArticleContent())){
queryWrapper.eq(DfProductArticle::getArticleContent,dfProductArticle.getArticleContent());
}
//状态0草稿1上架
if(Validator.isNotEmpty(dfProductArticle.getStatus())){
queryWrapper.eq(DfProductArticle::getStatus,dfProductArticle.getStatus());
}
//备注
if(Validator.isNotEmpty(dfProductArticle.getRemark())){
queryWrapper.eq(DfProductArticle::getRemark,dfProductArticle.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfProductArticle.getCreateDept())){
queryWrapper.eq(DfProductArticle::getCreateDept,dfProductArticle.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfProductArticle.getCreateBy())){
queryWrapper.eq(DfProductArticle::getCreateBy,dfProductArticle.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfProductArticle.getCreateTime())){
queryWrapper.eq(DfProductArticle::getCreateTime,dfProductArticle.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfProductArticle.getUpdateBy())){
queryWrapper.eq(DfProductArticle::getUpdateBy,dfProductArticle.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfProductArticle.getUpdateTime())){
queryWrapper.eq(DfProductArticle::getUpdateTime,dfProductArticle.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfProductArticle.getDelFlag())){
queryWrapper.eq(DfProductArticle::getDelFlag,dfProductArticle.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfProductArticle.getTenantId())){
queryWrapper.eq(DfProductArticle::getTenantId,dfProductArticle.getTenantId());
}
}
}

@ -0,0 +1,900 @@
package com.bs.df.controller;
import java.util.*;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.bs.common.annotation.Anonymous;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.core.domain.model.LoginUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.df.domain.*;
import com.bs.df.service.*;
import com.bs.df.utils.HtmlUtils;
import com.bs.system.domain.DfArea;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.service.IDfAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.aspectj.weaver.patterns.IToken;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import static com.bs.common.utils.ServletUtils.getSession;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "产品信息")
@RestController
@RequestMapping("/product/info")
public class DfProductInfoController extends BaseController {
@Resource
private IDfProductInfoService dfProductInfoService;
@Resource
private IDfProductPosterService dfProductPosterService;
@Resource
private IDfAreaService dfAreaService;
@Resource
private IDfBrokerProductService dfBrokerProductService;
@Resource
private IDfBrokerService dfBrokerService;
@Resource
private IDfOrderService dfOrderService;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private IDfProductRecommendService dfProductRecommendService;
/**
*
*/
@ApiOperation("分页查询产品信息列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfProductInfo dfProductInfo) {
SysUser sysUser = sysUserMapper.selectById(getUserId());
List<DfProductInfo> list = selectInfo(dfProductInfo,sysUser,false);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("分页查询产品信息列表")
@GetMapping("/pageListVo")
@Anonymous
public TableDataInfo pageListVo(DfProductInfo dfProductInfo) {
SysUser sysUser = sysUserMapper.selectById(dfProductInfo.getUserId());
List<DfProductInfo> list = selectInfo(dfProductInfo,sysUser,true);
return getDataTable(list);
}
private List<DfProductInfo> selectInfo(DfProductInfo dfProductInfo,SysUser sysUser,boolean isAnonymous) {
String reviewStatus = sysUser.getReviewStatus();
if ("1".equals(reviewStatus)) {
return null;
}
LambdaQueryWrapper<DfProductInfo> queryWrapper = new LambdaQueryWrapper();
if (Validator.isEmpty(dfProductInfo.getOrderByColumn())) {
queryWrapper.last("ORDER BY CASE WHEN serial_number IS NULL THEN 1 ELSE 0 END, serial_number ASC");
}
condition(queryWrapper,dfProductInfo);
String brokerIds = dfProductInfo.getBrokerIds();
if ("1".equals(dfProductInfo.getSelectByBroker())) {
if (Validator.isNotEmpty(dfProductInfo.getUserId())) {
if ("1".equals(dfProductInfo.getIsSelectBroker())) {
String userId = dfProductInfo.getUserId();
List<Long> productIdsByBrokerIdByUserId = dfBrokerService.getProductIdsByBrokerIdByUserId(Long.valueOf(userId));
if (productIdsByBrokerIdByUserId == null || productIdsByBrokerIdByUserId.isEmpty()) {
productIdsByBrokerIdByUserId.add(0L);
}
queryWrapper.in(DfProductInfo::getId,productIdsByBrokerIdByUserId);
} else {
String userId = dfProductInfo.getUserId();
List<Long> productIdsByBrokerIdByUserId = dfBrokerService.getProductIdsByBrokerIdByUserId(Long.valueOf(userId));
if (productIdsByBrokerIdByUserId == null || productIdsByBrokerIdByUserId.isEmpty()) {
productIdsByBrokerIdByUserId.add(0L);
}
if ("1".equals(dfProductInfo.getIsRecommend())) {
queryWrapper.and(wrapper ->
wrapper.in(DfProductInfo::getId, productIdsByBrokerIdByUserId)
.or()
.inSql(DfProductInfo::getId, "select product_id from df_broker_product where user_id in (" + dfProductInfo.getUserId() + ") and del_flag = '0' and staus = '1'")
);
queryWrapper.inSql(DfProductInfo::getId,"select product_id from df_product_recommend where user_id in (" + userId + ") and del_flag = '0'");
} else {
queryWrapper.inSql(DfProductInfo::getId,"select product_id from df_broker_product where user_id in (" + userId + ") and del_flag = '0' and staus = '1'");
}
}
} else {
queryWrapper.inSql(DfProductInfo::getId,"select product_id from df_broker_product where broker_id in (" + brokerIds + ") and del_flag = '0' and staus = '1'");
}
}
if (!SecurityUtils.isAdmin(sysUser.getUserId())) {
if (!sysUser.getDeptId().equals(-1L)) {
if (isAnonymous) {
List<Long> productIdsByBrokerId = dfBrokerService.getProductIdsByBrokerIdByUserId(sysUser.getUserId());
if (productIdsByBrokerId.size() == 0) {
productIdsByBrokerId.add(0L);
}
if (!"1".equals(dfProductInfo.getSelectByBroker())) {
queryWrapper.in(DfProductInfo::getId, productIdsByBrokerId)
.or()
.in(DfProductInfo::getCreateDept, SecurityUtils.getDeptId());
}
} else {
List<Long> productIdsByBrokerId = dfBrokerService.getProductIdsByBrokerId();
if (productIdsByBrokerId.size() == 0) {
productIdsByBrokerId.add(0L);
}
if (!"1".equals(dfProductInfo.getSelectByBroker())) {
queryWrapper.in(DfProductInfo::getId, productIdsByBrokerId)
.or()
.in(DfProductInfo::getCreateDept, SecurityUtils.getDeptId());
}
}
}
}
startPage();
List<DfProductInfo> list = dfProductInfoService.list(queryWrapper);
List<DfOrder> dfOrders = dfOrderService.list();
Map<Long, Integer> productOrderCounts = new HashMap<>();
// 计算申请人数
for (DfOrder order : dfOrders) {
if (!productOrderCounts.containsKey(order.getProductId())) {
productOrderCounts.put(order.getProductId(), 1000); // 从1000开始计数
} else {
productOrderCounts.put(order.getProductId(), productOrderCounts.get(order.getProductId()) + 1);
}
}
for (DfProductInfo productInfo : list) {
Long productId = productInfo.getId();
if (productOrderCounts.containsKey(productId)) {
productInfo.setApplicantNum(Long.valueOf(productOrderCounts.get(productId)));
} else {
productInfo.setApplicantNum(1000L);
}
}
//城市名称
Map<String, String> cityMap = new HashMap<>();
List<DfArea> allCities = dfAreaService.list();
for (DfArea city : allCities) {
cityMap.put(city.getAreaId(), city.getName());
}
DfBroker byId = null;
SysUser userInfo = null;
if ("1".equals(dfProductInfo.getSelectByBroker())) {
if (Validator.isNotEmpty(dfProductInfo.getUserId())) {
userInfo = sysUserMapper.selectById(dfProductInfo.getUserId());
} else {
byId = dfBrokerService.getById(brokerIds);
}
}
for (DfProductInfo productInfo : list) {
productInfo.setInterestRate(productInfo.getInterestRateBegin() + "%-" + productInfo.getInterestRateEnd() + "%");
productInfo.setProductIntro(HtmlUtils.stripHtmlTags(productInfo.getProductIntro()));
productInfo.setProductDetail(HtmlUtils.stripHtmlTags(productInfo.getProductDetail()));
String businessCity = productInfo.getBusinessCity();
if (Validator.isNotEmpty(businessCity)) {
String[] cityIds = businessCity.split(",");
StringBuilder translatedCities = new StringBuilder();
for (String cityId : cityIds) {
String cityName = cityMap.get(cityId);
if (cityName != null) {
translatedCities.append(cityName).append(",");
}
}
if (translatedCities.length() > 0) {
translatedCities.deleteCharAt(translatedCities.length() - 1);
}
productInfo.setBusinessCity(translatedCities.toString());
}
if ("1".equals(dfProductInfo.getSelectByBroker())) {
if (Validator.isNotEmpty(dfProductInfo.getUserId())) {
if ("1".equals(dfProductInfo.getIsSelectBroker())) {
Long deptId = userInfo.getDeptId();
DfBroker byIdNew = dfBrokerService.getById(deptId);
productInfo.setBrokerName(byIdNew.getBrokerName());
} else {
productInfo.setBrokerName(userInfo.getUserName());
}
} else {
productInfo.setBrokerName(byId.getBrokerName());
}
}
}
return list;
}
/**
*
*/
@ApiOperation("查询产品信息列表")
@GetMapping("/list")
public AjaxResult list(DfProductInfo dfProductInfo) {
LambdaQueryWrapper<DfProductInfo> queryWrapper = new LambdaQueryWrapper();
if ("1".equals(dfProductInfo.getSelectByBroker())) {
queryWrapper.notInSql(DfProductInfo::getId,"select product_id from df_broker_product where del_flag = '0'")
.or()
.eq(DfProductInfo::getId,dfProductInfo.getId());
}
condition(queryWrapper,dfProductInfo);
List<DfProductInfo> list = dfProductInfoService.list(queryWrapper);
return success(list);
}
/**
* userId
*/
@ApiOperation("根据userId查询产品信息列表")
@GetMapping("/listByUserId")
public AjaxResult listByUserId(DfProductInfo dfProductInfo) {
LambdaQueryWrapper<DfProductInfo> queryWrapper = new LambdaQueryWrapper();
List<Long> productIdsByBrokerIdByUserId = dfBrokerService.getProductIdsByBrokerIdByUserId(Long.valueOf(dfProductInfo.getUserId()));
queryWrapper.notInSql(DfProductInfo::getId,
"select product_id from df_broker_product where del_flag = '0' and user_id = " + dfProductInfo.getUserId() + "")
.eq(DfProductInfo::getStatus, "1")
.or()
.eq(DfProductInfo::getId,dfProductInfo.getId())
.eq(DfProductInfo::getStatus, "1");
condition(queryWrapper,dfProductInfo);
List<DfProductInfo> list = dfProductInfoService.list(queryWrapper);
Set<Long> idsToRemove = productIdsByBrokerIdByUserId.stream().collect(Collectors.toSet());
List<DfProductInfo> filteredList = list.stream()
.filter(product -> !idsToRemove.contains(product.getId()))
.collect(Collectors.toList());
return success(filteredList);
}
/**
* userId
*/
@ApiOperation("根据userId查询产品信息列表")
@GetMapping("/listByRecommend")
public AjaxResult listByRecommend(DfProductInfo dfProductInfo) {
List<DfProductRecommend> dfProductRecommends = dfProductRecommendService.list(new LambdaQueryWrapper<DfProductRecommend>().eq(DfProductRecommend::getUserId, dfProductInfo.getUserId()));
List<Long> recommendProductIds = dfProductRecommends.stream()
.map(DfProductRecommend::getProductId) // 提取 String 类型的 productId
.map(Long::parseLong) // 将 String 转换为 Long
.collect(Collectors.toList()); // 收集为 List<Long>
recommendProductIds.add(0L);
List<Long> brokerProductIds = dfBrokerService.getProductIdsByBrokerIdByUserId(Long.valueOf(dfProductInfo.getUserId()));
List<Long> productIdsByBrokerIdByUserId = dfBrokerService.getProductIdsByBrokerIdByUserId(Long.valueOf(dfProductInfo.getUserId()));
if (productIdsByBrokerIdByUserId.isEmpty()) {
productIdsByBrokerIdByUserId.add(0L); // 添加默认值避免空集合错误
}
Set<Long> allProductIds = new HashSet<>();
allProductIds.addAll(recommendProductIds);
allProductIds.addAll(brokerProductIds);
allProductIds.addAll(productIdsByBrokerIdByUserId);
allProductIds.add(0L);
LambdaQueryWrapper<DfProductInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.notIn(DfProductInfo::getId, recommendProductIds) // 排除推荐的产品
.in(DfProductInfo::getId, allProductIds) // 包含经纪人产品和broker产品
.or()
.eq(DfProductInfo::getId, dfProductInfo.getId()); // 或者直接匹配当前产品ID
condition(queryWrapper, dfProductInfo);
List<DfProductInfo> list = dfProductInfoService.list(queryWrapper);
return success(list);
}
/**
* id
*/
@ApiOperation("根据代理商经纪id查询产品信息列表")
@GetMapping("/listByBroker")
public AjaxResult listByBroker(DfProductInfo dfProductInfo) {
// Long userId = SecurityUtils.getUserId();
LambdaQueryWrapper<DfProductInfo> queryWrapper = new LambdaQueryWrapper();
DfBroker broker = dfBrokerService.getById(dfProductInfo.getBrokerId());
if (Validator.isEmpty(broker.getParentId())) {
List<DfBrokerProduct> listBrokerProduct = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getBrokerId, broker.getId())
.eq(DfBrokerProduct::getStaus, "1"));
List<Long> productIds = listBrokerProduct.stream()
.map(DfBrokerProduct::getProductId)
.collect(Collectors.toList());
productIds.removeIf(id -> Objects.equals(id, dfProductInfo.getId()));
// productIds.removeIf(id -> id.equals(dfProductInfo.getId()));
if (null != productIds && productIds.size() == 0) {
productIds.add(0L);
}
queryWrapper.notIn(DfProductInfo::getId, productIds);
} else {
List<DfBrokerProduct> listBrokerProduct = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getBrokerId, broker.getParentId())
.eq(DfBrokerProduct::getStaus, "1"));
List<Long> productIds = listBrokerProduct.stream()
.map(DfBrokerProduct::getProductId)
.collect(Collectors.toList());
if (null != productIds && productIds.size() == 0) {
productIds.add(0L);
}
queryWrapper.in(DfProductInfo::getId, productIds);
List<DfBrokerProduct> listProduct = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getBrokerId, broker.getId())
.eq(DfBrokerProduct::getStaus, "1"));
List<Long> productIdsNew = listProduct.stream()
.map(DfBrokerProduct::getProductId)
.collect(Collectors.toList());
productIdsNew.removeIf(id -> id.equals(dfProductInfo.getId()));
if (null != productIdsNew && productIdsNew.size() == 0) {
productIdsNew.add(0L);
}
queryWrapper.notIn(DfProductInfo::getId, productIdsNew);
}
queryWrapper.eq(DfProductInfo::getStatus, "1");
condition(queryWrapper,dfProductInfo);
List<DfProductInfo> list = dfProductInfoService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出产品信息列表")
@Log(title = "产品信息导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfProductInfo dfProductInfo) {
Map<String, String> cityMap = new HashMap<>();
List<DfArea> allCities = dfAreaService.list();
for (DfArea city : allCities) {
cityMap.put(city.getAreaId(), city.getName());
}
Map<Long, String> brokerProductMap = new HashMap<>();
List<DfBroker> listBroker = dfBrokerService.list();
Map<Long, String> brokerMap = new HashMap<>();
for (DfBroker broker : listBroker) {
brokerMap.put(broker.getId(), broker.getBrokerName());
}
List<DfBrokerProduct> listBrokerProduct = dfBrokerProductService.list();
for (DfBrokerProduct brokerProduct : listBrokerProduct) {
String brokerName = brokerMap.get(brokerProduct.getBrokerId());
brokerProduct.setBrokerName(brokerName);
}
for (DfBrokerProduct brokerProduct : listBrokerProduct) {
brokerProductMap.put(brokerProduct.getProductId(), brokerProduct.getBrokerName());
}
LambdaQueryWrapper<DfProductInfo> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductInfo);
List<DfProductInfo> list = dfProductInfoService.list(queryWrapper);
for (DfProductInfo productInfo : list) {
productInfo.setInterestRate(productInfo.getInterestRateBegin() + "%-" + productInfo.getInterestRateEnd() + "%");
productInfo.setProductIntro(HtmlUtils.stripHtmlTags(productInfo.getProductIntro()));
productInfo.setProductDetail(HtmlUtils.stripHtmlTags(productInfo.getProductDetail()));
String businessCity = productInfo.getBusinessCity(); // 获取原始的城市ID字符串
if (Validator.isNotEmpty(businessCity)) {
String[] cityIds = businessCity.split(","); // 按逗号分割城市ID
StringBuilder translatedCities = new StringBuilder();
for (String cityId : cityIds) {
String cityName = cityMap.get(cityId); // 从 Map 中获取城市名称
if (cityName != null) {
translatedCities.append(cityName).append(",");
}
}
if (translatedCities.length() > 0) {
translatedCities.deleteCharAt(translatedCities.length() - 1);
}
productInfo.setBusinessCity(translatedCities.toString());
productInfo.setBrokerName(brokerProductMap.get(productInfo.getId()));
}
}
ExcelUtil<DfProductInfo> util = new ExcelUtil<DfProductInfo>(DfProductInfo. class);
util.exportExcel(response, list, "产品信息数据");
}
/**
*
*/
@ApiOperation("获取产品信息详细信息")
@GetMapping(value = "/{id}")
@Anonymous
public AjaxResult getInfo(@PathVariable("id") Long id) {
Boolean isUser = true;
try {
LoginUser loginUser = getLoginUser();
} catch (Exception e) {
isUser = false;
// 捕获所有异常
e.printStackTrace(); // 或者记录日志等处理方式
}
DfProductInfo byId = dfProductInfoService.getById(id);
byId.setInterestRate(byId.getInterestRateBegin() + "%-" + byId.getInterestRateEnd() + "%");
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>().eq(DfBrokerProduct::getProductId, id));
List<DfOrder> dfOrders = dfOrderService.list();
Map<Long, Integer> productOrderCounts = new HashMap<>();
// 计算申请人数
for (DfOrder order : dfOrders) {
if (!productOrderCounts.containsKey(order.getProductId())) {
productOrderCounts.put(order.getProductId(), 1);
} else {
productOrderCounts.put(order.getProductId(), productOrderCounts.get(order.getProductId()) + 1);
}
}
Long productId = byId.getId();
if (productOrderCounts.containsKey(productId)) {
byId.setApplicantNum(Long.valueOf(productOrderCounts.get(productId)));
} else {
byId.setApplicantNum(0L);
}
if (list.size() > 0 && list != null) {
byId.setBrokerId(list.get(0).getBrokerId());
}
if (isUser == false) {
byId.setProductDetail(null);
} else {
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
List<Long> productIdsByBrokerId = dfBrokerService.getProductIdsByBrokerId();
if (!productIdsByBrokerId.contains(id)) {
byId.setProductDetail(null);
}
SysUser sysUser = sysUserMapper.selectById(getUserId());
String reviewStatus = sysUser.getReviewStatus();
if ("1".equals(reviewStatus)) {
byId.setProductDetail(null);
}
}
}
String businessCity = byId.getBusinessCity();
if (Validator.isEmpty(businessCity)) {
return success(byId);
}
List<String> businessCityList = Arrays.asList(businessCity.split(","));
List<DfArea> douAreas = dfAreaService.listByIds(businessCityList);
String concatenatedNames = douAreas.stream()
.map(DfArea::getName)
.collect(Collectors.joining(","));
byId.setBusinessCityByName(concatenatedNames);
return success(byId);
}
/**
*
*/
@ApiOperation("根据经纪人获取产品信息详细信息")
@GetMapping(value = "/getInfoByUserId/{id}")
@Anonymous
public AjaxResult getInfoByUserId(@PathVariable("id") Long id) {
List<Long> productIdsByBrokerIdByUserId = dfBrokerService.getProductIdsByBrokerIdByUserId(id);
if (productIdsByBrokerIdByUserId.size() == 0) {
return success(null);
}
List<DfProductInfo> list = dfProductInfoService.list(new LambdaQueryWrapper<DfProductInfo>().in(DfProductInfo::getId, productIdsByBrokerIdByUserId));
for (DfProductInfo productInfo : list) {
productInfo.setProductDetail(null);
}
List<DfOrder> dfOrders = dfOrderService.list();
Map<Long, Integer> productOrderCounts = new HashMap<>();
// 计算申请人数
for (DfOrder order : dfOrders) {
if (!productOrderCounts.containsKey(order.getProductId())) {
productOrderCounts.put(order.getProductId(), 1);
} else {
productOrderCounts.put(order.getProductId(), productOrderCounts.get(order.getProductId()) + 1);
}
}
for (DfProductInfo productInfo : list) {
productInfo.setInterestRate(productInfo.getInterestRateBegin() + "%-" + productInfo.getInterestRateEnd() + "%");
Long productId = productInfo.getId();
if (productOrderCounts.containsKey(productId)) {
productInfo.setApplicantNum(Long.valueOf(productOrderCounts.get(productId)));
} else {
productInfo.setApplicantNum(0L);
}
}
return success(list);
}
/**
*
*/
@ApiOperation("根据代理商获取产品信息详细信息")
@PutMapping(value = "/getInfoByBroker")
@Anonymous
public AjaxResult getInfoByBroker(@RequestBody DfProductInfo dfProductInfo) {
if(Validator.isNotEmpty(dfProductInfo.getBrokerId())) {
DfProductInfo byId = dfProductInfoService.getById(dfProductInfo.getId());
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getBrokerId, dfProductInfo.getBrokerId())
.eq(DfBrokerProduct::getProductId, dfProductInfo.getId()));
if (list.size() > 0 && list != null) {
byId.setBrokerId(list.get(0).getBrokerId());
}
String businessCity = byId.getBusinessCity();
if (Validator.isEmpty(businessCity)) {
return success(byId);
}
List<String> businessCityList = Arrays.asList(businessCity.split(","));
List<DfArea> douAreas = dfAreaService.listByIds(businessCityList);
String concatenatedNames = douAreas.stream()
.map(DfArea::getName)
.collect(Collectors.joining(","));
byId.setBusinessCityByName(concatenatedNames);
return success(byId);
} else {
DfProductInfo byId = dfProductInfoService.getById(dfProductInfo.getId());
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getUserId, dfProductInfo.getUserId())
.eq(DfBrokerProduct::getProductId, dfProductInfo.getId()));
if (list.size() > 0 && list != null) {
byId.setUserId(list.get(0).getUserId());
}
String businessCity = byId.getBusinessCity();
if (Validator.isEmpty(businessCity)) {
return success(byId);
}
List<String> businessCityList = Arrays.asList(businessCity.split(","));
List<DfArea> douAreas = dfAreaService.listByIds(businessCityList);
String concatenatedNames = douAreas.stream()
.map(DfArea::getName)
.collect(Collectors.joining(","));
byId.setBusinessCityByName(concatenatedNames);
return success(byId);
}
}
/**
*
*/
@ApiOperation("新增产品信息")
@Log(title = "产品信息新增", businessType = BusinessType.INSERT)
@PostMapping
@Anonymous
public AjaxResult add(@RequestBody DfProductInfo dfProductInfo) {
return toAjax(dfProductInfoService.save(dfProductInfo));
}
/**
*
*/
@ApiOperation("修改产品信息")
@Log(title = "产品信息修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfProductInfo dfProductInfo) {
return toAjax(dfProductInfoService.updateById(dfProductInfo));
}
/**
*
*/
@ApiOperation("删除产品信息")
@Log(title = "产品信息删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
List<DfProductPoster> list = dfProductPosterService.list(new LambdaQueryWrapper<DfProductPoster>().in(DfProductPoster::getProductId, ids));
List<DfProductInfo> infos = dfProductInfoService.list(new LambdaQueryWrapper<DfProductInfo>().in(DfProductInfo::getId, ids));
for (DfProductInfo dfProductInfo : infos) {
if ("1".equals(dfProductInfo.getStatus())) {
return AjaxResult.warn("该产品已经上架,请先下架再删除");
}
}
if(list.size() > 0){
return AjaxResult.warn("该产品下有海报,请先删除海报");
}
return toAjax(dfProductInfoService.removeBatchByIds(ids));
}
/**
*
*/
@ApiOperation("修改产品状态")
@Log(title = "修改产品状态", businessType = BusinessType.DELETE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody DfProductInfo dfProductInfo) {
Long[] ids = dfProductInfo.getIds();
String status = dfProductInfo.getStatus();
List<DfProductInfo> dfProductInfos = new ArrayList<>();
for (Long id : ids) {
DfProductInfo dfProductInfoNew = new DfProductInfo();
dfProductInfoNew.setId(id);
dfProductInfoNew.setStatus(status);
dfProductInfos.add(dfProductInfoNew);
}
if ("0".equals(status)) {
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>().in(DfBrokerProduct::getProductId, ids));
for (DfBrokerProduct dfBrokerProduct : list) {
dfBrokerProduct.setStaus("0");
}
dfBrokerProductService.updateBatchById(list);
}
if ("1".equals(dfProductInfo.getIsBroker())) {
if ("1".equals(status)) {
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>().in(DfBrokerProduct::getProductId, ids));
for (DfBrokerProduct dfBrokerProduct : list) {
dfBrokerProduct.setStaus("1");
}
dfBrokerProductService.updateBatchById(list);
}
}
return toAjax(dfProductInfoService.updateBatchById(dfProductInfos));
}
/**
*
*/
@ApiOperation("获取产品相关代理商数量")
@GetMapping(value = "/getBrokerNum/{ids}")
public AjaxResult getBrokerNum(@PathVariable("ids") List<Long> ids) {
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>().in(DfBrokerProduct::getProductId, ids));
list.size();
return success(list.size());
}
/**
*
*/
@ApiOperation("修改代理产品权限")
@Log(title = "代理产品权限修改", businessType = BusinessType.UPDATE)
@PutMapping("/editByBroker")
public AjaxResult editByBroker(@RequestBody DfProductInfo dfProductInfo) {
Long productInfoId = dfProductInfo.getId();
Long brokerId = dfProductInfo.getBrokerId();
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>().eq(DfBrokerProduct::getProductId, productInfoId)
.eq(DfBrokerProduct::getBrokerId, brokerId));
if (list != null && list.size() > 0) {
DfBrokerProduct dfBrokerProduct = new DfBrokerProduct().setBrokerId(brokerId).setProductId(productInfoId).setId(list.get(0).getId());
dfBrokerProduct.setStaus("1");
return toAjax(dfBrokerProductService.updateById(dfBrokerProduct));
} else {
DfBrokerProduct dfBrokerProduct = new DfBrokerProduct().setBrokerId(brokerId).setProductId(productInfoId);
dfBrokerProduct.setStaus("1");
return toAjax(dfBrokerProductService.save(dfBrokerProduct));
}
}
/**
*
*/
@ApiOperation("修改代理产品权限")
@Log(title = "代理产品权限修改", businessType = BusinessType.UPDATE)
@PutMapping("/editByBrokers")
public AjaxResult editByBrokers(@RequestBody DfProductInfo dfProductInfo) {
for (Long id : dfProductInfo.getIds()) {
if (Validator.isNotEmpty(dfProductInfo.getUserId())) {
Long productInfoId = id;
String userId = dfProductInfo.getUserId();
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getProductId, productInfoId)
.eq(DfBrokerProduct::getBrokerId, userId));
if (list != null && list.size() > 0) {
DfBrokerProduct dfBrokerProduct = new DfBrokerProduct().setUserId(userId).setProductId(productInfoId).setId(list.get(0).getId());
dfBrokerProduct.setStaus("1");
dfBrokerProductService.updateById(dfBrokerProduct);
} else {
DfBrokerProduct dfBrokerProduct = new DfBrokerProduct().setUserId(userId).setProductId(productInfoId);
dfBrokerProduct.setStaus("1");
dfBrokerProductService.save(dfBrokerProduct);
}
} else {
Long productInfoId = id;
Long brokerId = dfProductInfo.getBrokerId();
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.eq(DfBrokerProduct::getProductId, productInfoId)
.eq(DfBrokerProduct::getBrokerId, brokerId));
if (list != null && list.size() > 0) {
DfBrokerProduct dfBrokerProduct = new DfBrokerProduct().setBrokerId(brokerId).setProductId(productInfoId).setId(list.get(0).getId());
dfBrokerProduct.setStaus("1");
dfBrokerProductService.updateById(dfBrokerProduct);
} else {
DfBrokerProduct dfBrokerProduct = new DfBrokerProduct().setBrokerId(brokerId).setProductId(productInfoId);
dfBrokerProduct.setStaus("1");
dfBrokerProductService.save(dfBrokerProduct);
}
}
}
return toAjax(true);
}
/**
*
*/
@ApiOperation("移除代理产品权限")
@Log(title = "代理产品权限移除", businessType = BusinessType.DELETE)
@PutMapping("/removeByBroker")
public AjaxResult removeByBroker(@RequestBody DfProductInfo dfProductInfo) {
Long[] ids = dfProductInfo.getIds();
Long brokerId = dfProductInfo.getBrokerId();
if (Validator.isNotEmpty(dfProductInfo.getUserId())) {
boolean remove = dfBrokerProductService.remove(new LambdaQueryWrapper<DfBrokerProduct>()
.in(DfBrokerProduct::getProductId, ids)
.in(DfBrokerProduct::getUserId, dfProductInfo.getUserId()));
return toAjax(remove);
} else {
List<DfBroker> allSubordinates = dfBrokerService.findAllSubordinates(brokerId);
List<Long> brokerIds = allSubordinates.stream()
.map(DfBroker::getId)
.collect(Collectors.toList());
brokerIds.add(brokerId);
boolean remove = dfBrokerProductService.remove(new LambdaQueryWrapper<DfBrokerProduct>()
.in(DfBrokerProduct::getProductId, ids)
.in(DfBrokerProduct::getBrokerId, brokerIds));
return toAjax(remove);
}
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfProductInfo> queryWrapper,DfProductInfo dfProductInfo){
//产品id
if(Validator.isNotEmpty(dfProductInfo.getId())){
queryWrapper.eq(DfProductInfo::getId,dfProductInfo.getId());
}
//产品名称
if(Validator.isNotEmpty(dfProductInfo.getProductName())){
queryWrapper.like(DfProductInfo::getProductName,dfProductInfo.getProductName());
}
//产品简称
if(Validator.isNotEmpty(dfProductInfo.getSimpleName())){
queryWrapper.like(DfProductInfo::getSimpleName,dfProductInfo.getSimpleName());
}
//产品类型
if(Validator.isNotEmpty(dfProductInfo.getProductType())){
queryWrapper.eq(DfProductInfo::getProductType,dfProductInfo.getProductType());
}
//产品细类
if(Validator.isNotEmpty(dfProductInfo.getProductSubtype())){
queryWrapper.eq(DfProductInfo::getProductSubtype,dfProductInfo.getProductSubtype());
}
//最高额度(元)
if(Validator.isNotEmpty(dfProductInfo.getMaxAmount())){
queryWrapper.eq(DfProductInfo::getMaxAmount,dfProductInfo.getMaxAmount());
}
if(Validator.isNotEmpty(dfProductInfo.getMaxAmountBegin())){
queryWrapper.ge(DfProductInfo::getMaxAmount,dfProductInfo.getMaxAmountBegin());
}
if(Validator.isNotEmpty(dfProductInfo.getMaxAmountEnd())){
queryWrapper.le(DfProductInfo::getMaxAmount,dfProductInfo.getMaxAmountEnd());
}
//年利率(单利)
if(Validator.isNotEmpty(dfProductInfo.getInterestRateBegin())){
queryWrapper.ge(DfProductInfo::getInterestRateBegin,dfProductInfo.getInterestRateBegin());
}
if(Validator.isNotEmpty(dfProductInfo.getInterestRateEnd())){
queryWrapper.le(DfProductInfo::getInterestRateEnd,dfProductInfo.getInterestRateEnd());
}
//产品简介
if(Validator.isNotEmpty(dfProductInfo.getProductIntro())){
queryWrapper.eq(DfProductInfo::getProductIntro,dfProductInfo.getProductIntro());
}
//产品详情(富文本)
if(Validator.isNotEmpty(dfProductInfo.getProductDetail())){
queryWrapper.eq(DfProductInfo::getProductDetail,dfProductInfo.getProductDetail());
}
//上架时间起
if(Validator.isNotEmpty(dfProductInfo.getListBegin())){
queryWrapper.ge(DfProductInfo::getListBegin,dfProductInfo.getListBegin());
}
//上架时间止
if(Validator.isNotEmpty(dfProductInfo.getListEnd())){
queryWrapper.le(DfProductInfo::getListEnd,dfProductInfo.getListEnd());
}
if(Validator.isNotEmpty(dfProductInfo.getParams().get("beginTime"))){
queryWrapper.ge(DfProductInfo::getListBegin,dfProductInfo.getParams().get("beginTime"));
}
if(Validator.isNotEmpty(dfProductInfo.getParams().get("endTime"))){
queryWrapper.le(DfProductInfo::getListEnd,dfProductInfo.getParams().get("endTime"));
}
//还款周期
if(Validator.isNotEmpty(dfProductInfo.getRepaymentCycle())){
queryWrapper.eq(DfProductInfo::getRepaymentCycle,dfProductInfo.getRepaymentCycle());
}
//还款方式
if(Validator.isNotEmpty(dfProductInfo.getRepaymentMethod())){
queryWrapper.eq(DfProductInfo::getRepaymentMethod,dfProductInfo.getRepaymentMethod());
}
//展业城市
if(Validator.isNotEmpty(dfProductInfo.getBusinessCity())){
queryWrapper.eq(DfProductInfo::getBusinessCity,dfProductInfo.getBusinessCity());
}
//综合费率
if(Validator.isNotEmpty(dfProductInfo.getCombinedRates())){
queryWrapper.eq(DfProductInfo::getCombinedRates,dfProductInfo.getCombinedRates());
}
//状态0草稿1上架
if(Validator.isNotEmpty(dfProductInfo.getStatus())){
queryWrapper.eq(DfProductInfo::getStatus,dfProductInfo.getStatus());
}
//备注
if(Validator.isNotEmpty(dfProductInfo.getRemark())){
queryWrapper.eq(DfProductInfo::getRemark,dfProductInfo.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfProductInfo.getCreateDept())){
queryWrapper.eq(DfProductInfo::getCreateDept,dfProductInfo.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfProductInfo.getCreateBy())){
queryWrapper.eq(DfProductInfo::getCreateBy,dfProductInfo.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfProductInfo.getCreateTime())){
queryWrapper.eq(DfProductInfo::getCreateTime,dfProductInfo.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfProductInfo.getUpdateBy())){
queryWrapper.eq(DfProductInfo::getUpdateBy,dfProductInfo.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfProductInfo.getUpdateTime())){
queryWrapper.eq(DfProductInfo::getUpdateTime,dfProductInfo.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfProductInfo.getDelFlag())){
queryWrapper.eq(DfProductInfo::getDelFlag,dfProductInfo.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfProductInfo.getTenantId())){
queryWrapper.eq(DfProductInfo::getTenantId,dfProductInfo.getTenantId());
}
}
}

@ -0,0 +1,280 @@
package com.bs.df.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.df.domain.DfProductArticle;
import com.bs.df.domain.DfProductPoster;
import com.bs.df.utils.HtmlUtils;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.service.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfProductMoment;
import com.bs.df.service.IDfProductMomentService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "产品朋友圈")
@RestController
@RequestMapping("/moment/moment")
public class DfProductMomentController extends BaseController {
@Resource
private IDfProductMomentService dfProductMomentService;
@Resource
private ICmAttachService cmAttachService;
@Resource
private ISysUserService userService;
@Autowired
private SysUserMapper sysUserMapper;
/**
*
*/
@ApiOperation("分页查询产品朋友圈列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfProductMoment dfProductMoment) {
SysUser sysUser = sysUserMapper.selectById(getUserId());
startPage();
String reviewStatus = sysUser.getReviewStatus();
if ("1".equals(reviewStatus)) {
return null;
}
LambdaQueryWrapper<DfProductMoment> queryWrapper = new LambdaQueryWrapper();
if (Validator.isEmpty(dfProductMoment.getOrderByColumn())) {
queryWrapper.orderByDesc(DfProductMoment::getCreateTime);
}
condition(queryWrapper,dfProductMoment);
boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId());
if (!admin) {
if (!sysUser.getDeptId().equals(-1L)) {
if ("-99".equals(dfProductMoment.getStatus())) {
} else {
SysUser byId = userService.getById(SecurityUtils.getUserId());
if ("jj".equals(byId.getUserType()) || "kh".equals(byId.getUserType())) {
queryWrapper.eq(DfProductMoment::getStatus, "1");
}
}
}
}
List<DfProductMoment> list = dfProductMomentService.list(queryWrapper);
List<CmAttach> attachVo = cmAttachService.list();
Map<String, List<CmAttach>> attachMap = attachVo.stream()
.filter(cmAttach -> cmAttach.getFileId() != null)
.collect(Collectors.groupingBy(CmAttach::getFileId));
for (DfProductMoment moment : list) {
moment.setMomentContent(HtmlUtils.stripHtmlTags(moment.getMomentContent()));
String id = moment.getId();
List<CmAttach> matchingAttachments = attachMap.get(String.valueOf(id));
if (matchingAttachments != null) {
moment.setFiles(matchingAttachments);
}
}
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询产品朋友圈列表")
@GetMapping("/list")
public AjaxResult list(DfProductMoment dfProductMoment) {
LambdaQueryWrapper<DfProductMoment> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductMoment);
List<DfProductMoment> list = dfProductMomentService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出产品朋友圈列表")
@Log(title = "产品朋友圈导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfProductMoment dfProductMoment) {
LambdaQueryWrapper<DfProductMoment> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductMoment);
List<DfProductMoment> list = dfProductMomentService.list(queryWrapper);
for (DfProductMoment moment : list) {
moment.setMomentContent(HtmlUtils.stripHtmlTags(moment.getMomentContent()));
}
ExcelUtil<DfProductMoment> util = new ExcelUtil<DfProductMoment>(DfProductMoment. class);
util.exportExcel(response, list, "产品朋友圈数据");
}
/**
*
*/
@ApiOperation("获取产品朋友圈详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
DfProductMoment byId = dfProductMomentService.getById(id);
List<CmAttach> attachVo = cmAttachService.list(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId, id));
byId.setFiles(attachVo);
return success(byId);
}
/**
*
*/
@ApiOperation("新增产品朋友圈")
@Log(title = "产品朋友圈新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfProductMoment dfProductMoment) {
return toAjax(dfProductMomentService.save(dfProductMoment));
}
/**
*
*/
@ApiOperation("修改产品朋友圈")
@Log(title = "产品朋友圈修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfProductMoment dfProductMoment) {
return toAjax(dfProductMomentService.updateById(dfProductMoment));
}
/**
*
*/
@ApiOperation("修改产品朋友圈状态")
@Log(title = "修改产品朋友圈状态", businessType = BusinessType.DELETE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody DfProductMoment dfProductMoment) {
String[] ids = dfProductMoment.getIds();
String status = dfProductMoment.getStatus();
List<DfProductMoment> dfProductMoments = new ArrayList<>();
for (String id : ids) {
DfProductMoment dfProductMomentNew = new DfProductMoment();
dfProductMomentNew.setId(id);
dfProductMomentNew.setStatus(status);
dfProductMoments.add(dfProductMomentNew);
}
return toAjax(dfProductMomentService.updateBatchById(dfProductMoments));
}
/**
*
*/
@ApiOperation("删除产品朋友圈")
@Log(title = "产品朋友圈删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<String> ids) {
List<DfProductMoment> list = dfProductMomentService.list(new LambdaQueryWrapper<DfProductMoment>()
.in(DfProductMoment::getId, ids));
for (DfProductMoment dfProductMoment : list) {
if ("1".equals(dfProductMoment.getStatus())) {
return AjaxResult.warn("该产品朋友圈已经上架,请先下架再删除");
}
}
return toAjax(dfProductMomentService.removeBatchByIds(ids));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfProductMoment> queryWrapper,DfProductMoment dfProductMoment){
//朋友圈id
if(Validator.isNotEmpty(dfProductMoment.getId())){
queryWrapper.eq(DfProductMoment::getId,dfProductMoment.getId());
}
//朋友圈分类0产品朋友圈1经纪朋友圈
if(Validator.isNotEmpty(dfProductMoment.getMomentType())){
queryWrapper.eq(DfProductMoment::getMomentType,dfProductMoment.getMomentType());
}
//朋友圈类型
if(Validator.isNotEmpty(dfProductMoment.getMomentKind())){
queryWrapper.eq(DfProductMoment::getMomentKind,dfProductMoment.getMomentKind());
}
//朋友圈标题
if(Validator.isNotEmpty(dfProductMoment.getMomentTitle())){
queryWrapper.eq(DfProductMoment::getMomentTitle,dfProductMoment.getMomentTitle());
}
//朋友圈正文
if(Validator.isNotEmpty(dfProductMoment.getMomentContent())){
queryWrapper.eq(DfProductMoment::getMomentContent,dfProductMoment.getMomentContent());
}
//状态0草稿1上架
if(Validator.isNotEmpty(dfProductMoment.getStatus())){
queryWrapper.eq(DfProductMoment::getStatus,dfProductMoment.getStatus());
}
//备注
if(Validator.isNotEmpty(dfProductMoment.getRemark())){
queryWrapper.eq(DfProductMoment::getRemark,dfProductMoment.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfProductMoment.getCreateDept())){
queryWrapper.eq(DfProductMoment::getCreateDept,dfProductMoment.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfProductMoment.getCreateBy())){
queryWrapper.eq(DfProductMoment::getCreateBy,dfProductMoment.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfProductMoment.getCreateTime())){
queryWrapper.eq(DfProductMoment::getCreateTime,dfProductMoment.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfProductMoment.getUpdateBy())){
queryWrapper.eq(DfProductMoment::getUpdateBy,dfProductMoment.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfProductMoment.getUpdateTime())){
queryWrapper.eq(DfProductMoment::getUpdateTime,dfProductMoment.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfProductMoment.getDelFlag())){
queryWrapper.eq(DfProductMoment::getDelFlag,dfProductMoment.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfProductMoment.getTenantId())){
queryWrapper.eq(DfProductMoment::getTenantId,dfProductMoment.getTenantId());
}
}
}

@ -0,0 +1,402 @@
package com.bs.df.controller;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.df.domain.DfOrder;
import com.bs.df.domain.DfProductArticle;
import com.bs.df.domain.DfProductInfo;
import com.bs.df.service.IDfBrokerService;
import com.bs.df.service.IDfProductInfoService;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.service.ISysUserService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfProductPoster;
import com.bs.df.service.IDfProductPosterService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "产品海报")
@RestController
@RequestMapping("/poster/poster")
public class DfProductPosterController extends BaseController {
@Resource
private IDfProductPosterService dfProductPosterService;
@Resource
private IDfProductInfoService dfProductInfoService;
@Autowired
private ICmAttachService cmAttachService;
@Resource
private IDfBrokerService dfBrokerService;;
@Resource
private ISysUserService userService;
@Autowired
private SysUserMapper sysUserMapper;
/**
*
*/
@ApiOperation("分页查询产品海报列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfProductPoster dfProductPoster) {
SysUser sysUser = sysUserMapper.selectById(getUserId());
String reviewStatus = sysUser.getReviewStatus();
if ("1".equals(reviewStatus)) {
return null;
}
MPJLambdaWrapper<DfProductPoster> queryWrapper = new MPJLambdaWrapper();
queryWrapper.selectAll(DfProductPoster.class)
.select(DfProductInfo::getProductName)
.disableSubLogicDel()
.leftJoin(DfProductInfo.class,DfProductInfo::getId,DfProductPoster::getProductId);
if (Validator.isEmpty(dfProductPoster.getOrderByColumn())) {
queryWrapper.last("ORDER BY CASE WHEN t.serial_number IS NULL THEN 1 ELSE 0 END, t.serial_number ASC");
}
if (!SecurityUtils.isAdmin(SecurityUtils.getUserId())) {
if (!sysUser.getDeptId().equals(-1L)) {
if ("-99".equals(dfProductPoster.getStatus())) {
} else {
List<Long> productIdsByBrokerId = dfBrokerService.getProductIdsByBrokerId();
List<DfProductPoster> list = dfProductPosterService.list(new LambdaQueryWrapper<DfProductPoster>()
.eq(DfProductPoster::getPosterType, "1"));
List<Long> productIds = list.stream()
.map(DfProductPoster::getProductId)
.collect(Collectors.toList());
if (productIdsByBrokerId.size() == 0) {
productIdsByBrokerId.add(0L);
}
productIdsByBrokerId.addAll(productIds);
queryWrapper.nested(wrapper -> wrapper.in(DfProductPoster::getProductId, productIdsByBrokerId)
.or()
.isNull(DfProductPoster::getProductId));
SysUser byId = userService.getById(SecurityUtils.getUserId());
if ("jj".equals(byId.getUserType()) || "kh".equals(byId.getUserType())) {
queryWrapper.eq(DfProductPoster::getStatus,"1");
}
}
}
}
conditionByMPJ(queryWrapper,dfProductPoster);
startPage();
List<DfProductPoster> list = dfProductPosterService.list(queryWrapper);
List<CmAttach> attachVo = cmAttachService.list();
Map<String, List<CmAttach>> attachMap = attachVo.stream()
.filter(cmAttach -> cmAttach.getFileId() != null)
.collect(Collectors.groupingBy(CmAttach::getFileId));
for (DfProductPoster dfProductPosterVo : list) {
String id = dfProductPosterVo.getId();
List<CmAttach> matchingAttachments = attachMap.get(String.valueOf(id));
if (matchingAttachments != null) {
dfProductPosterVo.setFiles(matchingAttachments);
}
if ("1".equals(dfProductPosterVo.getPosterType())) {
dfProductPosterVo.setProductName(null);
}
}
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询产品海报列表")
@GetMapping("/list")
public AjaxResult list(DfProductPoster dfProductPoster) {
LambdaQueryWrapper<DfProductPoster> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductPoster);
List<DfProductPoster> list = dfProductPosterService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出产品海报列表")
@Log(title = "产品海报导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfProductPoster dfProductPoster) {
MPJLambdaWrapper<DfProductPoster> queryWrapper = new MPJLambdaWrapper();
queryWrapper.selectAll(DfProductPoster.class)
.select(DfProductInfo::getProductName)
.disableSubLogicDel()
.leftJoin(DfProductInfo.class,DfProductInfo::getId,DfProductPoster::getProductId);
conditionByMPJ(queryWrapper,dfProductPoster);
List<DfProductPoster> list = dfProductPosterService.list(queryWrapper);
ExcelUtil<DfProductPoster> util = new ExcelUtil<DfProductPoster>(DfProductPoster. class);
util.exportExcel(response, list, "产品海报数据");
}
/**
*
*/
@ApiOperation("获取产品海报详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
DfProductPoster byId = dfProductPosterService.getById(id);
List<CmAttach> attachVo = cmAttachService.list(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId, id));
byId.setFiles(attachVo);
return success(byId);
}
/**
*
*/
@ApiOperation("新增产品海报")
@Log(title = "产品海报新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfProductPoster dfProductPoster) {
if ("1".equals(dfProductPoster.getPosterType())) {
dfProductPoster.setProductId(-1L);
}
return toAjax(dfProductPosterService.save(dfProductPoster));
}
/**
*
*/
@ApiOperation("修改产品海报")
@Log(title = "产品海报修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfProductPoster dfProductPoster) {
if ("1".equals(dfProductPoster.getPosterType())) {
dfProductPoster.setProductId(-1L);
}
return toAjax(dfProductPosterService.updateById(dfProductPoster));
}
/**
*
*/
@ApiOperation("修改产品海报状态")
@Log(title = "修改产品海报状态", businessType = BusinessType.DELETE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody DfProductPoster dfProductPoster) {
String[] ids = dfProductPoster.getIds();
String status = dfProductPoster.getStatus();
List<DfProductPoster> dfProductPosters = new ArrayList<>();
for (String id : ids) {
DfProductPoster dfProductPosterNew = new DfProductPoster();
dfProductPosterNew.setId(id);
dfProductPosterNew.setStatus(status);
dfProductPosters.add(dfProductPosterNew);
}
return toAjax(dfProductPosterService.updateBatchById(dfProductPosters));
}
/**
*
*/
@ApiOperation("删除产品海报")
@Log(title = "产品海报删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<String> ids) {
List<DfProductPoster> list = dfProductPosterService.list(new LambdaQueryWrapper<DfProductPoster>().in(DfProductPoster::getId, ids));
for (DfProductPoster dfProductPoster : list) {
if ("1".equals(dfProductPoster.getStatus())) {
return AjaxResult.warn("该海报已经上架,请先下架再删除");
}
}
return toAjax(dfProductPosterService.removeBatchByIds(ids));
}
private void conditionByMPJ (MPJLambdaWrapper<DfProductPoster> queryWrapper,DfProductPoster dfProductPoster){
//海报id
if(Validator.isNotEmpty(dfProductPoster.getId())){
queryWrapper.eq(DfProductPoster::getId,dfProductPoster.getId());
}
//产品id
if(Validator.isNotEmpty(dfProductPoster.getProductId())){
queryWrapper.eq(DfProductPoster::getProductId,dfProductPoster.getProductId());
}
//产品名称
if(Validator.isNotEmpty(dfProductPoster.getProductName())){
queryWrapper.like(DfProductInfo::getProductName,dfProductPoster.getProductName());
}
//海报分类0产品海报1经纪海报
if(Validator.isNotEmpty(dfProductPoster.getPosterType())){
queryWrapper.eq(DfProductPoster::getPosterType,dfProductPoster.getPosterType());
}
//海报名称
if(Validator.isNotEmpty(dfProductPoster.getPosterName())){
queryWrapper.like(DfProductPoster::getPosterName,dfProductPoster.getPosterName());
}
//海报标签
if(Validator.isNotEmpty(dfProductPoster.getPosterTag())){
queryWrapper.eq(DfProductPoster::getPosterTag,dfProductPoster.getPosterTag());
}
//海报图片id
if(Validator.isNotEmpty(dfProductPoster.getPosterFileId())){
queryWrapper.eq(DfProductPoster::getPosterFileId,dfProductPoster.getPosterFileId());
}
//状态0草稿1上架
if(Validator.isNotEmpty(dfProductPoster.getStatus())){
queryWrapper.eq(DfProductPoster::getStatus,dfProductPoster.getStatus());
}
//备注
if(Validator.isNotEmpty(dfProductPoster.getRemark())){
queryWrapper.eq(DfProductPoster::getRemark,dfProductPoster.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfProductPoster.getCreateDept())){
queryWrapper.eq(DfProductPoster::getCreateDept,dfProductPoster.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfProductPoster.getCreateBy())){
queryWrapper.eq(DfProductPoster::getCreateBy,dfProductPoster.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfProductPoster.getCreateTime())){
queryWrapper.eq(DfProductPoster::getCreateTime,dfProductPoster.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfProductPoster.getUpdateBy())){
queryWrapper.eq(DfProductPoster::getUpdateBy,dfProductPoster.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfProductPoster.getUpdateTime())){
queryWrapper.eq(DfProductPoster::getUpdateTime,dfProductPoster.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfProductPoster.getDelFlag())){
queryWrapper.eq(DfProductPoster::getDelFlag,dfProductPoster.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfProductPoster.getTenantId())){
queryWrapper.eq(DfProductPoster::getTenantId,dfProductPoster.getTenantId());
}
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfProductPoster> queryWrapper,DfProductPoster dfProductPoster){
//海报id
if(Validator.isNotEmpty(dfProductPoster.getId())){
queryWrapper.eq(DfProductPoster::getId,dfProductPoster.getId());
}
//产品id
if(Validator.isNotEmpty(dfProductPoster.getProductId())){
queryWrapper.eq(DfProductPoster::getProductId,dfProductPoster.getProductId());
}
//海报分类0产品海报1经纪海报
if(Validator.isNotEmpty(dfProductPoster.getPosterType())){
queryWrapper.eq(DfProductPoster::getPosterType,dfProductPoster.getPosterType());
}
//海报名称
if(Validator.isNotEmpty(dfProductPoster.getPosterName())){
queryWrapper.eq(DfProductPoster::getPosterName,dfProductPoster.getPosterName());
}
//海报标签
if(Validator.isNotEmpty(dfProductPoster.getPosterTag())){
queryWrapper.eq(DfProductPoster::getPosterTag,dfProductPoster.getPosterTag());
}
//海报图片id
if(Validator.isNotEmpty(dfProductPoster.getPosterFileId())){
queryWrapper.eq(DfProductPoster::getPosterFileId,dfProductPoster.getPosterFileId());
}
//状态0草稿1上架
if(Validator.isNotEmpty(dfProductPoster.getStatus())){
queryWrapper.eq(DfProductPoster::getStatus,dfProductPoster.getStatus());
}
//备注
if(Validator.isNotEmpty(dfProductPoster.getRemark())){
queryWrapper.eq(DfProductPoster::getRemark,dfProductPoster.getRemark());
}
//创建部门
if(Validator.isNotEmpty(dfProductPoster.getCreateDept())){
queryWrapper.eq(DfProductPoster::getCreateDept,dfProductPoster.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfProductPoster.getCreateBy())){
queryWrapper.eq(DfProductPoster::getCreateBy,dfProductPoster.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfProductPoster.getCreateTime())){
queryWrapper.eq(DfProductPoster::getCreateTime,dfProductPoster.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfProductPoster.getUpdateBy())){
queryWrapper.eq(DfProductPoster::getUpdateBy,dfProductPoster.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfProductPoster.getUpdateTime())){
queryWrapper.eq(DfProductPoster::getUpdateTime,dfProductPoster.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfProductPoster.getDelFlag())){
queryWrapper.eq(DfProductPoster::getDelFlag,dfProductPoster.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfProductPoster.getTenantId())){
queryWrapper.eq(DfProductPoster::getTenantId,dfProductPoster.getTenantId());
}
}
}

@ -0,0 +1,175 @@
package com.bs.df.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.bs.common.annotation.Anonymous;
import com.bs.df.domain.DfBrokerProduct;
import com.bs.df.domain.DfProductInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfProductRecommend;
import com.bs.df.service.IDfProductRecommendService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-09-16
*/
@Api(tags = "代理产品推荐")
@RestController
@RequestMapping("/product/recommend")
public class DfProductRecommendController extends BaseController {
@Resource
private IDfProductRecommendService dfProductRecommendService;
/**
*
*/
@ApiOperation("分页查询代理产品推荐列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfProductRecommend dfProductRecommend) {
startPage();
LambdaQueryWrapper<DfProductRecommend> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductRecommend);
List<DfProductRecommend> list = dfProductRecommendService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询代理产品推荐列表")
@GetMapping("/list")
public AjaxResult list(DfProductRecommend dfProductRecommend) {
LambdaQueryWrapper<DfProductRecommend> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductRecommend);
List<DfProductRecommend> list = dfProductRecommendService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出代理产品推荐列表")
@Log(title = "代理产品推荐导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfProductRecommend dfProductRecommend) {
LambdaQueryWrapper<DfProductRecommend> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfProductRecommend);
List<DfProductRecommend> list = dfProductRecommendService.list(queryWrapper);
ExcelUtil<DfProductRecommend> util = new ExcelUtil<DfProductRecommend>(DfProductRecommend. class);
util.exportExcel(response, list, "代理产品推荐数据");
}
/**
*
*/
@ApiOperation("获取代理产品推荐详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
return success(dfProductRecommendService.getById(id));
}
/**
*
*/
@ApiOperation("修改代理产品推荐")
@Log(title = "代理产品推荐修改", businessType = BusinessType.UPDATE)
@PutMapping("/editByProducts")
public AjaxResult editByProducts(@RequestBody DfProductRecommend dfProductRecommend) {
for (Long productId : dfProductRecommend.getIds()) {
DfProductRecommend productRecommend = new DfProductRecommend();
productRecommend.setProductId(String.valueOf(productId));
productRecommend.setUserId(dfProductRecommend.getUserId());
dfProductRecommendService.save(productRecommend);
}
return toAjax(true);
}
/**
*
*/
@ApiOperation("新增代理产品推荐")
@Log(title = "代理产品推荐新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfProductRecommend dfProductRecommend) {
return toAjax(dfProductRecommendService.save(dfProductRecommend));
}
/**
*
*/
@ApiOperation("修改代理产品推荐")
@Log(title = "代理产品推荐修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfProductRecommend dfProductRecommend) {
return toAjax(dfProductRecommendService.updateById(dfProductRecommend));
}
/**
*
*/
@ApiOperation("删除代理产品推荐")
@Log(title = "代理产品推荐删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(dfProductRecommendService.removeBatchByIds(ids));
}
/**
*
*/
@ApiOperation("移除代理产品推荐")
@Log(title = "代理产品推荐移除", businessType = BusinessType.DELETE)
@PostMapping("/delInfoByRecommend")
public AjaxResult delInfoByRecommend(@RequestBody DfProductRecommend dfProductRecommend) {
boolean remove = dfProductRecommendService.remove(new LambdaQueryWrapper<DfProductRecommend>().in(DfProductRecommend::getProductId, dfProductRecommend.getIds())
.eq(DfProductRecommend::getUserId, dfProductRecommend.getUserId()));
return toAjax(remove);
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfProductRecommend> queryWrapper,DfProductRecommend dfProductRecommend){
//主键
if(Validator.isNotEmpty(dfProductRecommend.getId())){
queryWrapper.eq(DfProductRecommend::getId,dfProductRecommend.getId());
}
//用户id
if(Validator.isNotEmpty(dfProductRecommend.getUserId())){
queryWrapper.eq(DfProductRecommend::getUserId,dfProductRecommend.getUserId());
}
//产品id
if(Validator.isNotEmpty(dfProductRecommend.getProductId())){
queryWrapper.eq(DfProductRecommend::getProductId,dfProductRecommend.getProductId());
}
}
}

@ -0,0 +1,183 @@
package com.bs.df.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.bs.common.annotation.Anonymous;
import com.bs.common.core.domain.model.LoginBody;
import com.bs.web.utils.WeiXinUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.df.domain.DfUserBroker;
import com.bs.df.service.IDfUserBrokerService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-06
*/
@Api(tags = "客户经纪")
@RestController
@RequestMapping("/user/broker")
public class DfUserBrokerController extends BaseController {
@Resource
private IDfUserBrokerService dfUserBrokerService;
/**
*
*/
@ApiOperation("分页查询客户经纪列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfUserBroker dfUserBroker) {
startPage();
LambdaQueryWrapper<DfUserBroker> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfUserBroker);
List<DfUserBroker> list = dfUserBrokerService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询客户经纪列表")
@GetMapping("/list")
public AjaxResult list(DfUserBroker dfUserBroker) {
LambdaQueryWrapper<DfUserBroker> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfUserBroker);
List<DfUserBroker> list = dfUserBrokerService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出客户经纪列表")
@Log(title = "客户经纪导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfUserBroker dfUserBroker) {
LambdaQueryWrapper<DfUserBroker> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfUserBroker);
List<DfUserBroker> list = dfUserBrokerService.list(queryWrapper);
ExcelUtil<DfUserBroker> util = new ExcelUtil<DfUserBroker>(DfUserBroker. class);
util.exportExcel(response, list, "客户经纪数据");
}
/**
*
*/
@ApiOperation("获取客户经纪详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(dfUserBrokerService.getById(id));
}
/**
*
*/
@ApiOperation("新增客户经纪")
@Log(title = "客户经纪新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfUserBroker dfUserBroker) {
return toAjax(dfUserBrokerService.save(dfUserBroker));
}
/**
*
*/
@ApiOperation("修改客户经纪")
@Log(title = "客户经纪修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfUserBroker dfUserBroker) {
return toAjax(dfUserBrokerService.updateById(dfUserBroker));
}
/**
*
*/
@ApiOperation("删除客户经纪")
@Log(title = "客户经纪删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(dfUserBrokerService.removeBatchByIds(ids));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfUserBroker> queryWrapper,DfUserBroker dfUserBroker){
//id
if(Validator.isNotEmpty(dfUserBroker.getId())){
queryWrapper.eq(DfUserBroker::getId,dfUserBroker.getId());
}
//客户id
if(Validator.isNotEmpty(dfUserBroker.getUserId())){
queryWrapper.eq(DfUserBroker::getUserId,dfUserBroker.getUserId());
}
//经纪id
if(Validator.isNotEmpty(dfUserBroker.getBrokerId())){
queryWrapper.eq(DfUserBroker::getBrokerId,dfUserBroker.getBrokerId());
}
//创建部门
if(Validator.isNotEmpty(dfUserBroker.getCreateDept())){
queryWrapper.eq(DfUserBroker::getCreateDept,dfUserBroker.getCreateDept());
}
//创建人员
if(Validator.isNotEmpty(dfUserBroker.getCreateBy())){
queryWrapper.eq(DfUserBroker::getCreateBy,dfUserBroker.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(dfUserBroker.getCreateTime())){
queryWrapper.eq(DfUserBroker::getCreateTime,dfUserBroker.getCreateTime());
}
//修改人员
if(Validator.isNotEmpty(dfUserBroker.getUpdateBy())){
queryWrapper.eq(DfUserBroker::getUpdateBy,dfUserBroker.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(dfUserBroker.getUpdateTime())){
queryWrapper.eq(DfUserBroker::getUpdateTime,dfUserBroker.getUpdateTime());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(dfUserBroker.getDelFlag())){
queryWrapper.eq(DfUserBroker::getDelFlag,dfUserBroker.getDelFlag());
}
//租户id
if(Validator.isNotEmpty(dfUserBroker.getTenantId())){
queryWrapper.eq(DfUserBroker::getTenantId,dfUserBroker.getTenantId());
}
}
}

@ -0,0 +1,150 @@
package com.bs.df.domain;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* 线 df_biz_clue
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_biz_clue")
@Data
public class DfBizClue extends BaseEntity{
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
/** 数据类型0客户1经纪 */
@Excel(name = "数据类型",dictType = "product_classify")
@ApiModelProperty(value = "数据类型")
private String dataType;
/** 线索类型 */
@Excel(name = "线索类型",dictType = "clue_type")
@ApiModelProperty(value = "线索类型")
private String clueType;
/** 用户id */
@ApiModelProperty(value = "用户id")
private Long userId;
/** 用户的唯一标识 */
@ApiModelProperty(value = "用户的唯一标识")
private String openId;
/** 公众号绑定id */
@ApiModelProperty(value = "公众号绑定id")
private String unionId;
@ApiModelProperty(value = "平台来源")
private String fromType;
/** 用户昵称 */
@Excel(name = "用户昵称")
@ApiModelProperty(value = "用户昵称")
private String nickName;
/** 用户名称 */
@ApiModelProperty(value = "用户名称")
private String userName;
/** 浏览时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "浏览时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(value = "浏览时间")
private Date browseTime;
@Excel(name = "业务链接")
@ApiModelProperty(value = "业务链接")
private String businessLinks;
@Excel(name = "头像链接")
@ApiModelProperty(value = "头像链接")
private String avatarLink;
@Excel(name = "手机号")
@ApiModelProperty(value = "手机号")
private String phone;
@ApiModelProperty(value = "分享用户")
private String shareUser;
@ApiModelProperty(value = "订单id")
private String orderId;
/** 访问数量 */
@TableField(exist = false)
private Integer visitsNum;
/** 客户数量 */
@TableField(exist = false)
private Integer userNum;
@TableField(exist = false)
private List<String> avatarLinks;
/**
* 012
*
* */
@TableField(exist = false)
private String classify;
@TableField(exist = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" )
private Date createTimeVo;
/**
* 1
*
* */
@TableField(exist = false)
private String hasOrder;
@TableField(exist = false)
private String oldUserId;
@TableField(exist = false)
private String newUserId;
@TableField(exist = false)
private Long brokerId;
@TableField(exist = false)
private String realName;
}

@ -0,0 +1,113 @@
package com.bs.df.domain;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* df_broker
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_broker")
@Data
public class DfBroker extends BaseEntity{
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
/** 父级id */
//@Excel(name = "上级代理商")
@ApiModelProperty(value = "父级id")
private Long parentId;
@Excel(name = "上级代理商")
@ApiModelProperty(value = "代理商名称")
@TableField(exist = false)
private String parentName;
/** 代理商名称 */
@Excel(name = "代理商名称")
@ApiModelProperty(value = "代理商名称")
private String brokerName;
/** 地址 */
@Excel(name = "地址")
@ApiModelProperty(value = "地址")
private String brokerAddress;
/** 简介 */
@Excel(name = "简介")
@ApiModelProperty(value = "简介")
private String brokerDesc;
/** 显示顺序 */
@Excel(name = "显示顺序")
@ApiModelProperty(value = "显示顺序")
private Long orderNum;
/** 负责人 */
@Excel(name = "负责人")
@ApiModelProperty(value = "负责人")
private String chargePerson;
/** 联系电话 */
@Excel(name = "联系电话")
@ApiModelProperty(value = "联系电话")
private String contactPhone;
/** 邮箱 */
@Excel(name = "邮箱")
@ApiModelProperty(value = "邮箱")
private String email;
/** 是否机构 */
@Excel(name = "是否机构",dictType = "sys_yes_no")
@ApiModelProperty(value = "是否机构")
private String isInstitution;
/** 状态 */
@Excel(name = "状态",dictType = "df_broker_staus")
@ApiModelProperty(value = "状态")
private String staus;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
@TableField(exist = false)
private List<DfBroker> children;
@TableField(exist = false)
private Boolean isTopLevel;
}

@ -0,0 +1,73 @@
package com.bs.df.domain;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_broker_product
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_broker_product")
@Data
public class DfBrokerProduct extends BaseEntity{
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
/** 代理id */
@Excel(name = "代理id")
@ApiModelProperty(value = "代理id")
private Long brokerId;
/** 产品id */
@Excel(name = "产品id")
@ApiModelProperty(value = "产品id")
private Long productId;
/** 用户id */
@Excel(name = "用户id")
@ApiModelProperty(value = "用户id")
private String userId;
/** 代理商类型 */
// @Excel(name = "代理商类型")
// @ApiModelProperty(value = "代理商类型")
// private String type;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
/** 状态0草稿1上架 */
@ApiModelProperty(value = "状态")
private String staus;
@TableField(exist = false)
private String brokerName;
}

@ -0,0 +1,186 @@
package com.bs.df.domain;
import java.math.BigDecimal;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_order
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_order")
@Data
public class DfOrder extends BaseEntity{
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
/** 订单号 */
@Excel(name = "订单号")
@ApiModelProperty(value = "订单号")
private String orderNo;
/** 客户id */
//@Excel(name = "客户id")
@ApiModelProperty(value = "客户id")
private Long userId;
// @ApiModelProperty(value = "访客id")
// private Long openId;
/** 客户id */
@Excel(name = "客户")
private String userName;
/** 经纪id */
//@Excel(name = "经纪id")
@ApiModelProperty(value = "经纪id")
private Long brokerId;
@Excel(name = "经纪人")
@TableField(exist = false)
private String brokerName;
@Excel(name = "经纪人电话")
@TableField(exist = false)
private String brokerPhone;
/** 产品id */
//@Excel(name = "产品id")
@ApiModelProperty(value = "产品id")
private Long productId;
/** 产品名称 */
@Excel(name = "产品名称")
@ApiModelProperty(value = "产品名称")
private String productName;
/** 提交时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "提交时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty(value = "提交时间")
private Date submitTime;
/** 申请额(万元) */
@Excel(name = "申请额")
@ApiModelProperty(value = "申请额(万元)")
private BigDecimal applyAmount;
/** 授信额(万元) */
@Excel(name = "授信额")
@ApiModelProperty(value = "授信额(万元)")
private BigDecimal limitAmount;
/** 放款额(万元) */
@Excel(name = "放款额")
@ApiModelProperty(value = "放款额(万元)")
private BigDecimal loanAmount;
/** 放款利率 */
@Excel(name = "放款利率")
@ApiModelProperty(value = "放款利率")
private BigDecimal loanRate;
/** 贷款期限(月) */
@Excel(name = "贷款期限")
@ApiModelProperty(value = "贷款期限(月)")
private Long loadMonth;
/** 是否首贷 */
@Excel(name = "是否首贷")
@ApiModelProperty(value = "是否首贷")
private String isFirst;
/** 可结算金额(万元) */
@Excel(name = "可结算金额")
@ApiModelProperty(value = "可结算金额(万元)")
private Long settleAmount;
/** 状态 */
@Excel(name = "状态")
@ApiModelProperty(value = "状态")
private String staus;
/** 联系方式 */
@Excel(name = "联系方式")
@ApiModelProperty(value = "联系方式")
private String phone;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "分享用户")
private String shareUser;
/** 用户的唯一标识 */
@ApiModelProperty(value = "用户的唯一标识")
private String openId;
/** 公众号绑定id */
@ApiModelProperty(value = "公众号绑定id")
private String unionId;
@ApiModelProperty(value = "平台来源")
private String fromType;
@TableField(exist = false)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss" )
private Date createTimeVo;
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(exist = false)
private Date submitTimeBegin;
@JsonFormat(pattern = "yyyy-MM-dd")
@TableField(exist = false)
private Date submitTimeEnd;
@TableField(exist = false)
private String orderByColumn;
@TableField(exist = false)
private String isAsc;
@TableField(exist = false)
private String userOrProduct;
}

@ -0,0 +1,99 @@
package com.bs.df.domain;
import java.util.Date;
import java.util.List;
import com.bs.cm.domain.CmAttach;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_product_article
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_product_article")
@Data
public class DfProductArticle extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 文章id */
@TableId(value = "id",type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "文章id")
private String id;
/** 文章分类0产品文章1经纪文章 */
@Excel(name = "文章分类",dictType = "product_classify")
@ApiModelProperty(value = "文章分类0产品文章1经纪文章")
private String articleType;
/** 文章类型 */
@Excel(name = "文章类型",dictType = "article_kind")
@ApiModelProperty(value = "文章类型")
private String articleKind;
/** 文章标题 */
@Excel(name = "文章标题")
@ApiModelProperty(value = "文章标题")
private String articleTitle;
/** 发布时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "发布时间", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(value = "发布时间")
private Date publishTime;
/** 文章正文 */
@Excel(name = "文章正文")
@ApiModelProperty(value = "文章正文")
private String articleContent;
/** 状态0草稿1上架 */
@Excel(name = "状态",dictType = "product_status")
@ApiModelProperty(value = "状态0草稿1上架")
private String status;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
@Excel(name = "序号")
@ApiModelProperty(value = "序号")
private String serialNumber;
@TableField(exist = false)
private String publishTimeBegin;
@TableField(exist = false)
private String publishTimeEnd;
@TableField(exist = false)
private String[] ids;
@TableField(exist = false)
private List<CmAttach> files;
@TableField(exist = false)
private String orderByColumn;
}

@ -0,0 +1,208 @@
package com.bs.df.domain;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_product_info
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_product_info")
@Data
public class DfProductInfo extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 产品id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "产品id")
private Long id;
@Excel(name = "所属代理商")
@TableField(exist = false)
private String brokerName;
/** 产品名称 */
@Excel(name = "产品名称")
@ApiModelProperty(value = "产品名称")
private String productName;
/** 产品简称 */
@Excel(name = "产品简称")
@ApiModelProperty(value = "产品简称")
private String simpleName;
/** 产品类型 */
@Excel(name = "产品类型",dictType = "product_type")
@ApiModelProperty(value = "产品类型")
private String productType;
/** 产品细类 */
@Excel(name = "产品细类")
@ApiModelProperty(value = "产品细类")
private String productSubtype;
/** 贷款期限 */
@Excel(name = "贷款期限")
@ApiModelProperty(value = "贷款期限")
private String loanTerm;
/** 最高额度(元) */
@Excel(name = "最高额度(元)")
@ApiModelProperty(value = "最高额度(元)")
private Long maxAmount;
/** 年利率(单利) */
//@Excel(name = "年利率", readConverterExp = "单=利")
@ApiModelProperty(value = "年利率(单利)")
private BigDecimal interestRateBegin;
//@Excel(name = "年利率止", readConverterExp = "单=利")
@ApiModelProperty(value = "年利率(单利)")
private BigDecimal interestRateEnd;
@Excel(name = "年利率(单利)")
@TableField(exist = false)
private String interestRate;
/** 产品简介 */
@Excel(name = "产品简介")
@ApiModelProperty(value = "产品简介")
private String productIntro;
/** 产品详情(富文本) */
@Excel(name = "产品详情")
@ApiModelProperty(value = "产品详情(富文本)")
private String productDetail;
/** 上架时间起 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "上架时间起", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(value = "上架时间起")
private Date listBegin;
/** 上架时间止 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "上架时间止", width = 30, dateFormat = "yyyy-MM-dd")
@ApiModelProperty(value = "上架时间止")
private Date listEnd;
/** 还款周期 */
@Excel(name = "还款周期")
@ApiModelProperty(value = "还款周期")
private String repaymentCycle;
/** 还款方式 */
@Excel(name = "还款方式")
@ApiModelProperty(value = "还款方式")
private String repaymentMethod;
/** 展业城市 */
@Excel(name = "展业城市")
@ApiModelProperty(value = "展业城市")
private String businessCity;
/** 综合费率 */
@Excel(name = "综合费率")
@ApiModelProperty(value = "综合费率")
private String combinedRates;
/** 状态0草稿1上架 */
@Excel(name = "状态",dictType = "product_status")
@ApiModelProperty(value = "状态0草稿1上架")
private String status;
/** 申请链接 */
@Excel(name = "申请链接")
@ApiModelProperty(value = "申请链接")
private String applicationLink;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
@Excel(name = "序号")
@ApiModelProperty(value = "序号")
private String serialNumber;
@TableField(exist = false)
private Long maxAmountBegin;
@TableField(exist = false)
private Long maxAmountEnd;
@TableField(exist = false)
private String businessCityByName;
/** 判断是否根据代理商查询0为是 */
@TableField(exist = false)
private String selectByBroker;
@TableField(exist = false)
private String brokerIds;
//申请人数
@TableField(exist = false)
private Long applicantNum;
@TableField(exist = false)
private Long brokerId;
@TableField(exist = false)
private String userId;
@TableField(exist = false)
private Long[] ids;
//是否启动代理商权限
@TableField(exist = false)
private String isBroker;
@TableField(exist = false)
private String isSelectBroker;
@TableField(exist = false)
private String orderByColumn;
@TableField(exist = false)
private String isRecommend;
}

@ -0,0 +1,80 @@
package com.bs.df.domain;
import com.bs.cm.domain.CmAttach;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* df_product_moment
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_product_moment")
@Data
public class DfProductMoment extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 朋友圈id */
@TableId(value = "id",type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "朋友圈id")
private String id;
/** 朋友圈分类0产品朋友圈1经纪朋友圈 */
@Excel(name = "朋友圈分类",dictType = "product_classify")
@ApiModelProperty(value = "朋友圈分类0产品朋友圈1经纪朋友圈")
private String momentType;
/** 朋友圈类型 */
@Excel(name = "朋友圈类型",dictType = "moment_kind")
@ApiModelProperty(value = "朋友圈类型")
private String momentKind;
/** 朋友圈标题 */
@Excel(name = "朋友圈标题")
@ApiModelProperty(value = "朋友圈标题")
private String momentTitle;
/** 朋友圈正文 */
@Excel(name = "朋友圈正文")
@ApiModelProperty(value = "朋友圈正文")
private String momentContent;
/** 状态0草稿1上架 */
@Excel(name = "状态",dictType = "product_status")
@ApiModelProperty(value = "状态0草稿1上架")
private String status;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
@TableField(exist = false)
private String[] ids;
@TableField(exist = false)
private List<CmAttach> files;
@TableField(exist = false)
private String orderByColumn;
}

@ -0,0 +1,95 @@
package com.bs.df.domain;
import com.bs.cm.domain.CmAttach;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* df_product_poster
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_product_poster")
@Data
public class DfProductPoster extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 海报id */
@TableId(value = "id",type = IdType.ASSIGN_UUID)
@ApiModelProperty(value = "海报id")
private String id;
/** 产品id */
//@Excel(name = "产品id")
@ApiModelProperty(value = "产品id")
private Long productId;
@Excel(name = "产品名称")
@TableField(exist = false)
private String productName;
/** 海报分类0产品海报1经纪海报 */
@Excel(name = "海报分类",dictType = "product_classify")
@ApiModelProperty(value = "海报分类0产品海报1经纪海报")
private String posterType;
/** 海报名称 */
@Excel(name = "海报名称")
@ApiModelProperty(value = "海报名称")
private String posterName;
/** 海报标签 */
@Excel(name = "海报标签",dictType = "poster_tag")
@ApiModelProperty(value = "海报标签")
private String posterTag;
/** 海报图片id */
@Excel(name = "海报图片")
@ApiModelProperty(value = "海报图片id")
private String posterFileId;
/** 状态0草稿1上架 */
@Excel(name = "状态",dictType = "product_status")
@ApiModelProperty(value = "状态0草稿1上架")
private String status;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
@Excel(name = "序号")
@ApiModelProperty(value = "序号")
private String serialNumber;
@TableField(exist = false)
private String[] ids;
@TableField(exist = false)
private List<CmAttach> files;
@TableField(exist = false)
private String orderByColumn;
}

@ -0,0 +1,48 @@
package com.bs.df.domain;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_product_recommend
*
* @author bs
* @date 2024-09-16
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_product_recommend")
@Data
public class DfProductRecommend extends BaseEntity{
private static final long serialVersionUID = 1L;
/** 主键 */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "主键")
private Long id;
/** 用户id */
@Excel(name = "用户id")
@ApiModelProperty(value = "用户id")
private String userId;
/** 产品id */
@Excel(name = "产品id")
@ApiModelProperty(value = "产品id")
private String productId;
@TableField(exist = false)
private Long[] ids;
}

@ -0,0 +1,47 @@
package com.bs.df.domain;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_user_broker
*
* @author bs
* @date 2024-04-06
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_user_broker")
@Data
public class DfUserBroker extends BaseEntity{
private static final long serialVersionUID = 1L;
/** id */
@TableId(value = "id",type = IdType.AUTO)
@ApiModelProperty(value = "id")
private Long id;
/** 客户id */
@Excel(name = "客户id")
@ApiModelProperty(value = "客户id")
private Long userId;
/** 经纪id */
@Excel(name = "经纪id")
@ApiModelProperty(value = "经纪id")
private Long brokerId;
}

@ -0,0 +1,20 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfBizClue;
import com.bs.df.domain.DfOrder;
import org.apache.ibatis.annotations.Param;
/**
* 线Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfBizClueMapper extends BaseMapperX<DfBizClue> {
Boolean insertClue(@Param("dfBizClue") DfBizClue dfBizClue);
Boolean updateClue(@Param("dfBizClue") DfBizClue dfBizClue);
}

@ -0,0 +1,16 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfBroker;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfBrokerMapper extends BaseMapperX<DfBroker> {
void updateByNull(@Param("dfBroker") DfBroker dfBroker);
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfBrokerProduct;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfBrokerProductMapper extends BaseMapperX<DfBrokerProduct> {
}

@ -0,0 +1,20 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfOrder;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfOrderMapper extends BaseMapperX<DfOrder> {
Boolean insertOrder(@Param("dfOrder")DfOrder dfOrder);
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfProductArticle;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfProductArticleMapper extends BaseMapperX<DfProductArticle> {
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfProductInfo;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfProductInfoMapper extends BaseMapperX<DfProductInfo> {
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfProductMoment;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfProductMomentMapper extends BaseMapperX<DfProductMoment> {
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfProductPoster;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfProductPosterMapper extends BaseMapperX<DfProductPoster> {
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfProductRecommend;
/**
* Mapper
*
* @author bs
* @date 2024-09-16
*/
public interface DfProductRecommendMapper extends BaseMapperX<DfProductRecommend> {
}

@ -0,0 +1,14 @@
package com.bs.df.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.df.domain.DfUserBroker;
/**
* Mapper
*
* @author bs
* @date 2024-04-06
*/
public interface DfUserBrokerMapper extends BaseMapperX<DfUserBroker> {
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfBizClue;
/**
* 线Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfBizClueService extends MPJBaseService<DfBizClue>{
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfBrokerProduct;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfBrokerProductService extends MPJBaseService<DfBrokerProduct>{
}

@ -0,0 +1,47 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfBroker;
import java.util.List;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfBrokerService extends MPJBaseService<DfBroker>{
/**
* id
* @return
*/
public List<Long> filterByUser();
/**
* id
* @return
*/
public List<Long> filterByUserId(Long userId);
/**
* id
* @return
*/
public List<DfBroker> findAllSubordinates(Long brokerId);
/**
* idid
* @return id
*/
public List<Long> getProductIdsByBrokerId();
/**
* idid
* @return id
*/
public List<Long> getProductIdsByBrokerIdByUserId(Long userId);
}

@ -0,0 +1,19 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfOrder;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfOrderService extends MPJBaseService<DfOrder>{
/**
* ++RK202310010001
* @param billPrefix
* @return billPrefix+
*/
public String getBillNumber(String billPrefix);
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfProductArticle;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfProductArticleService extends MPJBaseService<DfProductArticle>{
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfProductInfo;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfProductInfoService extends MPJBaseService<DfProductInfo>{
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfProductMoment;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfProductMomentService extends MPJBaseService<DfProductMoment>{
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfProductPoster;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfProductPosterService extends MPJBaseService<DfProductPoster>{
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfProductRecommend;
/**
* Service
*
* @author bs
* @date 2024-09-16
*/
public interface IDfProductRecommendService extends MPJBaseService<DfProductRecommend>{
}

@ -0,0 +1,14 @@
package com.bs.df.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.df.domain.DfUserBroker;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
public interface IDfUserBrokerService extends MPJBaseService<DfUserBroker>{
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfBizClueMapper;
import com.bs.df.domain.DfBizClue;
import com.bs.df.service.IDfBizClueService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 线Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfBizClueServiceImpl extends MPJBaseServiceImpl<DfBizClueMapper, DfBizClue> implements IDfBizClueService {
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfBrokerProductMapper;
import com.bs.df.domain.DfBrokerProduct;
import com.bs.df.service.IDfBrokerProductService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfBrokerProductServiceImpl extends MPJBaseServiceImpl<DfBrokerProductMapper, DfBrokerProduct> implements IDfBrokerProductService {
}

@ -0,0 +1,91 @@
package com.bs.df.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.utils.SecurityUtils;
import com.bs.df.domain.DfBrokerProduct;
import com.bs.df.mapper.DfBrokerMapper;
import com.bs.df.domain.DfBroker;
import com.bs.df.service.IDfBrokerProductService;
import com.bs.df.service.IDfBrokerService;
import com.bs.system.service.ISysUserService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfBrokerServiceImpl extends MPJBaseServiceImpl<DfBrokerMapper, DfBroker> implements IDfBrokerService {
@Autowired
private ISysUserService userService;
@Autowired
private IDfBrokerService dfBrokerService;
@Autowired
private IDfBrokerProductService dfBrokerProductService;
public List<Long> filterByUser() {
//SecurityUtils.getUserId();
SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
Long deptId = sysUser.getDeptId();
List<DfBroker> allSubordinates = findAllSubordinates(deptId);
List<Long> brokerIds = allSubordinates.stream()
.map(DfBroker::getId)
.collect(Collectors.toList());
brokerIds.add(deptId);
return brokerIds;
}
public List<Long> filterByUserId(Long userId) {
SysUser sysUser = userService.selectUserById(userId);
Long deptId = sysUser.getDeptId();
List<DfBroker> allSubordinates = findAllSubordinates(deptId);
List<Long> brokerIds = allSubordinates.stream()
.map(DfBroker::getId)
.collect(Collectors.toList());
brokerIds.add(deptId);
return brokerIds;
}
public List<DfBroker> findAllSubordinates(Long brokerId) {
List<DfBroker> result = new ArrayList<>();
// 查询当前brokerId的所有下级
List<DfBroker> subordinates = dfBrokerService.list(new LambdaQueryWrapper<DfBroker>().eq(DfBroker::getParentId, brokerId));
result.addAll(subordinates);
for (DfBroker subordinate : subordinates) {
List<DfBroker> subSubordinates = findAllSubordinates(subordinate.getId());
result.addAll(subSubordinates);
}
return result;
}
public List<Long> getProductIdsByBrokerId() {
List<Long> longs = filterByUser();
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.in(DfBrokerProduct::getBrokerId, longs)
.eq(DfBrokerProduct::getStaus, "1")
.or()
.in(DfBrokerProduct::getUserId, SecurityUtils.getUserId()));
return list.stream().map(DfBrokerProduct::getProductId).collect(Collectors.toList());
}
public List<Long> getProductIdsByBrokerIdByUserId(Long UserId) {
List<Long> longs = filterByUserId(UserId);
List<DfBrokerProduct> list = dfBrokerProductService.list(new LambdaQueryWrapper<DfBrokerProduct>()
.in(DfBrokerProduct::getBrokerId, longs)
.eq(DfBrokerProduct::getStaus, "1"));
return list.stream().map(DfBrokerProduct::getProductId).collect(Collectors.toList());
}
}

@ -0,0 +1,44 @@
package com.bs.df.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.utils.DateUtils;
import com.bs.common.utils.StringUtils;
import com.bs.df.mapper.DfOrderMapper;
import com.bs.df.domain.DfOrder;
import com.bs.df.service.IDfOrderService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfOrderServiceImpl extends MPJBaseServiceImpl<DfOrderMapper, DfOrder> implements IDfOrderService {
@Resource
private IDfOrderService dfOrderService;
@Override
public String getBillNumber(String billPrefix) {
String billNo = "";
if (StringUtils.isBlank(billPrefix)) {
billPrefix = "DD";
}
String billDate = DateUtils.dateTimeNow("yyyyMMdd");
List<DfOrder> lsBill = dfOrderService.list(new LambdaQueryWrapper<DfOrder>().like(DfOrder::getOrderNo, billPrefix + billDate)
.orderByDesc(DfOrder::getId));
if (lsBill.size() == 0) {
billNo = billPrefix + billDate + String.format("%04d", 1);
return billNo;
}
Long id = lsBill.get(0).getId();
billNo = billPrefix + billDate + String.format("%04d", id + 1);
return billNo;
}
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfProductArticleMapper;
import com.bs.df.domain.DfProductArticle;
import com.bs.df.service.IDfProductArticleService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfProductArticleServiceImpl extends MPJBaseServiceImpl<DfProductArticleMapper, DfProductArticle> implements IDfProductArticleService {
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfProductInfoMapper;
import com.bs.df.domain.DfProductInfo;
import com.bs.df.service.IDfProductInfoService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfProductInfoServiceImpl extends MPJBaseServiceImpl<DfProductInfoMapper, DfProductInfo> implements IDfProductInfoService {
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfProductMomentMapper;
import com.bs.df.domain.DfProductMoment;
import com.bs.df.service.IDfProductMomentService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfProductMomentServiceImpl extends MPJBaseServiceImpl<DfProductMomentMapper, DfProductMoment> implements IDfProductMomentService {
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfProductPosterMapper;
import com.bs.df.domain.DfProductPoster;
import com.bs.df.service.IDfProductPosterService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfProductPosterServiceImpl extends MPJBaseServiceImpl<DfProductPosterMapper, DfProductPoster> implements IDfProductPosterService {
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfProductRecommendMapper;
import com.bs.df.domain.DfProductRecommend;
import com.bs.df.service.IDfProductRecommendService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-09-16
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfProductRecommendServiceImpl extends MPJBaseServiceImpl<DfProductRecommendMapper, DfProductRecommend> implements IDfProductRecommendService {
}

@ -0,0 +1,19 @@
package com.bs.df.service.impl;
import com.bs.df.mapper.DfUserBrokerMapper;
import com.bs.df.domain.DfUserBroker;
import com.bs.df.service.IDfUserBrokerService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-06
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfUserBrokerServiceImpl extends MPJBaseServiceImpl<DfUserBrokerMapper, DfUserBroker> implements IDfUserBrokerService {
}

@ -0,0 +1,20 @@
package com.bs.df.utils;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class HtmlUtils {
// 定义 HTML 标签的正则表达式
private static final Pattern HTML_TAG_PATTERN = Pattern.compile("<[^>]+>");
// 去除 HTML 标签的方法
public static String stripHtmlTags(String html) {
if (html == null || html.trim().isEmpty()) {
return "";
}
Matcher matcher = HTML_TAG_PATTERN.matcher(html);
return matcher.replaceAll("");
}
}

@ -0,0 +1,179 @@
package com.bs.system.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.system.domain.DfArea;
import com.bs.system.service.IDfAreaService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2024-04-13
*/
@Api(tags = "全国城市")
@RestController
@RequestMapping("/system/area")
public class DfAreaController extends BaseController {
@Resource
private IDfAreaService dfAreaService;
/**
*
*/
@ApiOperation("分页查询全国城市列表")
@GetMapping("/pageList")
public TableDataInfo pageList(DfArea dfArea) {
startPage();
LambdaQueryWrapper<DfArea> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfArea);
List<DfArea> list = dfAreaService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询全国城市列表")
@GetMapping("/list")
public AjaxResult list(DfArea dfArea) {
LambdaQueryWrapper<DfArea> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfArea);
List<DfArea> list = dfAreaService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出全国城市列表")
@Log(title = "全国城市导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, DfArea dfArea) {
LambdaQueryWrapper<DfArea> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,dfArea);
List<DfArea> list = dfAreaService.list(queryWrapper);
ExcelUtil<DfArea> util = new ExcelUtil<DfArea>(DfArea. class);
util.exportExcel(response, list, "全国城市数据");
}
/**
*
*/
@ApiOperation("获取全国城市详细信息")
@GetMapping(value = "/{areaId}")
public AjaxResult getInfo(@PathVariable("areaId") String areaId) {
return success(dfAreaService.getById(areaId));
}
/**
*
*/
@ApiOperation("新增全国城市")
@Log(title = "全国城市新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody DfArea dfArea) {
return toAjax(dfAreaService.save(dfArea));
}
/**
*
*/
@ApiOperation("修改全国城市")
@Log(title = "全国城市修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody DfArea dfArea) {
return toAjax(dfAreaService.updateById(dfArea));
}
/**
*
*/
@ApiOperation("删除全国城市")
@Log(title = "全国城市删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{areaIds}")
public AjaxResult remove(@PathVariable List<Long> areaIds) {
return toAjax(dfAreaService.removeBatchByIds(areaIds));
}
/**
*
*/
private void condition (LambdaQueryWrapper<DfArea> queryWrapper,DfArea dfArea){
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getAreaId())){
queryWrapper.eq(DfArea::getAreaId,dfArea.getAreaId());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getParentId())){
queryWrapper.eq(DfArea::getParentId,dfArea.getParentId());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getName())){
queryWrapper.eq(DfArea::getName,dfArea.getName());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getTenantId())){
queryWrapper.eq(DfArea::getTenantId,dfArea.getTenantId());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getCreateDept())){
queryWrapper.eq(DfArea::getCreateDept,dfArea.getCreateDept());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getCreateBy())){
queryWrapper.eq(DfArea::getCreateBy,dfArea.getCreateBy());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getCreateTime())){
queryWrapper.eq(DfArea::getCreateTime,dfArea.getCreateTime());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getUpdateBy())){
queryWrapper.eq(DfArea::getUpdateBy,dfArea.getUpdateBy());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getUpdateTime())){
queryWrapper.eq(DfArea::getUpdateTime,dfArea.getUpdateTime());
}
//${column.columnComment}
if(Validator.isNotEmpty(dfArea.getDelFlag())){
queryWrapper.eq(DfArea::getDelFlag,dfArea.getDelFlag());
}
}
}

@ -0,0 +1,47 @@
package com.bs.system.domain;
import com.bs.common.annotation.Excel;
import com.bs.common.core.domain.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
/**
* df_area
*
* @author bs
* @date 2024-04-13
*/
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("df_area")
@Data
public class DfArea extends BaseEntity{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId(value = "area_id",type = IdType.AUTO)
@ApiModelProperty(value = "${column.columnComment}")
private String areaId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@ApiModelProperty(value = "${column.columnComment}")
private String parentId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
@ApiModelProperty(value = "${column.columnComment}")
private String name;
}

@ -0,0 +1,14 @@
package com.bs.system.mapper;
import com.bs.common.mybatis.mapper.BaseMapperX;
import com.bs.system.domain.DfArea;
/**
* Mapper
*
* @author bs
* @date 2024-04-13
*/
public interface DfAreaMapper extends BaseMapperX<DfArea> {
}

@ -0,0 +1,14 @@
package com.bs.system.service;
import com.github.yulichang.base.MPJBaseService;
import com.bs.system.domain.DfArea;
/**
* Service
*
* @author bs
* @date 2024-04-13
*/
public interface IDfAreaService extends MPJBaseService<DfArea>{
}

@ -0,0 +1,19 @@
package com.bs.system.service.impl;
import com.bs.system.mapper.DfAreaMapper;
import com.bs.system.domain.DfArea;
import com.bs.system.service.IDfAreaService;
import com.github.yulichang.base.MPJBaseServiceImpl;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
*
* @author bs
* @date 2024-04-13
*/
@Service
@Transactional(rollbackFor = Exception.class)
public class DfAreaServiceImpl extends MPJBaseServiceImpl<DfAreaMapper, DfArea> implements IDfAreaService {
}

@ -0,0 +1,94 @@
package com.bs.web.controller.common;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.FastByteArrayOutputStream;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import com.google.code.kaptcha.Producer;
import com.bs.common.config.BsConfig;
import com.bs.common.constant.CacheConstants;
import com.bs.common.constant.Constants;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.redis.RedisCache;
import com.bs.common.utils.sign.Base64;
import com.bs.common.utils.uuid.IdUtils;
import com.bs.system.service.ISysConfigService;
/**
*
*
* @author bs
*/
@RestController
public class CaptchaController
{
@Resource(name = "captchaProducer")
private Producer captchaProducer;
@Resource(name = "captchaProducerMath")
private Producer captchaProducerMath;
@Autowired
private RedisCache redisCache;
@Autowired
private ISysConfigService configService;
/**
*
*/
@GetMapping("/captchaImage")
public AjaxResult getCode(HttpServletResponse response) throws IOException
{
AjaxResult ajax = AjaxResult.success();
boolean captchaEnabled = configService.selectCaptchaEnabled();
ajax.put("captchaEnabled", captchaEnabled);
if (!captchaEnabled)
{
return ajax;
}
// 保存验证码信息
String uuid = IdUtils.simpleUUID();
String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
String capStr = null, code = null;
BufferedImage image = null;
// 生成验证码
String captchaType = BsConfig.getCaptchaType();
if ("math".equals(captchaType))
{
String capText = captchaProducerMath.createText();
capStr = capText.substring(0, capText.lastIndexOf("@"));
code = capText.substring(capText.lastIndexOf("@") + 1);
image = captchaProducerMath.createImage(capStr);
}
else if ("char".equals(captchaType))
{
capStr = code = captchaProducer.createText();
image = captchaProducer.createImage(capStr);
}
redisCache.setCacheObject(verifyKey, code, Constants.CAPTCHA_EXPIRATION, TimeUnit.MINUTES);
// 转换流信息写出
FastByteArrayOutputStream os = new FastByteArrayOutputStream();
try
{
ImageIO.write(image, "jpg", os);
}
catch (IOException e)
{
return AjaxResult.error(e.getMessage());
}
ajax.put("uuid", uuid);
ajax.put("img", Base64.encode(os.toByteArray()));
return ajax;
}
}

@ -0,0 +1,297 @@
package com.bs.web.controller.common;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.config.BsConfig;
import com.bs.common.constant.Constants;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.exception.ServiceException;
import com.bs.common.utils.FileUtil;
import com.bs.common.utils.StringUtils;
import com.bs.common.utils.file.FileUploadUtils;
import com.bs.common.utils.file.FileUtils;
import com.bs.framework.config.ServerConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/common")
@Api(tags = "文件上传")
public class CommonController {
private static final Logger log = LoggerFactory.getLogger(CommonController.class);
@Autowired
private ServerConfig serverConfig;
@Autowired
private ICmAttachService cmAttachService;
private static final String FILE_DELIMETER = ",";
/**
*
*
* @param fileName
* @param delete
*/
@GetMapping("/download")
@ApiOperation("文件下载")
public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request) {
try {
if (!FileUtils.checkAllowDownload(fileName)) {
throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
}
String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
// String filePath = BsConfig.getUploadPath() + fileName;
String filePath = "C:/bs/uploadPath/download/2a582a06ed46ba81c45a77d8909b15c_20240423104003A001.jpg";
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, realFileName);
FileUtils.writeBytes(filePath, response.getOutputStream());
File file = new File(filePath);
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
FileUtil.downloadFile(request, response, file, false);
// if (delete) {
// FileUtils.deleteFile(filePath);
// }
} catch (Exception e) {
log.error("下载文件失败", e);
}
}
@ApiOperation("根据attachId下载对应文件")
@GetMapping("/fileDownloadById")
public void fileDownloadById(String attachId,HttpServletResponse response, HttpServletRequest request) {
if (StringUtils.isBlank(attachId) || "null".equals(attachId)) {
throw new ServiceException("附件ID不能为空");
}
CmAttach cmAttach = cmAttachService.getById(attachId);
String path =cmAttach.getAttachFileUrl();
path =BsConfig.getFilePath()+path;
// Constants.RESOURCE_PREFIX
path = path.replace(Constants.RESOURCE_PREFIX, "");
File compressedImageFile = new File(path);
response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
FileUtil.downloadFile(request, response, compressedImageFile, false);
}
/**
*
*/
@PostMapping("/upload")
@ApiOperation("单文件上传")
public AjaxResult uploadFile(MultipartFile file,String fileId) throws Exception {
try {
// 上传文件路径
String filePath = BsConfig.getUploadPath();
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
String newFileName = FileUtils.getName(fileName);
String originalFilename = file.getOriginalFilename();
CmAttach cmAttach = new CmAttach();
cmAttach.setFileId(fileId);
cmAttach.setFileSort(1);
cmAttach.setAttachName(newFileName);
cmAttach.setAttachContentType(file.getContentType());
cmAttach.setAttachFileSize(file.getSize());
String suffix = FileUtil.getExtensionName(originalFilename);
String type = FileUtil.getFileType(suffix);
cmAttach.setAttachFileType(type);
cmAttach.setAttachFileUrl(fileName);
cmAttach.setOldName(originalFilename);
cmAttach.setVersionNo("1");
cmAttach.setRemark("");
cmAttachService.save(cmAttach);
AjaxResult ajax = AjaxResult.success();
ajax.put("url", url);
ajax.put("fileName", fileName);
ajax.put("newFileName", newFileName);
ajax.put("cmAttach", cmAttach);
ajax.put("originalFilename", originalFilename);
return ajax;
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
}
}
/**
*
*/
@PostMapping("/uploads")
@ApiOperation("多文件上传")
public AjaxResult uploadFiles(List<MultipartFile> files, String fileId) throws Exception {
try {
// 上传文件路径
String filePath = BsConfig.getUploadPath();
List<String> urls = new ArrayList<String>();
List<String> fileNames = new ArrayList<String>();
List<String> newFileNames = new ArrayList<String>();
List<String> originalFilenames = new ArrayList<String>();
List<CmAttach> cmAttachList = new ArrayList<>();
for (MultipartFile file : files) {
// 上传并返回新文件名称
String fileName = FileUploadUtils.upload(filePath, file);
String url = serverConfig.getUrl() + fileName;
urls.add(url);
fileNames.add(fileName);
String newFileName = FileUtils.getName(fileName);
newFileNames.add(newFileName);
String originalFilename = file.getOriginalFilename();
originalFilenames.add(originalFilename);
CmAttach cmAttach = new CmAttach();
cmAttach.setFileId(fileId);
cmAttach.setFileSort(1);
cmAttach.setAttachName(newFileName);
cmAttach.setAttachContentType(file.getContentType());
cmAttach.setAttachFileSize(file.getSize());
String suffix = FileUtil.getExtensionName(originalFilename);
String type = FileUtil.getFileType(suffix);
cmAttach.setAttachFileType(type);
cmAttach.setAttachFileUrl(fileName);
cmAttach.setOldName(originalFilename);
cmAttach.setVersionNo("1");
cmAttach.setRemark("");
cmAttachList.add(cmAttach);
}
cmAttachService.saveBatch(cmAttachList);
AjaxResult ajax = AjaxResult.success();
ajax.put("urls", StringUtils.join(urls, FILE_DELIMETER));
ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
return ajax;
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error(e.getMessage());
}
}
/**
*
* @param fileId
* @param type
* @return
*/
@ApiOperation("根据fileId查找附件列表")
@GetMapping(value = "/getAttachList/{fileId}")
public AjaxResult getAttachVo(@PathVariable String fileId, String type) {
if (org.apache.commons.lang3.StringUtils.isBlank(fileId) || "null".equals(fileId)) {
return AjaxResult.error("fileId不能为空");
} else if ("undefined".equals(fileId)) {
return AjaxResult.success();
}
List<CmAttach> attachVo = cmAttachService.list(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId,fileId));
//压缩图片
return AjaxResult.success(attachVo);
}
/**
* fileIds
* @param fileIds
* @return
*/
@ApiOperation("根据fileIds查找附件列表")
@GetMapping(value = "/getFileIdsByAttachVos")
public AjaxResult getFileIdsByAttachVos(String[] fileIds) {
LambdaQueryWrapper<CmAttach> refWrapper = new LambdaQueryWrapper();
if (null != fileIds && fileIds.length > 0) {
refWrapper.in(CmAttach::getFileId, fileIds);
List<CmAttach> refs = cmAttachService.list(refWrapper);
//通过fileId进行分组
Map<String, List<CmAttach>> attachVoMap = refs.stream().collect(Collectors.groupingBy(CmAttach::getFileId));
return AjaxResult.success(attachVoMap);
} else {
return AjaxResult.warn("请输入文件fileIds!");
}
}
@ApiOperation("根据fileId删除表及对应文件")
@DeleteMapping(value = "/deleteFileByFileId/{fileId}")
public AjaxResult deleteFileByFileId(@PathVariable String fileId) {
if (org.apache.commons.lang3.StringUtils.isBlank(fileId) || "null".equals(fileId)) {
return AjaxResult.error("fileId不能为空");
}
List<CmAttach> cmAttachs = cmAttachService.list(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId,fileId));
cmAttachs.forEach(cmAttach->{
String path =cmAttach.getAttachFileUrl();
/* path = path.replace(Constants.RESOURCE_PREFIX, "");
path = path.replace(cmAttach.getAttachName(), "");
path =BsConfig.getFilePath()+path+"xt_"+cmAttach.getAttachName();*/
path =BsConfig.getFilePath()+path;
File compressedImageFile = new File(path);
if (compressedImageFile.exists()) {
FileUtil.del(compressedImageFile);
}
});
cmAttachService.remove(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId,fileId));
return AjaxResult.success();
}
@ApiOperation("根据attachId删除表及对应文件")
@DeleteMapping(value = "/deleteFile/{attachId}")
public AjaxResult deleteFile(@PathVariable Long attachId) {
if (attachId==null) {
return AjaxResult.error("attachId不能为空");
}
CmAttach cmAttach = cmAttachService.getById(attachId);
String path =cmAttach.getAttachFileUrl();
path =BsConfig.getFilePath()+path;
File compressedImageFile = new File(path);
if (compressedImageFile.exists()) {
FileUtil.del(compressedImageFile);
}
cmAttachService.removeById(attachId);
return AjaxResult.success();
}
/**
*
*/
@GetMapping("/download/resource")
public void resourceDownload(String resource, HttpServletRequest request, HttpServletResponse response)
throws Exception {
try {
if (!FileUtils.checkAllowDownload(resource)) {
throw new Exception(StringUtils.format("资源文件({})非法,不允许下载。 ", resource));
}
// 本地资源路径
String localPath = BsConfig.getProfile();
// 数据库资源地址
String downloadPath = localPath + StringUtils.substringAfter(resource, Constants.RESOURCE_PREFIX);
// 下载名称
String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
FileUtils.setAttachmentResponseHeader(response, downloadName);
FileUtils.writeBytes(downloadPath, response.getOutputStream());
} catch (Exception e) {
log.error("下载文件失败", e);
}
}
}

@ -0,0 +1,120 @@
package com.bs.web.controller.monitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisCallback;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.constant.CacheConstants;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.utils.StringUtils;
import com.bs.system.domain.SysCache;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/monitor/cache")
public class CacheController
{
@Autowired
private RedisTemplate<String, String> redisTemplate;
private final static List<SysCache> caches = new ArrayList<SysCache>();
{
caches.add(new SysCache(CacheConstants.LOGIN_TOKEN_KEY, "用户信息"));
caches.add(new SysCache(CacheConstants.SYS_CONFIG_KEY, "配置信息"));
caches.add(new SysCache(CacheConstants.SYS_DICT_KEY, "数据字典"));
caches.add(new SysCache(CacheConstants.CAPTCHA_CODE_KEY, "验证码"));
caches.add(new SysCache(CacheConstants.REPEAT_SUBMIT_KEY, "防重提交"));
caches.add(new SysCache(CacheConstants.RATE_LIMIT_KEY, "限流处理"));
caches.add(new SysCache(CacheConstants.PWD_ERR_CNT_KEY, "密码错误次数"));
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Properties info = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info());
Properties commandStats = (Properties) redisTemplate.execute((RedisCallback<Object>) connection -> connection.info("commandstats"));
Object dbSize = redisTemplate.execute((RedisCallback<Object>) connection -> connection.dbSize());
Map<String, Object> result = new HashMap<>(3);
result.put("info", info);
result.put("dbSize", dbSize);
List<Map<String, String>> pieList = new ArrayList<>();
commandStats.stringPropertyNames().forEach(key -> {
Map<String, String> data = new HashMap<>(2);
String property = commandStats.getProperty(key);
data.put("name", StringUtils.removeStart(key, "cmdstat_"));
data.put("value", StringUtils.substringBetween(property, "calls=", ",usec"));
pieList.add(data);
});
result.put("commandStats", pieList);
return AjaxResult.success(result);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getNames")
public AjaxResult cache()
{
return AjaxResult.success(caches);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getKeys/{cacheName}")
public AjaxResult getCacheKeys(@PathVariable String cacheName)
{
Set<String> cacheKeys = redisTemplate.keys(cacheName + "*");
return AjaxResult.success(cacheKeys);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@GetMapping("/getValue/{cacheName}/{cacheKey}")
public AjaxResult getCacheValue(@PathVariable String cacheName, @PathVariable String cacheKey)
{
String cacheValue = redisTemplate.opsForValue().get(cacheKey);
SysCache sysCache = new SysCache(cacheName, cacheKey, cacheValue);
return AjaxResult.success(sysCache);
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheName/{cacheName}")
public AjaxResult clearCacheName(@PathVariable String cacheName)
{
Collection<String> cacheKeys = redisTemplate.keys(cacheName + "*");
redisTemplate.delete(cacheKeys);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheKey/{cacheKey}")
public AjaxResult clearCacheKey(@PathVariable String cacheKey)
{
redisTemplate.delete(cacheKey);
return AjaxResult.success();
}
@PreAuthorize("@ss.hasPermi('monitor:cache:list')")
@DeleteMapping("/clearCacheAll")
public AjaxResult clearCacheAll()
{
Collection<String> cacheKeys = redisTemplate.keys("*");
redisTemplate.delete(cacheKeys);
return AjaxResult.success();
}
}

@ -0,0 +1,27 @@
package com.bs.web.controller.monitor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.framework.web.domain.Server;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/monitor/server")
public class ServerController
{
@PreAuthorize("@ss.hasPermi('monitor:server:list')")
@GetMapping()
public AjaxResult getInfo() throws Exception
{
Server server = new Server();
server.copyTo();
return AjaxResult.success(server);
}
}

@ -0,0 +1,82 @@
package com.bs.web.controller.monitor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.framework.web.service.SysPasswordService;
import com.bs.system.domain.SysLogininfor;
import com.bs.system.service.ISysLogininforService;
/**
* 访
*
* @author bs
*/
@RestController
@RequestMapping("/monitor/logininfor")
public class SysLogininforController extends BaseController
{
@Autowired
private ISysLogininforService logininforService;
@Autowired
private SysPasswordService passwordService;
@PreAuthorize("@ss.hasPermi('monitor:logininfor:list')")
@GetMapping("/list")
public TableDataInfo list(SysLogininfor logininfor)
{
startPage();
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
return getDataTable(list);
}
@Log(title = "登录日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:logininfor:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysLogininfor logininfor)
{
List<SysLogininfor> list = logininforService.selectLogininforList(logininfor);
ExcelUtil<SysLogininfor> util = new ExcelUtil<SysLogininfor>(SysLogininfor.class);
util.exportExcel(response, list, "登录日志");
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.DELETE)
@DeleteMapping("/{infoIds}")
public AjaxResult remove(@PathVariable Long[] infoIds)
{
return toAjax(logininforService.deleteLogininforByIds(infoIds));
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:remove')")
@Log(title = "登录日志", businessType = BusinessType.CLEAN)
@DeleteMapping("/clean")
public AjaxResult clean()
{
logininforService.cleanLogininfor();
return success();
}
@PreAuthorize("@ss.hasPermi('monitor:logininfor:unlock')")
@Log(title = "账户解锁", businessType = BusinessType.OTHER)
@GetMapping("/unlock/{userName}")
public AjaxResult unlock(@PathVariable("userName") String userName)
{
passwordService.clearLoginRecordCache(userName);
return success();
}
}

@ -0,0 +1,69 @@
package com.bs.web.controller.monitor;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.domain.SysOperLog;
import com.bs.system.service.ISysOperLogService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/monitor/operlog")
public class SysOperlogController extends BaseController
{
@Autowired
private ISysOperLogService operLogService;
@PreAuthorize("@ss.hasPermi('monitor:operlog:list')")
@GetMapping("/list")
public TableDataInfo list(SysOperLog operLog)
{
startPage();
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
return getDataTable(list);
}
@Log(title = "操作日志", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('monitor:operlog:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysOperLog operLog)
{
List<SysOperLog> list = operLogService.selectOperLogList(operLog);
ExcelUtil<SysOperLog> util = new ExcelUtil<SysOperLog>(SysOperLog.class);
util.exportExcel(response, list, "操作日志");
}
@Log(title = "操作日志", businessType = BusinessType.DELETE)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/{operIds}")
public AjaxResult remove(@PathVariable Long[] operIds)
{
return toAjax(operLogService.deleteOperLogByIds(operIds));
}
@Log(title = "操作日志", businessType = BusinessType.CLEAN)
@PreAuthorize("@ss.hasPermi('monitor:operlog:remove')")
@DeleteMapping("/clean")
public AjaxResult clean()
{
operLogService.cleanOperLog();
return success();
}
}

@ -0,0 +1,81 @@
package com.bs.web.controller.monitor;
import cn.hutool.core.lang.Validator;
import com.bs.common.annotation.Log;
import com.bs.common.constant.CacheConstants;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.model.LoginUser;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.core.redis.RedisCache;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.StringUtils;
import com.bs.system.domain.SysUserOnline;
import com.bs.system.service.ISysUserOnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
/**
* 线
*
* @author bs
*/
@RestController
@RequestMapping("/monitor/online")
public class SysUserOnlineController extends BaseController
{
@Autowired
private ISysUserOnlineService userOnlineService;
@Autowired
private RedisCache redisCache;
@PreAuthorize("@ss.hasPermi('monitor:online:list')")
@GetMapping("/list")
public TableDataInfo list(String ipaddr, String userName)
{
Collection<String> keys = redisCache.keys(CacheConstants.LOGIN_TOKEN_KEY + "*");
List<SysUserOnline> userOnlineList = new ArrayList<SysUserOnline>();
for (String key : keys)
{
LoginUser user = redisCache.getCacheObject(key);
if (Validator.isNotEmpty(ipaddr) && Validator.isNotEmpty(userName))
{
userOnlineList.add(userOnlineService.selectOnlineByInfo(ipaddr, userName, user));
}
else if (Validator.isNotEmpty(ipaddr))
{
userOnlineList.add(userOnlineService.selectOnlineByIpaddr(ipaddr, user));
}
else if (Validator.isNotEmpty(userName) && StringUtils.isNotNull(user.getUser()))
{
userOnlineList.add(userOnlineService.selectOnlineByUserName(userName, user));
}
else
{
userOnlineList.add(userOnlineService.loginUserToUserOnline(user));
}
}
Collections.reverse(userOnlineList);
userOnlineList.removeAll(Collections.singleton(null));
return getDataTable(userOnlineList);
}
/**
* 退
*/
@PreAuthorize("@ss.hasPermi('monitor:online:forceLogout')")
@Log(title = "在线用户", businessType = BusinessType.FORCE)
@DeleteMapping("/{tokenId}")
public AjaxResult forceLogout(@PathVariable String tokenId)
{
redisCache.deleteObject(CacheConstants.LOGIN_TOKEN_KEY + tokenId);
return success();
}
}

@ -0,0 +1,133 @@
package com.bs.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.domain.SysConfig;
import com.bs.system.service.ISysConfigService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/config")
public class SysConfigController extends BaseController
{
@Autowired
private ISysConfigService configService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:list')")
@GetMapping("/list")
public TableDataInfo list(SysConfig config)
{
startPage();
List<SysConfig> list = configService.selectConfigList(config);
return getDataTable(list);
}
@Log(title = "参数管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:config:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysConfig config)
{
List<SysConfig> list = configService.selectConfigList(config);
ExcelUtil<SysConfig> util = new ExcelUtil<SysConfig>(SysConfig.class);
util.exportExcel(response, list, "参数数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:query')")
@GetMapping(value = "/{configId}")
public AjaxResult getInfo(@PathVariable Long configId)
{
return success(configService.selectConfigById(configId));
}
/**
*
*/
@GetMapping(value = "/configKey/{configKey}")
public AjaxResult getConfigKey(@PathVariable String configKey)
{
return success(configService.selectConfigByKey(configKey));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:add')")
@Log(title = "参数管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysConfig config)
{
if (!configService.checkConfigKeyUnique(config))
{
return error("新增参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setCreateBy(getUsername());
return toAjax(configService.insertConfig(config));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:edit')")
@Log(title = "参数管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysConfig config)
{
if (!configService.checkConfigKeyUnique(config))
{
return error("修改参数'" + config.getConfigName() + "'失败,参数键名已存在");
}
config.setUpdateBy(getUsername());
return toAjax(configService.updateConfig(config));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{configIds}")
public AjaxResult remove(@PathVariable Long[] configIds)
{
configService.deleteConfigByIds(configIds);
return success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:config:remove')")
@Log(title = "参数管理", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
configService.resetConfigCache();
return success();
}
}

@ -0,0 +1,132 @@
package com.bs.web.controller.system;
import java.util.List;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.constant.UserConstants;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysDept;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.StringUtils;
import com.bs.system.service.ISysDeptService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/dept")
public class SysDeptController extends BaseController
{
@Autowired
private ISysDeptService deptService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list")
public AjaxResult list(SysDept dept)
{
List<SysDept> depts = deptService.selectDeptList(dept);
return success(depts);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:list')")
@GetMapping("/list/exclude/{deptId}")
public AjaxResult excludeChild(@PathVariable(value = "deptId", required = false) Long deptId)
{
List<SysDept> depts = deptService.selectDeptList(new SysDept());
depts.removeIf(d -> d.getDeptId().intValue() == deptId || ArrayUtils.contains(StringUtils.split(d.getAncestors(), ","), deptId + ""));
return success(depts);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:query')")
@GetMapping(value = "/{deptId}")
public AjaxResult getInfo(@PathVariable Long deptId)
{
deptService.checkDeptDataScope(deptId);
return success(deptService.selectDeptById(deptId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:add')")
@Log(title = "部门管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDept dept)
{
if (!deptService.checkDeptNameUnique(dept))
{
return error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
dept.setCreateBy(getUsername());
return toAjax(deptService.insertDept(dept));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:edit')")
@Log(title = "部门管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDept dept)
{
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept))
{
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}
else if (dept.getParentId().equals(deptId))
{
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
}
else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0)
{
return error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(getUsername());
return toAjax(deptService.updateDept(dept));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dept:remove')")
@Log(title = "部门管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{deptId}")
public AjaxResult remove(@PathVariable Long deptId)
{
if (deptService.hasChildByDeptId(deptId))
{
return warn("存在下级部门,不允许删除");
}
if (deptService.checkDeptExistUser(deptId))
{
return warn("部门存在用户,不允许删除");
}
deptService.checkDeptDataScope(deptId);
return toAjax(deptService.deleteDeptById(deptId));
}
}

@ -0,0 +1,121 @@
package com.bs.web.controller.system;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysDictData;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.StringUtils;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.service.ISysDictDataService;
import com.bs.system.service.ISysDictTypeService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/dict/data")
public class SysDictDataController extends BaseController
{
@Autowired
private ISysDictDataService dictDataService;
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictData dictData)
{
startPage();
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
return getDataTable(list);
}
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictData dictData)
{
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
util.exportExcel(response, list, "字典数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictCode}")
public AjaxResult getInfo(@PathVariable Long dictCode)
{
return success(dictDataService.selectDictDataById(dictCode));
}
/**
*
*/
@GetMapping(value = "/type/{dictType}")
public AjaxResult dictType(@PathVariable String dictType)
{
List<SysDictData> data = dictTypeService.selectDictDataByType(dictType);
if (StringUtils.isNull(data))
{
data = new ArrayList<SysDictData>();
}
return success(data);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典数据", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictData dict)
{
dict.setCreateBy(getUsername());
return toAjax(dictDataService.insertDictData(dict));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典数据", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictData dict)
{
dict.setUpdateBy(getUsername());
return toAjax(dictDataService.updateDictData(dict));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictCodes}")
public AjaxResult remove(@PathVariable Long[] dictCodes)
{
dictDataService.deleteDictDataByIds(dictCodes);
return success();
}
}

@ -0,0 +1,131 @@
package com.bs.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysDictType;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.service.ISysDictTypeService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/dict/type")
public class SysDictTypeController extends BaseController
{
@Autowired
private ISysDictTypeService dictTypeService;
@PreAuthorize("@ss.hasPermi('system:dict:list')")
@GetMapping("/list")
public TableDataInfo list(SysDictType dictType)
{
startPage();
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
return getDataTable(list);
}
@Log(title = "字典类型", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:dict:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysDictType dictType)
{
List<SysDictType> list = dictTypeService.selectDictTypeList(dictType);
ExcelUtil<SysDictType> util = new ExcelUtil<SysDictType>(SysDictType.class);
util.exportExcel(response, list, "字典类型");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:query')")
@GetMapping(value = "/{dictId}")
public AjaxResult getInfo(@PathVariable Long dictId)
{
return success(dictTypeService.selectDictTypeById(dictId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:add')")
@Log(title = "字典类型", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysDictType dict)
{
if (!dictTypeService.checkDictTypeUnique(dict))
{
return error("新增字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setCreateBy(getUsername());
return toAjax(dictTypeService.insertDictType(dict));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:edit')")
@Log(title = "字典类型", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysDictType dict)
{
if (!dictTypeService.checkDictTypeUnique(dict))
{
return error("修改字典'" + dict.getDictName() + "'失败,字典类型已存在");
}
dict.setUpdateBy(getUsername());
return toAjax(dictTypeService.updateDictType(dict));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.DELETE)
@DeleteMapping("/{dictIds}")
public AjaxResult remove(@PathVariable Long[] dictIds)
{
dictTypeService.deleteDictTypeByIds(dictIds);
return success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:dict:remove')")
@Log(title = "字典类型", businessType = BusinessType.CLEAN)
@DeleteMapping("/refreshCache")
public AjaxResult refreshCache()
{
dictTypeService.resetDictCache();
return success();
}
/**
*
*/
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
List<SysDictType> dictTypes = dictTypeService.selectDictTypeAll();
return success(dictTypes);
}
}

@ -0,0 +1,29 @@
package com.bs.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.config.BsConfig;
import com.bs.common.utils.StringUtils;
/**
*
*
* @author bs
*/
@RestController
public class SysIndexController
{
/** 系统基础配置 */
@Autowired
private BsConfig bsConfig;
/**
* 访
*/
@RequestMapping("/")
public String index()
{
return StringUtils.format("欢迎使用{}后台管理框架当前版本v{},请通过前端地址访问。", bsConfig.getName(), bsConfig.getVersion());
}
}

@ -0,0 +1,381 @@
package com.bs.web.controller.system;
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.bs.common.annotation.Anonymous;
import com.bs.common.annotation.Log;
import com.bs.common.constant.Constants;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.*;
import com.bs.common.core.domain.model.LoginBody;
import com.bs.common.core.domain.model.LoginUser;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.SecurityUtils;
import com.bs.common.utils.StringUtils;
import com.bs.framework.web.service.SysLoginService;
import com.bs.framework.web.service.SysPermissionService;
import com.bs.framework.web.service.TokenService;
import com.bs.system.domain.SysUserRole;
import com.bs.system.mapper.SysRoleMapper;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.mapper.SysUserRoleMapper;
import com.bs.system.service.ISysMenuService;
import com.bs.system.service.ITenantConfigService;
import com.bs.system.service.SysTenantService;
import com.bs.web.utils.SignUtil;
import com.bs.web.utils.WeiXinUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
*
*
* @author bs
*/
@RestController
public class SysLoginController
{
@Autowired
private SysLoginService loginService;
@Autowired
private ISysMenuService menuService;
@Autowired
private SysPermissionService permissionService;
@Autowired
private ITenantConfigService tenantConfigService;
@Resource
private WeiXinUtil weiXinUtil;
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private TokenService tokenService;
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private SysRoleMapper sysRoleMapper;
@Autowired
private SysTenantService tenantService;
/**
*
*
* @param loginBody
* @return
*/
@PostMapping("/login")
public AjaxResult login(@RequestBody LoginBody loginBody)
{
AjaxResult ajax = AjaxResult.success();
// 生成令牌
String token = loginService.login(loginBody.getUsername(), loginBody.getPassword(), loginBody.getCode(),
loginBody.getUuid());
if (StringUtils.isNotEmpty(loginBody.getUsername())) {
SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, loginBody.getUsername()));
if (sysUser != null) {
if (StringUtils.isNotEmpty(loginBody.getXcxOpenId())) {
sysUser.setXcxOpenId(loginBody.getXcxOpenId());
}
if (StringUtils.isNotEmpty(loginBody.getGzhOpenId())) {
sysUser.setGzhOpenId(loginBody.getGzhOpenId());
}
if (StringUtils.isNotEmpty(loginBody.getUnionId())) {
sysUser.setUnionId(loginBody.getUnionId());
}
sysUserMapper.updateById(sysUser);
}
}
ajax.put(Constants.TOKEN, token);
return ajax;
}
/**
*
*
* @return
*/
@GetMapping("getInfo")
public AjaxResult getInfo()
{
SysUser user = SecurityUtils.getLoginUser().getUser();
TenantConfig tenantConfig = tenantConfigService.getOne(new LambdaQueryWrapper<TenantConfig>().eq(TenantConfig::getId, user.getTenantId()));
// 角色集合
Set<String> roles = permissionService.getRolePermission(user);
// 权限集合
Set<String> permissions = permissionService.getMenuPermission(user);
if(tenantConfig==null){
tenantConfig = new TenantConfig();
}
AjaxResult ajax = AjaxResult.success();
SysUser sysUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserId, user.getUserId()));
user.setLabel(sysUser.getLabel());
user.setUserDesc(sysUser.getUserDesc());
user.setAddress(sysUser.getAddress());
user.setCompany(sysUser.getCompany());
ajax.put("user", user);
ajax.put("tenantConfig", tenantConfig);
ajax.put("roles", roles);
ajax.put("permissions", permissions);
// ajax.put("xcxOpenId", user.getXcxOpenId());
// ajax.put("gzhOpenId", user.getGzhOpenId());
// ajax.put("unionId", user.getUnionId());
// ajax.put("wechatNo", user.getWechatNo());
// ajax.put("address", user.getAddress());
// ajax.put("company", user.getCompany());
return ajax;
}
/**
*
* CodewxCode
*
* @param loginBody
* @return
*/
@PostMapping("/getOpenId")
@Log(title = "用户获取公众号id", businessType = BusinessType.GRANT)
@ApiOperation(value = "获取openId暂时无用")
public AjaxResult getGzhOpenId(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
if (StringUtils.isEmpty(loginBody.getWxCode())) {
return AjaxResult.error("请传入微信Code");
}
if (StringUtils.isEmpty(loginBody.getGzhCode())) {
return AjaxResult.error("请传ghzCode");
}
JSONObject xcxJo = weiXinUtil.getXCXOpenId(loginBody.getWxCode());
if (StringUtils.isEmpty(xcxJo.getString("openId"))) {
return AjaxResult.error("code错误");
}
JSONObject gzhJo = null;
gzhJo = weiXinUtil.getGZHOpenId(loginBody.getGzhCode());
return AjaxResult.success().put("openId", xcxJo.getString("openId"))
.put("gzhOpenId", gzhJo.getString("openId")).put("unionId", xcxJo.getString("unionid"));
}
/**
*
* @return
*/
@PostMapping("/unbindWx")
@ApiOperation(value = "解绑微信")
@Log(title = "用户获取公众号id", businessType = BusinessType.GRANT)
public AjaxResult unbindWx() {
SysUser sysUser = sysUserMapper.selectById(SecurityUtils.getUserId());
sysUser.setXcxOpenId("");
sysUser.setGzhOpenId("");
sysUser.setUnionId("");
sysUserMapper.updateById(sysUser);
LoginUser loginUser = SecurityUtils.getLoginUser();
loginUser.getUser().setXcxOpenId("");
loginUser.getUser().setGzhOpenId("");
loginUser.getUser().setUnionId("");
tokenService.refreshToken(loginUser);
return AjaxResult.success("解绑成功").put("user",sysUser);
}
/**
*
* @return
*/
@PostMapping("/bindingWx")
@ApiOperation(value = "绑定微信")
@Log(title = "用户获取公众号id", businessType = BusinessType.GRANT)
public AjaxResult bindingWx(@RequestBody LoginBody loginBody) {
// 生成令牌
// if (StringUtils.isEmpty(loginBody.getWxCode())) {
// return AjaxResult.error("请传入微信Code");
// }
if (StringUtils.isEmpty(loginBody.getGzhCode())) {
return AjaxResult.error("请传ghzCode");
}
JSONObject xcxJo = weiXinUtil.getXCXOpenId(loginBody.getWxCode());
// if (StringUtils.isEmpty(xcxJo.getString("openId"))) {
// return AjaxResult.error("微信code错误");
// }
JSONObject gzhJo = null;
gzhJo = weiXinUtil.getGZHOpenId(loginBody.getGzhCode());
if (StringUtils.isEmpty(gzhJo.getString("openId"))) {
return AjaxResult.error("公众号code错误");
}
//判断微信是否被其他用户绑定
SysUser tempUser = sysUserMapper.selectOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getGzhOpenId, gzhJo.getString("openId")));
if (tempUser!=null) {
return AjaxResult.error("此微信已被绑定");
}
SysUser updateUser = new SysUser();
updateUser.setXcxOpenId("");
if (StringUtils.isEmpty(loginBody.getWxCode())) {
sysUserMapper.update(updateUser,new LambdaUpdateWrapper<SysUser>().eq(SysUser::getXcxOpenId, gzhJo.getString("openId")));
} else {
sysUserMapper.update(updateUser,new LambdaUpdateWrapper<SysUser>().eq(SysUser::getXcxOpenId, xcxJo.getString("openId")));
}
SysUser sysUser = sysUserMapper.selectById(SecurityUtils.getUserId());
if(StringUtils.isNotEmpty(sysUser.getGzhOpenId())&&!sysUser.getGzhOpenId().equals(gzhJo.getString("openId"))){
return AjaxResult.error("您的账号已经绑定过其他微信,请先解绑");
}
sysUser.setXcxOpenId(xcxJo.getString("openId"));
sysUser.setGzhOpenId( gzhJo.getString("openId"));
if (StringUtils.isEmpty(loginBody.getWxCode())) {
sysUser.setUnionId(gzhJo.getString("unionid"));
} else {
sysUser.setUnionId(xcxJo.getString("unionid"));
}
sysUserMapper.updateById(sysUser);
LoginUser loginUser = SecurityUtils.getLoginUser();
loginUser.getUser().setXcxOpenId(sysUser.getXcxOpenId());
loginUser.getUser().setGzhOpenId(sysUser.getGzhOpenId());
loginUser.getUser().setUnionId(sysUser.getUnionId());
tokenService.refreshToken(loginUser);
return AjaxResult.success("绑定成功").put("user",sysUser);
}
/**
*
* CodewxCode
*
* @param loginBody
* @return
*/
@PostMapping("/wxlogin")
@ApiOperation(value = "微信登入")
@Anonymous
public AjaxResult wxlogin(@RequestBody LoginBody loginBody) {
AjaxResult ajax = AjaxResult.success();
// 生成令牌
if (StringUtils.isEmpty(loginBody.getWxCode())) {
// return AjaxResult.error("请传入微信Code");
}
SysUser sysUser;
JSONObject xcxJo = new JSONObject();
if (!StringUtils.isEmpty(loginBody.getWxCode())) {
xcxJo = weiXinUtil.getXCXOpenId(loginBody.getWxCode());
}
// JSONObject xcxJo = weiXinUtil.getXCXOpenId(loginBody.getWxCode());
if (StringUtils.isEmpty(xcxJo.getString("openId"))) {
// return AjaxResult.error("code错误");
}
JSONObject gzhJo = new JSONObject();
if(StringUtils.isNotEmpty(loginBody.getGzhCode())){
gzhJo = weiXinUtil.getGZHOpenId(loginBody.getGzhCode());
}
List<SysUser> lsUser = null;
if (!StringUtils.isEmpty(loginBody.getWxCode())) {
lsUser = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().eq(SysUser::getXcxOpenId, xcxJo.getString("openId")));
} else {
lsUser = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().eq(SysUser::getGzhOpenId, gzhJo.getString("openId")));
}
// List<SysUser> lsUser = sysUserMapper.selectList(new LambdaQueryWrapper<SysUser>().eq(SysUser::getXcxOpenId, xcxJo.getString("openId")));
if (lsUser != null && lsUser.size() > 0) {
sysUser = lsUser.get(0);
} else {
//没找到账号,需要手动绑定
return AjaxResult.error("未查找到用户").put("code", "501").put("openId", xcxJo.getString("openId"))
.put("gzhOpenId", gzhJo.getString("openId")!=null?gzhJo.getString("openId"):"").put("unionId", xcxJo.getString("unionid"));
}
if(StringUtils.isEmpty(sysUser.getXcxOpenId())){
if (StringUtils.isEmpty(loginBody.getWxCode())) {
sysUser.setXcxOpenId(gzhJo.getString("openId"));
} else {
sysUser.setXcxOpenId(xcxJo.getString("openId"));
}
}
if(StringUtils.isEmpty(sysUser.getGzhOpenId())){
sysUser.setGzhOpenId(gzhJo.getString("openId")!=null?gzhJo.getString("openId"):"");
}
if(StringUtils.isEmpty(sysUser.getUnionId())){
if (StringUtils.isEmpty(loginBody.getWxCode())) {
sysUser.setUnionId(gzhJo.getString("unionid"));
} else {
sysUser.setUnionId(xcxJo.getString("unionid"));
}
// sysUser.setUnionId(xcxJo.getString("unionid"));
}
String token = setLoginUser(sysUser);
ajax.put(Constants.TOKEN, token);
return ajax;
}
public String setLoginUser(SysUser user) {
LoginBody loginBody = new LoginBody();
loginBody.setXcxOpenId(user.getXcxOpenId());
//登入成功,查询租户配置
if (null != user.getTenantId()) {
// SysTenant tenant = tenantService.getById(user.getTenantId());
SysTenant tenant = new SysTenant();
TenantConfig config = tenantConfigService.getOne(new LambdaQueryWrapper<TenantConfig>().eq(TenantConfig::getId, "5"));
if (config == null) {
config = new TenantConfig();
config.setIsUserAstrict("0");
config.setIsOnLine("0");
config.setIsDefinitionName("0");
config.setIsDefinitionLogo("0");
config.setIsDefinitionHue("0");
}
tenant.setTenantConfig(config);
LoginUser loginUser = createLoginUser(user, tenant);
loginService.recordLoginInfo(user.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
LoginUser loginUser = createLoginUser(user, null);
loginService.recordLoginInfo(user.getUserId());
// 生成token
return tokenService.createToken(loginUser);
}
public LoginUser createLoginUser(SysUser user, SysTenant tenant) {
//查询用户下的权限
LambdaQueryWrapper<SysUserRole> userRoleWrapper = new LambdaQueryWrapper<>();
userRoleWrapper.select(SysUserRole::getRoleId);
userRoleWrapper.eq(SysUserRole::getUserId,user.getUserId());
List<Object> roleIds = sysUserRoleMapper.selectObjs(userRoleWrapper);
//查询用户下的权限
LambdaQueryWrapper<SysRole> roleWrapper = new LambdaQueryWrapper<>();
roleWrapper.in(SysRole::getRoleId,roleIds);
user.setRoles(sysRoleMapper.selectList(roleWrapper));
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
}
/**
*
*
* @return
*/
@GetMapping("getRouters")
public AjaxResult getRouters()
{
Long userId = SecurityUtils.getUserId();
List<SysMenu> menus = menuService.selectMenuTreeByUserId(userId);
return AjaxResult.success(menuService.buildMenus(menus));
}
/**
*
*/
@PostMapping("/getConfig")
@Anonymous
public AjaxResult getConfig(@RequestBody LoginBody loginBody)
{
Map<String, String> config = weiXinUtil.getConfig(loginBody.getUrl());
return AjaxResult.success(config);
}
}

@ -0,0 +1,139 @@
package com.bs.web.controller.system;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.annotation.Log;
import com.bs.common.constant.UserConstants;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysMenu;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.StringUtils;
import com.bs.system.mapper.SysMenuMapper;
import com.bs.system.service.ISysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/menu")
public class SysMenuController extends BaseController
{
@Autowired
private ISysMenuService menuService;
@Autowired
private SysMenuMapper sysMenuMapper;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:list')")
@GetMapping("/list")
public AjaxResult list(SysMenu menu)
{
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return success(menus);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:query')")
@GetMapping(value = "/{menuId}")
public AjaxResult getInfo(@PathVariable Long menuId)
{
return success(menuService.selectMenuById(menuId));
}
/**
*
*/
@GetMapping("/treeselect")
public AjaxResult treeselect(SysMenu menu)
{
List<SysMenu> menus = menuService.selectMenuList(menu, getUserId());
return success(menuService.buildMenuTreeSelect(menus));
}
/**
*
*/
@GetMapping(value = "/roleMenuTreeselect/{roleId}")
public AjaxResult roleMenuTreeselect(@PathVariable("roleId") Long roleId)
{
List<SysMenu> menus = menuService.selectMenuList(getUserId());
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", menuService.selectMenuListByRoleId(roleId));
ajax.put("menus", menuService.buildMenuTreeSelect(menus));
return ajax;
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:add')")
@Log(title = "菜单管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysMenu menu)
{
if (!menuService.checkMenuNameUnique(menu))
{
return error("新增菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return error("新增菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
menu.setCreateBy(getUsername());
return toAjax(menuService.insertMenu(menu));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:edit')")
@Log(title = "菜单管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysMenu menu)
{
if (!menuService.checkMenuNameUnique(menu))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,菜单名称已存在");
}
else if (UserConstants.YES_FRAME.equals(menu.getIsFrame()) && !StringUtils.ishttp(menu.getPath()))
{
return error("修改菜单'" + menu.getMenuName() + "'失败地址必须以http(s)://开头");
}
else if (menu.getMenuId().equals(menu.getParentId()))
{
return error("修改菜单'" + menu.getMenuName() + "'失败,上级菜单不能选择自己");
}
menu.setUpdateBy(getUsername());
return toAjax(menuService.updateMenu(menu));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:menu:remove')")
@Log(title = "菜单管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{menuId}")
public AjaxResult remove(@PathVariable("menuId") Long menuId)
{
if (menuService.checkMenuExistRole(menuId))
{
return warn("菜单已分配,不允许删除");
}
//select count(1) from sys_menu where parent_id = #{menuId}
sysMenuMapper.delete(new LambdaQueryWrapper<SysMenu>().eq(SysMenu::getParentId, menuId));
return toAjax(menuService.deleteMenuById(menuId));
}
}

@ -0,0 +1,170 @@
package com.bs.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import cn.hutool.core.lang.Validator;
import com.bs.system.domain.SysNotice;
import com.bs.system.service.ISysNoticeService;
import javax.annotation.Resource;
/**
* Controller
*
* @author bs
* @date 2023-08-06
*/
@Api(tags = "通知公告")
@RestController
@RequestMapping("/system/notice")
public class SysNoticeController extends BaseController {
@Resource
private ISysNoticeService sysNoticeService;
/**
*
*/
@ApiOperation("分页查询通知公告列表")
@GetMapping("/pageList")
public TableDataInfo pageList(SysNotice sysNotice) {
startPage();
LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,sysNotice);
List<SysNotice> list = sysNoticeService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询通知公告列表")
@GetMapping("/list")
public AjaxResult list(SysNotice sysNotice) {
LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,sysNotice);
List<SysNotice> list = sysNoticeService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出通知公告列表")
@Log(title = "通知公告导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysNotice sysNotice) {
LambdaQueryWrapper<SysNotice> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper,sysNotice);
List<SysNotice> list = sysNoticeService.list(queryWrapper);
ExcelUtil<SysNotice> util = new ExcelUtil<SysNotice>(SysNotice. class);
util.exportExcel(response, list, "通知公告数据");
}
/**
*
*/
@ApiOperation("获取通知公告详细信息")
@GetMapping(value = "/{noticeId}")
public AjaxResult getInfo(@PathVariable("noticeId") Long noticeId) {
return success(sysNoticeService.getById(noticeId));
}
/**
*
*/
@ApiOperation("新增通知公告")
@Log(title = "通知公告新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody SysNotice sysNotice) {
return toAjax(sysNoticeService.save(sysNotice));
}
/**
*
*/
@ApiOperation("修改通知公告")
@Log(title = "通知公告修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysNotice sysNotice) {
return toAjax(sysNoticeService.updateById(sysNotice));
}
/**
*
*/
@ApiOperation("删除通知公告")
@Log(title = "通知公告删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{noticeIds}")
public AjaxResult remove(@PathVariable List<Long> noticeIds) {
return toAjax(sysNoticeService.removeBatchByIds(noticeIds));
}
/**
*
*/
private void condition (LambdaQueryWrapper<SysNotice> queryWrapper,SysNotice sysNotice){
//公告标题
if(Validator.isNotEmpty(sysNotice.getNoticeTitle())){
queryWrapper.eq(SysNotice::getNoticeTitle,sysNotice.getNoticeTitle());
}
//公告类型sys_notice_type字典1通知 2公告
if(Validator.isNotEmpty(sysNotice.getNoticeType())){
queryWrapper.eq(SysNotice::getNoticeType,sysNotice.getNoticeType());
}
//公告内容
if(Validator.isNotEmpty(sysNotice.getNoticeContent())){
queryWrapper.eq(SysNotice::getNoticeContent,sysNotice.getNoticeContent());
}
//公告状态0正常 1关闭
if(Validator.isNotEmpty(sysNotice.getStatus())){
queryWrapper.eq(SysNotice::getStatus,sysNotice.getStatus());
}
//阅读状态0未阅读 1已阅读
if(Validator.isNotEmpty(sysNotice.getReadStatus())){
queryWrapper.eq(SysNotice::getReadStatus,sysNotice.getReadStatus());
}
//查看人
if(sysNotice.getReadUser()!=null){
queryWrapper.eq(SysNotice::getReadUser,sysNotice.getReadUser());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(sysNotice.getDelFlag())){
queryWrapper.eq(SysNotice::getDelFlag,sysNotice.getDelFlag());
}
//创建人
if(sysNotice.getCreateBy()!=null){
queryWrapper.eq(SysNotice::getCreateBy,sysNotice.getCreateBy());
}
}
}

@ -0,0 +1,129 @@
package com.bs.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.domain.SysPost;
import com.bs.system.service.ISysPostService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/post")
public class SysPostController extends BaseController
{
@Autowired
private ISysPostService postService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:list')")
@GetMapping("/list")
public TableDataInfo list(SysPost post)
{
startPage();
List<SysPost> list = postService.selectPostList(post);
return getDataTable(list);
}
@Log(title = "岗位管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:post:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysPost post)
{
List<SysPost> list = postService.selectPostList(post);
ExcelUtil<SysPost> util = new ExcelUtil<SysPost>(SysPost.class);
util.exportExcel(response, list, "岗位数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:query')")
@GetMapping(value = "/{postId}")
public AjaxResult getInfo(@PathVariable Long postId)
{
return success(postService.selectPostById(postId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:add')")
@Log(title = "岗位管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysPost post)
{
if (!postService.checkPostNameUnique(post))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (!postService.checkPostCodeUnique(post))
{
return error("新增岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setCreateBy(getUsername());
return toAjax(postService.insertPost(post));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:edit')")
@Log(title = "岗位管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysPost post)
{
if (!postService.checkPostNameUnique(post))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位名称已存在");
}
else if (!postService.checkPostCodeUnique(post))
{
return error("修改岗位'" + post.getPostName() + "'失败,岗位编码已存在");
}
post.setUpdateBy(getUsername());
return toAjax(postService.updatePost(post));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:post:remove')")
@Log(title = "岗位管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{postIds}")
public AjaxResult remove(@PathVariable Long[] postIds)
{
return toAjax(postService.deletePostByIds(postIds));
}
/**
*
*/
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
List<SysPost> posts = postService.selectPostAll();
return success(posts);
}
}

@ -0,0 +1,147 @@
package com.bs.web.controller.system;
import cn.hutool.core.lang.Validator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.annotation.Log;
import com.bs.common.config.BsConfig;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysTenant;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.core.domain.model.LoginUser;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.SecurityUtils;
import com.bs.common.utils.file.FileUploadUtils;
import com.bs.common.utils.file.MimeTypeUtils;
import com.bs.framework.web.service.TokenService;
import com.bs.system.service.ISysUserService;
import com.bs.system.service.SysTenantService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/user/profile")
public class SysProfileController extends BaseController
{
@Autowired
private ISysUserService userService;
@Autowired
private SysTenantService sysTenantService;
@Autowired
private TokenService tokenService;
/**
*
*/
@GetMapping
public AjaxResult profile()
{
LoginUser loginUser = getLoginUser();
SysUser user = loginUser.getUser();
AjaxResult ajax = AjaxResult.success(user);
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
ajax.put("postGroup", userService.selectUserPostGroup(loginUser.getUsername()));
return ajax;
}
/**
*
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult updateProfile(@RequestBody SysUser user)
{
LoginUser loginUser = getLoginUser();
SysUser sysUser = loginUser.getUser();
user.setUserName(sysUser.getUserName());
if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
}
if (Validator.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user))
{
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUserId(sysUser.getUserId());
user.setPassword(null);
user.setAvatar(null);
user.setDeptId(null);
if (userService.updateUserProfile(user) > 0)
{
// 更新缓存用户信息
sysUser.setNickName(user.getNickName());
sysUser.setPhonenumber(user.getPhonenumber());
sysUser.setEmail(user.getEmail());
sysUser.setSex(user.getSex());
tokenService.setLoginUser(loginUser);
return success();
}
return error("修改个人信息异常,请联系管理员");
}
/**
*
*/
@Log(title = "个人信息", businessType = BusinessType.UPDATE)
@PutMapping("/updatePwd")
public AjaxResult updatePwd(String oldPassword, String newPassword)
{
LoginUser loginUser = getLoginUser();
String userName = loginUser.getUsername();
String password = loginUser.getPassword();
if (!SecurityUtils.matchesPassword(oldPassword, password))
{
return error("修改密码失败,旧密码错误");
}
if (SecurityUtils.matchesPassword(newPassword, password))
{
return error("新密码不能与旧密码相同");
}
if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
{
SysUser user = userService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getUserName, userName));
//如果是租户管理员,密码写一份到租户信息
if(user.getIsTenantAdmin().equals("Y")){
SysTenant sysTenant = sysTenantService.getById(user.getTenantId());
sysTenant.setPassword(newPassword);
sysTenantService.updateById(sysTenant);
}
// 更新缓存用户密码
loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
tokenService.setLoginUser(loginUser);
return success();
}
return error("修改密码异常,请联系管理员");
}
/**
*
*/
@Log(title = "用户头像", businessType = BusinessType.UPDATE)
@PostMapping("/avatar")
public AjaxResult avatar(@RequestParam("avatarfile") MultipartFile file) throws Exception
{
if (!file.isEmpty())
{
LoginUser loginUser = getLoginUser();
String avatar = FileUploadUtils.upload(BsConfig.getAvatarPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
{
AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", avatar);
// 更新缓存用户头像
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
return ajax;
}
}
return error("上传图片异常,请联系管理员");
}
}

@ -0,0 +1,135 @@
package com.bs.web.controller.system;
import cn.hutool.core.lang.Validator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.constant.Constants;
import com.bs.common.core.domain.entity.SysRole;
import com.bs.common.core.domain.entity.SysTenant;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.core.domain.model.LoginUser;
import com.bs.framework.web.service.SysLoginService;
import com.bs.framework.web.service.SysPermissionService;
import com.bs.framework.web.service.TokenService;
import com.bs.system.domain.SysUserRole;
import com.bs.system.mapper.SysRoleMapper;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.mapper.SysUserRoleMapper;
import com.bs.system.service.ISysUserService;
import io.swagger.util.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.model.RegisterBody;
import com.bs.common.utils.StringUtils;
import com.bs.framework.web.service.SysRegisterService;
import com.bs.system.service.ISysConfigService;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*
*
* @author bs
*/
@RestController
public class SysRegisterController extends BaseController
{
@Autowired
private SysRegisterService registerService;
@Autowired
private ISysConfigService configService;
@Autowired
private ISysUserService userService;
@Autowired
private SysUserMapper userMapper;
@Autowired
private SysLoginService loginService;
@Autowired
private TokenService tokenService;
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private SysRoleMapper sysRoleMapper;
@Autowired
private SysPermissionService permissionService;
@PostMapping("/register")
public AjaxResult register(@RequestBody RegisterBody user)
{
// if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
// {
// return error("当前系统没有开启注册功能!");
// }
String msg = registerService.register(user);
if (Validator.isNotEmpty(msg)) {
return error(msg);
}
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysUser::getUserName,user.getUsername());
List<SysUser> sysUsers = userMapper.selectList(wrapper);
SysUser sysUser = sysUsers.get(0);
userService.insertUserAuth(sysUser.getUserId(), new Long[]{2L});
LoginUser loginUser = createLoginUser(sysUser, null);
String token = tokenService.createToken(loginUser);
AjaxResult ajax = AjaxResult.success();
ajax.put(Constants.TOKEN, token);
return ajax;
}
@GetMapping("/ceshi")
public AjaxResult ceshi()
{
// if (!("true".equals(configService.selectConfigByKey("sys.account.registerUser"))))
// {
// return error("当前系统没有开启注册功能!");
// }
RegisterBody user = new RegisterBody();
user.setPassword("123456");
user.setUsername("测试手机号5");
user.setPhonenumber("18396103855");
// INSERT INTO sys_user (user_id, dept_id, user_name, nick_name, email, phonenumber, sex, avatar, password, status, review_status,
// tenant_id, user_type, create_time)
// VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
// 09:56:48.703 [http-nio-8089-exec-19] DEBUG c.b.s.m.S.insertNew - [debug,137] - ==> Parameters: 1737683808874(Long), 0(Long),
// 测试手机号2(String), 测试手机号2(String), null, 18396103859(String), null, null
String msg = registerService.register(user);
if (Validator.isNotEmpty(msg)) {
return error(msg);
}
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SysUser::getUserName,user.getUsername());
List<SysUser> sysUsers = userMapper.selectList(wrapper);
SysUser sysUser = sysUsers.get(0);
userService.insertUserAuth(sysUser.getUserId(), new Long[]{2L});
LoginUser loginUser = createLoginUser(sysUser, null);
String token = tokenService.createToken(loginUser);
AjaxResult ajax = AjaxResult.success();
ajax.put(Constants.TOKEN, token);
return ajax;
}
public LoginUser createLoginUser(SysUser user, SysTenant tenant) {
//查询用户下的权限
LambdaQueryWrapper<SysUserRole> userRoleWrapper = new LambdaQueryWrapper<>();
userRoleWrapper.select(SysUserRole::getRoleId);
userRoleWrapper.eq(SysUserRole::getUserId,user.getUserId());
List<Object> roleIds = sysUserRoleMapper.selectObjs(userRoleWrapper);
//查询用户下的权限
LambdaQueryWrapper<SysRole> roleWrapper = new LambdaQueryWrapper<>();
roleWrapper.in(SysRole::getRoleId,roleIds);
user.setRoles(sysRoleMapper.selectList(roleWrapper));
return new LoginUser(user.getUserId(), user.getDeptId(), user, permissionService.getMenuPermission(user));
}
}

@ -0,0 +1,262 @@
package com.bs.web.controller.system;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysDept;
import com.bs.common.core.domain.entity.SysRole;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.core.domain.model.LoginUser;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.StringUtils;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.framework.web.service.SysPermissionService;
import com.bs.framework.web.service.TokenService;
import com.bs.system.domain.SysUserRole;
import com.bs.system.service.ISysDeptService;
import com.bs.system.service.ISysRoleService;
import com.bs.system.service.ISysUserService;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/role")
public class SysRoleController extends BaseController
{
@Autowired
private ISysRoleService roleService;
@Autowired
private TokenService tokenService;
@Autowired
private SysPermissionService permissionService;
@Autowired
private ISysUserService userService;
@Autowired
private ISysDeptService deptService;
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/list")
public TableDataInfo list(SysRole role)
{
startPage();
List<SysRole> list = roleService.selectRoleList(role);
return getDataTable(list);
}
@Log(title = "角色管理", businessType = BusinessType.EXPORT)
@PreAuthorize("@ss.hasPermi('system:role:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysRole role)
{
List<SysRole> list = roleService.selectRoleList(role);
ExcelUtil<SysRole> util = new ExcelUtil<SysRole>(SysRole.class);
util.exportExcel(response, list, "角色数据");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/{roleId}")
public AjaxResult getInfo(@PathVariable Long roleId)
{
roleService.checkRoleDataScope(roleId);
return success(roleService.selectRoleById(roleId));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:add')")
@Log(title = "角色管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysRole role)
{
if (!roleService.checkRoleNameUnique(role))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (!roleService.checkRoleKeyUnique(role))
{
return error("新增角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setCreateBy(getUsername());
return toAjax(roleService.insertRole(role));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
if (!roleService.checkRoleNameUnique(role))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色名称已存在");
}
else if (!roleService.checkRoleKeyUnique(role))
{
return error("修改角色'" + role.getRoleName() + "'失败,角色权限已存在");
}
role.setUpdateBy(getUsername());
if (roleService.updateRole(role) > 0)
{
// 更新缓存用户权限
LoginUser loginUser = getLoginUser();
if (StringUtils.isNotNull(loginUser.getUser()) && !loginUser.getUser().isAdmin())
{
loginUser.setPermissions(permissionService.getMenuPermission(loginUser.getUser()));
loginUser.setUser(userService.selectUserByUserName(loginUser.getUser().getUserName()));
tokenService.setLoginUser(loginUser);
}
return success();
}
return error("修改角色'" + role.getRoleName() + "'失败,请联系管理员");
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/dataScope")
public AjaxResult dataScope(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
return toAjax(roleService.authDataScope(role));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysRole role)
{
roleService.checkRoleAllowed(role);
roleService.checkRoleDataScope(role.getRoleId());
role.setUpdateBy(getUsername());
return toAjax(roleService.updateRoleStatus(role));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:remove')")
@Log(title = "角色管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{roleIds}")
public AjaxResult remove(@PathVariable Long[] roleIds)
{
return toAjax(roleService.deleteRoleByIds(roleIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping("/optionselect")
public AjaxResult optionselect()
{
return success(roleService.selectRoleAll());
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/allocatedList")
public TableDataInfo allocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectAllocatedList(user);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:list')")
@GetMapping("/authUser/unallocatedList")
public TableDataInfo unallocatedList(SysUser user)
{
startPage();
List<SysUser> list = userService.selectUnallocatedList(user);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancel")
public AjaxResult cancelAuthUser(@RequestBody SysUserRole userRole)
{
return toAjax(roleService.deleteAuthUser(userRole));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/cancelAll")
public AjaxResult cancelAuthUserAll(Long roleId, Long[] userIds)
{
return toAjax(roleService.deleteAuthUsers(roleId, userIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:edit')")
@Log(title = "角色管理", businessType = BusinessType.GRANT)
@PutMapping("/authUser/selectAll")
public AjaxResult selectAuthUserAll(Long roleId, Long[] userIds)
{
roleService.checkRoleDataScope(roleId);
return toAjax(roleService.insertAuthUsers(roleId, userIds));
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:role:query')")
@GetMapping(value = "/deptTree/{roleId}")
public AjaxResult deptTree(@PathVariable("roleId") Long roleId)
{
AjaxResult ajax = AjaxResult.success();
ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
ajax.put("depts", deptService.selectDeptTreeList(new SysDept()));
return ajax;
}
}

@ -0,0 +1,335 @@
package com.bs.web.controller.system;
import cn.hutool.core.lang.Validator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysDept;
import com.bs.common.core.domain.entity.SysTenant;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.SecurityUtils;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.domain.SysPost;
import com.bs.system.domain.SysUserRole;
import com.bs.system.mapper.SysDeptMapper;
import com.bs.system.mapper.SysPostMapper;
import com.bs.system.mapper.SysUserMapper;
import com.bs.system.mapper.SysUserRoleMapper;
import com.bs.system.service.ISysUserService;
import com.bs.system.service.SysTenantService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* Controller
*
* @author bs
* @date 2024-02-22
*/
@Api(tags = "租户信息")
@RestController
@RequestMapping("/system/tenant")
public class SysTenantController extends BaseController {
@Resource
private SysTenantService sysTenantService;
@Autowired
private ISysUserService userService;
@Autowired
private SysUserMapper userMapper;
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private SysDeptMapper deptMapper;
@Autowired
private SysPostMapper postMapepr;
/**
*
*/
@ApiOperation("分页查询租户信息列表")
@GetMapping("/pageList")
public TableDataInfo pageList(SysTenant sysTenant) {
startPage();
LambdaQueryWrapper<SysTenant> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, sysTenant);
List<SysTenant> list = sysTenantService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@ApiOperation("查询租户信息列表")
@GetMapping("/list")
public AjaxResult list(SysTenant sysTenant) {
LambdaQueryWrapper<SysTenant> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, sysTenant);
List<SysTenant> list = sysTenantService.list(queryWrapper);
return success(list);
}
/**
*
*/
@ApiOperation("导出租户信息列表")
@Log(title = "租户信息导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SysTenant sysTenant) {
LambdaQueryWrapper<SysTenant> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, sysTenant);
List<SysTenant> list = sysTenantService.list(queryWrapper);
ExcelUtil<SysTenant> util = new ExcelUtil<SysTenant>(SysTenant.class);
util.exportExcel(response, list, "租户信息数据");
}
/**
*
*/
@ApiOperation("获取租户信息详细信息")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id) {
final SysTenant sysTenant = sysTenantService.getById(id);
SysUser sysUser = userMapper.selectTenantAdmin(sysTenant.getId());
final List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, sysUser.getUserId()));
final List<Long> roleIds = sysUserRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList());
sysTenant.setRoleIds(roleIds);
return success(sysTenant);
}
/**
*
*/
@ApiOperation("新增租户信息")
@Log(title = "租户信息新增", businessType = BusinessType.INSERT)
@PostMapping
@Transactional(rollbackFor = Exception.class)
public AjaxResult add(@RequestBody SysTenant sysTenant) {
//新增租户的时候,进行租户管理员账号的添加
sysTenantService.save(sysTenant);
SysUser user = new SysUser();
user.setNickName(sysTenant.getName() + "管理员");
user.setUserName(sysTenant.getUserName());
user.setPassword(sysTenant.getPassword());
user.setStatus("0");
user.setIsTenant("Y");
user.setIsTenantAdmin("Y");
user.setPhonenumber(sysTenant.getContactPhone());
if (!userService.checkUserNameUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
}
if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
}
user.setCreateBy(getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setTenantId(sysTenant.getId());
initTenantDate(user);
userMapper.insert(user);
List<SysUserRole> userRoles = new ArrayList<>();
sysTenant.getRoleIds().forEach(roleId -> {
SysUserRole sysUserRole = new SysUserRole();
sysUserRole.setUserId(user.getUserId());
sysUserRole.setRoleId(roleId);
userRoles.add(sysUserRole);
});
sysUserRoleMapper.insertBatch(userRoles);
return success("添加成功");
}
/**
*
* admin
*
*/
public void initTenantDate(SysUser user) {
//查询 sys_dept 表租户id为空的复制一份
//初始化部门
SysDept parentsysDepts = new SysDept();
parentsysDepts.setParentId(0L);
parentsysDepts.setDeptName("总公司");
parentsysDepts.setOrderNum(0);
parentsysDepts.setAncestors("0");
parentsysDepts.setLeader("admin");
parentsysDepts.setPhone("15888888888");
parentsysDepts.setEmail("zgs@qq.com");
parentsysDepts.setTenantId(user.getTenantId());
deptMapper.insert(parentsysDepts);
SysDept sonSysDepts = new SysDept();
sonSysDepts.setParentId(parentsysDepts.getDeptId());
sonSysDepts.setDeptName("福建分公司");
sonSysDepts.setOrderNum(1);
//祖辈id列表
sonSysDepts.setAncestors("0," + parentsysDepts.getDeptId());
sonSysDepts.setLeader("admin");
sonSysDepts.setPhone("15888888888");
sonSysDepts.setEmail("zgs@qq.com");
sonSysDepts.setTenantId(user.getTenantId());
deptMapper.insert(sonSysDepts);
//初始化岗位
List<SysPost> sysPosts = postMapepr.selectList(new LambdaQueryWrapper<SysPost>().eq(SysPost::getDelFlag, "0").eq(SysPost::getTenantId, "0"));
sysPosts.forEach(ele -> {
ele.setTenantId(user.getTenantId());
ele.setPostId(null);
});
postMapepr.insertBatch(sysPosts);
//最高部门
user.setDeptId(parentsysDepts.getDeptId());
//ceo
Long[] postIds = new Long[1];
sysPosts.forEach(ele -> {
if (ele.getPostCode().equals("ceo")) {
postIds[0] = ele.getPostId();
}
});
user.setPostIds(postIds);
}
/**
*
*/
@ApiOperation("修改租户信息")
@Log(title = "租户信息修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody SysTenant sysTenant) {
//修改租户,判断密码是否有更换,如有更换进行修改用户密码
SysTenant tenant = sysTenantService.getById(sysTenant.getId());
SysUser user = userMapper.selectTenantAdmin(sysTenant.getId());
if (!tenant.getPassword().equals(sysTenant.getPassword()) || !tenant.getUserName().equals(sysTenant.getUserName())) {
user.setPassword(SecurityUtils.encryptPassword(sysTenant.getPassword()));
user.setUserName(sysTenant.getUserName());
userService.resetPwd(user);
}
//修改租户的角色信息
sysUserRoleMapper.delete(new LambdaUpdateWrapper<SysUserRole>().eq(SysUserRole::getUserId, user.getUserId()));
List<SysUserRole> userRoles = new ArrayList<>();
sysTenant.getRoleIds().forEach(roleId -> {
SysUserRole sysUserRole = new SysUserRole();
sysUserRole.setUserId(user.getUserId());
sysUserRole.setRoleId(roleId);
userRoles.add(sysUserRole);
});
if(userRoles.size()>0){
sysUserRoleMapper.insertBatch(userRoles);
}
return toAjax(sysTenantService.updateById(sysTenant));
}
/**
*
*/
@ApiOperation("删除租户信息")
@Log(title = "租户信息删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(sysTenantService.removeBatchByIds(ids));
}
/**
*
*/
private void condition(LambdaQueryWrapper<SysTenant> queryWrapper, SysTenant sysTenant) {
//用户ID
if (Validator.isNotEmpty(sysTenant.getId())) {
queryWrapper.eq(SysTenant::getId, sysTenant.getId());
}
//租户名
if (Validator.isNotEmpty(sysTenant.getName())) {
queryWrapper.eq(SysTenant::getName, sysTenant.getName());
}
//租户简名
if (Validator.isNotEmpty(sysTenant.getSimpleName())) {
queryWrapper.eq(SysTenant::getSimpleName, sysTenant.getSimpleName());
}
//行政区划
if (Validator.isNotEmpty(sysTenant.getAreaCode())) {
queryWrapper.eq(SysTenant::getAreaCode, sysTenant.getAreaCode());
}
//租户密码
if (Validator.isNotEmpty(sysTenant.getPassword())) {
queryWrapper.eq(SysTenant::getPassword, sysTenant.getPassword());
}
//租户账号
if (Validator.isNotEmpty(sysTenant.getUserName())) {
queryWrapper.eq(SysTenant::getUserName, sysTenant.getUserName());
}
//联系人
if (Validator.isNotEmpty(sysTenant.getContactUser())) {
queryWrapper.eq(SysTenant::getContactUser, sysTenant.getContactUser());
}
//联系电话
if (Validator.isNotEmpty(sysTenant.getContactPhone())) {
queryWrapper.eq(SysTenant::getContactPhone, sysTenant.getContactPhone());
}
//状态启用1禁用0即将过期2
if (Validator.isNotEmpty(sysTenant.getStatus())) {
queryWrapper.eq(SysTenant::getStatus, sysTenant.getStatus());
}
//创建部门
if (Validator.isNotEmpty(sysTenant.getCreateDept())) {
queryWrapper.eq(SysTenant::getCreateDept, sysTenant.getCreateDept());
}
//创建人
if (Validator.isNotEmpty(sysTenant.getCreateBy())) {
queryWrapper.eq(SysTenant::getCreateBy, sysTenant.getCreateBy());
}
//创建时间
if (Validator.isNotEmpty(sysTenant.getCreateTime())) {
queryWrapper.eq(SysTenant::getCreateTime, sysTenant.getCreateTime());
}
//修改人
if (Validator.isNotEmpty(sysTenant.getUpdateBy())) {
queryWrapper.eq(SysTenant::getUpdateBy, sysTenant.getUpdateBy());
}
//修改时间
if (Validator.isNotEmpty(sysTenant.getUpdateTime())) {
queryWrapper.eq(SysTenant::getUpdateTime, sysTenant.getUpdateTime());
}
//备注
if (Validator.isNotEmpty(sysTenant.getRemark())) {
queryWrapper.eq(SysTenant::getRemark, sysTenant.getRemark());
}
//删除标志0代表存在 2代表删除
if (Validator.isNotEmpty(sysTenant.getDelFlag())) {
queryWrapper.eq(SysTenant::getDelFlag, sysTenant.getDelFlag());
}
}
}

@ -0,0 +1,528 @@
package com.bs.web.controller.system;
import cn.hutool.core.lang.Validator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.cm.domain.CmAttach;
import com.bs.cm.service.ICmAttachService;
import com.bs.common.annotation.Anonymous;
import com.bs.common.annotation.Log;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.SysDept;
import com.bs.common.core.domain.entity.SysRole;
import com.bs.common.core.domain.entity.SysUser;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.SecurityUtils;
import com.bs.common.utils.StringUtils;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.df.utils.HtmlUtils;
import com.bs.system.domain.DfArea;
import com.bs.system.domain.SysUserRole;
import com.bs.system.mapper.SysUserRoleMapper;
import com.bs.system.service.*;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
*
*
* @author bs
*/
@RestController
@RequestMapping("/system/user")
public class SysUserController extends BaseController {
@Autowired
private ISysUserService userService;
@Autowired
private ISysRoleService roleService;
@Autowired
private SysUserRoleMapper sysUserRoleMapper;
@Autowired
private ISysDeptService deptService;
@Autowired
private ISysPostService postService;
@Resource
private IDfAreaService dfAreaService;
@Resource
private ICmAttachService cmAttachService;
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/list")
public TableDataInfo list(SysUser user) {
startPage();
List<SysUser> list = userService.selectUserList(user);
return getDataTable(list);
}
@GetMapping("/listUserAll")
public AjaxResult listUserAll(SysUser user) {
List<SysUser> list = userService.selectUserList(user);
return success(list);
}
@PostMapping("/removeDepts")
public AjaxResult removeDepts(@RequestBody SysUser user) {
for (Long userId : user.getUserIds()) {
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setDeptId(0L);
userService.updateById(sysUser);
}
return success(true);
}
@PostMapping("/updateDepts")
public AjaxResult updateDepts(@RequestBody SysUser user) {
for (Long userId : user.getUserIds()) {
SysUser sysUser = new SysUser();
sysUser.setUserId(userId);
sysUser.setDeptId(user.getDeptId());
userService.updateById(sysUser);
}
return success(true);
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
@PostMapping("/exportByType")
public void exportByType(HttpServletResponse response, SysUser user) {
LambdaQueryWrapper<SysUser> wrapper = new LambdaQueryWrapper<>();
if (user.getDeptIds()!=null) {
wrapper.in(SysUser::getDeptId, user.getDeptIds());
}
condition(wrapper,user);
List<SysUser> list = userService.list(wrapper);
List<DfArea> dfAreas = dfAreaService.list();
Map<String, String> mapByArea = dfAreas.stream().collect(Collectors.toMap(DfArea::getAreaId, DfArea::getName));
for (SysUser sysUser : list) {
sysUser.setUserDesc(HtmlUtils.stripHtmlTags(sysUser.getUserDesc()));
String cityName = mapByArea.get(sysUser.getCity());
if (Validator.isNotEmpty(cityName)) {
sysUser.setCity(cityName);
}
}
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.EXPORT)
//@PreAuthorize("@ss.hasPermi('system:user:export')")
@PostMapping("/export")
public void export(HttpServletResponse response, SysUser user) {
List<SysUser> list = userService.selectUserList(user);
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.exportExcel(response, list, "用户数据");
}
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PreAuthorize("@ss.hasPermi('system:user:import')")
@PostMapping("/importData")
public AjaxResult importData(MultipartFile file, boolean updateSupport) throws Exception {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
List<SysUser> userList = util.importExcel(file.getInputStream());
Long operName = getUsername();
String message = userService.importUser(userList, updateSupport, operName);
return success(message);
}
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
ExcelUtil<SysUser> util = new ExcelUtil<SysUser>(SysUser.class);
util.importTemplateExcel(response, "用户数据");
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping(value = {"/", "/{userId}"})
public AjaxResult getInfo(@PathVariable(value = "userId", required = false) Long userId) {
userService.checkUserDataScope(userId);
AjaxResult ajax = AjaxResult.success();
List<SysRole> roles = roleService.selectRoleAll();
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
ajax.put("posts", postService.selectPostAll());
if (StringUtils.isNotNull(userId)) {
SysUser sysUser = userService.selectUserById(userId);
final List<SysUserRole> sysUserRoles = sysUserRoleMapper.selectList(new LambdaQueryWrapper<SysUserRole>().eq(SysUserRole::getUserId, userId));
ajax.put(AjaxResult.DATA_TAG, sysUser);
ajax.put("postIds", postService.selectPostListByUserId(userId));
ajax.put("roleIds", sysUserRoles.stream().map(SysUserRole::getRoleId).collect(Collectors.toList()));
}
return ajax;
}
/**
*
*/
@GetMapping(value = {"/getUsers"})
public TableDataInfo getInfosById(SysUser user) {
SysUser sysUser = userService.selectUserById(user.getUserId());
// Long deptId = sysUser.getDeptId();
// LambdaQueryWrapper<DfBroker> dfBrokerLambdaQueryWrapper = new LambdaQueryWrapper<>();
// if (!sysUser.getDeptId().equals(-1L)) {
// dfBrokerLambdaQueryWrapper.eq(DfBroker::getParentId, deptId);
// }
// List<DfBroker> list = dfBrokerService.list(dfBrokerLambdaQueryWrapper);
// List<Long> idList = list.stream()
// .map(DfBroker::getId)
// .collect(Collectors.toList());
// if (idList.isEmpty()) {
// idList.add(0L);
// }
startPage();
LambdaQueryWrapper<SysUser> queryWrapper = new LambdaQueryWrapper<>();
if (sysUser.getDeptId().equals(-1L)) {
queryWrapper.or()
.isNotNull(SysUser::getUserId);
}
List<SysUser> sysUsers = userService.list(queryWrapper);
return getDataTable(sysUsers);
}
/**
*
*/
@GetMapping(value = {"/getUser/{userId}"})
@Anonymous
public AjaxResult getUser(@PathVariable(value = "userId", required = false) Long userId) {
SysUser sysUser = userService.selectUserById(userId);
List<CmAttach> attachVo = cmAttachService.list(new LambdaQueryWrapper<CmAttach>().eq(CmAttach::getFileId, "userId" + userId));
sysUser.setFiles(attachVo);
return success(sysUser);
}
/**
admin
*/
@GetMapping("/getRoles")
public AjaxResult getRoles() {
List<SysRole> roles = roleService.selectRoleAll();
return AjaxResult.success().put("roles", roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:add')")
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@Validated @RequestBody SysUser user) {
if (!userService.checkUserNameUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
} else if (Validator.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setIsTenant(SecurityUtils.getLoginUser().getIsTenant());
user.setIsTenantAdmin("N");
if (!"kh".equals(user.getUserType())) {
user.setUserType("jj");
}
user.setCreateBy(getUsername());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
if (Validator.isNotEmpty(user.getUserIdNew())) {
user.setUserId(Long.valueOf(user.getUserIdNew()));
}
int i = userService.insertUser(user);
return toAjax(i);
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@Validated @RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
if (!userService.checkUserNameUnique(user)) {
return error("修改用户'" + user.getUserName() + "'失败,登录账号已存在");
} else if (Validator.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(user)) {
return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
} else if (Validator.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(user)) {
return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
}
user.setUpdateBy(getUsername());
user.setPassword(null);
if (null == user.getDeptId()) {
user.setDeptId(0L);
}
return toAjax(userService.updateUser(user));
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:remove')")
@Log(title = "用户管理", businessType = BusinessType.DELETE)
@DeleteMapping("/{userIds}")
public AjaxResult remove(@PathVariable Long[] userIds) {
if (ArrayUtils.contains(userIds, getUserId())) {
return error("当前用户不能删除");
}
return toAjax(userService.deleteUserByIds(userIds));
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:resetPwd')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/resetPwd")
public AjaxResult resetPwd(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
user.setUpdateBy(getUsername());
return toAjax(userService.resetPwd(user));
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeStatus")
public AjaxResult changeStatus(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user));
}
/**
*
*/
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
@PutMapping("/changeUserReviewStatus")
public AjaxResult changeUserReviewStatus(@RequestBody SysUser user) {
userService.checkUserAllowed(user);
userService.checkUserDataScope(user.getUserId());
user.setUpdateBy(getUsername());
return toAjax(userService.updateUserStatus(user));
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:query')")
@GetMapping("/authRole/{userId}")
public AjaxResult authRole(@PathVariable("userId") Long userId) {
AjaxResult ajax = AjaxResult.success();
SysUser user = userService.selectUserById(userId);
List<SysRole> roles = roleService.selectRolesByUserId(userId);
ajax.put("user", user);
ajax.put("roles", SysUser.isAdmin(userId) ? roles : roles.stream().filter(r -> !r.isAdmin()).collect(Collectors.toList()));
return ajax;
}
/**
*
*/
//@PreAuthorize("@ss.hasPermi('system:user:edit')")
@Log(title = "用户管理", businessType = BusinessType.GRANT)
@PutMapping("/authRole")
public AjaxResult insertAuthRole(Long userId, Long[] roleIds) {
userService.checkUserDataScope(userId);
userService.insertUserAuth(userId, roleIds);
return success();
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('system:user:list')")
@GetMapping("/deptTree")
public AjaxResult deptTree(SysDept dept) {
return success(deptService.selectDeptTreeList(dept));
}
/**
*
*/
private void condition (LambdaQueryWrapper<SysUser> queryWrapper,SysUser sysUser){
//用户ID
if(Validator.isNotEmpty(sysUser.getUserId())){
queryWrapper.eq(SysUser::getUserId,sysUser.getUserId());
}
//用户账号
if(Validator.isNotEmpty(sysUser.getUserName())){
queryWrapper.like(SysUser::getUserName,sysUser.getUserName());
}
//用户昵称
if(Validator.isNotEmpty(sysUser.getNickName())){
queryWrapper.like(SysUser::getNickName,sysUser.getNickName());
}
//用户类型00系统用户
if(Validator.isNotEmpty(sysUser.getUserType())){
queryWrapper.eq(SysUser::getUserType,sysUser.getUserType());
}
//身份证号
if(Validator.isNotEmpty(sysUser.getIdentityCard())){
queryWrapper.like(SysUser::getIdentityCard,sysUser.getIdentityCard());
}
//城市
if(Validator.isNotEmpty(sysUser.getCity())){
queryWrapper.eq(SysUser::getCity,sysUser.getCity());
}
//注册时间
if(Validator.isNotEmpty(sysUser.getRegistrationTime())){
queryWrapper.eq(SysUser::getRegistrationTime,sysUser.getRegistrationTime());
}
//用户邮箱
if(Validator.isNotEmpty(sysUser.getEmail())){
queryWrapper.like(SysUser::getEmail,sysUser.getEmail());
}
//手机号码
if(Validator.isNotEmpty(sysUser.getPhonenumber())){
queryWrapper.like(SysUser::getPhonenumber,sysUser.getPhonenumber());
}
//真实姓名
if(Validator.isNotEmpty(sysUser.getRealName())){
queryWrapper.like(SysUser::getRealName,sysUser.getRealName());
}
//用户性别0男 1女 2未知
if(Validator.isNotEmpty(sysUser.getSex())){
queryWrapper.eq(SysUser::getSex,sysUser.getSex());
}
//地址
if(Validator.isNotEmpty(sysUser.getAddress())){
queryWrapper.eq(SysUser::getAddress,sysUser.getAddress());
}
//公司
if(Validator.isNotEmpty(sysUser.getCompany())){
queryWrapper.eq(SysUser::getCompany,sysUser.getCompany());
}
//头像地址
if(Validator.isNotEmpty(sysUser.getAvatar())){
queryWrapper.eq(SysUser::getAvatar,sysUser.getAvatar());
}
//密码
if(Validator.isNotEmpty(sysUser.getPassword())){
queryWrapper.eq(SysUser::getPassword,sysUser.getPassword());
}
//帐号状态0正常 1停用
if(Validator.isNotEmpty(sysUser.getStatus())){
queryWrapper.eq(SysUser::getStatus,sysUser.getStatus());
}
//最后登录IP
if(Validator.isNotEmpty(sysUser.getLoginIp())){
queryWrapper.eq(SysUser::getLoginIp,sysUser.getLoginIp());
}
//最后登录时间
if(Validator.isNotEmpty(sysUser.getLoginDate())){
queryWrapper.eq(SysUser::getLoginDate,sysUser.getLoginDate());
}
//是否是租户Y是N不是
if(Validator.isNotEmpty(sysUser.getIsTenant())){
queryWrapper.eq(SysUser::getIsTenant,sysUser.getIsTenant());
}
//是否是租户管理员Y是N不是
if(Validator.isNotEmpty(sysUser.getIsTenantAdmin())){
queryWrapper.eq(SysUser::getIsTenantAdmin,sysUser.getIsTenantAdmin());
}
//创建部门
if(Validator.isNotEmpty(sysUser.getCreateDept())){
queryWrapper.eq(SysUser::getCreateDept,sysUser.getCreateDept());
}
//创建人
if(Validator.isNotEmpty(sysUser.getCreateBy())){
queryWrapper.eq(SysUser::getCreateBy,sysUser.getCreateBy());
}
//创建时间
if(Validator.isNotEmpty(sysUser.getCreateTime())){
queryWrapper.eq(SysUser::getCreateTime,sysUser.getCreateTime());
}
if(Validator.isNotEmpty(sysUser.getParams().get("beginTime"))){
queryWrapper.ge(SysUser::getCreateTime,sysUser.getParams().get("beginTime"));
}
if(Validator.isNotEmpty(sysUser.getParams().get("endTime"))){
queryWrapper.le(SysUser::getCreateTime,sysUser.getParams().get("endTime"));
}
//修改人
if(Validator.isNotEmpty(sysUser.getUpdateBy())){
queryWrapper.eq(SysUser::getUpdateBy,sysUser.getUpdateBy());
}
//修改时间
if(Validator.isNotEmpty(sysUser.getUpdateTime())){
queryWrapper.eq(SysUser::getUpdateTime,sysUser.getUpdateTime());
}
//备注
if(Validator.isNotEmpty(sysUser.getRemark())){
queryWrapper.eq(SysUser::getRemark,sysUser.getRemark());
}
//删除标志0代表存在 2代表删除
if(Validator.isNotEmpty(sysUser.getDelFlag())){
queryWrapper.eq(SysUser::getDelFlag,sysUser.getDelFlag());
}
//${column.columnComment}
if(Validator.isNotEmpty(sysUser.getTenantId())){
queryWrapper.eq(SysUser::getTenantId,sysUser.getTenantId());
}
}
}

@ -0,0 +1,231 @@
package com.bs.web.controller.system;
import cn.hutool.core.lang.Validator;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.bs.common.annotation.Log;
import com.bs.common.config.BsConfig;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.AjaxResult;
import com.bs.common.core.domain.entity.TenantConfig;
import com.bs.common.core.page.TableDataInfo;
import com.bs.common.enums.BusinessType;
import com.bs.common.utils.file.FileUploadUtils;
import com.bs.common.utils.file.MimeTypeUtils;
import com.bs.common.utils.poi.ExcelUtil;
import com.bs.system.service.ITenantConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* Controller
*
* @author ruoyi
* @date 2023-04-02
*/
@RestController
@RequestMapping("/tenant/config")
public class TenantConfigController extends BaseController {
@Autowired
private ITenantConfigService tenantConfigService;
/**
*
*/
@PreAuthorize("@ss.hasPermi('tenant:config:pageList')")
@GetMapping("/pageList")
public TableDataInfo pageList(TenantConfig tenantConfig) {
startPage();
LambdaQueryWrapper<TenantConfig> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, tenantConfig);
List<TenantConfig> list = tenantConfigService.list(queryWrapper);
return getDataTable(list);
}
/**
*
*/
@PreAuthorize("@ss.hasPermi('tenant:config:list')")
@GetMapping("/list")
public AjaxResult list(TenantConfig tenantConfig) {
LambdaQueryWrapper<TenantConfig> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, tenantConfig);
List<TenantConfig> list = tenantConfigService.list(queryWrapper);
return success(list);
}
/**
*
*/
@Log(title = "租户配置导出", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, TenantConfig tenantConfig) {
LambdaQueryWrapper<TenantConfig> queryWrapper = new LambdaQueryWrapper();
condition(queryWrapper, tenantConfig);
List<TenantConfig> list = tenantConfigService.list(queryWrapper);
ExcelUtil<TenantConfig> util = new ExcelUtil<TenantConfig>(TenantConfig.class);
util.exportExcel(response, list, "租户配置数据");
}
/**
*
*/
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) {
TenantConfig tenantConfig = tenantConfigService.getById(id);
tenantConfig.setTenantId(tenantConfig.getId()) ;
return success(tenantConfig);
}
/**
*
*/
@Log(title = "租户配置新增", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TenantConfig tenantConfig) {
tenantConfig.setId(tenantConfig.getTenantId()) ;
return toAjax(tenantConfigService.save(tenantConfig));
}
/**
*
*/
@Log(title = "租户配置修改", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TenantConfig tenantConfig) {
tenantConfig.setId(tenantConfig.getTenantId()) ;
return toAjax(tenantConfigService.updateById(tenantConfig));
}
/**
*
*/
@Log(title = "租户配置删除", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable List<Long> ids) {
return toAjax(tenantConfigService.removeBatchByIds(ids));
}
/**
* logo
*/
@Log(title = "租户logo图片上传", businessType = BusinessType.UPDATE)
@PostMapping("/logo")
public AjaxResult avatar(@RequestParam("tenantLogo") MultipartFile file) throws Exception {
if (!file.isEmpty()) {
String logo = FileUploadUtils.upload(BsConfig.getUploadPath(), file, MimeTypeUtils.IMAGE_EXTENSION);
AjaxResult ajax = success();
ajax.put("imgUrl", logo);
return ajax;
}
return error("上传图片异常,请联系管理员");
}
/**
*
*/
private void condition(LambdaQueryWrapper<TenantConfig> queryWrapper, TenantConfig tenantConfig) {
//${column.columnComment}
if (Validator.isNotEmpty(tenantConfig.getId())) {
queryWrapper.eq(TenantConfig::getId, tenantConfig.getId());
}
//开始时间
if (tenantConfig.getStartData() != null) {
queryWrapper.eq(TenantConfig::getStartData, tenantConfig.getStartData());
}
//结束时间
if (tenantConfig.getStopData() != null) {
queryWrapper.eq(TenantConfig::getStopData, tenantConfig.getStopData());
}
//是否限制用户数
if (Validator.isNotEmpty(tenantConfig.getIsUserAstrict())) {
queryWrapper.eq(TenantConfig::getIsUserAstrict, tenantConfig.getIsUserAstrict());
}
//用户数
if (tenantConfig.getUserQuantity() != null) {
queryWrapper.eq(TenantConfig::getUserQuantity, tenantConfig.getUserQuantity());
}
//是否限制在线数
if (Validator.isNotEmpty(tenantConfig.getIsOnLine())) {
queryWrapper.eq(TenantConfig::getIsOnLine, tenantConfig.getIsOnLine());
}
//在线数
if (tenantConfig.getOnLineUserQuantity() != null) {
queryWrapper.eq(TenantConfig::getOnLineUserQuantity, tenantConfig.getOnLineUserQuantity());
}
//是否定义系统名称
if (Validator.isNotEmpty(tenantConfig.getIsDefinitionName())) {
queryWrapper.eq(TenantConfig::getIsDefinitionName, tenantConfig.getIsDefinitionName());
}
//系统名称
if (Validator.isNotEmpty(tenantConfig.getSysName())) {
queryWrapper.like(TenantConfig::getSysName, tenantConfig.getSysName());
}
//是否定义系统logo
if (Validator.isNotEmpty(tenantConfig.getIsDefinitionLogo())) {
queryWrapper.eq(TenantConfig::getIsDefinitionLogo, tenantConfig.getIsDefinitionLogo());
}
//系统log
if (Validator.isNotEmpty(tenantConfig.getSysLog())) {
queryWrapper.eq(TenantConfig::getSysLog, tenantConfig.getSysLog());
}
//是否定义系统色调
if (Validator.isNotEmpty(tenantConfig.getIsDefinitionHue())) {
queryWrapper.eq(TenantConfig::getIsDefinitionHue, tenantConfig.getIsDefinitionHue());
}
//系统色调
if (Validator.isNotEmpty(tenantConfig.getSysHue())) {
queryWrapper.eq(TenantConfig::getSysHue, tenantConfig.getSysHue());
}
//定制化数据,键值对{key:{type1:"",type2:"",value:""},key2:{type1:"",type2:"",value:""}}具体操作时候,做具体说明
if (Validator.isNotEmpty(tenantConfig.getCustomizationFields())) {
queryWrapper.eq(TenantConfig::getCustomizationFields, tenantConfig.getCustomizationFields());
}
//创建人员
if (Validator.isNotEmpty(tenantConfig.getCreateBy())) {
queryWrapper.eq(TenantConfig::getCreateBy, tenantConfig.getCreateBy());
}
//修改人员
if (Validator.isNotEmpty(tenantConfig.getUpdateBy())) {
queryWrapper.eq(TenantConfig::getUpdateBy, tenantConfig.getUpdateBy());
}
//部门ID
if (Validator.isNotEmpty(tenantConfig.getCreateDept())) {
queryWrapper.eq(TenantConfig::getCreateDept, tenantConfig.getCreateDept());
}
//删除标示 默认为1 有效数据 ,0为无效已删除
if (Validator.isNotEmpty(tenantConfig.getDelFlag())) {
queryWrapper.eq(TenantConfig::getDelFlag, tenantConfig.getDelFlag());
}
}
}

@ -0,0 +1,183 @@
package com.bs.web.controller.tool;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bs.common.core.controller.BaseController;
import com.bs.common.core.domain.R;
import com.bs.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
/**
* swagger
*
* @author bs
*/
@Api("用户信息管理")
@RestController
@RequestMapping("/test/user")
public class TestController extends BaseController
{
private final static Map<Integer, UserEntity> users = new LinkedHashMap<Integer, UserEntity>();
{
users.put(1, new UserEntity(1, "admin", "admin123", "15888888888"));
users.put(2, new UserEntity(2, "ry", "admin123", "15666666666"));
}
@ApiOperation("获取用户列表")
@GetMapping("/list")
public R<List<UserEntity>> userList()
{
List<UserEntity> userList = new ArrayList<UserEntity>(users.values());
return R.ok(userList);
}
@ApiOperation("获取用户详细")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@GetMapping("/{userId}")
public R<UserEntity> getUser(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
return R.ok(users.get(userId));
}
else
{
return R.fail("用户不存在");
}
}
@ApiOperation("新增用户")
@ApiImplicitParams({
@ApiImplicitParam(name = "userId", value = "用户id", dataType = "Integer", dataTypeClass = Integer.class),
@ApiImplicitParam(name = "username", value = "登陆账号", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "password", value = "用户密码", dataType = "String", dataTypeClass = String.class),
@ApiImplicitParam(name = "mobile", value = "用户手机", dataType = "String", dataTypeClass = String.class)
})
@PostMapping("/save")
public R<String> save(UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return R.fail("用户ID不能为空");
}
users.put(user.getUserId(), user);
return R.ok();
}
@ApiOperation("更新用户")
@PutMapping("/update")
public R<String> update(@RequestBody UserEntity user)
{
if (StringUtils.isNull(user) || StringUtils.isNull(user.getUserId()))
{
return R.fail("用户ID不能为空");
}
if (users.isEmpty() || !users.containsKey(user.getUserId()))
{
return R.fail("用户不存在");
}
users.remove(user.getUserId());
users.put(user.getUserId(), user);
return R.ok();
}
@ApiOperation("删除用户信息")
@ApiImplicitParam(name = "userId", value = "用户ID", required = true, dataType = "int", paramType = "path", dataTypeClass = Integer.class)
@DeleteMapping("/{userId}")
public R<String> delete(@PathVariable Integer userId)
{
if (!users.isEmpty() && users.containsKey(userId))
{
users.remove(userId);
return R.ok();
}
else
{
return R.fail("用户不存在");
}
}
}
@ApiModel(value = "UserEntity", description = "用户实体")
class UserEntity
{
@ApiModelProperty("用户ID")
private Integer userId;
@ApiModelProperty("登陆账号")
private String username;
@ApiModelProperty("用户密码")
private String password;
@ApiModelProperty("用户手机")
private String mobile;
public UserEntity()
{
}
public UserEntity(Integer userId, String username, String password, String mobile)
{
this.userId = userId;
this.username = username;
this.password = password;
this.mobile = mobile;
}
public Integer getUserId()
{
return userId;
}
public void setUserId(Integer userId)
{
this.userId = userId;
}
public String getUsername()
{
return username;
}
public void setUsername(String username)
{
this.username = username;
}
public String getPassword()
{
return password;
}
public void setPassword(String password)
{
this.password = password;
}
public String getMobile()
{
return mobile;
}
public void setMobile(String mobile)
{
this.mobile = mobile;
}
}

@ -0,0 +1,125 @@
package com.bs.web.core.config;
import java.util.ArrayList;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.bs.common.config.BsConfig;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.Contact;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.service.SecurityScheme;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
/**
* Swagger2
*
* @author bs
*/
@Configuration
public class SwaggerConfig
{
/** 系统基础配置 */
@Autowired
private BsConfig bsConfig;
/** 是否开启swagger */
@Value("${swagger.enabled}")
private boolean enabled;
/** 设置请求的统一前缀 */
@Value("${swagger.pathMapping}")
private String pathMapping;
/**
* API
*/
@Bean
public Docket createRestApi()
{
return new Docket(DocumentationType.OAS_30)
// 是否启用Swagger
.enable(enabled)
// 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
.apiInfo(apiInfo())
// 设置哪些接口暴露给Swagger展示
.select()
// 扫描所有有注解的api用这种方式更灵活
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解
// .apis(RequestHandlerSelectors.basePackage("com.bs.project.tool.swagger"))
// 扫描所有 .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build()
/* 设置安全模式swagger可以设置访问token */
.securitySchemes(securitySchemes())
.securityContexts(securityContexts())
.pathMapping(pathMapping);
}
/**
* tokenAuthorization
*/
private List<SecurityScheme> securitySchemes()
{
List<SecurityScheme> apiKeyList = new ArrayList<SecurityScheme>();
apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue()));
return apiKeyList;
}
/**
*
*/
private List<SecurityContext> securityContexts()
{
List<SecurityContext> securityContexts = new ArrayList<>();
securityContexts.add(
SecurityContext.builder()
.securityReferences(defaultAuth())
.operationSelector(o -> o.requestMappingPattern().matches("/.*"))
.build());
return securityContexts;
}
/**
*
*/
private List<SecurityReference> defaultAuth()
{
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
List<SecurityReference> securityReferences = new ArrayList<>();
securityReferences.add(new SecurityReference("Authorization", authorizationScopes));
return securityReferences;
}
/**
*
*/
private ApiInfo apiInfo()
{
// 用ApiInfoBuilder进行定制
return new ApiInfoBuilder()
// 设置标题
.title("标题德富金服经纪推广系统_接口文档")
// 描述
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// 作者信息
.contact(new Contact(bsConfig.getName(), null, null))
// 版本
.version("版本号:" + bsConfig.getVersion())
.build();
}
}

@ -0,0 +1,94 @@
package com.bs.web.utils;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.bs.system.domain.SysConfig;
import com.bs.system.mapper.SysConfigMapper;
import com.bs.system.service.ISysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
/**
*
* <br>
* WeiXinUtil <br>
*
*
* @author Tjw
* @date 201987 3:21:16
*/
@Slf4j
@Component
public class SignUtil {
public static Map<String, String> sign(String jsapi_ticket, String url) {
Map<String, String> ret = new HashMap<String, String>();
String nonce_str = create_nonce_str();
String timestamp = create_timestamp();
String string1;
String signature = "";
//注意这里参数名必须全部小写,且必须有序
string1 = "jsapi_ticket=" + jsapi_ticket +
"&noncestr=" + nonce_str +
"&timestamp=" + timestamp +
"&url=" + url;
try
{
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
crypt.reset();
crypt.update(string1.getBytes("UTF-8"));
signature = byteToHex(crypt.digest());
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
ret.put("nonceStr", nonce_str);
ret.put("timestamp", timestamp);
ret.put("signature", signature);
return ret;
}
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash)
{
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
private static String create_nonce_str() {
return UUID.randomUUID().toString();
}
private static String create_timestamp() {
return Long.toString(System.currentTimeMillis() / 1000);
}
}

@ -0,0 +1,109 @@
package com.bs.web.utils;
import com.alibaba.fastjson2.JSONObject;
import com.bs.system.service.ISysConfigService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* @author: gfk
* @create: 2023/6/23
* @Description:
* @FileName: WXSenMsgUtil
* @History:
* @
*/
@Slf4j
@Component
public class WXSenMsgUtil {
@Resource
private ISysConfigService sysConfigService;
@Resource
private WeiXinUtil weiXinUtil;
public boolean sendOpenIdToTemplateMessage(String templateKey,String openId,String path, JSONObject data) {
String templateId = getSysTemplate(templateKey);
if (!StringUtils.isEmpty(openId)) {
return weiXinUtil.sendMessage(data,openId,templateId,path);
}
return false;
}
/**
* <br>
* <br>
* https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1433751277
*
* @param templateKey
* @param openId openIdopenId
* @param path path
* @param values values
* @return
* @throws Exception
* @date: 201995 2:45:19
* @author Tjw
*/
public boolean sendOpenIdToTemplateMessage(String templateKey,String openId,String path, List<String> values)
{
String templateId = getSysTemplate(templateKey);
int size = values.size();
JSONObject data = new JSONObject();
for (int i = 0; i < size; i++) {
if (i == 0) {
JSONObject first = new JSONObject();
first.put("value",values.get(0));
data.put("first",first);
} else if (i == size-1) {
JSONObject remark = new JSONObject();
remark.put("value",values.get(0));
data.put("remark",remark);
} else {
JSONObject keyword = new JSONObject();
keyword.put("value",values.get(i));
data.put("keyword"+i,keyword);
}
}
if (!StringUtils.isEmpty(openId)) {
return weiXinUtil.sendMessage(data,openId,templateId,path);
}
return false;
}
/**
*
* @param templateCongifKey key
* @return
* @throws Exception
*/
private String getSysTemplate(String templateCongifKey){
String value = sysConfigService.selectConfigByKey(templateCongifKey);
if(StringUtils.isEmpty(value)){
return null;
}
return value;
}
public static void main(String[] args) throws Exception {
List<String> list = new ArrayList<>();
list.add("123");
list.add("456");
list.add("789");
list.add("10");
list.add("abc");
//sendOpenIdToTemplateMessage("kc6ADrWzxuFxVsvgKqM5V255LGCMe1DXg40S1CmL3Uc","otHaO4u_ISeXjLrTr3TZ5H_t0ZBw","",list);
}
}

File diff suppressed because it is too large Load Diff

@ -0,0 +1,132 @@
package com.bs.web.utils;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import cn.hutool.json.XML;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import javax.annotation.Resource;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.io.UnsupportedEncodingException;
class Sign {
@Resource
private WeiXinUtil weiXinUtil;
public static void main(String[] args) {
String jsapi_ticket = " <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<Root>\n" +
" <Corporation Name=\"三明市***电脑贸易有限公司\"/>\n" +
" <Corporation Name=\"三明市**运输有限公司\"/>\n" +
" <Corporation Name=\"东山县****有限公司\"/>\n" +
" <Corporation Name=\"中科**(福建)****有限公司\"/>\n" +
" <Corporation Name=\"仙游县*****铜门加工厂\"/>\n" +
" <Corporation Name=\"光泽县****开发有限公司\"/>\n" +
" <Corporation Name=\"南安市******有限公司\"/>\n" +
" <Corporation Name=\"南安市****加工厂\"/>\n" +
" <Corporation Name=\"南安****有限公司\"/>\n" +
" <Corporation Name=\"南靖县******有限公司\"/>\n" +
"</Root>";
String s = convertXmlToJson(jsapi_ticket);
Map<String, Object> mapJson = new HashMap<>();
try {
ObjectMapper mapper = new ObjectMapper();
mapJson = mapper.readValue(s, Map.class);
} catch (Exception e) {
e.printStackTrace();
}
Object messageJson = mapJson.get("Root");
LinkedHashMap<String, Object> nestedMapNts = (LinkedHashMap<String, Object>) messageJson;
LinkedHashMap<String, LinkedHashMap<String, Object>> nestedMapInfo = (LinkedHashMap<String, LinkedHashMap<String, Object>>) messageJson;
Object corporation = nestedMapNts.get("Corporation");
try {
JSONArray jsonArray = new JSONArray(corporation);
List<String> names = new ArrayList<>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String name = jsonObject.getStr("Name");
names.add(name);
}
System.out.println(names);
} catch (JSONException e) {
e.printStackTrace();
}
};
public static Map<String, String> sign(String jsapi_ticket, String url) {
Map<String, String> ret = new HashMap<String, String>();
String nonce_str = create_nonce_str();
String timestamp = create_timestamp();
String string1;
String signature = "";
//注意这里参数名必须全部小写,且必须有序
string1 = "jsapi_ticket=" + jsapi_ticket +
"&noncestr=" + nonce_str +
"&timestamp=" + timestamp +
"&url=" + url;
try
{
MessageDigest crypt = MessageDigest.getInstance("SHA-1");
crypt.reset();
crypt.update(string1.getBytes("UTF-8"));
signature = byteToHex(crypt.digest());
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
catch (UnsupportedEncodingException e)
{
e.printStackTrace();
}
ret.put("url", url);
ret.put("jsapi_ticket", jsapi_ticket);
ret.put("nonceStr", nonce_str);
ret.put("timestamp", timestamp);
ret.put("signature", signature);
return ret;
}
private static String byteToHex(final byte[] hash) {
Formatter formatter = new Formatter();
for (byte b : hash)
{
formatter.format("%02x", b);
}
String result = formatter.toString();
formatter.close();
return result;
}
private static String create_nonce_str() {
return UUID.randomUUID().toString();
}
private static String create_timestamp() {
return Long.toString(System.currentTimeMillis() / 1000);
}
public static String convertXmlToJson(String xmlString) {
JSONObject jsonObject = XML.toJSONObject(xmlString); // 使用JSON库将XML字符串转换为JSONObject对象
String jsonString = jsonObject.toString(); // 将JSONObject对象转换为JSON字符串
return jsonString;
}
}

@ -0,0 +1 @@
restart.include.json=/com.alibaba.fastjson.*.jar

@ -0,0 +1,68 @@
# 数据源配置
spring:
datasource:
type: com.alibaba.druid.pool.DruidDataSource
driverClassName: com.mysql.cj.jdbc.Driver
druid:
# 主库数据源
master:
url: jdbc:mysql://localhost:3306/df-broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
username: root
password: root
# url: jdbc:mysql://120.77.170.30:3306/df-broker?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&rewriteBatchedStatements=true
# username: root
# password: fastrise@chain
# 从库数据源
slave:
# 从数据源开关/默认关闭
enabled: false
url:
username:
password:
# 初始连接数
initialSize: 5
# 最小连接池数量
minIdle: 10
# 最大连接池数量
maxActive: 20
# 配置获取连接等待超时的时间
maxWait: 60000
# 配置连接超时时间
connectTimeout: 30000
# 配置网络超时时间
socketTimeout: 60000
# 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
# 配置一个连接在池中最大生存的时间,单位是毫秒
maxEvictableIdleTimeMillis: 900000
# 配置检测连接是否有效
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
webStatFilter:
enabled: true
statViewServlet:
enabled: true
# 设置白名单,不填则允许所有访问
allow:
url-pattern: /druid/*
# 控制台管理用户名和密码
login-username: bs
login-password: 123456
filter:
stat:
enabled: true
# 慢SQL记录
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
bs:
tenant:
#开启租户
openTenant: true

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save