|
|
@@ -0,0 +1,67 @@
|
|
|
+package com.ydtech.modules.admin.controller;
|
|
|
+
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.ydtech.core.page.HttpResult;
|
|
|
+import com.ydtech.modules.admin.model.SysUser;
|
|
|
+import com.ydtech.modules.admin.model.po.SysQyWeChat;
|
|
|
+import com.ydtech.modules.admin.service.SysQyWeChatService;
|
|
|
+import com.ydtech.modules.admin.service.SysUserService;
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
+import com.ydtech.modules.protocol.utils.AssertionUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/sys/qy/wechat")
|
|
|
+@RequiredArgsConstructor
|
|
|
+@Api(tags = "企业微信宣传图管理")
|
|
|
+public class SysQyWeChatController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysQyWeChatService sysQyWeChatService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysUserService sysUserService;
|
|
|
+
|
|
|
+ @ApiOperation(value = "配置宣传图")
|
|
|
+ @PostMapping(value = "/save/picture")
|
|
|
+ public HttpResult<SysQyWeChat> save(@RequestBody SysQyWeChat sysQyWeChat) {
|
|
|
+ SysQyWeChat serviceOne = sysQyWeChatService.getOne(new LambdaQueryWrapper<SysQyWeChat>().eq(SysQyWeChat::getUserId, sysQyWeChat.getUserId()));
|
|
|
+ if (serviceOne != null) {
|
|
|
+ sysQyWeChatService.removeById(serviceOne);
|
|
|
+ }
|
|
|
+ sysQyWeChat.setOperator(BaseController.getUser().getName());
|
|
|
+ sysQyWeChat.setOperatorTime(LocalDateTime.now());
|
|
|
+ boolean save = sysQyWeChatService.save(sysQyWeChat);
|
|
|
+ AssertionUtils.isSucceed(save, "添加失败");
|
|
|
+ return HttpResult.ok("添加成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询当前员工宣传图")
|
|
|
+ @GetMapping(value = "/find/picture")
|
|
|
+ public HttpResult<SysQyWeChat> findWechatPicture() {
|
|
|
+ String userId = BaseController.getUser().getId();
|
|
|
+ SysUser user = sysUserService.getOne(new LambdaQueryWrapper<SysUser>().eq(SysUser::getId, userId));
|
|
|
+ user.setLeaderId(null);
|
|
|
+ SysQyWeChat sysQyWeChat = sysQyWeChatService.getOne(new LambdaQueryWrapper<SysQyWeChat>().eq(SysQyWeChat::getUserId, user.getLeaderId()));
|
|
|
+ if (sysQyWeChat == null) {
|
|
|
+ List<SysQyWeChat> list = sysQyWeChatService.list();
|
|
|
+ return HttpResult.ok(list.get(0));
|
|
|
+ }
|
|
|
+ return HttpResult.ok(sysQyWeChat);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "查询对应员工宣传图")
|
|
|
+ @GetMapping(value = "/find/picture/{userId}")
|
|
|
+ public HttpResult<SysQyWeChat> findWechatPictureByUserId(@PathVariable("userId") String userId) {
|
|
|
+ SysQyWeChat sysQyWeChat = sysQyWeChatService.getOne(new LambdaQueryWrapper<SysQyWeChat>().eq(SysQyWeChat::getUserId, userId));
|
|
|
+ return HttpResult.ok(sysQyWeChat);
|
|
|
+ }
|
|
|
+}
|