u
This commit is contained in:
1 parent
7cd7bbd166
commit
ff327ba2fd
47 files changed
+4362
-1230
No files matched your search
+1
-1
@@ -23,7 +23,7 @@ public class AuthRegisterDTO {
|
||||
@NotBlank(message = "所属行业不能为空")
|
||||
private String industry;
|
||||
@NotBlank(message = "公司地址不能为空")
|
||||
private String address;
|
||||
private String area;
|
||||
private String phone;
|
||||
private String email;
|
||||
private String profile;
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@ public class AuthIdentityService {
|
||||
.setId(companyId)
|
||||
.setName(company.getName())
|
||||
.setIndustry(company.getIndustry())
|
||||
.setAddress(company.getAddress())
|
||||
.setArea(company.getArea())
|
||||
.setPhone(company.getPhone())
|
||||
.setEmail(company.getEmail())
|
||||
.setProfile(company.getProfile())
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
package cn.link56.base.controller;
|
||||
|
||||
import cn.link56.base.model.dto.AddFileDTO;
|
||||
import cn.link56.base.model.vo.AliyunKeyVO;
|
||||
import cn.link56.base.service.FileService;
|
||||
import cn.link56.common.Result;
|
||||
import cn.link56.common.utils.HttpUtils;
|
||||
import cn.link56.common.utils.JsonUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/base/file")
|
||||
public class FileController {
|
||||
@Resource
|
||||
private FileService fileService;
|
||||
|
||||
@PostMapping("/getAliyunKey")
|
||||
public Result<AliyunKeyVO> getAliyunKey() {
|
||||
String requestUrl = "http://g3oss.g3soft.cn:8082/upload?orgid=link56&bucket=g3hdzjsj";
|
||||
String s = HttpUtils.sendGet(requestUrl);
|
||||
AliyunKeyVO aliyunKeyVO = (AliyunKeyVO) JsonUtils.toBean(s, AliyunKeyVO.class);
|
||||
|
||||
assert aliyunKeyVO != null;
|
||||
|
||||
return Result.success(aliyunKeyVO);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
public Result<Void> insertFile(@RequestBody @Validated AddFileDTO addFileDTO) {
|
||||
fileService.addFile(addFileDTO);
|
||||
|
||||
return Result.success();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package cn.link56.base.mapper;
|
||||
|
||||
import cn.link56.base.model.po.FilePO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface FileMapper extends BaseMapper<FilePO> {
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package cn.link56.base.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AddFileDTO {
|
||||
@NotBlank(
|
||||
message = "文件名称不能为空"
|
||||
)
|
||||
private String fileName;
|
||||
|
||||
@NotBlank(
|
||||
message = "文件大小不能为空"
|
||||
)
|
||||
private String fileSize;
|
||||
|
||||
@NotBlank(
|
||||
message = "文件全路径oss不能为空"
|
||||
)
|
||||
private String fileMapName;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package cn.link56.base.model.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@TableName("b_file")
|
||||
@Accessors(chain = true)
|
||||
public class FilePO {
|
||||
@TableId(value = "b_id")
|
||||
private String id;
|
||||
|
||||
@TableField("mx_filename")
|
||||
private String name;
|
||||
|
||||
@TableField("mx_filesize")
|
||||
private String size;
|
||||
|
||||
@TableField("mx_fileext")
|
||||
private String ext;
|
||||
|
||||
@TableField("mx_mapfilename")
|
||||
private String mapName;
|
||||
|
||||
@TableField(
|
||||
value = "b_create_time",
|
||||
fill = FieldFill.INSERT
|
||||
)
|
||||
private String createTime;
|
||||
|
||||
@TableField(
|
||||
value = "b_create_by",
|
||||
fill = FieldFill.INSERT
|
||||
)
|
||||
private String createBy;
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.link56.base.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AliyunKeyVO {
|
||||
private String accessid;
|
||||
private String policy;
|
||||
private String signature;
|
||||
private String dir;
|
||||
private String host;
|
||||
private String expire;
|
||||
private String callback;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package cn.link56.base.service;
|
||||
|
||||
import cn.link56.base.mapper.FileMapper;
|
||||
import cn.link56.base.model.dto.AddFileDTO;
|
||||
import cn.link56.base.model.po.FilePO;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Service
|
||||
public class FileService extends ServiceImpl<FileMapper, FilePO> {
|
||||
@Resource
|
||||
private FileMapper fileMapper;
|
||||
|
||||
@Transactional
|
||||
public void addFile(AddFileDTO addFileDTO){
|
||||
String fileName = addFileDTO.getFileName();
|
||||
String fileSize = addFileDTO.getFileSize();
|
||||
String fileMapName = addFileDTO.getFileMapName();
|
||||
|
||||
String suffix = "";
|
||||
if (StringUtils.isNotEmpty(fileName)) {
|
||||
int lastDotIndex = fileName.lastIndexOf(46);
|
||||
if (lastDotIndex != -1 && lastDotIndex < fileName.length() - 1) {
|
||||
suffix = fileName.substring(lastDotIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
FilePO filePO = new FilePO();
|
||||
filePO.setExt(suffix).setName(fileName).setMapName(fileMapName).setSize(fileSize);
|
||||
fileMapper.insert(filePO);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.link56.common;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
@Accessors(chain = true)
|
||||
public class BasePageVO<T> {
|
||||
private long total;
|
||||
private List<T> records;
|
||||
}
|
||||
@@ -19,8 +19,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
|
||||
.addPathPatterns("/**")
|
||||
.excludePathPatterns(
|
||||
"/auth/**",
|
||||
"/company/getCompanyPage",
|
||||
"/company/getPublicDetail",
|
||||
"/company/query",
|
||||
"/company/detail/**",
|
||||
"/company/recommend",
|
||||
"/company/recommend/hot",
|
||||
|
||||
|
||||
@@ -0,0 +1,197 @@
|
||||
package cn.link56.common.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import javax.net.ssl.*;
|
||||
import java.io.*;
|
||||
import java.net.ConnectException;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.cert.X509Certificate;
|
||||
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
|
||||
public static String sendGet(String url) {
|
||||
return sendGet(url, "");
|
||||
}
|
||||
|
||||
public static String sendGet(String url, String param) {
|
||||
return sendGet(url, param, "UTF-8");
|
||||
}
|
||||
|
||||
public static String sendGet(String url, String param, String contentType) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
BufferedReader in = null;
|
||||
|
||||
try {
|
||||
String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
|
||||
URL realUrl = new URL(urlNameString);
|
||||
URLConnection connection = realUrl.openConnection();
|
||||
connection.setRequestProperty("accept", "*/*");
|
||||
connection.setRequestProperty("connection", "Keep-Alive");
|
||||
connection.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
||||
connection.connect();
|
||||
in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
|
||||
|
||||
String line;
|
||||
while((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
} catch (ConnectException e) {
|
||||
log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
|
||||
} catch (SocketTimeoutException e) {
|
||||
log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
|
||||
} catch (IOException e) {
|
||||
log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
|
||||
} catch (Exception e) {
|
||||
log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
|
||||
} finally {
|
||||
try {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String sendPost(String url, String param) {
|
||||
return sendPost(url, param, "application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
public static String sendPost(String url, String param, String contentType) {
|
||||
PrintWriter out = null;
|
||||
BufferedReader in = null;
|
||||
StringBuilder result = new StringBuilder();
|
||||
|
||||
try {
|
||||
log.info("sendPost - {}", url);
|
||||
URL realUrl = new URL(url);
|
||||
URLConnection conn = realUrl.openConnection();
|
||||
conn.setRequestProperty("accept", "*/*");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
||||
conn.setRequestProperty("Accept-Charset", "utf-8");
|
||||
conn.setRequestProperty("Content-Type", contentType);
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
out = new PrintWriter(conn.getOutputStream());
|
||||
out.print(param);
|
||||
out.flush();
|
||||
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
|
||||
|
||||
String line;
|
||||
while((line = in.readLine()) != null) {
|
||||
result.append(line);
|
||||
}
|
||||
|
||||
log.info("recv - {}", result);
|
||||
} catch (ConnectException e) {
|
||||
log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
|
||||
} catch (SocketTimeoutException e) {
|
||||
log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
|
||||
} catch (IOException e) {
|
||||
log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
|
||||
} catch (Exception e) {
|
||||
log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
|
||||
} finally {
|
||||
try {
|
||||
if (out != null) {
|
||||
out.close();
|
||||
}
|
||||
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String sendSSLPost(String url, String param) {
|
||||
return sendSSLPost(url, param, "application/x-www-form-urlencoded");
|
||||
}
|
||||
|
||||
public static String sendSSLPost(String url, String param, String contentType) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
String urlNameString = url + "?" + param;
|
||||
|
||||
try {
|
||||
log.info("sendSSLPost - {}", urlNameString);
|
||||
SSLContext sc = SSLContext.getInstance("SSL");
|
||||
sc.init((KeyManager[])null, new TrustManager[]{new TrustAnyTrustManager()}, new SecureRandom());
|
||||
URL console = new URL(urlNameString);
|
||||
HttpsURLConnection conn = (HttpsURLConnection)console.openConnection();
|
||||
conn.setRequestProperty("accept", "*/*");
|
||||
conn.setRequestProperty("connection", "Keep-Alive");
|
||||
conn.setRequestProperty("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
|
||||
conn.setRequestProperty("Accept-Charset", "utf-8");
|
||||
conn.setRequestProperty("Content-Type", contentType);
|
||||
conn.setDoOutput(true);
|
||||
conn.setDoInput(true);
|
||||
conn.setSSLSocketFactory(sc.getSocketFactory());
|
||||
conn.setHostnameVerifier(new TrustAnyHostnameVerifier());
|
||||
conn.connect();
|
||||
InputStream is = conn.getInputStream();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(is));
|
||||
String ret = "";
|
||||
|
||||
while((ret = br.readLine()) != null) {
|
||||
if (ret != null && !"".equals(ret.trim())) {
|
||||
result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
|
||||
log.info("recv - {}", result);
|
||||
conn.disconnect();
|
||||
br.close();
|
||||
} catch (ConnectException e) {
|
||||
log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
|
||||
} catch (SocketTimeoutException e) {
|
||||
log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
|
||||
} catch (IOException e) {
|
||||
log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
|
||||
} catch (Exception e) {
|
||||
log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
|
||||
}
|
||||
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private static class TrustAnyTrustManager implements X509TrustManager {
|
||||
private TrustAnyTrustManager() {
|
||||
}
|
||||
|
||||
public void checkClientTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
public void checkServerTrusted(X509Certificate[] chain, String authType) {
|
||||
}
|
||||
|
||||
public X509Certificate[] getAcceptedIssuers() {
|
||||
return new X509Certificate[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static class TrustAnyHostnameVerifier implements HostnameVerifier {
|
||||
private TrustAnyHostnameVerifier() {
|
||||
}
|
||||
|
||||
public boolean verify(String hostname, SSLSession session) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
-3
@@ -1,12 +1,16 @@
|
||||
package cn.link56.company.controller;
|
||||
|
||||
import cn.link56.common.BasePageVO;
|
||||
import cn.link56.common.Result;
|
||||
import cn.link56.company.model.dto.PageCompanyDTO;
|
||||
import cn.link56.company.model.vo.CompanyDetailVO;
|
||||
import cn.link56.company.model.vo.PageCompanyVO;
|
||||
import cn.link56.company.model.vo.RecommendCompanyVO;
|
||||
import cn.link56.company.model.vo.RecommendHotCompanyVO;
|
||||
import cn.link56.company.service.CompanyService;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
@@ -17,15 +21,32 @@ public class CompanyController {
|
||||
@Resource
|
||||
private CompanyService companyService;
|
||||
|
||||
// 公司分页
|
||||
@PostMapping("/query")
|
||||
public Result<BasePageVO<PageCompanyVO>> query(@RequestBody PageCompanyDTO pageCompanyDTO){
|
||||
BasePageVO<PageCompanyVO> data = companyService.queryCompany(pageCompanyDTO);
|
||||
return Result.success(data);
|
||||
}
|
||||
|
||||
// 企业名录
|
||||
@GetMapping("/recommend")
|
||||
public Result<List<RecommendCompanyVO>> listRecommend(){
|
||||
List<RecommendCompanyVO> list = companyService.listRecommend();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
// 热门推荐
|
||||
@GetMapping("/recommend/hot")
|
||||
public Result<List<RecommendHotCompanyVO>> listHot(){
|
||||
List<RecommendHotCompanyVO> list = companyService.listHot();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
// 公司详细
|
||||
@GetMapping("/detail/{id}")
|
||||
public Result<CompanyDetailVO> getCompanyDetail(@PathVariable Long id){
|
||||
CompanyDetailVO companyDetailVO = companyService.getCompanyDetail(id);
|
||||
return Result.success(companyDetailVO);
|
||||
}
|
||||
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package cn.link56.company.model.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PageCompanyDTO {
|
||||
private Integer currentPage;
|
||||
private Integer pageSize;
|
||||
|
||||
private List<String> areas;
|
||||
private List<String> industries;
|
||||
private String name;
|
||||
}
|
||||
@@ -30,8 +30,8 @@ public class CompanyPO {
|
||||
@TableField("b_phone")
|
||||
private String phone;
|
||||
|
||||
@TableField("b_address")
|
||||
private String address;
|
||||
@TableField("b_area")
|
||||
private String area;
|
||||
|
||||
@TableField("b_industry")
|
||||
private String industry;
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
package cn.link56.company.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CompanyDetailVO {
|
||||
private Long id;
|
||||
private String name;
|
||||
private List<String> areas;
|
||||
private List<String> industries;
|
||||
private String logo;
|
||||
private String profile;
|
||||
private String email;
|
||||
private String phone;
|
||||
private String description;
|
||||
private List<User> users;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class User{
|
||||
private Long id;
|
||||
private Long companyId;
|
||||
private String email;
|
||||
private String phone;
|
||||
private Integer role;
|
||||
private String position;
|
||||
private String name;
|
||||
}
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package cn.link56.company.model.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Accessors(chain = true)
|
||||
public class PageCompanyVO {
|
||||
private Long id;
|
||||
private String name;
|
||||
private List<String> areas;
|
||||
private List<String> industries;
|
||||
private String logo;
|
||||
private String profile;
|
||||
private String phone;
|
||||
private String email;
|
||||
}
|
||||
+93
@@ -1,15 +1,26 @@
|
||||
package cn.link56.company.service;
|
||||
|
||||
import cn.link56.common.BasePageVO;
|
||||
import cn.link56.company.mapper.CompanyMapper;
|
||||
import cn.link56.company.mapper.CompanyUserMapper;
|
||||
import cn.link56.company.model.dto.PageCompanyDTO;
|
||||
import cn.link56.company.model.middle.RecommendCompanyRow;
|
||||
import cn.link56.company.model.po.CompanyPO;
|
||||
import cn.link56.company.model.po.CompanyUserPO;
|
||||
import cn.link56.company.model.vo.CompanyDetailVO;
|
||||
import cn.link56.company.model.vo.PageCompanyVO;
|
||||
import cn.link56.company.model.vo.RecommendCompanyVO;
|
||||
import cn.link56.company.model.vo.RecommendHotCompanyVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -17,6 +28,8 @@ import java.util.stream.Collectors;
|
||||
public class CompanyService extends ServiceImpl<CompanyMapper,CompanyPO> {
|
||||
@Resource
|
||||
private CompanyMapper companyMapper;
|
||||
@Resource
|
||||
private CompanyUserService companyUserService;
|
||||
|
||||
public List<RecommendCompanyVO> listRecommend() {
|
||||
List<RecommendCompanyRow> rows = companyMapper.listRecommend();
|
||||
@@ -86,4 +99,84 @@ public class CompanyService extends ServiceImpl<CompanyMapper,CompanyPO> {
|
||||
return count > 0;
|
||||
}
|
||||
|
||||
public BasePageVO<PageCompanyVO> queryCompany(PageCompanyDTO pageCompanyDTO) {
|
||||
Integer currentPage = pageCompanyDTO.getCurrentPage();
|
||||
Integer pageSize = pageCompanyDTO.getPageSize();
|
||||
|
||||
String name = pageCompanyDTO.getName();
|
||||
List<String> areas = pageCompanyDTO.getAreas();
|
||||
List<String> industries = pageCompanyDTO.getIndustries();
|
||||
|
||||
// 分页
|
||||
Page<CompanyPO> companyPage = new Page<>(currentPage,pageSize);
|
||||
LambdaQueryWrapper<CompanyPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
// 名称
|
||||
if (StringUtils.isNotBlank(name)){
|
||||
queryWrapper.like(CompanyPO::getName,name);
|
||||
}
|
||||
|
||||
// 地区
|
||||
if (areas != null && !areas.isEmpty()){
|
||||
queryWrapper.and(wrapper -> {
|
||||
for (String area : areas) {
|
||||
wrapper.or(w -> w.like(CompanyPO::getArea, area));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 行业
|
||||
if (industries != null && !industries.isEmpty()) {
|
||||
queryWrapper.and(wrapper -> {
|
||||
for (String industry : industries) {
|
||||
wrapper.or(w -> w.like(CompanyPO::getIndustry, industry));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
queryWrapper.eq(CompanyPO::getCanuse,"1");
|
||||
|
||||
List<PageCompanyVO> result = companyMapper.selectList(companyPage, queryWrapper).stream().map(item -> {
|
||||
PageCompanyVO pageCompanyVO = new PageCompanyVO();
|
||||
|
||||
pageCompanyVO.setId(item.getId());
|
||||
pageCompanyVO.setName(item.getName());
|
||||
pageCompanyVO.setProfile(item.getProfile());
|
||||
pageCompanyVO.setLogo(item.getLogo());
|
||||
pageCompanyVO.setAreas(Arrays.stream(item.getArea().split(","))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
pageCompanyVO.setIndustries(Arrays.stream(item.getIndustry().split(","))
|
||||
.collect(Collectors.toList()));
|
||||
return pageCompanyVO;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
|
||||
return new BasePageVO<PageCompanyVO>()
|
||||
.setRecords(result)
|
||||
.setTotal(companyPage.getTotal());
|
||||
}
|
||||
|
||||
public CompanyDetailVO getCompanyDetail(Long companyId) {
|
||||
CompanyPO companyPO = companyMapper.selectById(companyId);
|
||||
List<CompanyUserPO> companyUserPOS = companyUserService.listByCompanyId(companyId);
|
||||
|
||||
CompanyDetailVO companyDetailVO = new CompanyDetailVO();
|
||||
|
||||
BeanUtils.copyProperties(companyPO,companyDetailVO);
|
||||
companyDetailVO.setAreas(Arrays.stream(companyPO.getArea().split(","))
|
||||
.collect(Collectors.toList()));
|
||||
companyDetailVO.setIndustries(Arrays.stream(companyPO.getIndustry().split(","))
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
companyDetailVO.setUsers(companyUserPOS.stream()
|
||||
.map(item -> {
|
||||
CompanyDetailVO.User user = new CompanyDetailVO.User();
|
||||
BeanUtils.copyProperties(item, user); // 复制属性
|
||||
return user;
|
||||
})
|
||||
.collect(Collectors.toList()));
|
||||
|
||||
return companyDetailVO;
|
||||
}
|
||||
}
|
||||
+7
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class CompanyUserService extends ServiceImpl<CompanyUserMapper, CompanyUserPO> {
|
||||
@@ -56,4 +57,10 @@ public class CompanyUserService extends ServiceImpl<CompanyUserMapper, CompanyUs
|
||||
return companyUserMapper.selectOne(queryWrapper);
|
||||
}
|
||||
|
||||
public List<CompanyUserPO> listByCompanyId(Long companyId){
|
||||
LambdaQueryWrapper<CompanyUserPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CompanyUserPO::getCompanyId,companyId);
|
||||
|
||||
return companyUserMapper.selectList(queryWrapper);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -19,7 +19,7 @@
|
||||
LEFT JOIN b_company c
|
||||
ON c.b_canuse = '1'
|
||||
AND c.b_recommend = '1'
|
||||
AND c.b_address LIKE '%' + shi.b_name + '%'
|
||||
AND c.b_area LIKE '%' + shi.b_name + '%'
|
||||
|
||||
WHERE
|
||||
shi.b_canuse = '1'
|
||||
|
||||
Reference in new issue
Block a user