Commit 119a2d1b authored by lixiaolei's avatar lixiaolei

submit

parent fbfb6af1
package com.dsk.web.controller.business;
import com.dsk.common.config.RuoYiConfig;
import com.dsk.common.core.controller.BaseController;
import com.dsk.common.core.domain.AjaxResult;
import com.dsk.common.utils.file.FileUtils;
import lombok.extern.slf4j.Slf4j;
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 java.io.IOException;
import java.util.List;
/**
* @author lxl
* @Description: 项目文件管理Controller
* @Date 2023/5/30 上午 8:44
**/
@Slf4j
@RestController
@RequestMapping("/business/file")
public class BusinessFileController extends BaseController {
// 本地资源路径
public static final String LOCALPATH = RuoYiConfig.getProfile();
/**
* 新建文件夹
*/
// @PreAuthorize("@ss.hasPermi('system:file:add')")
// @Log(title = "项目资料文档", businessType = BusinessType.INSERT)
@GetMapping("/new/{filePath}")
public AjaxResult newFolder(@PathVariable String filePath) {
return FileUtils.newFolder(LOCALPATH + filePath) ? AjaxResult.success() : AjaxResult.error();
}
/**
* 删除某个文件或整个文件夹
*/
@GetMapping("/remove/{filePath}")
public AjaxResult removeFile(@PathVariable String filePath) {
boolean deleteFile = FileUtils.deleteFile(LOCALPATH + filePath);
return deleteFile ? AjaxResult.success() : AjaxResult.error();
}
/**
* 获取文件夹中所有文件
*/
@GetMapping("/all/{folderPath}")
public AjaxResult getAllFiles(@PathVariable String folderPath) {
List<String> allFiles = FileUtils.getAllFiles(LOCALPATH + folderPath);
return AjaxResult.success(allFiles);
}
/**
* 上传文件及文件夹
* @param url
* @param folderPath
* @return
*/
@GetMapping("/upload/{url}/{folderPath}")
public AjaxResult uploadFolder(@PathVariable("url") String url,@PathVariable("folderPath") String folderPath) throws IOException {
return toAjax(FileUtils.uploadFolder(url, LOCALPATH + folderPath));
}
/**
* 下载文件
* @param url
* @param targetFolder
* @return
*/
@GetMapping("/download/{url}/{targetFolder}")
public AjaxResult downloadFolder(@PathVariable("url") String url,@PathVariable("targetFolder") String targetFolder) throws IOException {
return toAjax(FileUtils.downloadFolder(url, targetFolder));
}
}
...@@ -90,7 +90,7 @@ public class BusinessInfoController extends BaseController ...@@ -90,7 +90,7 @@ public class BusinessInfoController extends BaseController
* 删除项目列表 * 删除项目列表
*/ */
// @PreAuthorize("@ss.hasPermi('system:business:remove')") // @PreAuthorize("@ss.hasPermi('system:business:remove')")
@Log(title = "项目管理", businessType = BusinessType.DELETE) // @Log(title = "项目管理", businessType = BusinessType.DELETE)
@DeleteMapping("/remove/{ids}") @DeleteMapping("/remove/{ids}")
public AjaxResult remove(@PathVariable(value = "ids",required=false) Long[] ids) public AjaxResult remove(@PathVariable(value = "ids",required=false) Long[] ids)
{ {
...@@ -101,7 +101,7 @@ public class BusinessInfoController extends BaseController ...@@ -101,7 +101,7 @@ public class BusinessInfoController extends BaseController
* 新增项目详情 * 新增项目详情
*/ */
// @PreAuthorize("@ss.hasPermi('system:business:add')") // @PreAuthorize("@ss.hasPermi('system:business:add')")
@Log(title = "项目管理", businessType = BusinessType.INSERT) // @Log(title = "项目管理", businessType = BusinessType.INSERT)
@PostMapping("/add") @PostMapping("/add")
public AjaxResult add(@RequestBody BusinessAddDto dto) public AjaxResult add(@RequestBody BusinessAddDto dto)
{ {
...@@ -112,7 +112,7 @@ public class BusinessInfoController extends BaseController ...@@ -112,7 +112,7 @@ public class BusinessInfoController extends BaseController
* 修改项目详情 * 修改项目详情
*/ */
// @PreAuthorize("@ss.hasPermi('system:business:edit')") // @PreAuthorize("@ss.hasPermi('system:business:edit')")
@Log(title = "项目管理", businessType = BusinessType.UPDATE) // @Log(title = "项目管理", businessType = BusinessType.UPDATE)
@PostMapping("/edit") @PostMapping("/edit")
public AjaxResult edit(@RequestBody BusinessInfo businessInfo) public AjaxResult edit(@RequestBody BusinessInfo businessInfo)
{ {
......
...@@ -53,6 +53,10 @@ public class BusinessRelateCompany extends BaseEntity ...@@ -53,6 +53,10 @@ public class BusinessRelateCompany extends BaseEntity
@Excel(name = "对接深度/竞争力度") @Excel(name = "对接深度/竞争力度")
private String depth; private String depth;
/** 企业类型 */
@Excel(name = "企业类型")
private String companyType;
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
...@@ -66,6 +70,7 @@ public class BusinessRelateCompany extends BaseEntity ...@@ -66,6 +70,7 @@ public class BusinessRelateCompany extends BaseEntity
.append("createTime", getCreateTime()) .append("createTime", getCreateTime())
.append("updateTime", getUpdateTime()) .append("updateTime", getUpdateTime())
.append("depth", getDepth()) .append("depth", getDepth())
.append("companyType", getCompanyType())
.toString(); .toString();
} }
......
...@@ -26,6 +26,14 @@ import org.apache.commons.lang3.ArrayUtils; ...@@ -26,6 +26,14 @@ import org.apache.commons.lang3.ArrayUtils;
import com.dsk.common.config.RuoYiConfig; import com.dsk.common.config.RuoYiConfig;
import com.dsk.common.utils.uuid.IdUtils; import com.dsk.common.utils.uuid.IdUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.entity.mime.content.FileBody;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
/** /**
* 文件处理工具类 * 文件处理工具类
...@@ -292,12 +300,12 @@ public class FileUtils ...@@ -292,12 +300,12 @@ public class FileUtils
/** /**
* 下载文件 * 下载文件
*
* @param url 要下载的文件链接 * @param url 要下载的文件链接
* @param targetFolder 目标文件 * @param targetFolder 目标文件
* @return
* @throws IOException * @throws IOException
*/ */
public static void downloadFolder(String url, String targetFolder) throws IOException { public static boolean downloadFolder(String url, String targetFolder) throws IOException {
URL downloadUrl = new URL(url); URL downloadUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection(); HttpURLConnection connection = (HttpURLConnection) downloadUrl.openConnection();
connection.setRequestMethod("GET"); connection.setRequestMethod("GET");
...@@ -330,6 +338,52 @@ public class FileUtils ...@@ -330,6 +338,52 @@ public class FileUtils
} }
} }
} }
return true;
}
/**
* 上传文件
* @param url 上传链接
* @param folderPath 文件路径
* @return
* @throws IOException
*/
public static boolean uploadFolder(String url, String folderPath) throws IOException {
File folder = new File(folderPath);
if (!folder.exists() || !folder.isDirectory()) {
throw new IllegalArgumentException("文件夹路径无效: " + folderPath);
}
List<File> files = new ArrayList<>();
listFiles(folder, files);
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(url);
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
for (File file : files) {
FileBody fileBody = new FileBody(file, ContentType.DEFAULT_BINARY);
builder.addPart("file", fileBody);
}
HttpEntity multipart = builder.build();
httpPost.setEntity(multipart);
HttpResponse response = httpClient.execute(httpPost);
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode != 200) {
throw new RuntimeException("上传文件夹失败: " + response.getStatusLine().getReasonPhrase());
}
}
return true;
}
private static void listFiles(File folder, List<File> files) {
File[] subFiles = folder.listFiles();
for (File subFile : subFiles) {
if (subFile.isDirectory()) {
listFiles(subFile, files);
} else {
files.add(subFile);
}
}
} }
......
...@@ -169,6 +169,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -169,6 +169,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
//新增项目主信息 //新增项目主信息
BusinessInfo businessInfo = new BusinessInfo(); BusinessInfo businessInfo = new BusinessInfo();
BeanUtil.copyProperties(dto, businessInfo); BeanUtil.copyProperties(dto, businessInfo);
businessInfo.setConstructionUnit(dto.getOwnerCompany());
int addBusiness = businessInfoMapper.insertBusinessInfo(businessInfo); int addBusiness = businessInfoMapper.insertBusinessInfo(businessInfo);
if (addBusiness > 0) { if (addBusiness > 0) {
//获取登陆用户的部门id //获取登陆用户的部门id
...@@ -176,9 +177,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService { ...@@ -176,9 +177,7 @@ public class BusinessInfoServiceImpl implements IBusinessInfoService {
// Long deptId = 100l; // Long deptId = 100l;
//新增用户-项目关系信息 //新增用户-项目关系信息
int addbusinessUser = businessUserMapper.insertBusinessUser(new BusinessUser(businessInfo.getId(), deptId.intValue(), dto.getUserId(), 1)); int addbusinessUser = businessUserMapper.insertBusinessUser(new BusinessUser(businessInfo.getId(), deptId.intValue(), dto.getUserId(), 1));
//新增项目-关联企业信息 return addbusinessUser > 0 ? AjaxResult.success() : AjaxResult.error();
int addRelateCompany = businessRelateCompanyMapper.insertBusinessRelateCompany(new BusinessRelateCompany(businessInfo.getId(), dto.getCompanyId(), dto.getOwnerCompany(), "业主"));
return addbusinessUser > 0 && addRelateCompany > 0 ? AjaxResult.success() : AjaxResult.error();
} }
return AjaxResult.error(); return AjaxResult.error();
......
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="depth" column="depth"/> <result property="depth" column="depth"/>
<result property="companyType" column="company_type"/>
</resultMap> </resultMap>
<sql id="selectBusinessRelateCompanyVo"> <sql id="selectBusinessRelateCompanyVo">
...@@ -27,7 +28,8 @@ ...@@ -27,7 +28,8 @@
phone, phone,
depth, depth,
create_time, create_time,
update_time update_time,
company_type
from business_relate_company from business_relate_company
</sql> </sql>
...@@ -46,6 +48,7 @@ ...@@ -46,6 +48,7 @@
#{responsiblePerson} #{responsiblePerson}
</if> </if>
<if test="phone != null and phone != ''">and phone = #{phone}</if> <if test="phone != null and phone != ''">and phone = #{phone}</if>
<if test="companyType != null and companyType != ''">and company_type = #{companyType}</if>
</where> </where>
</select> </select>
...@@ -67,6 +70,7 @@ ...@@ -67,6 +70,7 @@
<if test="phone != null">phone,</if> <if test="phone != null">phone,</if>
<if test="createTime != null">create_time,</if> <if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if> <if test="updateTime != null">update_time,</if>
<if test="companyType != null">company_type,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="businessId != null">#{businessId},</if> <if test="businessId != null">#{businessId},</if>
...@@ -78,6 +82,7 @@ ...@@ -78,6 +82,7 @@
<if test="phone != null">#{phone},</if> <if test="phone != null">#{phone},</if>
<if test="createTime != null">#{createTime},</if> <if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if> <if test="updateTime != null">#{updateTime},</if>
<if test="companyType != null">#{companyType},</if>
</trim> </trim>
</insert> </insert>
...@@ -93,6 +98,7 @@ ...@@ -93,6 +98,7 @@
<if test="phone != null">phone = #{phone},</if> <if test="phone != null">phone = #{phone},</if>
<if test="createTime != null">create_time = #{createTime},</if> <if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="updateTime != null">update_time = #{updateTime},</if>
<if test="companyType != null">company_type = #{companyType},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment