|
@@ -0,0 +1,136 @@
|
|
|
+package com.ozs.web.controller.app;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.ozs.common.core.controller.BaseController;
|
|
|
+import com.ozs.common.core.domain.AjaxResult;
|
|
|
+
|
|
|
+import com.ozs.service.entity.MsgAppPush;
|
|
|
+import com.ozs.service.entity.vo.MsgAppPushVo;
|
|
|
+import com.ozs.service.service.MsgAppPushService;
|
|
|
+import com.ozs.system.service.ISysUserService;
|
|
|
+import com.ozs.web.controller.tool.ImgUtil;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.util.UUID;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author wyy
|
|
|
+ * @subject
|
|
|
+ * @creat 2023/3/6
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/app/mine")
|
|
|
+@Slf4j
|
|
|
+public class GeoHazardMineController extends BaseController {
|
|
|
+ @Value("${file.avatarUrl:#{null}}")
|
|
|
+ private String avatarURL;
|
|
|
+ @Value("${file.filreUrl:#{null}}")
|
|
|
+ private String fileUrl;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService sysUserService;
|
|
|
+ @Autowired
|
|
|
+ private MsgAppPushService msgAppPushService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改头像
|
|
|
+ */
|
|
|
+ @PostMapping("/updateAvatar")
|
|
|
+ @ApiOperation("app修改头像")
|
|
|
+ public AjaxResult updateAvatar(MultipartFile image, Long userId) {
|
|
|
+
|
|
|
+ String imageUrl = null;
|
|
|
+ try {
|
|
|
+ if (image != null) {
|
|
|
+ //获取文件名
|
|
|
+ String fileName = image.getOriginalFilename();
|
|
|
+ if (org.springframework.util.StringUtils.isEmpty(fileName) || image.getSize() == 0) {
|
|
|
+ throw new Exception("图像文件不能为空!");
|
|
|
+ }
|
|
|
+ //验证文件名是否合格
|
|
|
+ if (!ImgUtil.isImg(fileName)) {
|
|
|
+ throw new Exception("图像文件必须是图片格式!");
|
|
|
+ }
|
|
|
+ String saveFileName = UUID.randomUUID().toString();
|
|
|
+ File saveDirFile = new File(avatarURL);
|
|
|
+ if (!saveDirFile.exists()) {
|
|
|
+ saveDirFile.mkdirs();
|
|
|
+ }
|
|
|
+ File picFullFile = new File(saveDirFile.getAbsolutePath(), saveFileName);
|
|
|
+ FileOutputStream fos = new FileOutputStream(picFullFile);
|
|
|
+ fos.write(image.getBytes());
|
|
|
+ imageUrl = fileUrl + avatarURL + saveFileName;
|
|
|
+ sysUserService.updateUserAvatarById(userId, imageUrl);
|
|
|
+ } else {
|
|
|
+ throw new Exception("上传文件不能为空");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return AjaxResult.success(imageUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改密码
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/updateAvatar", method = RequestMethod.POST)
|
|
|
+ @ApiOperation("app修改密码")
|
|
|
+ public AjaxResult updateAvatar(@RequestParam("userId") Long userId,@RequestParam("newPwd") String newPwd) {
|
|
|
+ sysUserService.updatePassword(userId,newPwd);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * app推送报警信息记录分页显示(全部信息)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "allList", method = RequestMethod.POST)
|
|
|
+ @ApiOperation("app推送报警信息记录分页显示(全部信息)")
|
|
|
+ public AjaxResult allList(@RequestBody MsgAppPushVo msgAppPushVo) {
|
|
|
+ QueryWrapper<MsgAppPush> queryWrapper = new QueryWrapper<MsgAppPush>();
|
|
|
+ IPage<MsgAppPush> page = msgAppPushService.page(new Page<>(msgAppPushVo.getPageNum(), msgAppPushVo.getPageSize()), queryWrapper);
|
|
|
+ return AjaxResult.success(page);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * app推送报警信息记录分页显示(未读信息)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "unReadList", method = RequestMethod.POST)
|
|
|
+ @ApiOperation("app推送报警信息记录分页显示(未读信息)")
|
|
|
+ public AjaxResult unReadList(@RequestBody MsgAppPushVo msgAppPushVo) {
|
|
|
+ LambdaQueryWrapper<MsgAppPush> queryWrapper = new LambdaQueryWrapper<MsgAppPush>();
|
|
|
+ if (!ObjectUtils.isEmpty(msgAppPushVo.getStatus())) {
|
|
|
+ queryWrapper.eq(MsgAppPush::getStatus, 0);
|
|
|
+ }
|
|
|
+ IPage<MsgAppPush> page = msgAppPushService.page(new Page<>(msgAppPushVo.getPageNum(), msgAppPushVo.getPageSize()), queryWrapper);
|
|
|
+ return AjaxResult.success(page);
|
|
|
+ }
|
|
|
+ /**
|
|
|
+ * app推送报警信息记录分页显示(已读信息)
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "readList", method = RequestMethod.POST)
|
|
|
+ @ApiOperation("app推送报警信息记录分页显示(已读信息)")
|
|
|
+ @ApiImplicitParams(value = {
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "caseMonth", value = "分析年份"),
|
|
|
+ @ApiImplicitParam(paramType = "query", name = "current", value = "当前页数"),
|
|
|
+ })
|
|
|
+ public AjaxResult readList(@RequestBody MsgAppPushVo msgAppPushVo) {
|
|
|
+ LambdaQueryWrapper<MsgAppPush> queryWrapper = new LambdaQueryWrapper<MsgAppPush>();
|
|
|
+ if (!ObjectUtils.isEmpty(msgAppPushVo.getStatus())) {
|
|
|
+ queryWrapper.eq(MsgAppPush::getStatus, 1);
|
|
|
+ }
|
|
|
+ IPage<MsgAppPush> page = msgAppPushService.page(new Page<>(msgAppPushVo.getPageNum(), msgAppPushVo.getPageSize()), queryWrapper);
|
|
|
+ return AjaxResult.success(page);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|