This commit is contained in:
oneao committed 2025-12-16 22:26:59 +08:00
1 parent 8a25c14a1b
commit 7cd7bbd166
34 files changed
+516 -227

No files matched your search

@@ -9,11 +9,11 @@ import cn.link56.auth.identity.model.vo.AuthLoginVO;
import cn.link56.auth.token.model.AuthToken;
import cn.link56.auth.token.model.TokenPayload;
import cn.link56.auth.token.service.AuthTokenService;
import cn.link56.entity.BCompany;
import cn.link56.entity.BCompanyUser;
import cn.link56.company.model.po.CompanyPO;
import cn.link56.company.model.po.CompanyUserPO;
import cn.link56.auth.identity.model.dto.AuthRegisterDTO;
import cn.link56.base.service.BCompanyService;
import cn.link56.base.service.BCompanyUserService;
import cn.link56.company.service.CompanyService;
import cn.link56.company.service.CompanyUserService;
import cn.link56.common.exception.BusinessException;
import cn.link56.common.utils.snowflake.idgen.IdGenerator;
import org.apache.commons.lang3.StringUtils;
@@ -25,9 +25,9 @@ import javax.annotation.Resource;
@Service
public class AuthIdentityService {
@Resource
private BCompanyService companyService;
private CompanyService companyService;
@Resource
private BCompanyUserService companyUserService;
private CompanyUserService companyUserService;
@Resource
private AuthTokenService tokenService;
@Resource
@@ -57,7 +57,7 @@ public class AuthIdentityService {
long companyId = IdGenerator.nextId();
companyService.save(
new BCompany()
new CompanyPO()
.setId(companyId)
.setName(company.getName())
.setIndustry(company.getIndustry())
@@ -68,7 +68,7 @@ public class AuthIdentityService {
);
companyUserService.save(
new BCompanyUser()
new CompanyUserPO()
.setId(IdGenerator.nextId())
.setCompanyId(companyId)
.setName(admin.getName())
@@ -81,7 +81,7 @@ public class AuthIdentityService {
}
public AuthLoginVO loginByPassword(AuthLoginPasswordDTO dto) {
BCompanyUser user = companyUserService.loginByEmailAndPassword(dto.getEmail(), dto.getPassword());
CompanyUserPO user = companyUserService.loginByEmailAndPassword(dto.getEmail(), dto.getPassword());
if (user == null) {
throw new BusinessException("邮箱或密码错误");
}
@@ -103,7 +103,7 @@ public class AuthIdentityService {
throw new BusinessException("邮箱或验证码失效");
}
BCompanyUser user = companyUserService.loginByEmail(email);
CompanyUserPO user = companyUserService.loginByEmail(email);
if (user == null) {
throw new BusinessException("邮箱不存在");
}
@@ -114,8 +114,8 @@ public class AuthIdentityService {
/**
* 公共逻辑:根据用户生成 LoginVO
*/
private AuthLoginVO buildLoginVO(BCompanyUser user) {
BCompany company = companyService.getById(user.getCompanyId());
private AuthLoginVO buildLoginVO(CompanyUserPO user) {
CompanyPO company = companyService.getById(user.getCompanyId());
AuthToken authToken = tokenService.generateToken(new TokenPayload(user.getCompanyId(), user.getId()));
return new AuthLoginVO(
@@ -1,6 +1,6 @@
package cn.link56.base.mapper;
import cn.link56.entity.BArea;
import cn.link56.base.model.po.AreaPO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@@ -11,5 +11,5 @@ public interface AreaMapper {
* 获取所有区域信息
* @return 区域集合
*/
List<BArea> listAllArea();
List<AreaPO> listAllArea();
}
@@ -1,9 +0,0 @@
package cn.link56.base.mapper;
import cn.link56.entity.BCompany;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BCompanyMapper extends BaseMapper<BCompany> {
}
@@ -1,9 +0,0 @@
package cn.link56.base.mapper;
import cn.link56.entity.BCompanyUser;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface BCompanyUserMapper extends BaseMapper<BCompanyUser> {
}
@@ -1,9 +1,9 @@
package cn.link56.base.mapper;
import cn.link56.entity.BIndustry;
import cn.link56.base.model.po.IndustryPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface IndustryMapper extends BaseMapper<BIndustry> {
public interface IndustryMapper extends BaseMapper<IndustryPO> {
}
@@ -1,4 +1,4 @@
package cn.link56.entity;
package cn.link56.base.model.po;
import lombok.AllArgsConstructor;
import lombok.Data;
@@ -7,7 +7,7 @@ import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BArea {
public class AreaPO {
private String id;
private Integer xh;
private String name;
@@ -1,4 +1,4 @@
package cn.link56.entity;
package cn.link56.base.model.po;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
@@ -13,7 +13,7 @@ import lombok.experimental.Accessors;
@NoArgsConstructor
@TableName("b_industry")
@Accessors(chain = true)
public class BIndustry {
public class IndustryPO {
@TableId(value = "b_id")
private Long id;
@TableField("b_xh")
@@ -1,39 +0,0 @@
package cn.link56.base.service;
import cn.link56.base.mapper.BCompanyMapper;
import cn.link56.entity.BCompany;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class BCompanyService extends ServiceImpl<BCompanyMapper, BCompany> {
@Resource
private BCompanyMapper companyMapper;
/**
* 检查公司名称是否重复
*/
public boolean isNameExists(String name) {
Long count = companyMapper.selectCount(
new LambdaQueryWrapper<BCompany>()
.eq(BCompany::getName, name)
);
return count > 0;
}
/**
* 检查公司手机号是否重复
*/
public boolean isPhoneExists(String phone) {
Long count = companyMapper.selectCount(
new LambdaQueryWrapper<BCompany>()
.eq(BCompany::getPhone, phone)
);
return count > 0;
}
}
@@ -1,59 +0,0 @@
package cn.link56.base.service;
import cn.link56.base.mapper.BCompanyUserMapper;
import cn.link56.entity.BCompanyUser;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class BCompanyUserService extends ServiceImpl<BCompanyUserMapper, BCompanyUser> {
@Resource
private BCompanyUserMapper companyUserMapper;
/**
* 判断邮箱是否重复
* @param email 用户邮箱
* @return true 表示邮箱已存在,false 表示可用
*/
public boolean isEmailExists(String email) {
long count = companyUserMapper.selectCount(
new LambdaQueryWrapper<BCompanyUser>()
.eq(BCompanyUser::getEmail, email)
);
return count > 0;
}
/**
* 判断手机号是否重复
* @param phone 用户手机号
* @return true 表示手机号已存在,false 表示可用
*/
public boolean isPhoneExists(String phone) {
long count = companyUserMapper.selectCount(
new LambdaQueryWrapper<BCompanyUser>()
.eq(BCompanyUser::getPhone, phone)
);
return count > 0;
}
public BCompanyUser loginByEmailAndPassword(String email, String password){
LambdaQueryWrapper<BCompanyUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BCompanyUser::getEmail,email)
.eq(BCompanyUser::getPassword,password);
return companyUserMapper.selectOne(queryWrapper);
}
public BCompanyUser loginByEmail(String email){
LambdaQueryWrapper<BCompanyUser> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(BCompanyUser::getEmail,email);
return companyUserMapper.selectOne(queryWrapper);
}
}
@@ -2,8 +2,8 @@ package cn.link56.base.service;
import cn.link56.base.mapper.AreaMapper;
import cn.link56.base.mapper.IndustryMapper;
import cn.link56.entity.BArea;
import cn.link56.entity.BIndustry;
import cn.link56.base.model.po.AreaPO;
import cn.link56.base.model.po.IndustryPO;
import cn.link56.base.model.vo.BaseDataVO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.stereotype.Service;
@@ -15,17 +15,17 @@ import java.util.stream.Collectors;
@Service
public class BaseDataService {
@Resource
private IndustryMapper industryMapper;
private IndustryMapper IndustryMapper;
@Resource
private AreaMapper areaMapper;
private AreaMapper AreaMapper;
public BaseDataVO getBaseData() {
BaseDataVO baseDataVO = new BaseDataVO();
// 查询可用行业
List<BaseDataVO.Industry> industries = industryMapper.selectList(
new LambdaQueryWrapper<BIndustry>()
.eq(BIndustry::getCanuse, "1")
List<BaseDataVO.Industry> industries = IndustryMapper.selectList(
new LambdaQueryWrapper<IndustryPO>()
.eq(IndustryPO::getCanuse, "1")
).stream()
.map(industry -> new BaseDataVO.Industry(
industry.getId(),
@@ -37,7 +37,7 @@ public class BaseDataService {
baseDataVO.setIndustries(industries);
// 地区
List<BArea> allAreas = areaMapper.listAllArea();
List<AreaPO> allAreas = AreaMapper.listAllArea();
List<BaseDataVO.Area> areaTree = buildAreaTree(allAreas);
baseDataVO.setAreas(areaTree);
@@ -47,7 +47,7 @@ public class BaseDataService {
/**
* BArea → BaseDataVO.Area 树
*/
private List<BaseDataVO.Area> buildAreaTree(List<BArea> areas) {
private List<BaseDataVO.Area> buildAreaTree(List<AreaPO> areas) {
if (areas == null || areas.isEmpty()) {
return Collections.emptyList();
}
@@ -56,7 +56,7 @@ public class BaseDataService {
Map<String, BaseDataVO.Area> map = new HashMap<>(areas.size());
// 1️⃣ 先全部转 VO
for (BArea a : areas) {
for (AreaPO a : areas) {
BaseDataVO.Area vo = new BaseDataVO.Area(
a.getId(),
a.getXh(),
@@ -72,7 +72,7 @@ public class BaseDataService {
for (BaseDataVO.Area area : map.values()) {
String parentId = area.getFatherId();
if (parentId == null || "0".equals(parentId)) {
if (parentId == null || parentId.isEmpty()) {
roots.add(area);
} else {
BaseDataVO.Area parent = map.get(parentId);
@@ -21,8 +21,8 @@ public class WebMvcConfig implements WebMvcConfigurer {
"/auth/**",
"/company/getCompanyPage",
"/company/getPublicDetail",
"/company/getRecommendList",
"/company/getRecommendRightList",
"/company/recommend",
"/company/recommend/hot",
"/forum/post/page",
"/forum/post/detail",
@@ -0,0 +1,31 @@
package cn.link56.company.controller;
import cn.link56.common.Result;
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 javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/company")
public class CompanyController {
@Resource
private CompanyService companyService;
@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);
}
}
@@ -0,0 +1,13 @@
package cn.link56.company.mapper;
import cn.link56.company.model.middle.RecommendCompanyRow;
import cn.link56.company.model.po.CompanyPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface CompanyMapper extends BaseMapper<CompanyPO> {
List<RecommendCompanyRow> listRecommend();
}
@@ -0,0 +1,9 @@
package cn.link56.company.mapper;
import cn.link56.company.model.po.CompanyUserPO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface CompanyUserMapper extends BaseMapper<CompanyUserPO> {
}
@@ -0,0 +1,17 @@
package cn.link56.company.model.middle;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RecommendCompanyRow {
private String shengName;
private String shiName;
private Long companyId;
private String companyName;
private String color;
}
@@ -1,4 +1,4 @@
package cn.link56.entity;
package cn.link56.company.model.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -17,7 +17,7 @@ import java.util.Date;
@NoArgsConstructor
@TableName("b_company")
@Accessors(chain = true)
public class BCompany {
public class CompanyPO {
@TableId(value = "b_id")
private Long id;
@@ -59,6 +59,9 @@ public class BCompany {
@TableField("b_recommend")
private String recommend;
@TableField("b_recommend_color")
private String recommendColor;
@TableField("b_hot_recommend")
private String hotRecommend;
}
@@ -1,4 +1,4 @@
package cn.link56.entity;
package cn.link56.company.model.po;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
@@ -17,7 +17,7 @@ import java.util.Date;
@NoArgsConstructor
@TableName("b_company_user")
@Accessors(chain = true)
public class BCompanyUser {
public class CompanyUserPO {
@TableId(value = "b_id")
private Long id;
@@ -0,0 +1,25 @@
package cn.link56.company.model.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RecommendCompanyVO {
private String shengName;
private String shiName;
private List<Company> companies;
@Data
@AllArgsConstructor
@NoArgsConstructor
public static class Company {
private Long id;
private String name;
private String color;
}
}
@@ -0,0 +1,13 @@
package cn.link56.company.model.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class RecommendHotCompanyVO {
private Long id;
private String name;
}
@@ -0,0 +1,89 @@
package cn.link56.company.service;
import cn.link56.company.mapper.CompanyMapper;
import cn.link56.company.model.middle.RecommendCompanyRow;
import cn.link56.company.model.po.CompanyPO;
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.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class CompanyService extends ServiceImpl<CompanyMapper,CompanyPO> {
@Resource
private CompanyMapper companyMapper;
public List<RecommendCompanyVO> listRecommend() {
List<RecommendCompanyRow> rows = companyMapper.listRecommend();
return rows.stream()
.collect(Collectors.groupingBy(
row -> row.getShengName() + "_" + row.getShiName()
))
.values()
.stream()
.map(group -> {
RecommendCompanyRow first = group.get(0);
List<RecommendCompanyVO.Company> companies = group.stream()
.filter(r -> r.getCompanyId() != null)
.map(r -> new RecommendCompanyVO.Company(
r.getCompanyId(),
r.getCompanyName(),
r.getColor()
))
.collect(Collectors.toList());
return new RecommendCompanyVO(
first.getShengName(),
first.getShiName(),
companies
);
})
.filter(vo -> vo.getCompanies() != null && !vo.getCompanies().isEmpty())
.collect(Collectors.toList());
}
public List<RecommendHotCompanyVO> listHot() {
LambdaQueryWrapper<CompanyPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CompanyPO::getHotRecommend, "1")
.select(CompanyPO::getId, CompanyPO::getName);
return companyMapper.selectList(queryWrapper)
.stream()
.map(company -> new RecommendHotCompanyVO(
company.getId(),
company.getName()
))
.collect(Collectors.toList());
}
/**
* 检查公司名称是否重复
*/
public boolean isNameExists(String name) {
Long count = companyMapper.selectCount(
new LambdaQueryWrapper<CompanyPO>()
.eq(CompanyPO::getName, name)
);
return count > 0;
}
/**
* 检查公司手机号是否重复
*/
public boolean isPhoneExists(String phone) {
Long count = companyMapper.selectCount(
new LambdaQueryWrapper<CompanyPO>()
.eq(CompanyPO::getPhone, phone)
);
return count > 0;
}
}
@@ -0,0 +1,59 @@
package cn.link56.company.service;
import cn.link56.company.mapper.CompanyUserMapper;
import cn.link56.company.model.po.CompanyUserPO;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@Service
public class CompanyUserService extends ServiceImpl<CompanyUserMapper, CompanyUserPO> {
@Resource
private CompanyUserMapper companyUserMapper;
/**
* 判断邮箱是否重复
* @param email 用户邮箱
* @return true 表示邮箱已存在,false 表示可用
*/
public boolean isEmailExists(String email) {
long count = companyUserMapper.selectCount(
new LambdaQueryWrapper<CompanyUserPO>()
.eq(CompanyUserPO::getEmail, email)
);
return count > 0;
}
/**
* 判断手机号是否重复
* @param phone 用户手机号
* @return true 表示手机号已存在,false 表示可用
*/
public boolean isPhoneExists(String phone) {
long count = companyUserMapper.selectCount(
new LambdaQueryWrapper<CompanyUserPO>()
.eq(CompanyUserPO::getPhone, phone)
);
return count > 0;
}
public CompanyUserPO loginByEmailAndPassword(String email, String password){
LambdaQueryWrapper<CompanyUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CompanyUserPO::getEmail,email)
.eq(CompanyUserPO::getPassword,password);
return companyUserMapper.selectOne(queryWrapper);
}
public CompanyUserPO loginByEmail(String email){
LambdaQueryWrapper<CompanyUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CompanyUserPO::getEmail,email);
return companyUserMapper.selectOne(queryWrapper);
}
}
@@ -1,9 +0,0 @@
package cn.link56.feature.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/features")
public class FeatureController {
}
@@ -15,7 +15,7 @@
b_order AS [order]
</sql>
<select id="listAllArea" resultType="cn.link56.entity.BArea">
<select id="listAllArea" resultType="cn.link56.base.model.po.AreaPO">
SELECT <include refid="area_columns"/> FROM b_area_sheng WHERE b_canuse = '1'
UNION ALL
SELECT <include refid="area_columns"/> FROM b_area_shi WHERE b_canuse = '1'
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.link56.company.mapper.CompanyMapper">
<select id="listRecommend" resultType="cn.link56.company.model.middle.RecommendCompanyRow">
SELECT
sheng.b_name AS shengName,
shi.b_name AS shiName,
c.b_id AS companyId,
c.b_name AS companyName,
c.b_recommend_color AS color
FROM b_area_shi shi
JOIN b_area_sheng sheng
ON shi.b_father_id = sheng.b_id
LEFT JOIN b_company c
ON c.b_canuse = '1'
AND c.b_recommend = '1'
AND c.b_address LIKE '%' + shi.b_name + '%'
WHERE
shi.b_canuse = '1'
AND shi.b_visible = '1'
AND sheng.b_canuse = '1'
ORDER BY
sheng.b_order ASC,
shi.b_order ASC
</select>
</mapper>