zhangbin 1 year ago
parent
commit
ba37f2925c

+ 3 - 2
xpgx-admin/src/main/java/com/miaxis/app/controller/birthday/BirthdayLogController.java

@@ -73,10 +73,11 @@ public class BirthdayLogController extends BaseController {
      */
     @PostMapping
     @ApiOperation("新增查询记录")
-    public Response<Integer> add(@RequestBody BirthdayLog birthdayLog) {
+    public Response<BirthdayLog> add(@RequestBody BirthdayLog birthdayLog) {
         Long userId = SecurityUtils.getLoginUser().getStudent().getId();
         birthdayLog.setUserId(userId);
-        return toResponse(birthdayLogService.saveBirthdayLog(birthdayLog) ? 1 : 0);
+        BirthdayLog birthdayLogDb = birthdayLogService.saveBirthdayLog(birthdayLog);
+        return Response.success(birthdayLogDb);
     }
 
 

+ 1 - 0
xpgx-service/src/main/java/com/miaxis/birthday/mapper/BirthdayLogMapper.java

@@ -22,4 +22,5 @@ public interface BirthdayLogMapper extends BaseMapper<BirthdayLog> {
 
     public int selectBirthdayLogCount(BirthdayLog birthdayLog);
 
+    BirthdayLog selectBirthdayLogId(BirthdayLog birthdayLog);
 }

+ 1 - 1
xpgx-service/src/main/java/com/miaxis/birthday/service/IBirthdayLogService.java

@@ -19,5 +19,5 @@ public interface IBirthdayLogService extends IService<BirthdayLog>{
      */
     public List<BirthdayLog> selectBirthdayLogList(BirthdayLog birthdayLog);
 
-    boolean saveBirthdayLog(BirthdayLog birthdayLog);
+    BirthdayLog saveBirthdayLog(BirthdayLog birthdayLog);
 }

+ 4 - 3
xpgx-service/src/main/java/com/miaxis/birthday/service/impl/BirthdayLogServiceImpl.java

@@ -40,14 +40,15 @@ public class BirthdayLogServiceImpl extends ServiceImpl<BirthdayLogMapper, Birth
      * @return 查询记录
      */
     @Override
-    public boolean saveBirthdayLog(BirthdayLog birthdayLog){
+    public BirthdayLog saveBirthdayLog(BirthdayLog birthdayLog){
         int count = birthdayLogMapper.selectBirthdayLogCount(birthdayLog);
 
         if(count>0) {
             log.info("当前查询8字已存在");
-            return true;
+            return birthdayLogMapper.selectBirthdayLogId(birthdayLog);
         } else {
-            return this.save(birthdayLog);
+            this.save(birthdayLog);
+            return birthdayLogMapper.selectBirthdayLogId(birthdayLog);
         }
 
     }

+ 11 - 0
xpgx-service/src/main/resources/mapper/birthday/BirthdayLogMapper.xml

@@ -43,4 +43,15 @@
     </select>
 
 
+    <select id="selectBirthdayLogId" parameterType="BirthdayLog" resultMap="BirthdayLogResult">
+        select * from birthday_log
+        <where>
+            <if test="name != null  and name != ''">and name = #{name}</if>
+            <if test="sex != null  and sex != ''">and sex = #{sex}</if>
+            <if test="birthday != null ">and birthday = #{birthday}</if>
+            <if test="userId != null ">and user_id = #{userId}</if>
+        </where>
+    </select>
+
+
 </mapper>