This commit is contained in:
sxu 2023-12-09 17:44:13 +08:00
parent 42ea13df4b
commit ba742a0baf
4 changed files with 96 additions and 1 deletions

View File

@ -79,4 +79,5 @@ public class DevInfoVo extends DevInfo {
private String cityStr; private String cityStr;
@ApiModelProperty(value = "区名称") @ApiModelProperty(value = "区名称")
private String areaStr; private String areaStr;
private Long userId;
} }

View File

@ -45,6 +45,7 @@ public interface DevInfoMapper
*/ */
public List<DevInfoVo> selectDevInfoList(DevInfo devInfo); public List<DevInfoVo> selectDevInfoList(DevInfo devInfo);
// public List<DevInfoVo> selectDevInfoList4Collect(DevInfo devInfo);
public List<UserCollect> selectUserCollectByUserId(Long userId); public List<UserCollect> selectUserCollectByUserId(Long userId);
public List<DevInfoVo> selectDevInfoHotList(DevInfo devInfo); public List<DevInfoVo> selectDevInfoHotList(DevInfo devInfo);

View File

@ -128,12 +128,19 @@ public class DevInfoServiceImpl implements IDevInfoService
public List<DevInfoVo> selectUserCollectList(DevInfoVo devInfo) public List<DevInfoVo> selectUserCollectList(DevInfoVo devInfo)
{ {
List<DevInfoVo> result = new ArrayList<>(); List<DevInfoVo> result = new ArrayList<>();
//simple way
result = devInfoMapper.selectDevInfoList(devInfo); result = devInfoMapper.selectDevInfoList(devInfo);
LoginUser user = SecurityUtils.getLoginUser(); LoginUser user = SecurityUtils.getLoginUser();
if (Objects.nonNull(user)) { if (Objects.nonNull(user)) {
List<UserCollect> userCollectList = devInfoMapper.selectUserCollectByUserId(user.getUserid()); List<UserCollect> userCollectList = devInfoMapper.selectUserCollectByUserId(user.getUserid());
result = filterUserCollect(result, userCollectList); result = filterUserCollect(result, userCollectList);
} }
//complex sql, it works
// LoginUser user = SecurityUtils.getLoginUser();
// if (Objects.nonNull(user)) {
// devInfo.setUserId(user.getUserid());
// result = devInfoMapper.selectDevInfoList4Collect(devInfo);
// }
fillInMaStatusStr(result); fillInMaStatusStr(result);
fillInCityStr(result); fillInCityStr(result);
return result; return result;
@ -143,7 +150,7 @@ public class DevInfoServiceImpl implements IDevInfoService
List<DevInfoVo> result = new ArrayList<>(); List<DevInfoVo> result = new ArrayList<>();
for (DevInfoVo devInfoVo : list) { for (DevInfoVo devInfoVo : list) {
for (UserCollect userCollect : userCollectList) { for (UserCollect userCollect : userCollectList) {
if (devInfoVo.getMaId() == userCollect.getMaId()) { if (String.valueOf(devInfoVo.getMaId()).equals(String.valueOf(userCollect.getMaId()))) {
result.add(devInfoVo); result.add(devInfoVo);
} }
} }

View File

@ -131,6 +131,92 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if> </if>
</select> </select>
<!-- <select id="selectDevInfoList4Collect" parameterType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo" resultType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo">-->
<!-- select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name,u.type as type-->
<!-- from ma_dev_info d-->
<!-- left join (select t.*, p.type_name as parent_name-->
<!-- from ma_type_info t-->
<!-- left join ma_type_info p on t.parent_id=p.type_id) t on d.type_id = t.type_id-->
<!-- left join bm_company_info c on d.own_co = c.company_id-->
<!-- left join ma_up_off u on d.ma_id = u.ma_id-->
<!-- left join ma_user_collect col on d.ma_id = col.ma_id-->
<!-- &#45;&#45; select d.*,t.type_name,c.company_name ,u.type, u.id as up_id-->
<!-- &#45;&#45; from ma_dev_info d-->
<!-- &#45;&#45; left join ma_type_info t on d.type_id = t.type_id-->
<!-- &#45;&#45; left join bm_company_info c on d.own_co = c.company_id-->
<!-- &#45;&#45; left join ma_up_off u on d.ma_id = u.ma_id-->
<!-- <where>-->
<!-- <if test="maId != null "> and d.ma_id = #{maId}</if>-->
<!-- <if test="code != null and code != ''"> and d.code = #{code}</if>-->
<!-- <if test="typeId != null">-->
<!-- <if test="level != null and level == 2">-->
<!-- and t.parent_id = #{typeId}-->
<!-- </if>-->
<!-- <if test="level != null and level == 3">-->
<!-- and d.type_id = #{typeId}-->
<!-- </if>-->
<!-- </if>-->
<!-- <if test="maStatus != null and maStatus != ''"> and d.ma_status = #{maStatus}</if>-->
<!-- <if test="leaseScope != null "> and d.lease_scope = #{leaseScope}</if>-->
<!-- <if test="location != null and location != ''"> and d.location = #{location}</if>-->
<!-- <if test="provinceId != null and provinceId != ''"> and d.province_id = #{provinceId}</if>-->
<!-- <if test="cityId != null and cityId != ''"> and d.city_id = #{cityId}</if>-->
<!-- <if test="areaId != null and areaId != ''"> and d.area_id = #{areaId}</if>-->
<!-- <if test="brand != null and brand != ''"> and d.brand = #{brand}</if>-->
<!-- <if test="modelName != null and modelName != ''"> and d.model_name like concat('%', #{modelName}, '%')</if>-->
<!-- <if test="ageMin != null and ageMin != '' and ageMax != null and ageMax != ''">-->
<!-- and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) &gt;= #{ageMin} * 365-->
<!-- and DATEDIFF(DATE_FORMAT(now(), '%Y-%m-%d'), d.production_date) &lt;= #{ageMax} * 365-->
<!-- </if>-->
<!-- <if test="workingHoursMin != null and workingHoursMin != '' and workingHoursMax != null and workingHoursMax != ''">-->
<!-- and d.working_hours &gt;= #{workingHoursMin} and d.working_hours &lt;= #{workingHoursMax}-->
<!-- </if>-->
<!-- <if test="serialNumber != null and serialNumber != ''"> and d.serial_number = #{serialNumber}</if>-->
<!-- <if test="monthLeasePriceMin != null and monthLeasePriceMax != null">-->
<!-- and d.month_lease_price &gt;= #{monthLeasePriceMin} and d.month_lease_price &lt;= #{monthLeasePriceMax}-->
<!-- </if>-->
<!-- <if test="dayLeasePrice != null and dayLeasePrice != ''"> and d.day_lease_price = #{dayLeasePrice}</if>-->
<!-- <if test="picUrl != null and picUrl != ''"> and d.pic_url = #{picUrl}</if>-->
<!-- <if test="jsMonthPrice != null and jsMonthPrice != ''"> and d.js_month_price = #{jsMonthPrice}</if>-->
<!-- <if test="jsDayPrice != null and jsDayPrice != ''"> and d.js_day_price = #{jsDayPrice}</if>-->
<!-- <if test="description != null and description != ''"> and d.description = #{description}</if>-->
<!-- <if test="gpsCode != null and gpsCode != ''"> and d.gps_code = #{gpsCode}</if>-->
<!-- <if test="ownCo != null "> and d.own_co = #{ownCo}</if>-->
<!-- <if test="creator != null "> and d.creator = #{creator}</if>-->
<!-- <if test="updateBy != null "> and d.update_by = #{updateBy}</if>-->
<!-- <if test="specification != null "> and d.specification = #{specification}</if>-->
<!-- <if test="deposit != null "> and d.deposit = #{deposit}</if>-->
<!-- <if test="isActive != null and isActive != ''"> and d.is_active = #{isActive}</if>-->
<!-- <if test="keyWord != null and keyWord != ''">-->
<!-- and (-->
<!-- locate(#{keyWord},t.type_name) > 0-->
<!-- or locate(#{keyWord},c.company_name) > 0-->
<!-- or locate(#{keyWord},d.ma_id) > 0-->
<!-- or locate(#{keyWord},d.model_name) > 0-->
<!-- or locate(#{keyWord},d.specification) > 0-->
<!-- or locate(#{keyWord},d.serial_number) > 0-->
<!-- or locate(#{keyWord},d.description) > 0-->
<!-- )-->
<!-- </if>-->
<!-- and d.is_active='1' and col.user_id = #{userId}-->
<!-- </where>-->
<!-- order by-->
<!-- d.is_active-->
<!-- <if test="monthLeasePriceOrderBy != null and monthLeasePriceOrderBy == 'ASC'">-->
<!-- ,d.month_lease_price-->
<!-- </if>-->
<!-- <if test="monthLeasePriceOrderBy != null and monthLeasePriceOrderBy == 'DESC'">-->
<!-- ,d.month_lease_price DESC-->
<!-- </if>-->
<!-- <if test="updateTimeOrderBy != null and updateTimeOrderBy == 'ASC'">-->
<!-- ,d.update_time-->
<!-- </if>-->
<!-- <if test="updateTimeOrderBy != null and updateTimeOrderBy == 'DESC'">-->
<!-- ,d.update_time DESC-->
<!-- </if>-->
<!-- </select>-->
<select id="selectDevInfoHotList" parameterType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo" resultType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo"> <select id="selectDevInfoHotList" parameterType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo" resultType="com.bonus.zlpt.equip.api.domain.vo.DevInfoVo">
select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name,search_num select d.*,t.type_name as device_name,t.parent_name as group_name,c.company_name,search_num
from ma_dev_info d from ma_dev_info d