|
@@ -0,0 +1,62 @@
|
|
|
+package com.management.platform.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.management.platform.entity.Information;
|
|
|
+import com.management.platform.mapper.InformationMapper;
|
|
|
+import com.management.platform.mapper.UserMapper;
|
|
|
+import com.management.platform.service.InformationService;
|
|
|
+import com.management.platform.util.HttpRespMsg;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author 吴涛涛
|
|
|
+ * @since 2020-02-18
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class InformationServiceImpl extends ServiceImpl<InformationMapper, Information> implements InformationService {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private InformationMapper informationMapper;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private UserMapper userMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg getInformationList(HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ String userId = userMapper.selectById(request.getHeader("Token")).getId();
|
|
|
+ httpRespMsg.data = informationMapper.selectList(new QueryWrapper<Information>()
|
|
|
+ .eq("user_id", userId).orderByDesc("time").last("LIMIT 10"));
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg checkInformation(Integer id, HttpServletRequest request) {
|
|
|
+ HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
+ try {
|
|
|
+ Information information = informationMapper.selectById(id).setChecked(1);
|
|
|
+ if (information != null) {
|
|
|
+ informationMapper.updateById(information);
|
|
|
+ } else {
|
|
|
+ httpRespMsg.setError("未检查到相关信息");
|
|
|
+ }
|
|
|
+ } catch (NullPointerException e) {
|
|
|
+ httpRespMsg.setError("验证失败");
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+}
|