ezhizao_zx 4 місяців тому
батько
коміт
c35a5613c5

+ 93 - 0
src/main/java/cn/ezhizao/project/business/message/controller/BizMessageController.java

@@ -0,0 +1,93 @@
+package cn.ezhizao.project.business.message.controller;
+
+import cn.ezhizao.common.utils.poi.ExcelUtil;
+import cn.ezhizao.framework.aspectj.lang.annotation.Log;
+import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
+import cn.ezhizao.framework.web.controller.BaseController;
+import cn.ezhizao.framework.web.domain.AjaxResult;
+import cn.ezhizao.framework.web.page.TableDataInfo;
+import cn.ezhizao.project.business.message.domain.BizMessage;
+import cn.ezhizao.project.business.message.service.IBizMessageService;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+@RestController
+@RequestMapping("/business/message")
+public class BizMessageController  extends BaseController {
+    @Resource
+    IBizMessageService bizMessageService;
+
+    /**
+     * 查询消息列表
+     */
+//    @PreAuthorize("@ss.hasPermi('business:carrier:list')")
+    @Log(title = "查询消息列表", businessType = BusinessType.SELECT)
+    @GetMapping("/list")
+    public TableDataInfo list(BizMessage data) throws NoSuchFieldException, IllegalAccessException, JsonProcessingException {
+        Integer zero = 0;
+//        String tenantId = request.getHeader("tenantId");
+//        if (tenantId != null && !zero.toString().equals(tenantId)) {
+//            data.setTenantId(Long.valueOf(tenantId));
+//        }
+        startPage();
+        List<BizMessage> list = bizMessageService.getList(data);
+        return getDataTable(list);
+    }
+    /**
+     * 导出消息列表
+     */
+    @Log(title = "报工技术咨询", businessType = BusinessType.EXPORT)
+    @PostMapping("/export")
+    public void export(HttpServletResponse response, BizMessage bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
+    {
+        setTenantId(bizDayworkItemConsult);
+        List<BizMessage> list = bizMessageService.getList(bizDayworkItemConsult);
+        ExcelUtil<BizMessage> util = new ExcelUtil<BizMessage>(BizMessage.class);
+        util.exportExcel(response, list, "报工技术咨询数据");
+    }
+
+    /**
+     * 获取消息详情
+     */
+    @GetMapping(value = "/{id}")
+    public AjaxResult getInfo(@PathVariable("id") Long id)
+    {
+        return success(bizMessageService.getById(id));
+    }
+
+    /**
+     * 新增消息
+     */
+    @Log(title = "新增消息", businessType = BusinessType.INSERT)
+    @PostMapping
+    public AjaxResult add(@RequestBody BizMessage bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
+    {
+//        setTenantId(bizDayworkItemConsult);
+        return toAjax(bizMessageService.save(bizDayworkItemConsult));
+    }
+
+    /**
+     * 修改消息信息
+     */
+    @Log(title = "修改消息", businessType = BusinessType.UPDATE)
+    @PutMapping
+    public AjaxResult edit(@RequestBody BizMessage bizDayworkItemConsult) throws NoSuchFieldException, IllegalAccessException
+    {
+//        setTenantId(bizDayworkItemConsult);
+        return toAjax(bizMessageService.updateById(bizDayworkItemConsult));
+    }
+
+    /**
+     * 删除报工技术咨询
+     */
+    @Log(title = "删除消息", businessType = BusinessType.DELETE)
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable List<Long> ids)
+    {
+        return toAjax(bizMessageService.removeBatchByIds(ids));
+    }
+}

+ 10 - 0
src/main/java/cn/ezhizao/project/business/message/domain/BizMessage.java

@@ -35,10 +35,20 @@ public class BizMessage
     @ApiModelProperty(value = "消息")
     private Long fromUserId;
 
+    @TableField(exist = false)
+    private String fromUserName;
+    @TableField(exist = false)
+    private String fromNickName;
+
     /** 去向id */
     @ApiModelProperty(value = "消息")
     private Long toUserId;
 
+    @TableField(exist = false)
+    private String toUserName;
+    @TableField(exist = false)
+    private String toNickName;
+
     /** 发信时间 */
     @JsonFormat(pattern = "yyyy-MM-dd")
     @Excel(name = "发信时间", width = 30, dateFormat = "yyyy-MM-dd")

+ 32 - 0
src/main/resources/mybatis/business/message/BizMessageMapper.xml

@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.ezhizao.project.business.message.mapper.BizMessageMapper">
+
+    <resultMap type="cn.ezhizao.project.business.message.domain.BizMessage" id="BizMessageResult">
+        <id column="id" property="id"/>
+    </resultMap>
+
+
+    <select id="getList" parameterType="BizMessage" resultMap="BizMessageResult">
+        SELECT t.*, fu.user_name as from_user_name, fu.nick_name as from_nick_name, tu.user_name as to_user_name,
+        tu.nick_name as to_nick_name FROM biz_message t left join sys_user fu on fu.user_id = t.from_user_id
+        left join sys_user tu on tu.user_id = t.to_user_id
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            1=1
+            <if test="fromUserId != null ">AND t.from_user_id = #{fromUserId}</if>
+            <if test="toUserId != null ">AND t.to_user_id = #{toUserId}</if>
+        </trim>
+    </select>
+
+    <delete id="physicalDelete">
+        DELETE FROM biz_message
+        <trim prefix=" WHERE" suffix="" suffixOverrides="AND">
+            <if test="id != null">
+                id = #{id} AND
+            </if>
+            <!-- 删除条件为其他外键可以在这里加 -->
+        </trim>
+    </delete>
+</mapper>