From aa98675ac7f5ebb1e72473a870a4de4cbb518b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E8=8B=B1=E6=9D=B0?= <327782001@qq.com> Date: Mon, 20 Feb 2023 22:13:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E5=9C=A8sql=E4=B8=AD=E4=BD=BF=E7=94=A8or?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/UserController.java | 12 ++++++++--- .../entity/query/QueryInfo.java | 13 ++++++++++++ .../springbootkwan/mapper/UserMapper.java | 17 +++++++++++++++ .../springbootkwan/service/IUserService.java | 7 +++++++ .../service/impl/UserServiceImpl.java | 11 ++++++++++ src/main/resources/mapper/UserMapper.xml | 21 +++++++++++++++++++ 6 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 src/main/java/com/kwan/springbootkwan/entity/query/QueryInfo.java diff --git a/src/main/java/com/kwan/springbootkwan/controller/UserController.java b/src/main/java/com/kwan/springbootkwan/controller/UserController.java index 2de7df5..f929784 100644 --- a/src/main/java/com/kwan/springbootkwan/controller/UserController.java +++ b/src/main/java/com/kwan/springbootkwan/controller/UserController.java @@ -6,15 +6,12 @@ import com.kwan.springbootkwan.service.IUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.apache.ibatis.annotations.Param; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpRequest; import org.springframework.validation.BindingResult; import org.springframework.validation.ObjectError; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import javax.servlet.http.HttpServletRequest; import java.io.UnsupportedEncodingException; import java.util.ArrayList; import java.util.List; @@ -67,4 +64,13 @@ public class UserController { public User getUserByName(@RequestParam String sex) { return userService.getUserByName(sex); } + + + @ApiOperation(value = "or拼接", notes = "or拼接") + @RequestMapping(value = "/getUserByOr", method = RequestMethod.GET) + public List getUserByOr() { + return userService.getUserByOr(); + } + + } \ No newline at end of file diff --git a/src/main/java/com/kwan/springbootkwan/entity/query/QueryInfo.java b/src/main/java/com/kwan/springbootkwan/entity/query/QueryInfo.java new file mode 100644 index 0000000..71e71a8 --- /dev/null +++ b/src/main/java/com/kwan/springbootkwan/entity/query/QueryInfo.java @@ -0,0 +1,13 @@ +package com.kwan.springbootkwan.entity.query; + +import lombok.Data; + +@Data +public class QueryInfo { + + private String invQtyA; + private String invQtyB; + private String invQtyC; + private String invQtyD; + +} diff --git a/src/main/java/com/kwan/springbootkwan/mapper/UserMapper.java b/src/main/java/com/kwan/springbootkwan/mapper/UserMapper.java index 908e069..0ffcc39 100644 --- a/src/main/java/com/kwan/springbootkwan/mapper/UserMapper.java +++ b/src/main/java/com/kwan/springbootkwan/mapper/UserMapper.java @@ -3,6 +3,9 @@ package com.kwan.springbootkwan.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.kwan.springbootkwan.entity.User; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** @@ -15,6 +18,20 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface UserMapper extends BaseMapper { + /** + * 通过性别获取user + * + * @param sex + * @return + */ User getUserByName(String sex); + + /** + * 通过id获取user + * + * @param invFlag + * @return + */ + List getUserByOr(@Param("invFlag") List invFlag); } diff --git a/src/main/java/com/kwan/springbootkwan/service/IUserService.java b/src/main/java/com/kwan/springbootkwan/service/IUserService.java index 9591165..28810c5 100644 --- a/src/main/java/com/kwan/springbootkwan/service/IUserService.java +++ b/src/main/java/com/kwan/springbootkwan/service/IUserService.java @@ -37,4 +37,11 @@ public interface IUserService extends IService { */ User saveUser(User user); + /** + * 使用or拼接数据 + * + * @return + */ + List getUserByOr(); + } diff --git a/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java b/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java index 8b3899e..7cfe747 100644 --- a/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java +++ b/src/main/java/com/kwan/springbootkwan/service/impl/UserServiceImpl.java @@ -11,6 +11,7 @@ import io.seata.spring.annotation.GlobalTransactional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -53,4 +54,14 @@ public class UserServiceImpl extends ServiceImpl implements IU personService.savePerson(person); return user; } + + @Override + public List getUserByOr() { + List invFlag = new ArrayList<>(); + invFlag.add(1); + invFlag.add(2); + invFlag.add(3); + invFlag.add(4); + return userMapper.getUserByOr(invFlag); + } } \ No newline at end of file diff --git a/src/main/resources/mapper/UserMapper.xml b/src/main/resources/mapper/UserMapper.xml index 228606a..8b084dc 100644 --- a/src/main/resources/mapper/UserMapper.xml +++ b/src/main/resources/mapper/UserMapper.xml @@ -14,4 +14,25 @@ FROM user WHERE sex = #{sex} + -- GitLab