张延森 4 jaren geleden
bovenliggende
commit
4a97d716dd

+ 12
- 1
src/main/java/com/yunzhi/demo/controller/TaPersonController.java Bestand weergeven

@@ -86,10 +86,21 @@ public class TaPersonController extends BaseController {
86 86
             throw new Exception("校验人员信息失败");
87 87
         }
88 88
 
89
+        if (!StringUtils.isEmpty(taPerson.getStudentId())) {
90
+            TaPerson stu = iTaPersonService.getByStudentId(taPerson.getStudentId());
91
+            if (null != stu && stu.getPersonId().equals(taPerson.getPersonId())) {
92
+                throw new Exception("学号信息重复");
93
+            }
94
+        }
95
+
89 96
         taPerson.setUpdateDate(LocalDateTime.now());
90 97
 
91 98
         if (iTaPersonService.updateById(taPerson)){
92
-            return ResponseBean.success(iTaPersonService.getById(taPerson.getPersonId()));
99
+
100
+            taPerson = iTaPersonService.getById(taPerson.getPersonId());
101
+            fillInfo(taPerson);
102
+
103
+            return ResponseBean.success(taPerson);
93 104
         }else {
94 105
             return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
95 106
         }

+ 12
- 0
src/main/java/com/yunzhi/demo/controller/TaPostController.java Bestand weergeven

@@ -58,6 +58,9 @@ public class TaPostController extends BaseController {
58 58
     @Autowired
59 59
     public ITaPostSaveService iTaPostSaveService;
60 60
 
61
+    @Autowired
62
+    public ITaShareSettingService iTaShareSettingService;
63
+
61 64
 
62 65
     /**
63 66
      * 分页查询列表
@@ -175,6 +178,15 @@ public class TaPostController extends BaseController {
175 178
         TaPostData taPostData = iTaPostDataService.getById(id);
176 179
         taPost.setPostData(taPostData);
177 180
 
181
+        // 分享信息
182
+        TaShareSetting taShareSetting = iTaShareSettingService.getSettingBy(Constants.RESOURCE_TYPE_POST, id);
183
+        if (!"admin".equals(client)) {
184
+            if (Constants.STATUS_NORMAL.equals(taShareSetting.getStatus())) {
185
+                taPost.setShareSetting(taShareSetting);
186
+            }
187
+        } else {
188
+            taPost.setShareSetting(taShareSetting);
189
+        }
178 190
 
179 191
         // 获取试题
180 192
         List<TaPostTest> postTestList = new ArrayList<>();

+ 104
- 0
src/main/java/com/yunzhi/demo/controller/TaShareSettingController.java Bestand weergeven

@@ -0,0 +1,104 @@
1
+package com.yunzhi.demo.controller;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
+import com.yunzhi.demo.common.BaseController;
7
+import com.yunzhi.demo.common.Constants;
8
+import com.yunzhi.demo.common.ResponseBean;
9
+import com.yunzhi.demo.common.StringUtils;
10
+import io.swagger.annotations.Api;
11
+import io.swagger.annotations.ApiOperation;
12
+import io.swagger.annotations.ApiParam;
13
+import org.slf4j.Logger;
14
+import org.slf4j.LoggerFactory;
15
+import org.springframework.beans.factory.annotation.Autowired;
16
+import org.springframework.web.bind.annotation.PathVariable;
17
+import org.springframework.web.bind.annotation.RequestBody;
18
+import org.springframework.web.bind.annotation.RequestMapping;
19
+import org.springframework.web.bind.annotation.RequestMethod;
20
+import org.springframework.web.bind.annotation.RequestParam;
21
+import com.yunzhi.demo.service.ITaShareSettingService;
22
+import com.yunzhi.demo.entity.TaShareSetting;
23
+import org.springframework.web.bind.annotation.RestController;
24
+
25
+/**
26
+ * <p>
27
+    * 分享设置  前端控制器
28
+    * </p>
29
+ *
30
+ * @author yansen
31
+ * @since 2021-04-25
32
+ */
33
+
34
+@Api(tags = "分享设置 ")
35
+@RestController
36
+@RequestMapping("/")
37
+public class TaShareSettingController extends BaseController {
38
+
39
+    private final Logger logger = LoggerFactory.getLogger(TaShareSettingController.class);
40
+
41
+    @Autowired
42
+    public ITaShareSettingService iTaShareSettingService;
43
+
44
+
45
+    /**
46
+     * 保存对象
47
+     * @param taShareSetting 实体对象
48
+     * @return
49
+     */
50
+    @RequestMapping(value="/admin/share-setting",method= RequestMethod.POST)
51
+    @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
52
+    public ResponseBean taShareSettingAdd(@ApiParam("保存内容") @RequestBody TaShareSetting taShareSetting) throws Exception {
53
+        if (StringUtils.isEmpty(taShareSetting.getTargetId())) {
54
+            throw new Exception("未设置分享对象");
55
+        }
56
+
57
+        if (StringUtils.isEmpty(taShareSetting.getTargetType())) {
58
+            taShareSetting.setTargetType(Constants.RESOURCE_TYPE_POST);
59
+        }
60
+
61
+        if (iTaShareSettingService.save(taShareSetting)){
62
+            return ResponseBean.success(taShareSetting);
63
+        }else {
64
+            return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
65
+        }
66
+    }
67
+
68
+    /**
69
+     * 修改对象
70
+     * @param id  实体ID
71
+     * @param taShareSetting 实体对象
72
+     * @return
73
+     */
74
+    @RequestMapping(value="/admin/share-setting/{id}",method= RequestMethod.PUT)
75
+    @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
76
+    public ResponseBean taShareSettingUpdate(@ApiParam("对象ID") @PathVariable Integer id,
77
+                                             @ApiParam("更新内容") @RequestBody TaShareSetting taShareSetting) throws Exception{
78
+        if (StringUtils.isEmpty(taShareSetting.getTargetId())) {
79
+            throw new Exception("未设置分享对象");
80
+        }
81
+
82
+        if (StringUtils.isEmpty(taShareSetting.getTargetType())) {
83
+            taShareSetting.setTargetType(Constants.RESOURCE_TYPE_POST);
84
+        }
85
+
86
+        taShareSetting.setSerialNo(id);
87
+
88
+        if (iTaShareSettingService.updateById(taShareSetting)){
89
+            return ResponseBean.success(iTaShareSettingService.getById(id));
90
+        }else {
91
+            return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
92
+        }
93
+    }
94
+
95
+//    /**
96
+//     * 根据id查询对象
97
+//     * @param id  实体ID
98
+//     */
99
+//    @RequestMapping(value="/admin/share-setting/{id}",method= RequestMethod.GET)
100
+//    @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
101
+//    public ResponseBean taShareSettingGet(@ApiParam("对象ID") @PathVariable Integer id) throws Exception{
102
+//        return ResponseBean.success(iTaShareSettingService.getById(id));
103
+//    }
104
+}

+ 4
- 0
src/main/java/com/yunzhi/demo/entity/TaPost.java Bestand weergeven

@@ -99,6 +99,10 @@ public class TaPost implements Serializable {
99 99
     @TableField(exist = false)
100 100
     private List<TaPostTest> postTestList;
101 101
 
102
+    @ApiModelProperty(value = "分享设置")
103
+    @TableField(exist = false)
104
+    private TaShareSetting shareSetting;
105
+
102 106
     @ApiModelProperty(value = "是否被收藏")
103 107
     @TableField(exist = false)
104 108
     private Boolean isSaved;

+ 55
- 0
src/main/java/com/yunzhi/demo/entity/TaShareSetting.java Bestand weergeven

@@ -0,0 +1,55 @@
1
+package com.yunzhi.demo.entity;
2
+
3
+import com.baomidou.mybatisplus.annotation.IdType;
4
+import com.baomidou.mybatisplus.annotation.TableId;
5
+import java.time.LocalDateTime;
6
+import java.io.Serializable;
7
+import io.swagger.annotations.ApiModel;
8
+import io.swagger.annotations.ApiModelProperty;
9
+import lombok.Data;
10
+import lombok.EqualsAndHashCode;
11
+import lombok.experimental.Accessors;
12
+
13
+/**
14
+ * <p>
15
+ * 分享设置 
16
+ * </p>
17
+ *
18
+ * @author yansen
19
+ * @since 2021-04-25
20
+ */
21
+@Data
22
+@EqualsAndHashCode(callSuper = false)
23
+@Accessors(chain = true)
24
+@ApiModel(value="TaShareSetting对象", description="分享设置 ")
25
+public class TaShareSetting implements Serializable {
26
+
27
+    private static final long serialVersionUID = 1L;
28
+
29
+    @ApiModelProperty(value = "主键")
30
+    @TableId(value = "serial_no", type = IdType.AUTO)
31
+    private Integer serialNo;
32
+
33
+    @ApiModelProperty(value = "分享名称")
34
+    private String title;
35
+
36
+    @ApiModelProperty(value = "分享图片")
37
+    private String imageUrl;
38
+
39
+    @ApiModelProperty(value = "分享对象")
40
+    private String targetType;
41
+
42
+    @ApiModelProperty(value = "对象ID")
43
+    private String targetId;
44
+
45
+    @ApiModelProperty(value = "状态")
46
+    private Integer status;
47
+
48
+    @ApiModelProperty(value = "创建时间")
49
+    private LocalDateTime createDate;
50
+
51
+    @ApiModelProperty(value = "更新时间")
52
+    private LocalDateTime updateDate;
53
+
54
+
55
+}

+ 18
- 0
src/main/java/com/yunzhi/demo/mapper/TaShareSettingMapper.java Bestand weergeven

@@ -0,0 +1,18 @@
1
+package com.yunzhi.demo.mapper;
2
+
3
+import com.yunzhi.demo.entity.TaShareSetting;
4
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
5
+import org.apache.ibatis.annotations.Mapper;
6
+
7
+/**
8
+ * <p>
9
+ * 分享设置  Mapper 接口
10
+ * </p>
11
+ *
12
+ * @author yansen
13
+ * @since 2021-04-25
14
+ */
15
+@Mapper
16
+public interface TaShareSettingMapper extends BaseMapper<TaShareSetting> {
17
+
18
+}

+ 17
- 0
src/main/java/com/yunzhi/demo/service/ITaShareSettingService.java Bestand weergeven

@@ -0,0 +1,17 @@
1
+package com.yunzhi.demo.service;
2
+
3
+import com.yunzhi.demo.entity.TaShareSetting;
4
+import com.baomidou.mybatisplus.extension.service.IService;
5
+
6
+/**
7
+ * <p>
8
+ * 分享设置  服务类
9
+ * </p>
10
+ *
11
+ * @author yansen
12
+ * @since 2021-04-25
13
+ */
14
+public interface ITaShareSettingService extends IService<TaShareSetting> {
15
+
16
+    TaShareSetting getSettingBy(String targetType, String targetId);
17
+}

+ 32
- 0
src/main/java/com/yunzhi/demo/service/impl/TaShareSettingServiceImpl.java Bestand weergeven

@@ -0,0 +1,32 @@
1
+package com.yunzhi.demo.service.impl;
2
+
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.yunzhi.demo.common.Constants;
5
+import com.yunzhi.demo.entity.TaShareSetting;
6
+import com.yunzhi.demo.mapper.TaShareSettingMapper;
7
+import com.yunzhi.demo.service.ITaShareSettingService;
8
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
+import org.springframework.stereotype.Service;
10
+
11
+/**
12
+ * <p>
13
+ * 分享设置  服务实现类
14
+ * </p>
15
+ *
16
+ * @author yansen
17
+ * @since 2021-04-25
18
+ */
19
+@Service
20
+public class TaShareSettingServiceImpl extends ServiceImpl<TaShareSettingMapper, TaShareSetting> implements ITaShareSettingService {
21
+
22
+    @Override
23
+    public TaShareSetting getSettingBy(String targetType, String targetId) {
24
+        QueryWrapper<TaShareSetting> queryWrapper = new QueryWrapper<TaShareSetting>()
25
+                .eq("target_type", targetType)
26
+                .eq("target_id", targetId)
27
+                .gt("status", Constants.STATUS_DELETED)
28
+                .last("limit 1");
29
+
30
+        return getOne(queryWrapper);
31
+    }
32
+}

+ 5
- 0
src/main/resources/mapper/TaShareSettingMapper.xml Bestand weergeven

@@ -0,0 +1,5 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.yunzhi.demo.mapper.TaShareSettingMapper">
4
+
5
+</mapper>