فهرست منبع

oa消息通知

Zimo 2 روز پیش
والد
کامیت
730a3d38c2

+ 98 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/OaNoticeController.java

@@ -0,0 +1,98 @@
+package cn.iocoder.yudao.server.controller.admin;
+
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticePageReqVO;
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticeRespVO;
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticeSaveReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
+import cn.iocoder.yudao.server.service.oa.OaNoticeService;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.security.access.prepost.PreAuthorize;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import io.swagger.v3.oas.annotations.Parameter;
+import io.swagger.v3.oas.annotations.Operation;
+
+import java.util.*;
+import java.io.IOException;
+
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
+
+
+@Tag(name = "管理后台 - OA消息通知")
+@RestController
+@RequestMapping("/rq/iot-oa-notice")
+@Validated
+public class OaNoticeController {
+
+    @Resource
+    private OaNoticeService iotOaNoticeService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建OA消息通知")
+    @PreAuthorize("@ss.hasPermission('rq:iot-oa-notice:create')")
+    public CommonResult<Long> createIotOaNotice(@Valid @RequestBody IotOaNoticeSaveReqVO createReqVO) {
+        return success(iotOaNoticeService.createIotOaNotice(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新OA消息通知")
+    @PreAuthorize("@ss.hasPermission('rq:iot-oa-notice:update')")
+    public CommonResult<Boolean> updateIotOaNotice(@Valid @RequestBody IotOaNoticeSaveReqVO updateReqVO) {
+        iotOaNoticeService.updateIotOaNotice(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除OA消息通知")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-oa-notice:delete')")
+    public CommonResult<Boolean> deleteIotOaNotice(@RequestParam("id") Long id) {
+        iotOaNoticeService.deleteIotOaNotice(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得OA消息通知")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-oa-notice:query')")
+    public CommonResult<IotOaNoticeRespVO> getIotOaNotice(@RequestParam("id") Long id) {
+        OaNoticeDO iotOaNotice = iotOaNoticeService.getIotOaNotice(id);
+        return success(BeanUtils.toBean(iotOaNotice, IotOaNoticeRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得OA消息通知分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-oa-notice:query')")
+    public CommonResult<PageResult<IotOaNoticeRespVO>> getIotOaNoticePage(@Valid IotOaNoticePageReqVO pageReqVO) {
+        PageResult<OaNoticeDO> pageResult = iotOaNoticeService.getIotOaNoticePage(pageReqVO);
+        return success(BeanUtils.toBean(pageResult, IotOaNoticeRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出OA消息通知 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-oa-notice:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotOaNoticeExcel(@Valid IotOaNoticePageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<OaNoticeDO> list = iotOaNoticeService.getIotOaNoticePage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "OA消息通知.xls", "数据", IotOaNoticeRespVO.class,
+                        BeanUtils.toBean(list, IotOaNoticeRespVO.class));
+    }
+
+}

+ 38 - 2
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/TodoController.java

@@ -6,13 +6,15 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.framework.common.pojo.CommonResult;
 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
 import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
+import cn.iocoder.yudao.module.system.dal.dataobject.notice.NoticeDO;
 import cn.iocoder.yudao.module.system.dal.dataobject.oa.IotOaPersonDO;
 import cn.iocoder.yudao.module.system.dal.mysql.oa.IotOaPersonMapper;
 import cn.iocoder.yudao.module.system.oa.OaFlow;
 import cn.iocoder.yudao.module.system.util.DingtalkUtil;
-import cn.iocoder.yudao.server.controller.admin.vo.IotOaPersonRespVO;
 import cn.iocoder.yudao.server.dal.dataobject.CrmNoticeDO;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
 import cn.iocoder.yudao.server.dal.mysql.CrmNoticeMapper;
+import cn.iocoder.yudao.server.dal.mysql.OaNoticeMapper;
 import cn.iocoder.yudao.server.dal.mysql.PmsMapper;
 import cn.iocoder.yudao.server.rest.CrmRest;
 import cn.iocoder.yudao.server.service.PortalOaFlow;
@@ -28,6 +30,7 @@ import org.springframework.web.bind.annotation.RestController;
 import javax.annotation.Resource;
 import javax.annotation.security.PermitAll;
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 
 @Tag(name = "管理后台 - 待办接口")
@@ -49,6 +52,8 @@ public class TodoController {
     private CrmNoticeMapper crmNoticeMapper;
     @Autowired
     private IotOaPersonMapper iotOaPersonMapper;
+    @Autowired
+    private OaNoticeMapper oaNoticeMapper;
 
     @GetMapping("/oa")
     @PermitAll
@@ -121,7 +126,12 @@ public class TodoController {
             AdminUserRespDTO userByUsername = adminUserApi.getUserByUsername(workcode);
             if (userByUsername == null) {throw new ServiceException(new ErrorCode(1,"门户系统中不存在该用户"));}
 
-            String dingUserId = DingtalkUtil.getUserInfoByMobile(userByUsername.getMobile());
+            String dingUserId = null;
+            try {
+                dingUserId = DingtalkUtil.getUserInfoByMobile(userByUsername.getMobile());
+            } catch (Exception e) {
+                throw new ServiceException(new ErrorCode(1,e.getMessage()));
+            }
             String crmUserId = crmRest.querySqlUser(String.valueOf(stringStringImmutableMap.get("access")), dingUserId);
             if (StringUtils.isBlank(crmUserId)) {
                 return CommonResult.success(new ArrayList());
@@ -131,6 +141,25 @@ public class TodoController {
         }
     }
 
+    @GetMapping("/oa/notice")
+    @PermitAll
+    public CommonResult<List> oaNotice(String workcode) throws Exception {
+        List<IotOaPersonDO> workcode1 = iotOaPersonMapper.selectList("workcode", workcode);
+        if (CollUtil.isEmpty(workcode1)) {
+            oaFlow.getPerson();
+            workcode1 = iotOaPersonMapper.selectList("workcode", workcode);
+            if (CollUtil.isEmpty(workcode1)) {
+                throw new ServiceException(new ErrorCode(1,"不存在OA用户"));
+            }
+        }
+        OaNoticeDO workcode2 = oaNoticeMapper.selectList("workcode", workcode).stream().max(Comparator.comparing(OaNoticeDO::getOaCreateTime))
+                .orElse(null);
+        List oaNotice = portalOaFlow.getOaNotice(workcode1.get(0).getOaId(), workcode2, workcode);
+        return CommonResult.success(oaNotice);
+
+    }
+
+
     @GetMapping("/crm/notice/self")
     @PermitAll
     public CommonResult<List> crmNoticeSelfSystem(String workcode) throws Exception {
@@ -138,6 +167,13 @@ public class TodoController {
         return CommonResult.success(workCode);
     }
 
+    @GetMapping("/oa/notice/self")
+    @PermitAll
+    public CommonResult<List> oaNoticeSelfSystem(String workcode) throws Exception {
+        List<OaNoticeDO> workCode = oaNoticeMapper.selectList("work_code", workcode);
+        return CommonResult.success(workCode);
+    }
+
     @GetMapping("/crm/notice/readed")
     @PermitAll
     public CommonResult<String> crmNoticeReaded(String workcode) throws Exception {

+ 41 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/oa/IotOaNoticePageReqVO.java

@@ -0,0 +1,41 @@
+package cn.iocoder.yudao.server.controller.admin.vo.oa;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - OA消息通知分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotOaNoticePageReqVO extends PageParam {
+
+    @Schema(description = "oa的创建人")
+    private String oaCreator;
+
+    @Schema(description = "OA的创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private String[] oaCreateTime;
+
+    @Schema(description = "OA的创建人", example = "李四")
+    private String oaCreateName;
+
+    @Schema(description = "消息标题")
+    private String title;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "工号")
+    private String workCode;
+
+    @Schema(description = "crm的消息主键id", example = "8663")
+    private String crmNoticeId;
+
+}

+ 48 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/oa/IotOaNoticeRespVO.java

@@ -0,0 +1,48 @@
+package cn.iocoder.yudao.server.controller.admin.vo.oa;
+
+import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
+import cn.idev.excel.annotation.ExcelProperty;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+@Schema(description = "管理后台 - OA消息通知 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotOaNoticeRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21323")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "oa的创建人")
+    @ExcelProperty("oa的创建人")
+    private String oaCreator;
+
+    @Schema(description = "OA的创建时间")
+    @ExcelProperty("OA的创建时间")
+    private String oaCreateTime;
+
+    @Schema(description = "OA的创建人", example = "李四")
+    @ExcelProperty("OA的创建人")
+    private String oaCreateName;
+
+    @Schema(description = "消息标题", requiredMode = Schema.RequiredMode.REQUIRED)
+    @ExcelProperty("消息标题")
+    private String title;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "工号")
+    @ExcelProperty("工号")
+    private String workCode;
+
+    @Schema(description = "crm的消息主键id", example = "8663")
+    @ExcelProperty("crm的消息主键id")
+    private String crmNoticeId;
+
+}

+ 35 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/controller/admin/vo/oa/IotOaNoticeSaveReqVO.java

@@ -0,0 +1,35 @@
+package cn.iocoder.yudao.server.controller.admin.vo.oa;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+
+import javax.validation.constraints.NotEmpty;
+import java.util.*;
+
+@Schema(description = "管理后台 - OA消息通知新增/修改 Request VO")
+@Data
+public class IotOaNoticeSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "21323")
+    private Long id;
+
+    @Schema(description = "oa的创建人")
+    private String oaCreator;
+
+    @Schema(description = "OA的创建时间")
+    private String oaCreateTime;
+
+    @Schema(description = "OA的创建人", example = "李四")
+    private String oaCreateName;
+
+    @Schema(description = "消息标题", requiredMode = Schema.RequiredMode.REQUIRED)
+    @NotEmpty(message = "消息标题不能为空")
+    private String title;
+
+    @Schema(description = "工号")
+    private String workCode;
+
+    @Schema(description = "crm的消息主键id", example = "8663")
+    private String crmNoticeId;
+
+}

+ 52 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/dal/dataobject/OaNoticeDO.java

@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.server.dal.dataobject;
+
+import lombok.*;
+import com.baomidou.mybatisplus.annotation.*;
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+
+/**
+ * OA消息通知 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_oa_notice")
+@KeySequence("rq_iot_oa_notice_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class OaNoticeDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * oa的创建人
+     */
+    private String oaCreator;
+    /**
+     * OA的创建时间
+     */
+    private String oaCreateTime;
+    /**
+     * OA的创建人
+     */
+    private String oaCreateName;
+    /**
+     * 消息标题
+     */
+    private String title;
+    /**
+     * 工号
+     */
+    private String workCode;
+    /**
+     * crm的消息主键id
+     */
+    private String crmNoticeId;
+
+}

+ 30 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/dal/mysql/OaNoticeMapper.java

@@ -0,0 +1,30 @@
+package cn.iocoder.yudao.server.dal.mysql;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticePageReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * OA消息通知 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface OaNoticeMapper extends BaseMapperX<OaNoticeDO> {
+
+    default PageResult<OaNoticeDO> selectPage(IotOaNoticePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<OaNoticeDO>()
+                .eqIfPresent(OaNoticeDO::getOaCreator, reqVO.getOaCreator())
+                .betweenIfPresent(OaNoticeDO::getOaCreateTime, reqVO.getOaCreateTime())
+                .likeIfPresent(OaNoticeDO::getOaCreateName, reqVO.getOaCreateName())
+                .eqIfPresent(OaNoticeDO::getTitle, reqVO.getTitle())
+                .betweenIfPresent(OaNoticeDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(OaNoticeDO::getWorkCode, reqVO.getWorkCode())
+                .eqIfPresent(OaNoticeDO::getCrmNoticeId, reqVO.getCrmNoticeId())
+                .orderByDesc(OaNoticeDO::getId));
+    }
+
+}

+ 64 - 5
yudao-server/src/main/java/cn/iocoder/yudao/server/service/PortalOaFlow.java

@@ -1,10 +1,17 @@
 package cn.iocoder.yudao.server.service;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.framework.common.exception.ServiceException;
 import cn.iocoder.yudao.module.system.oa.E9ApiTokenUtil;
 import cn.iocoder.yudao.module.system.oa.SslSkippingRestTemplate;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
+import cn.iocoder.yudao.server.dal.mysql.OaNoticeMapper;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.ImmutableMap;
+import lombok.Data;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.http.impl.client.HttpClients;
 import org.apache.http.impl.client.LaxRedirectStrategy;
@@ -16,12 +23,11 @@ import org.springframework.http.MediaType;
 import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.util.MultiValueMap;
+import org.springframework.web.client.RestClientException;
 import org.springframework.web.client.RestTemplate;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.stream.Collectors;
 
 @Component
 public class PortalOaFlow {
@@ -48,7 +54,7 @@ public class PortalOaFlow {
 
     private static String spk = "";
     private static String secret = "";
-
+    private OaNoticeMapper oaNoticeMapper;
 
 
     public void register() throws Exception{
@@ -150,5 +156,58 @@ public class PortalOaFlow {
         return ImmutableMap.of("todoCount", out, "todoList", jsonObjects,"doneCount", done,"doneList", doneJsonObjects);
     }
 
+    public List getOaNotice(String oaId, OaNoticeDO oaNoticeDO, String workcode) throws Exception {
+        String token = getToken();
+
+        HttpHeaders headersOut = new HttpHeaders();
+        headersOut.add("token", token);
+        headersOut.add("appid", appid);
+        String person = E9ApiTokenUtil.encryptString(spk, oaId);
+        headersOut.add("userid", person);
+        headersOut.setContentType(MediaType.APPLICATION_JSON);
+        headersOut.remove(HttpHeaders.COOKIE); // 保险清空
+
+        Map<String, Object> params = new HashMap<>();
+        params.put("userId", oaId);
+        if (oaNoticeDO != null) {
+            params.put("dateTime", oaNoticeDO.getOaCreateTime());
+        }
+
+        HttpEntity<Map<String, Object>> requestEntityOut = new HttpEntity<>(params, headersOut);
 
+        RestTemplate noCookieRestTemplate = getNewRestTemplateWithoutCookie();
+        //消息通知
+        JSONObject out = null;
+        try {
+            out = noCookieRestTemplate.postForObject(
+                    "https://yfoa.keruioil.com/api/msgDataInfo/flow/get", requestEntityOut, JSONObject.class
+            );
+        } catch (RestClientException e) {
+            throw new ServiceException(new ErrorCode(1,"获取OA消息通知信息失败"));
+        }
+        if (Objects.isNull(out)) {return new ArrayList();}
+        //查询的某个日期后面的未读消息中心
+        String data1 = out.getString("data");
+        List<OaNoticeVo> oaNoticeDOS = JSON.parseArray(data1, OaNoticeVo.class);
+        if (CollUtil.isEmpty(oaNoticeDOS)) {return  new ArrayList();}
+        List<OaNoticeDO> collect = oaNoticeDOS.stream().map(e -> {
+            OaNoticeDO oaNoticeDO1 = new OaNoticeDO();
+            oaNoticeDO1.setOaCreateName(e.getCreatorName());
+            oaNoticeDO1.setOaCreateTime(e.getCreateTime());
+            oaNoticeDO1.setOaCreator(e.getCreator());
+            oaNoticeDO1.setDeleted(false);
+            oaNoticeDO1.setWorkCode(workcode);
+            return oaNoticeDO1;
+        }).collect(Collectors.toList());
+        oaNoticeMapper.insertBatch(collect);
+        return oaNoticeDOS;
+    }
+
+    @Data
+    static class OaNoticeVo{
+        private String creator;
+        private String createTime;
+        private String creatorName;
+        private String title;
+    }
 }

+ 55 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/service/oa/OaNoticeService.java

@@ -0,0 +1,55 @@
+package cn.iocoder.yudao.server.service.oa;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticePageReqVO;
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticeSaveReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
+
+import javax.validation.Valid;
+
+/**
+ * OA消息通知 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface OaNoticeService {
+
+    /**
+     * 创建OA消息通知
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotOaNotice(@Valid IotOaNoticeSaveReqVO createReqVO);
+
+    /**
+     * 更新OA消息通知
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotOaNotice(@Valid IotOaNoticeSaveReqVO updateReqVO);
+
+    /**
+     * 删除OA消息通知
+     *
+     * @param id 编号
+     */
+    void deleteIotOaNotice(Long id);
+
+    /**
+     * 获得OA消息通知
+     *
+     * @param id 编号
+     * @return OA消息通知
+     */
+    OaNoticeDO getIotOaNotice(Long id);
+
+    /**
+     * 获得OA消息通知分页
+     *
+     * @param pageReqVO 分页查询
+     * @return OA消息通知分页
+     */
+    PageResult<OaNoticeDO> getIotOaNoticePage(IotOaNoticePageReqVO pageReqVO);
+
+}

+ 72 - 0
yudao-server/src/main/java/cn/iocoder/yudao/server/service/oa/OaNoticeServiceImpl.java

@@ -0,0 +1,72 @@
+package cn.iocoder.yudao.server.service.oa;
+
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticePageReqVO;
+import cn.iocoder.yudao.server.controller.admin.vo.oa.IotOaNoticeSaveReqVO;
+import cn.iocoder.yudao.server.dal.dataobject.OaNoticeDO;
+import cn.iocoder.yudao.server.dal.mysql.OaNoticeMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+
+
+import javax.annotation.Resource;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+
+/**
+ * OA消息通知 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class OaNoticeServiceImpl implements OaNoticeService {
+
+    @Resource
+    private OaNoticeMapper iotOaNoticeMapper;
+
+    @Override
+    public Long createIotOaNotice(IotOaNoticeSaveReqVO createReqVO) {
+        // 插入
+        OaNoticeDO iotOaNotice = BeanUtils.toBean(createReqVO, OaNoticeDO.class);
+        iotOaNoticeMapper.insert(iotOaNotice);
+        // 返回
+        return iotOaNotice.getId();
+    }
+
+    @Override
+    public void updateIotOaNotice(IotOaNoticeSaveReqVO updateReqVO) {
+        // 校验存在
+        validateIotOaNoticeExists(updateReqVO.getId());
+        // 更新
+        OaNoticeDO updateObj = BeanUtils.toBean(updateReqVO, OaNoticeDO.class);
+        iotOaNoticeMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotOaNotice(Long id) {
+        // 校验存在
+        validateIotOaNoticeExists(id);
+        // 删除
+        iotOaNoticeMapper.deleteById(id);
+    }
+
+    private void validateIotOaNoticeExists(Long id) {
+        if (iotOaNoticeMapper.selectById(id) == null) {
+            throw exception(IOT_OA_NOTICE_NOT_EXISTS);
+        }
+    }
+
+    @Override
+    public OaNoticeDO getIotOaNotice(Long id) {
+        return iotOaNoticeMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<OaNoticeDO> getIotOaNoticePage(IotOaNoticePageReqVO pageReqVO) {
+        return iotOaNoticeMapper.selectPage(pageReqVO);
+    }
+
+}