feat(新增): 获取地址信息
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
b41919f218
commit
54d1b7f662
|
@ -20,5 +20,17 @@
|
|||
<dependencies>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>8</source>
|
||||
<target>8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -8,6 +8,7 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
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;
|
||||
|
||||
|
@ -27,4 +28,10 @@ public class UserAddressController {
|
|||
List<UserAddress> list = userAddressService.findUserAddressList();
|
||||
return Result.success(list);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取地址信息")
|
||||
@GetMapping("getUserAddress/{id}")
|
||||
public UserAddress getUserAddress(@PathVariable Long id) {
|
||||
return userAddressService.getById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,4 +14,12 @@ public interface UserAddressMapper {
|
|||
* @return 地址列表
|
||||
*/
|
||||
List<UserAddress> selectByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*
|
||||
* @param id 地址Id
|
||||
* @return 地址信息
|
||||
*/
|
||||
UserAddress getById(Long id);
|
||||
}
|
||||
|
|
|
@ -11,4 +11,12 @@ public interface UserAddressService {
|
|||
* @return 用户地址列表
|
||||
*/
|
||||
List<UserAddress> findUserAddressList();
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*
|
||||
* @param id 地址Id
|
||||
* @return 地址信息
|
||||
*/
|
||||
UserAddress getById(Long id);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import com.atguigu.exception.BunnyException;
|
|||
import com.atguigu.spzx.model.entity.user.UserAddress;
|
||||
import com.atguigu.user.mapper.UserAddressMapper;
|
||||
import com.atguigu.user.service.UserAddressService;
|
||||
import com.atguigu.utils.EmptyUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
@ -17,6 +18,8 @@ import java.util.List;
|
|||
public class UserAddressServiceImpl implements UserAddressService {
|
||||
@Autowired
|
||||
private UserAddressMapper userAddressMapper;
|
||||
@Autowired
|
||||
private EmptyUtil emptyUtil;
|
||||
|
||||
/**
|
||||
* 获取用户地址列表
|
||||
|
@ -32,4 +35,16 @@ public class UserAddressServiceImpl implements UserAddressService {
|
|||
}
|
||||
throw new BunnyException(MessageConstant.FIND_ID_IS_NOT_EMPTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取地址信息
|
||||
*
|
||||
* @param id 地址Id
|
||||
* @return 地址信息
|
||||
*/
|
||||
@Override
|
||||
public UserAddress getById(Long id) {
|
||||
emptyUtil.isEmpty(id, MessageConstant.FIND_ID_IS_NOT_EMPTY);
|
||||
return userAddressMapper.getById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,4 +8,9 @@
|
|||
from user_address
|
||||
where user_id = #{userId}
|
||||
</select>
|
||||
<select id="getById" resultType="com.atguigu.spzx.model.entity.user.UserAddress">
|
||||
select *
|
||||
from user_address
|
||||
where id = #{id};
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue