小说微服务开发完成,用户微服务开发中

This commit is contained in:
xiongxiaoyang
2020-05-28 22:16:26 +08:00
parent bcd1caf7a8
commit 861e966a88
18 changed files with 583 additions and 19 deletions

View File

@ -3,8 +3,11 @@ package com.java2nb.novel.user.api;
import com.java2nb.novel.user.entity.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* 用户微服务API接口定义内部
* @author xiongxiaoyang
@ -19,8 +22,16 @@ public interface UserApi {
* @param password 密码
* @return 用户对象不存在返回null
* */
@GetMapping("api/queryByUsernameAndPassword")
@GetMapping("api/user/queryByUsernameAndPassword")
User queryByUsernameAndPassword(@RequestParam("username") String username, @RequestParam("password") String password);
/**
* 根据用户名ID集合查询用户集合信息
* @param ids 用户ID集合
* @return 用户集合对象
* */
@GetMapping("api/user/queryById")
List<User> queryById(@RequestBody List<Long> ids);
}

View File

@ -3,9 +3,10 @@ package com.java2nb.novel.user.entity;
import io.swagger.annotations.ApiModelProperty;
import javax.annotation.Generated;
import java.io.Serializable;
import java.util.Date;
public class User {
public class User implements Serializable {
@ApiModelProperty(value = "主键")
@Generated("org.mybatis.generator.api.MyBatisGenerator")
private Long id;

View File

@ -4,11 +4,11 @@ package com.java2nb.novel.user.controller.api;
import com.java2nb.novel.user.entity.User;
import com.java2nb.novel.user.service.UserService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.List;
/**
* 用户微服务API接口内部调用
* @author xiongxiaoyang
@ -33,6 +33,16 @@ public class UserApi {
}
/**
* 根据用户名ID集合查询用户集合信息
* @param ids 用户ID集合
* @return 用户集合对象
* */
@GetMapping("queryById")
List<User> queryById(@RequestBody List<Long> ids){
return userService.queryById(ids);
}

View File

@ -5,6 +5,8 @@ import com.java2nb.novel.common.bean.UserDetails;
import com.java2nb.novel.user.entity.User;
import com.java2nb.novel.user.form.UserForm;
import java.util.List;
/**
* 用户服务接口
* @author xiongxiaoyang
@ -29,4 +31,10 @@ public interface UserService {
UserDetails login(UserForm form);
/**
* 根据用户名ID集合查询用户集合信息
* @param ids 用户ID集合
* @return 用户集合对象
* */
List<User> queryById(List<Long> ids);
}

View File

@ -18,6 +18,7 @@ import org.springframework.stereotype.Service;
import java.util.List;
import static org.mybatis.dynamic.sql.SqlBuilder.isEqualTo;
import static org.mybatis.dynamic.sql.SqlBuilder.isIn;
import static org.mybatis.dynamic.sql.select.SelectDSL.select;
/**
@ -62,4 +63,14 @@ public class UserServiceImpl implements UserService {
userDetails.setUsername(form.getUsername());
return userDetails;
}
@Override
public List<User> queryById(List<Long> ids) {
return userMapper.selectMany(
select(UserDynamicSqlSupport.id,UserDynamicSqlSupport.username,
UserDynamicSqlSupport.userPhoto)
.from(UserDynamicSqlSupport.user)
.where(UserDynamicSqlSupport.id,isIn(ids)).build()
.render(RenderingStrategies.MYBATIS3));
}
}