mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-05-15 15:28:41 +08:00
新增 用户添加/取消收藏站点接口、用户查询收藏站点列表接口
This commit is contained in:
@@ -16,10 +16,7 @@ import com.jsowell.common.util.StringUtils;
|
|||||||
import com.jsowell.pile.domain.MemberPlateNumberRelation;
|
import com.jsowell.pile.domain.MemberPlateNumberRelation;
|
||||||
import com.jsowell.pile.domain.UserFrequentedStationInfo;
|
import com.jsowell.pile.domain.UserFrequentedStationInfo;
|
||||||
import com.jsowell.pile.dto.*;
|
import com.jsowell.pile.dto.*;
|
||||||
import com.jsowell.pile.service.MemberBasicInfoService;
|
import com.jsowell.pile.service.*;
|
||||||
import com.jsowell.pile.service.MemberPlateNumberRelationService;
|
|
||||||
import com.jsowell.pile.service.OrderBasicInfoService;
|
|
||||||
import com.jsowell.pile.service.PileMerchantInfoService;
|
|
||||||
import com.jsowell.pile.vo.base.MemberWalletVO;
|
import com.jsowell.pile.vo.base.MemberWalletVO;
|
||||||
import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO;
|
import com.jsowell.pile.vo.uniapp.customer.InvoiceTitleVO;
|
||||||
import com.jsowell.pile.vo.uniapp.customer.MemberVO;
|
import com.jsowell.pile.vo.uniapp.customer.MemberVO;
|
||||||
@@ -47,6 +44,9 @@ public class MemberController extends BaseController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MemberBasicInfoService memberBasicInfoService;
|
private MemberBasicInfoService memberBasicInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberStationRelationService memberStationRelationService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PileMerchantInfoService pileMerchantInfoService;
|
private PileMerchantInfoService pileMerchantInfoService;
|
||||||
|
|
||||||
@@ -629,4 +629,47 @@ public class MemberController extends BaseController {
|
|||||||
logger.info("查询用户常去站点(最近半年) result:{}", response);
|
logger.info("查询用户常去站点(最近半年) result:{}", response);
|
||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户收藏的站点信息
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/getCollectedStationIdList")
|
||||||
|
public RestApiResponse<?> getCollectedStationIdList(HttpServletRequest request, @RequestBody QueryStationDTO dto) {
|
||||||
|
RestApiResponse<?> response;
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
dto.setMemberId(memberId);
|
||||||
|
PageResponse pageResponse = memberStationRelationService.getCollectedStationIdList(dto);
|
||||||
|
response = new RestApiResponse<>(pageResponse);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("查询用户收藏的站点信息 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("查询用户收藏的站点信息 result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户修改收藏的站点
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@PostMapping("/updateCollectedStation")
|
||||||
|
public RestApiResponse<?> updateCollectedStation(HttpServletRequest request, @RequestBody CollectedStationDTO dto) {
|
||||||
|
RestApiResponse<?> response = null;
|
||||||
|
try {
|
||||||
|
String memberId = getMemberIdByAuthorization(request);
|
||||||
|
dto.setMemberId(memberId);
|
||||||
|
int i = memberStationRelationService.updateCollectedStation(dto);
|
||||||
|
response = new RestApiResponse<>(i);
|
||||||
|
}catch (Exception e) {
|
||||||
|
logger.error("用户修改收藏的站点 error", e);
|
||||||
|
response = new RestApiResponse<>(e);
|
||||||
|
}
|
||||||
|
logger.info("用户修改收藏的站点 result:{}", response);
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class MemberStationRelation extends BaseEntity {
|
|||||||
* 会员id
|
* 会员id
|
||||||
*/
|
*/
|
||||||
@Excel(name = "会员id")
|
@Excel(name = "会员id")
|
||||||
private Long memberId;
|
private String memberId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 站点id
|
* 站点id
|
||||||
@@ -39,11 +39,11 @@ public class MemberStationRelation extends BaseEntity {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMemberId(Long memberId) {
|
public void setMemberId(String memberId) {
|
||||||
this.memberId = memberId;
|
this.memberId = memberId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getMemberId() {
|
public String getMemberId() {
|
||||||
return memberId;
|
return memberId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.jsowell.pile.dto;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 个人收藏站点DTO
|
||||||
|
*
|
||||||
|
* @author Lemon
|
||||||
|
* @Date 2025/3/20 13:38:38
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Builder
|
||||||
|
public class CollectedStationDTO {
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
|
private String stationId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作类型
|
||||||
|
* true - 收藏
|
||||||
|
* false - 取消收藏
|
||||||
|
*/
|
||||||
|
private boolean operatorType;
|
||||||
|
}
|
||||||
@@ -125,6 +125,8 @@ public class QueryStationDTO extends BaseEntity {
|
|||||||
|
|
||||||
private List<String> stationIds;
|
private List<String> stationIds;
|
||||||
|
|
||||||
|
private String memberId;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public static class OtherOptions {
|
public static class OtherOptions {
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -67,4 +67,11 @@ public interface MemberStationRelationMapper {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<String> getStationIdListByMemberId(String memberId);
|
List<String> getStationIdListByMemberId(String memberId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户取消收藏站点
|
||||||
|
* @param memberStationRelation
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int deleteMemberStationRelation(MemberStationRelation memberStationRelation);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,10 @@ package com.jsowell.pile.service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.pile.domain.MemberStationRelation;
|
import com.jsowell.pile.domain.MemberStationRelation;
|
||||||
|
import com.jsowell.pile.dto.CollectedStationDTO;
|
||||||
|
import com.jsowell.pile.dto.QueryStationDTO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 会员与收藏的站点关系Service接口
|
* 会员与收藏的站点关系Service接口
|
||||||
@@ -61,8 +64,15 @@ public interface MemberStationRelationService {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过memberId查询站点idList
|
* 通过memberId查询站点idList
|
||||||
* @param memberId
|
* @param dto
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<String> getStationIdListByMemberId(String memberId);
|
public PageResponse getCollectedStationIdList(QueryStationDTO dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改收藏站点状态
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
int updateCollectedStation(CollectedStationDTO dto);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,13 @@ package com.jsowell.pile.service.impl;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jsowell.common.core.page.PageResponse;
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
|
import com.jsowell.pile.dto.CollectedStationDTO;
|
||||||
|
import com.jsowell.pile.dto.QueryStationDTO;
|
||||||
import com.jsowell.pile.service.MemberStationRelationService;
|
import com.jsowell.pile.service.MemberStationRelationService;
|
||||||
|
import com.jsowell.pile.service.PileStationInfoService;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.jsowell.pile.mapper.MemberStationRelationMapper;
|
import com.jsowell.pile.mapper.MemberStationRelationMapper;
|
||||||
@@ -20,6 +25,9 @@ public class MemberStationRelationServiceImpl implements MemberStationRelationSe
|
|||||||
@Autowired
|
@Autowired
|
||||||
private MemberStationRelationMapper memberStationRelationMapper;
|
private MemberStationRelationMapper memberStationRelationMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private PileStationInfoService pileStationInfoService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询会员与收藏的站点关系
|
* 查询会员与收藏的站点关系
|
||||||
*
|
*
|
||||||
@@ -88,8 +96,49 @@ public class MemberStationRelationServiceImpl implements MemberStationRelationSe
|
|||||||
return memberStationRelationMapper.deleteMemberStationRelationById(id);
|
return memberStationRelationMapper.deleteMemberStationRelationById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户收藏的站点信息
|
||||||
|
* @param dto
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<String> getStationIdListByMemberId(String memberId) {
|
public PageResponse getCollectedStationIdList(QueryStationDTO dto) {
|
||||||
return memberStationRelationMapper.getStationIdListByMemberId(memberId);
|
// 先查出来站点idList
|
||||||
|
List<String> stationIdList = memberStationRelationMapper.getStationIdListByMemberId(dto.getMemberId());
|
||||||
|
if (CollectionUtils.isEmpty(stationIdList)) {
|
||||||
|
return new PageResponse();
|
||||||
|
}
|
||||||
|
// 根据站点idList批量查站点信息
|
||||||
|
dto.setStationIds(stationIdList);
|
||||||
|
PageResponse pageResponse = pileStationInfoService.uniAppQueryStationInfoList(dto);
|
||||||
|
|
||||||
|
return pageResponse;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 某用户取消收藏站点
|
||||||
|
* @param memberStationRelation
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int deleteMemberStationRelation(MemberStationRelation memberStationRelation) {
|
||||||
|
return memberStationRelationMapper.deleteMemberStationRelation(memberStationRelation);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int updateCollectedStation(CollectedStationDTO dto) {
|
||||||
|
int result = 0;
|
||||||
|
// 判断操作类型
|
||||||
|
boolean operatorType = dto.isOperatorType();
|
||||||
|
MemberStationRelation relation = new MemberStationRelation();
|
||||||
|
relation.setStationId(Long.parseLong(dto.getStationId()));
|
||||||
|
relation.setMemberId(dto.getMemberId());
|
||||||
|
if (operatorType) {
|
||||||
|
// 添加收藏
|
||||||
|
result = insertMemberStationRelation(relation);
|
||||||
|
}else {
|
||||||
|
// 取消收藏
|
||||||
|
result = deleteMemberStationRelation(relation);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,8 +82,14 @@
|
|||||||
|
|
||||||
<select id="getStationIdListByMemberId" resultType="java.lang.String">
|
<select id="getStationIdListByMemberId" resultType="java.lang.String">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List"/>
|
station_id
|
||||||
from member_station_relation
|
from member_station_relation
|
||||||
where member_id = #{memberId,jdbcType=VARCHAR}
|
where member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<delete id="deleteMemberStationRelation">
|
||||||
|
delete from member_station_relation
|
||||||
|
where member_id = #{memberId,jdbcType=VARCHAR}
|
||||||
|
and station_id = #{stationId,jdbcType=BIGINT}
|
||||||
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
||||||
@@ -386,6 +386,12 @@
|
|||||||
#{stationDeptId}
|
#{stationDeptId}
|
||||||
</foreach>
|
</foreach>
|
||||||
</if>
|
</if>
|
||||||
|
<if test="stationDTO.stationIds != null and stationDTO.stationIds.size() != 0">
|
||||||
|
and t1.id in
|
||||||
|
<foreach collection="stationDTO.stationIds" item="stationId" open="(" separator="," close=")">
|
||||||
|
#{stationId}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
GROUP BY
|
GROUP BY
|
||||||
t1.id,
|
t1.id,
|
||||||
t1.station_name,
|
t1.station_name,
|
||||||
|
|||||||
Reference in New Issue
Block a user