mirror of
https://github.com/201206030/novel-cloud.git
synced 2025-06-24 05:56:38 +00:00
小说微服务开发完成,用户微服务开发中
This commit is contained in:
@ -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);
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user