浏览代码

完成个人生平页面功能

Alex 4 年之前
父节点
当前提交
cdfa4f8a5c

+ 69 - 8
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ApiTemplateController.java

@@ -1,21 +1,29 @@
 package com.ruoyi.web.controller.api;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.github.pagehelper.PageHelper;
+import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.system.domain.TPersonalImg;
+import com.ruoyi.system.domain.TPersonalMessage;
+import com.ruoyi.system.domain.TPersonalModel;
 import com.ruoyi.system.domain.TPersonalPage;
 import com.ruoyi.system.service.ITPersonalImgService;
+import com.ruoyi.system.service.ITPersonalMessageService;
+import com.ruoyi.system.service.ITPersonalModelService;
 import com.ruoyi.system.service.ITPersonalPageService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
 
+import java.util.Date;
 import java.util.List;
 
 /**
@@ -30,13 +38,16 @@ public class ApiTemplateController extends BaseController {
     private ITPersonalImgService tPersonalImgService;
     @Autowired
     private ITPersonalPageService tPersonalPageService;
+    @Autowired
+    private ITPersonalModelService modelService;
+    @Autowired
+    private ITPersonalMessageService messageService;
     /**
      * 查询个人页 图片列表
      */
     @ApiOperation("个人图片列表")
     @GetMapping("/allImg")
-    public AjaxResult allImg(TPersonalImg tPersonalImg)
-    {
+    public AjaxResult allImg(TPersonalImg tPersonalImg) {
         List<TPersonalImg> list = tPersonalImgService.list(new QueryWrapper<TPersonalImg>()
             .eq(StringUtils.isNotBlank(tPersonalImg.getEnable()),"enable", tPersonalImg.getEnable())
         );
@@ -47,8 +58,7 @@ public class ApiTemplateController extends BaseController {
      */
     @ApiOperation("获取个人页详细信息")
     @GetMapping(value = "/getPersonal/{id}")
-    public AjaxResult getPersonal(@PathVariable("id") Long id)
-    {
+    public AjaxResult getPersonal(@PathVariable("id") Long id) {
         TPersonalPage personalPage = tPersonalPageService.getById(id);
         if (personalPage != null && "1".equals(personalPage.getEnable())) {
             return AjaxResult.success();
@@ -56,4 +66,55 @@ public class ApiTemplateController extends BaseController {
         return AjaxResult.success(personalPage);
     }
 
+    /**
+     * 查询个人页留言模板列表
+     */
+    @ApiOperation("查询个人页留言模板列表")
+    @GetMapping("/allModel")
+    public AjaxResult all() {
+        LambdaQueryWrapper<TPersonalModel> lqw = new LambdaQueryWrapper<TPersonalModel>();
+        lqw.eq(TPersonalModel::getEnable ,"0");
+        List<TPersonalModel> list = modelService.list(lqw);
+        return AjaxResult.success(list);
+    }
+
+
+    /**
+     * 新增个人页留言内容
+     */
+    @ApiOperation("新增个人页留言内容")
+    @PostMapping("/addMessage")
+    public AjaxResult add(@RequestBody TPersonalMessage tPersonalMessage) {
+        if (tPersonalMessage.getPersonalId() == null){
+            return AjaxResult.error("个人id不能为空");
+        }
+        if (StringUtils.isBlank(tPersonalMessage.getName())){
+            return AjaxResult.error("姓名不能为空");
+        }
+        if (StringUtils.isBlank(tPersonalMessage.getContents())){
+            return AjaxResult.error("留言不能为空");
+        }
+        tPersonalMessage.setCreateTime(new Date());
+        return toAjax(messageService.save(tPersonalMessage) ? 1 : 0);
+    }
+
+    /**
+     * 查询个人页留言内容列表
+     */
+    @ApiOperation("查询个人页留言内容列表")
+    @GetMapping("/messageList")
+    public TableDataInfo list(Integer pageNum,Integer pageSize,Long personalId) {
+        if (personalId == null) {
+            return new TableDataInfo();
+        }
+
+        pageNum = pageNum == null ? 1 : pageNum;
+        pageSize = pageSize == null ? 10 : pageSize;
+        PageHelper.startPage(pageNum, pageSize, "create_time desc");
+
+        LambdaQueryWrapper<TPersonalMessage> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(TPersonalMessage::getPersonalId , personalId);
+        List<TPersonalMessage> list = messageService.list(lqw);
+        return getDataTable(list);
+    }
 }

+ 3 - 0
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/TPersonalMessageController.java

@@ -55,6 +55,9 @@ public class TPersonalMessageController extends BaseController {
         if (tPersonalMessage.getPersonalId() != null){
             lqw.eq(TPersonalMessage::getPersonalId ,tPersonalMessage.getPersonalId());
         }
+        if (StringUtils.isNotBlank(tPersonalMessage.getName())){
+            lqw.eq(TPersonalMessage::getName ,tPersonalMessage.getName());
+        }
         if (StringUtils.isNotBlank(tPersonalMessage.getType())){
             lqw.eq(TPersonalMessage::getType ,tPersonalMessage.getType());
         }

+ 1 - 1
ruoyi-admin/src/main/resources/application.yml

@@ -68,7 +68,7 @@ token:
     # 令牌密钥
     secret: abcdefghijklmnopqrstuvwxyz
     # 令牌有效期(默认30分钟)
-    expireTime: 30
+    expireTime: 120
   
 # MyBatis配置
 mybatis-plus:

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TPersonalMessage.java

@@ -50,6 +50,11 @@ public class TPersonalMessage implements Serializable {
     @Excel(name = "类型 1留言语 2留念语 3缅怀语")
     private String type;
 
+    /** 留言人 */
+    @ApiModelProperty(value="留言人")
+    @Excel(name = "留言人")
+    private String name;
+
     /** 留言内容(选择内容模板) */
     @ApiModelProperty(value="留言内容(选择内容模板)")
     @Excel(name = "留言内容" , readConverterExp = "选=择内容模板")

+ 5 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/TPersonalPage.java

@@ -53,6 +53,11 @@ public class TPersonalPage implements Serializable {
     @JsonFormat(pattern = "yyyy-MM-dd")
     private Date stakeholderBirthday;
 
+    /** 离世时间 */
+    @Excel(name = "离世时间" , width = 30, dateFormat = "yyyy-MM-dd")
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    private Date deathsDate;
+
     /** 头像url */
     @Excel(name = "头像url")
     private String avatar;

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/TPersonalMessageMapper.xml

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="TPersonalMessage" id="TPersonalMessageResult">
         <result property="id"    column="id"    />
         <result property="personalId"    column="personal_id"    />
+        <result property="name"    column="name"    />
         <result property="type"    column="type"    />
         <result property="contents"    column="contents"    />
         <result property="createBy"    column="create_by"    />

+ 1 - 0
ruoyi-system/src/main/resources/mapper/system/TPersonalPageMapper.xml

@@ -10,6 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="customer"    column="customer"    />
         <result property="stakeholder"    column="stakeholder"    />
         <result property="stakeholderBirthday"    column="stakeholder_birthday"    />
+        <result property="deathsDate"    column="deaths_date"    />
         <result property="avatar"    column="avatar"    />
         <result property="templateId"    column="template_id"    />
         <result property="content"    column="content"    />