Lijy пре 6 месеци
родитељ
комит
fdd21575e4
21 измењених фајлова са 514 додато и 45 уклоњено
  1. 20 2
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/controller/ArticleController.java
  2. 5 2
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/controller/CategoryController.java
  3. 4 0
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/ArticleCoverImgMapper.java
  4. 5 4
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/ArticleMapper.java
  5. 6 0
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/CategoryMapper.java
  6. 15 0
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/DictMapper.java
  7. 1 0
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/pojo/Article.java
  8. 10 0
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/pojo/Dict.java
  9. 4 1
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/ArticleService.java
  10. 5 1
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/CategoryService.java
  11. 22 2
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/impl/ArticleServiceImpl.java
  12. 23 1
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/impl/CategoryServiceImpl.java
  13. 17 4
      fhKeeper/formulahousekeeper/ArticleOperation/src/main/resources/com/my/bigevent/mapper/ArticleMapper.xml
  14. 32 4
      fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/CommonUploadController.java
  15. 28 23
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue
  16. 13 1
      fhKeeper/formulahousekeeper/timesheet_h5/src/views/view/index.vue
  17. 97 0
      fhKeeper/formulahousekeeper/webttkuaiban/src/main/java/com/firerock/webttkuaiban/demos/controller/ArticleTemplateController.java
  18. 4 0
      fhKeeper/formulahousekeeper/webttkuaiban/src/main/java/com/firerock/webttkuaiban/demos/pojo/Article.java
  19. 3 0
      fhKeeper/formulahousekeeper/webttkuaiban/src/main/java/com/firerock/webttkuaiban/demos/service/impl/ArticleServiceImpl.java
  20. 81 0
      fhKeeper/formulahousekeeper/webttkuaiban/src/main/resources/templates/knowledge.ftl
  21. 119 0
      fhKeeper/formulahousekeeper/webttkuaiban/src/main/resources/templates/knowledgeDetails.ftl

+ 20 - 2
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/controller/ArticleController.java

@@ -1,6 +1,8 @@
 package com.my.bigevent.controller;
 
+import com.my.bigevent.mapper.DictMapper;
 import com.my.bigevent.pojo.Article;
+import com.my.bigevent.pojo.Dict;
 import com.my.bigevent.pojo.PageBean;
 import com.my.bigevent.pojo.Result;
 import com.my.bigevent.service.ArticleService;
@@ -17,6 +19,9 @@ public class ArticleController
     @Autowired
     ArticleService articleService;
 
+    @Autowired
+    private DictMapper dictMapper;
+
     /**
      * 新增文章
      * @param article
@@ -69,9 +74,11 @@ public class ArticleController
                                          @RequestParam(value = "profile",required = false) String profile,
                                          @RequestParam(value = "state",required = true) String state,
                                          @RequestParam(value = "coverImage",required = false) MultipartFile coverImage,
-                                         @RequestParam(value = "id",required = false) Integer id)
+                                         @RequestParam(value = "id",required = false) Integer id,
+                                         @RequestParam(value = "productId",required = true) String productId
+                                        )
     {
-        articleService.insertOrUpdateArticle(title,categoryIds,profile,content,state,coverImage,id);
+        articleService.insertOrUpdateArticle(title,categoryIds,profile,content,state,coverImage,id,productId);
         return Result.success();
     }
 
@@ -95,4 +102,15 @@ public class ArticleController
         return Result.success(relatedList);
     }
 
+    @GetMapping ("/deleteById")
+    public Result deleteById(@RequestParam("id") Integer id) {
+        return articleService.deleteById(id);
+    }
+
+    @GetMapping ("/dictProduction")
+    public Result dictProduction() {
+        List<Dict> dictList= dictMapper.dictProduction();
+        return Result.success(dictList);
+    }
+
 }

+ 5 - 2
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/controller/CategoryController.java

@@ -24,8 +24,7 @@ public class CategoryController
     @PostMapping
     public Result add(@RequestBody @Validated Category category)
     {
-        categoryService.add(category);
-        return Result.success("新增分类成功!");
+        return categoryService.add(category);
     }
 
     /**
@@ -59,6 +58,10 @@ public class CategoryController
     @DeleteMapping
     public Result delete(Integer id)
     {
+        Integer count= categoryService.selectArticleCountByCategoryId(id.toString());
+        if(count>0){
+            return Result.error("存在文章关联该标签,不能删除");
+        }
         categoryService.delete(id);
         return Result.success("文章删除成功!");
     }

+ 4 - 0
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/ArticleCoverImgMapper.java

@@ -4,6 +4,7 @@ import com.my.bigevent.pojo.ArticleCoverImg;
 import org.apache.ibatis.annotations.Delete;
 import org.apache.ibatis.annotations.Insert;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
 
 @Mapper
 public interface ArticleCoverImgMapper {
@@ -12,4 +13,7 @@ public interface ArticleCoverImgMapper {
 
     @Insert("insert into article_cover_img(article_id,cover_img_data) values (#{articleId},#{coverImgData})")
     void insert(ArticleCoverImg articleCoverImg);
+
+    @Select("select * from article_cover_img where article_id=#{articleId}")
+    ArticleCoverImg selectByArticleId(Integer articleId);
 }

+ 5 - 4
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/ArticleMapper.java

@@ -1,9 +1,7 @@
 package com.my.bigevent.mapper;
 
 import com.my.bigevent.pojo.Article;
-import org.apache.ibatis.annotations.Insert;
-import org.apache.ibatis.annotations.Mapper;
-import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.*;
 
 import java.util.List;
 
@@ -16,7 +14,7 @@ public interface ArticleMapper
     void add(Article article);
 
     // 动态实现 sql,所以这里不用注解
-    List<Article> list(Integer userId, Integer categoryId, String state);
+    List<Article> list(@Param("userId") Integer userId,@Param("categoryId") String categoryId,@Param("state") String state);
     List<Article> pageList(Integer userId, String info);
 
     @Select("select * from article where id = #{id}")
@@ -29,4 +27,7 @@ public interface ArticleMapper
     List<Article> latestList();
 
     List<Article> relatedList(List<String> strings);
+
+    @Delete("delete from article where id = #{articleId}")
+    void deleteById(Integer articleId);
 }

+ 6 - 0
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/CategoryMapper.java

@@ -21,4 +21,10 @@ public interface CategoryMapper
 
     @Delete("delete from category where id=#{id}")
     void delete(Integer id);
+
+    @Select("select count(*) from article where JSON_CONTAINS(category_ids, #{id})")
+    Integer selectArticleCountByCategoryId(String id);
+
+    @Select("select count(*) from category where category_name=#{categoryName}")
+    Integer selectCountByName(String categoryName);
 }

+ 15 - 0
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/mapper/DictMapper.java

@@ -0,0 +1,15 @@
+package com.my.bigevent.mapper;
+
+import com.my.bigevent.pojo.Dict;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+@Mapper
+public interface DictMapper {
+
+    @Select("select * from dict where code='productName'")
+    List<Dict> dictProduction();
+
+}

+ 1 - 0
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/pojo/Article.java

@@ -33,6 +33,7 @@ public class Article {
 
     private String categoryIds;//文章分类 category_ids
     private Integer createUser;//创建人ID
+    private String productId;
 
     @JsonFormat(pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")

+ 10 - 0
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/pojo/Dict.java

@@ -0,0 +1,10 @@
+package com.my.bigevent.pojo;
+
+import lombok.Data;
+
+@Data
+public class Dict {
+    private String code;
+    private String id;
+    private String name;
+}

+ 4 - 1
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/ArticleService.java

@@ -2,6 +2,7 @@ package com.my.bigevent.service;
 
 import com.my.bigevent.pojo.Article;
 import com.my.bigevent.pojo.PageBean;
+import com.my.bigevent.pojo.Result;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.util.List;
@@ -16,11 +17,13 @@ public interface ArticleService
 
     Article getArticleById(Integer id);
 
-    void insertOrUpdateArticle(String title, String categoryIds,String profile, String content, String state, MultipartFile coverImage,Integer id);
+    void insertOrUpdateArticle(String title, String categoryIds,String profile, String content, String state, MultipartFile coverImage,Integer id,String productId);
 
     PageBean<Article> PageList(Integer pageIndex, Integer pageSize, String info);
 
     List<Article> latestList();
 
     List<Article> relatedList(Integer articleId);
+
+    Result deleteById(Integer articleId);
 }

+ 5 - 1
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/CategoryService.java

@@ -1,16 +1,20 @@
 package com.my.bigevent.service;
 
 import com.my.bigevent.pojo.Category;
+import com.my.bigevent.pojo.Result;
 
 import java.util.List;
 
 public interface CategoryService
 {
-    void add(Category category);
+    Result add(Category category);
 
     List<Category> list();
 
     void update(Category category);
 
     void delete(Integer id);
+
+
+    Integer selectArticleCountByCategoryId(String id);
 }

+ 22 - 2
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/impl/ArticleServiceImpl.java

@@ -9,6 +9,7 @@ import com.my.bigevent.mapper.CategoryMapper;
 import com.my.bigevent.pojo.Article;
 import com.my.bigevent.pojo.ArticleCoverImg;
 import com.my.bigevent.pojo.PageBean;
+import com.my.bigevent.pojo.Result;
 import com.my.bigevent.service.ArticleService;
 import com.my.bigevent.utils.ThreadLocalUtil;
 import org.junit.platform.commons.util.StringUtils;
@@ -103,7 +104,16 @@ public class ArticleServiceImpl implements ArticleService
         // 调用 mapper
         Map<String,Object> map=ThreadLocalUtil.get();
         Integer userId=(Integer)map.get("id");
-        List<Article> as=articleMapper.list(userId,categoryId,state);
+        String categoryIdStr=categoryId==null?"":categoryId.toString();
+        List<Article> as=articleMapper.list(userId,categoryIdStr,state);
+        if (!as.isEmpty()){
+            for (Article a : as) {
+                ArticleCoverImg articleCoverImg= coverImgMapper.selectByArticleId(a.getId());
+                if(null!=articleCoverImg&&articleCoverImg.getCoverImgData()!=null){
+                    a.setCoverImg(articleCoverImg.getCoverImgData());
+                }
+            }
+        }
         // Page 中提供了方法,可以获取 PageHelper 分页查询后,得到的总记录条数和当前页数据
         Page<Article> p=(Page<Article>) as;
 
@@ -122,10 +132,11 @@ public class ArticleServiceImpl implements ArticleService
 
     @Override
     @Transactional
-    public void insertOrUpdateArticle(String title, String categoryIds,String profile, String content, String state, MultipartFile coverImage, Integer id) {
+    public void insertOrUpdateArticle(String title, String categoryIds,String profile, String content, String state, MultipartFile coverImage, Integer id,String productId) {
         Optional.ofNullable(title).orElseThrow(() -> new RuntimeException("请传标题"));
         Optional.ofNullable(content).orElseThrow(() -> new RuntimeException("请书写文章内容"));
         Optional.ofNullable(state).orElseThrow(() -> new RuntimeException("请传递发布类型"));
+        Optional.ofNullable(productId).orElseThrow(() -> new RuntimeException("请传递产品类型"));
 
         // 新增
         if (id == null) {
@@ -142,6 +153,7 @@ public class ArticleServiceImpl implements ArticleService
             article.setCreateTime(LocalDateTime.now());
             article.setUpdateTime(LocalDateTime.now());
             article.setCreateUser(6);
+            article.setProductId(productId);
 
             articleMapper.insert(article);
             log.info("文章的id{}", article.getId());
@@ -163,6 +175,7 @@ public class ArticleServiceImpl implements ArticleService
             article.setState(state);
             article.setUpdateTime(LocalDateTime.now());
             article.setId(id);
+            article.setProductId(productId);
             articleMapper.update(article);
 
             if (coverImage != null) {
@@ -213,6 +226,13 @@ public class ArticleServiceImpl implements ArticleService
         }
     }
 
+    @Override
+    public Result deleteById(Integer articleId) {
+        articleMapper.deleteById(articleId);
+        coverImgMapper.deleteByArticleId(articleId);
+        return Result.success();
+    }
+
     private void handleCoverImage(MultipartFile coverImage, Integer articleId) {
         String fileName = coverImage.getOriginalFilename();
         String fileType = fileName.substring(fileName.lastIndexOf("."));

+ 23 - 1
fhKeeper/formulahousekeeper/ArticleOperation/src/main/java/com/my/bigevent/service/impl/CategoryServiceImpl.java

@@ -1,7 +1,9 @@
 package com.my.bigevent.service.impl;
 
+import com.my.bigevent.mapper.ArticleMapper;
 import com.my.bigevent.mapper.CategoryMapper;
 import com.my.bigevent.pojo.Category;
+import com.my.bigevent.pojo.Result;
 import com.my.bigevent.service.CategoryService;
 import com.my.bigevent.utils.ThreadLocalUtil;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,9 +18,22 @@ public class CategoryServiceImpl implements CategoryService
 {
     @Autowired
     CategoryMapper categoryMapper;
+
+    @Autowired
+    ArticleMapper articleMapper;
     @Override
-    public void add(Category category)
+    public Result add(Category category)
     {
+        if(null==category.getCategoryName()||category.getCategoryName().isEmpty()){
+            return Result.error("分类名称不能为空");
+        }
+        if(null==category.getCategoryAlias()||category.getCategoryAlias().isEmpty()){
+            return Result.error("分类别名不能为空");
+        }
+        Integer count=categoryMapper.selectCountByName(category.getCategoryName());
+        if(count>0){
+            return Result.error("标签名称重复");
+        }
         // 补充属性值,数据库里规定 category 的字段都不为 null
         category.setCreateTime(LocalDateTime.now());
         category.setUpdateTime(LocalDateTime.now());
@@ -28,6 +43,8 @@ public class CategoryServiceImpl implements CategoryService
         category.setCreateUser(userId);
 
         categoryMapper.add(category);
+
+        return Result.success("新增分类成功!");
     }
 
     @Override
@@ -50,4 +67,9 @@ public class CategoryServiceImpl implements CategoryService
     {
         categoryMapper.delete(id);
     }
+
+    @Override
+    public Integer selectArticleCountByCategoryId(String id) {
+        return categoryMapper.selectArticleCountByCategoryId(id);
+    }
 }

+ 17 - 4
fhKeeper/formulahousekeeper/ArticleOperation/src/main/resources/com/my/bigevent/mapper/ArticleMapper.xml

@@ -31,6 +31,9 @@
             <if test=" updateTime!=null">
                  update_time,
             </if>
+            <if test=" productId!=null and productId!=''">
+                product_id,
+            </if>
         </trim>
         <trim prefix=" values (" suffix=")" suffixOverrides=",">
             <if test="title !=null and title !=''">
@@ -57,6 +60,9 @@
             <if test="updateTime !=null">
                 #{updateTime},
             </if>
+            <if test=" productId!=null and productId!=''">
+                #{productId},
+            </if>
         </trim>
     </insert>
     <update id="update">
@@ -80,6 +86,9 @@
                 <if test="updateTime !=null">
                     update_time=#{updateTime},
                 </if>
+                <if test=" productId!=null and productId!=''">
+                    product_id=#{productId},
+                </if>
             </set>
         where id=#{id}
     </update>
@@ -87,15 +96,19 @@
     <select id="list" resultType="com.my.bigevent.pojo.Article">
         select * from article
         <where>
-            <if test="categoryId!=null">
-                category_id=#{categoryId}
+            <if test="categoryId!=null and categoryId !='' ">
+               and JSON_CONTAINS(category_ids, #{categoryId})
             </if>
 
-            <if test="state!=null">
-                and state=#{state}
+            <if test="state!=null and state=='yes'">
+                and state='已发布'
+            </if>
+            <if test="state!=null and state=='no'">
+                and state='草稿'
             </if>
         and create_user=#{userId}
         </where>
+        order by update_time desc
     </select>
     <select id="pageList" resultType="com.my.bigevent.pojo.Article">
         select a.* ,aci.cover_img_data coverImg

+ 32 - 4
fhKeeper/formulahousekeeper/management-workshop/src/main/java/com/management/platform/controller/CommonUploadController.java

@@ -5,14 +5,18 @@ import org.apache.log4j.LogManager;
 import org.apache.log4j.Logger;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.io.OutputStream;
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 import java.util.UUID;
 
 @RestController
@@ -26,6 +30,9 @@ public class CommonUploadController {
     @Value(value = "${upload.tempUpdatePath}")
     private String tempUpdatePath;
 
+    @Value(value = "${logging.path}")
+    private String logPath;
+
     @RequestMapping(value="uploadFile")
     public HttpRespMsg uploadFile(MultipartFile multipartFile) {
         HttpRespMsg msg = new HttpRespMsg();
@@ -97,4 +104,25 @@ public class CommonUploadController {
 
         return msg;
     }
+
+    @RequestMapping("/downLoadLog")
+    public ResponseEntity<byte[]> downLoadLog() throws IOException {
+        // 🧐🧐🧐读取本地的文件
+        // 获取File对象
+        System.out.println("读取目录=="+logPath);
+        logger.info("读取目录=={}"+logPath);
+        String fileName = "workshop.out";
+        File readFile=new File(logPath+fileName);
+        // 🐳🐳🐳设置响应头,把文件名称放入响应头中,确保文件可下载
+        HttpHeaders headers = new HttpHeaders();
+        headers.set("Content-Disposition", "attachment;filename=" + URLEncoder.encode(readFile.getName(), "UTF-8"));
+        // 🐳🐳🐳设置内容类型为「application/octet-stream」二进制流
+        headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
+
+        Path path = Paths.get(readFile.toURI());
+        // 获取File对象的字节码文件
+        byte[] bytes = Files.readAllBytes(path);
+        //return new ResponseEntity<>(bytes, headers, HttpStatus.OK);
+        return ResponseEntity.ok().headers(headers).body(bytes);
+    }
 }

+ 28 - 23
fhKeeper/formulahousekeeper/timesheet_h5/src/views/edit/index.vue

@@ -1239,30 +1239,35 @@ export default {
             });
         },
         cancel() {
-            const toast = this.$toast.loading({
-                forbidClick: true,
-                duration: 0
-            });
-            var ids = '';
-            var data = this.form.domains;
-            data.forEach(element => {
-                if (element.id != null && element.id != '') {
-                    if (element.id) {
-                        ids += (element.id + ',');
-                    }
-                }
-            });
-            this.$axios.post("/report/cancel", { userId: this.user.id, reportIds: ids })
-                .then(res => {
-                    if (res.code == "ok") {
-                        this.$toast.clear();
-                        this.$toast.success('撤销成功');
-                        this.getReport();
-                    } else {
-                        this.$toast.clear();
-                        this.$toast.fail('获取失败');
+            this.$dialog.confirm({
+                title: '撤回日报',
+                message: '确定要撤回当天日报吗?'
+            }).then(() => {
+                const toast = this.$toast.loading({
+                    forbidClick: true,
+                    duration: 0
+                });
+                var ids = '';
+                var data = this.form.domains;
+                data.forEach(element => {
+                    if (element.id != null && element.id != '') {
+                        if (element.id) {
+                            ids += (element.id + ',');
+                        }
                     }
-                }).catch(err => { this.$toast.clear(); });
+                });
+                this.$axios.post("/report/cancel", { userId: this.user.id, reportIds: ids })
+                    .then(res => {
+                        if (res.code == "ok") {
+                            this.$toast.clear();
+                            this.$toast.success('撤销成功');
+                            this.getReport();
+                        } else {
+                            this.$toast.clear();
+                            this.$toast.fail('获取失败');
+                        }
+                    }).catch(err => { this.$toast.clear(); });
+            }).catch(() => { });
         },
 
         confirmWorkTime(field) {

+ 13 - 1
fhKeeper/formulahousekeeper/timesheet_h5/src/views/view/index.vue

@@ -67,7 +67,8 @@
                             </template>
                             <div class="form_text" v-if="user.timeType.onlyShowPercent == 0">
                                 <span style="margin-right:20px;margin-left:5px;font-size:14px;">
-                                    总填报:
+                                    <span v-if="user.timeType.showCorpwxCardtime" :style="item.cardTime !=item.reportTime?'color:#ff0000;':''">考勤时长:{{item.cardTime | amounts}}h</span>
+                                    总填报时长:
                                     <span>{{ parseFloat(item.reportTime).toFixed(1) }}h</span>
                                 </span>
                             </div>
@@ -326,7 +327,18 @@ export default {
     },
     created() {
     },
+    filters:{
+        // 过滤
+        amounts(value) {
+            if(value == NaN || value == undefined || value == 'undefined' || value == null || value == 'null') {
+                return 0
+            }
+            var zhi = +value + 0
+            return zhi.toFixed(1)
+        },
+    },
     methods: {
+        
         onDownRefresh() {
             this.pageIndex = 1
             this.upFinished = false // 不写这句会导致你上拉到底过后在下拉刷新将不能触发下拉加载事件

+ 97 - 0
fhKeeper/formulahousekeeper/webttkuaiban/src/main/java/com/firerock/webttkuaiban/demos/controller/ArticleTemplateController.java

@@ -0,0 +1,97 @@
+package com.firerock.webttkuaiban.demos.controller;
+
+import com.firerock.webttkuaiban.demos.pojo.Article;
+import com.firerock.webttkuaiban.demos.service.ArticleService;
+import org.apache.tomcat.util.codec.binary.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.ArrayList;
+import java.util.Base64;
+import java.util.HashMap;
+import java.util.List;
+
+@Controller
+@RequestMapping("articleTemplate")
+public class ArticleTemplateController {
+
+    @Autowired
+    ArticleService articleService;
+
+    @GetMapping("/pageList")  // 这里的 PageBean 是事先定义好的实体类
+    public Object PageList(Model model, Integer pageIndex, Integer pageSize,
+                           @RequestParam(required = false) String info)
+    {
+        List<Article> articleList= articleService.PageList(pageIndex,pageSize,info);
+        Integer total=articleService.getTotal(info);
+        if (!articleList.isEmpty()){
+            for (Article article : articleList) {
+                byte[] imageData = article.getCoverImg();
+                if (imageData != null){
+                    String base64Image = Base64.getEncoder().encodeToString(imageData);
+                    article.setBaseImage(base64Image);
+                }else {
+                    article.setBaseImage("");
+                }
+
+            }
+        }
+        model.addAttribute("knowledgeFieldTableList", articleList);
+        model.addAttribute("total",total );
+        return "knowledge";
+    }
+    @RequestMapping(value = "/articleList", method = RequestMethod.GET)
+    public String articleList(Model model) {
+        List<HashMap> articles = new ArrayList<>();
+        for (int i = 0; i < 10; i++) {
+            HashMap<String, String> article = new HashMap<>();
+            article.put("id", "" + (i+1));
+            article.put("title", "Article Title " + i);
+            article.put("content", "Article Content " + i);
+            articles.add(article);
+        }
+        model.addAttribute("articles", articles);
+        return "articleList";
+    }
+    @GetMapping("/articleDetail")  // 这里的 PageBean 是事先定义好的实体类
+    public Object articleDetail(Model model,@RequestParam("id") Integer id)
+    {
+        List<Article> latestList =articleService.latestList();
+        if (!latestList.isEmpty()){
+            for (Article article : latestList) {
+                byte[] imageData = article.getCoverImg();
+                if (imageData != null){
+                    String base64Image = Base64.getEncoder().encodeToString(imageData);
+                    article.setBaseImage(base64Image);
+                }
+                else {
+                    article.setBaseImage("");
+                }
+            }
+        }
+        List<Article> relatedList =articleService.relatedList(id);
+        if (!relatedList.isEmpty()){
+            for (Article article : relatedList) {
+                byte[] imageData = article.getCoverImg();
+                if (imageData != null){
+                    String base64Image = Base64.getEncoder().encodeToString(imageData);
+                    article.setBaseImage(base64Image);
+                }
+                else {
+                    article.setBaseImage("");
+                }
+            }
+        }
+        Article article = articleService.getArticleById(id);
+        model.addAttribute("latestList", latestList);
+        model.addAttribute("relatedList",relatedList );
+        model.addAttribute("article",article);
+        model.addAttribute("categoryNameList",article.getCategoryNameList()==null?new ArrayList<String>():article.getCategoryNameList());
+        return "knowledgeDetails";
+    }
+}

+ 4 - 0
fhKeeper/formulahousekeeper/webttkuaiban/src/main/java/com/firerock/webttkuaiban/demos/pojo/Article.java

@@ -8,6 +8,7 @@ import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 @Data
 public class Article {
@@ -30,8 +31,11 @@ public class Article {
 
     private String categoryIds;//文章分类 category_ids
     private String categoryNames;//文章分类 category_ids
+    private List<String> categoryNameList;//文章分类 category_ids
     private Integer createUser;//创建人ID
 
+    private String baseImage;
+
     @JsonFormat(pattern = "yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
     private LocalDateTime createTime;//创建时间

+ 3 - 0
fhKeeper/formulahousekeeper/webttkuaiban/src/main/java/com/firerock/webttkuaiban/demos/service/impl/ArticleServiceImpl.java

@@ -13,6 +13,7 @@ import org.springframework.util.StringUtils;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.StringJoiner;
+import java.util.stream.Collectors;
 
 @Service
 public class ArticleServiceImpl implements ArticleService {
@@ -61,6 +62,8 @@ public class ArticleServiceImpl implements ArticleService {
             List<Category> list = categoryMapper.listByIds(categoryIds);
             StringJoiner stringJoiner = new StringJoiner(",");
             if (list != null && !list.isEmpty()) {
+                List<String> categoryList = list.stream().map(Category::getCategoryName).collect(Collectors.toList());
+                article.setCategoryNameList(categoryList);
                 list.forEach(a -> stringJoiner.add(a.getCategoryName()));
                 article.setCategoryNames(stringJoiner.toString());
             }

+ 81 - 0
fhKeeper/formulahousekeeper/webttkuaiban/src/main/resources/templates/knowledge.ftl

@@ -0,0 +1,81 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <meta name="keywords"
+    content="工时管理,工时统计,工时填报,项目成本统计,生产工时管理系统,工时成本管理,工时管理软件,研发工时管理系统,企业工时管理系统,项目工时统计,项目工时统计软件,项目工时统计系统,工时统计系统,工时统计表" />
+  <meta name="description" content="工时管家提供专业的工时填报和统计报表。支持PC和手机端。可按项目,部门,岗位等多维度统计成本。" />
+  <title>工时管家-专注工时管理,手机移动填报,核算项目投入人力成本,企业IPO利器!</title>
+  <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
+  <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700&display=swap&subset=latin-ext"
+    rel="stylesheet">
+  <link href="/css/bootstrap.css" rel="stylesheet">
+  <link href="/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/swiper.css" rel="stylesheet">
+  <link href="/css/magnific-popup.css" rel="stylesheet">
+  <link href="/css/styles.css" rel="stylesheet">
+  <link rel="stylesheet" href="/css/reset.css">
+  <link rel="stylesheet" href="/css/tongyong.css">
+  <link rel="stylesheet" href="/css/knowledgeField.css">
+</head>
+
+<body>
+  <iframe id="headerIframe" src="/moduleView/header.html" class="iframeClass" onLoad="reinitIframe();"></iframe>
+  <div class="knowledgeFieldCon">
+    <div v-loading="detailsSwitchingLoading" class="wh100 flex">
+      <div class="knowledgeField">
+        <div class="knowledgeField-header">
+          <div class="knowledgeField-header-text">知识园地</div>
+          <div class="flex">
+            <input id="knowledgeInput" type="text" class="knowledgeInput" placeholder="请输入关键字搜索">
+            <button class="searchButton" onclick="search()">搜索</button>
+          </div>
+        </div>
+        <div class="flex1 knowledgeField-content">
+          <#list knowledgeFieldTableList as item>
+            <div>
+              <div class="knowledgeField-content-item">
+                <div class="image"><img src="data:image;base64,${item.baseImage}" class="wh100" class="wh100"></img>
+                </div>
+                <div class="textContent">
+                  <div>${ item.title }</div>
+                  <p>${ item.profile }</p>
+                  <button class="linkButton" onclick="learnMore(${item.id})">了解详情></button>
+                </div>
+              </div>
+              <div class="dividingLine"></div>
+            </div>
+          </#list>
+        </div>
+        <div class="knowledgeField-bottom flex-center">
+          
+        </div>
+      </div>
+    </div>
+  </div>
+</body>
+<script src="/js/js/jquery.min.js"></script> <!-- jQuery for Bootstrap's JavaScript plugins -->
+<script src="/js/js/popper.min.js"></script> <!-- Popper tooltip library for Bootstrap -->
+<script src="/js/js/bootstrap.min.js"></script> <!-- Bootstrap framework -->
+<script src="/js/js/jquery.easing.min.js"></script> <!-- jQuery Easing for smooth scrolling between anchors -->
+<script src="/js/js/swiper.min.js"></script> <!-- Swiper for image and text sliders -->
+<script src="/js/js/jquery.magnific-popup.js"></script> <!-- Magnific Popup for lightboxes -->
+<script src="/js/js/validator.min.js"></script> <!-- Validator.js - Bootstrap plugin that validates forms -->
+<script src="/js/js/scripts.js"></script>
+<script src="/js/iframe.js"></script>
+
+<script>
+  function search() {
+    const inputVal = document.getElementById("knowledgeInput").value;
+    console.log(inputVal)
+    window.location.href = '/articleTemplate/pageList?pageIndex=1&pageSize=10&info='+inputVal
+  }
+  function learnMore(id) {
+    window.location.href = '/articleTemplate/articleDetail?id='+id
+  }
+</script>
+
+</html>

+ 119 - 0
fhKeeper/formulahousekeeper/webttkuaiban/src/main/resources/templates/knowledgeDetails.ftl

@@ -0,0 +1,119 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="utf-8">
+  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+  <meta name="keywords"
+    content="工时管理,工时统计,工时填报,项目成本统计,生产工时管理系统,工时成本管理,工时管理软件,研发工时管理系统,企业工时管理系统,项目工时统计,项目工时统计软件,项目工时统计系统,工时统计系统,工时统计表" />
+  <meta name="description" content="工时管家提供专业的工时填报和统计报表。支持PC和手机端。可按项目,部门,岗位等多维度统计成本。" />
+  <title>工时管家-专注工时管理,手机移动填报,核算项目投入人力成本,企业IPO利器!</title>
+  <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
+  <link href="https://fonts.googleapis.com/css?family=Open+Sans:400,400i,700&display=swap&subset=latin-ext"
+    rel="stylesheet">
+  <link href="/css/bootstrap.css" rel="stylesheet">
+  <link href="/css/font-awesome.css" rel="stylesheet">
+  <link href="/css/swiper.css" rel="stylesheet">
+  <link href="/css/magnific-popup.css" rel="stylesheet">
+  <link href="/css/styles.css" rel="stylesheet">
+  <link rel="stylesheet" href="/css/reset.css">
+  <link rel="stylesheet" href="/css/tongyong.css">
+  <link rel="stylesheet" href="/css/knowledgeField.css">
+</head>
+
+<body>
+  <iframe id="headerIframe" src="/moduleView/header.html" class="iframeClass" onLoad="reinitIframe();"></iframe>
+  <div class="knowledgeFieldCon">
+    <div v-if="isItForDetails" class="knowledgeDetails">
+      <div class="returnIcon">
+        <i class="el-icon-arrow-left"></i>
+      </div>
+      <div class="knowledgeDetails-left">
+        <div class="knowledgeDetails-left-title">${article.title}</div>
+        <el-divider></el-divider>
+        <div class="knowledgeDetails-left-con">
+          <div class="flex distribution">
+            <ul class="flex">
+              <li class="grey">标签:</li>
+              <#list categoryNameList as item>
+                <li class="blue">${item}</li>
+              </#list>
+            </ul>
+          </div>
+          <div class="flex-center distribution timeContent">
+            <p>发布时间</p>
+            <span>${ article.createTime }</span>
+          </div>
+          <div class="flex-center distribution readUse" style="justify-content: flex-end;">
+            <div class="text">推荐使用:</div>
+            <div><img src="/image/detailWork.png" alt=""></div>
+          </div>
+        </div>
+        <div class="hypertextContent">
+          ${article.content}
+        </div>
+        <div class="knowledgeDetails-left-bottom flex-center"></div>
+      </div>
+      <div class="knowledgeDetails-right">
+        <div class="latestArticles">
+          <div class="knowledgeDetails-right-title">
+            <div>最新文章</div>
+            <buttom class="linkButton" onclick="toKnowledge()">查看更多></buttom>
+          </div>
+          <div class="line"></div>
+          <div class="latestList">
+            <#list latestList as item>
+              <div class="latestList-item">
+                <div class="latestList-item-image">
+                  <img src="data:image;base64,${item.baseImage}" class="wh100"></img>
+                </div>
+                <div class="latestList-item-text">
+                  <div class="latestList-item-text-title">${ item.title }</div>
+                  <div class="data">${ item.createTime }</div>
+                </div>
+              </div>
+            </#list>
+          </div>
+        </div>
+        <div class="relatedRecommendations">
+          <div class="knowledgeDetails-right-title">
+            <div>相关推荐</div>
+            <buttom class="linkButton" onclick="toKnowledge()">查看更多></buttom>
+          </div>
+          <div class="line"></div>
+          <div class="latestList">
+            <#list relatedList as item>
+              <div class="latestList-item">
+                <div class="latestList-item-image">
+                  <img src="data:image;base64,${item.baseImage}" class="wh100"></img>
+                </div>
+                <div class="latestList-item-text">
+                  <div class="latestList-item-text-title">${ item.title }</div>
+                  <div class="data">${ item.createTime }</div>
+                </div>
+              </div>
+            </#list>
+          </div>
+        </div>
+      </div>
+    </div>
+  </div>
+</body>
+<script src="/js/js/jquery.min.js"></script> <!-- jQuery for Bootstrap's JavaScript plugins -->
+<script src="/js/js/popper.min.js"></script> <!-- Popper tooltip library for Bootstrap -->
+<script src="/js/js/bootstrap.min.js"></script> <!-- Bootstrap framework -->
+<script src="/js/js/jquery.easing.min.js"></script> <!-- jQuery Easing for smooth scrolling between anchors -->
+<script src="/js/js/swiper.min.js"></script> <!-- Swiper for image and text sliders -->
+<script src="/js/js/jquery.magnific-popup.js"></script> <!-- Magnific Popup for lightboxes -->
+<script src="/js/js/validator.min.js"></script> <!-- Validator.js - Bootstrap plugin that validates forms -->
+<script src="/js/js/scripts.js"></script>
+<script src="/js/iframe.js"></script>
+
+<script>
+  function toKnowledge() {
+    window.location.href = `/articleTemplate/pageList?pageIndex=1&pageSize=10`
+  }
+</script>
+
+</html>