Browse Source

青创赛模块

pengcheng 6 months ago
parent
commit
6ebc1e2754

+ 5 - 0
renren-admin/src/main/java/io/renren/modules/qmgj/entity/WorkEntity.java

@@ -255,6 +255,11 @@ public class WorkEntity implements Serializable {
      */
     private Boolean isNeedVip;
 
+    /**
+     * 非付费会员所需积分
+     */
+    private Integer needPoints;
+
     /**
      * 工作制
      */

+ 90 - 0
renren-admin/src/main/java/io/renren/modules/qyh/controller/NewsController.java

@@ -0,0 +1,90 @@
+package io.renren.modules.qyh.controller;
+
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.R;
+import io.renren.common.validator.ValidatorUtils;
+import io.renren.modules.qyh.entity.NewsEntity;
+import io.renren.modules.qyh.model.dto.NewsDTO;
+import io.renren.modules.qyh.service.NewsService;
+import io.renren.modules.sys.controller.AbstractController;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 青雲慧-青创赛
+ *
+ * @author pengc
+ * @email sunlightcs@gmail.com
+ * @date 2025-09-22 18:00:53
+ */
+@RestController
+@RequestMapping("qyh/news")
+@Api(tags = "青雲慧-青创赛管理")
+public class NewsController extends AbstractController {
+    @Autowired
+    private NewsService newsService;
+
+    @GetMapping("/page")
+    @ApiOperation("分页")
+    @RequiresPermissions("qyh:news:list")
+    public R page(@RequestParam Map<String, Object> params) {
+        PageUtils page = newsService.queryPage(params);
+        return R.ok().put("page", page);
+    }
+
+    @GetMapping("/list")
+    @ApiOperation("列表")
+    public R list() {
+        return R.ok().put("list", newsService.list());
+    }
+
+    @GetMapping("/info/{id}")
+    @ApiOperation("信息")
+    @RequiresPermissions("qyh:news:info")
+    public R info(@PathVariable("id") Long id) {
+        NewsEntity news = newsService.getById(id);
+        return R.ok().put("news", news);
+    }
+
+    @PostMapping("/save")
+    @ApiOperation("新增")
+    @RequiresPermissions("qyh:news:save")
+    public R save(@RequestBody NewsDTO dto) {
+        ValidatorUtils.validateEntity(dto);
+        dto.setCreateId(getUserId());
+        dto.setUpdateId(getUserId());
+        newsService.saveNews(dto);
+        return R.ok();
+    }
+
+    @PutMapping("/update")
+    @ApiOperation("修改")
+    @RequiresPermissions("qyh:news:update")
+    public R update(@RequestBody NewsDTO dto) {
+        ValidatorUtils.validateEntity(dto);
+        dto.setUpdateId(getUserId());
+        newsService.updateNews(dto);
+        return R.ok();
+    }
+
+    @DeleteMapping("/delete")
+    @ApiOperation("删除")
+    @RequiresPermissions("qyh:news:delete")
+    public R delete(@RequestBody Long[] ids) {
+        newsService.deleteNewsByIds(ids);
+        return R.ok();
+    }
+
+    @PostMapping("/getByIdList")
+    @ApiOperation("根据id列表查询青创赛列表(不建议调用)")
+    public R getByIdList(@RequestBody List<Long> ids) {
+        return R.ok().put("list", newsService.getByIdList(ids));
+    }
+
+}

+ 77 - 0
renren-admin/src/main/java/io/renren/modules/qyh/entity/NewsEntity.java

@@ -0,0 +1,77 @@
+package io.renren.modules.qyh.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 青雲慧-青创赛管理
+ *
+ * @author pengc
+ * @email sunlightcs@gmail.com
+ * @date 2025-09-22 18:00:53
+ */
+@Data
+@TableName("qyh_news")
+public class NewsEntity implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键
+	 */
+	@TableId
+	private Long id;
+	/**
+	 * 标题
+	 */
+	private String title;
+
+	/**
+	 * 发布人
+	 */
+	private Long publishId;
+
+	/**
+	 * 发布时间
+	 */
+	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
+	private LocalDateTime publishTime;
+
+	/**
+	 * 内容
+	 */
+	private String content;
+
+	/**
+	 * 状态 1启用 0禁用
+	 */
+	private Integer status;
+
+	/**
+	 * 创建人
+	 */
+	private Long createId;
+	/**
+	 * 创建时间
+	 */
+	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
+	private LocalDateTime createTime;
+	/**
+	 * 修改人
+	 */
+	private Long updateId;
+	/**
+	 * 修改时间
+	 */
+	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
+	private LocalDateTime updateTime;
+	/**
+	 * 是否删除(0正常 -1删除)
+	 */
+	private String isDelete;
+
+}

+ 17 - 0
renren-admin/src/main/java/io/renren/modules/qyh/mapper/NewsMapper.java

@@ -0,0 +1,17 @@
+package io.renren.modules.qyh.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import io.renren.modules.qyh.entity.NewsEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * 青雲慧-青创赛管理
+ *
+ * @author pengc
+ * @email sunlightcs@gmail.com
+ * @date 2025-09-22 18:00:53
+ */
+@Mapper
+public interface NewsMapper extends BaseMapper<NewsEntity> {
+
+}

+ 82 - 0
renren-admin/src/main/java/io/renren/modules/qyh/model/dto/NewsDTO.java

@@ -0,0 +1,82 @@
+package io.renren.modules.qyh.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.renren.common.validator.group.AddGroup;
+import io.renren.common.validator.group.UpdateGroup;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 青雲慧-青创赛管理
+ *
+ * @author pengc
+ * @email sunlightcs@gmail.com
+ * @date 2025-09-22 18:00:53
+ */
+@Data
+public class NewsDTO implements Serializable {
+	private static final long serialVersionUID = 1L;
+
+	/**
+	 * 主键
+	 */
+	@ApiModelProperty(value = "主键")
+	private Long id;
+	/**
+	 * 标题
+	 */
+	@NotBlank(message = "标题不能为空", groups = {AddGroup.class, UpdateGroup.class})
+	@Size(min = 0, max = 250, message = "标题长度不能超过250个字符")
+	@ApiModelProperty(value = "标题")
+	private String title;
+
+	/**
+	 * 发布人
+	 */
+	private Long publishId;
+
+	/**
+	 * 发布时间
+	 */
+	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm")
+	private LocalDateTime publishTime;
+
+	/**
+	 * 内容
+	 */
+	@NotBlank(message = "内容不能为空", groups = {AddGroup.class, UpdateGroup.class})
+	@ApiModelProperty(value = "内容")
+	private String content;
+
+	@ApiModelProperty(value = "状态 1启用 0禁用")
+	private Integer status;
+
+	/**
+	 * 创建人
+	 */
+	private Long createId;
+	/**
+	 * 创建时间
+	 */
+	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
+	private LocalDateTime createTime;
+	/**
+	 * 修改人
+	 */
+	private Long updateId;
+	/**
+	 * 修改时间
+	 */
+	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
+	private LocalDateTime updateTime;
+	/**
+	 * 是否删除(0正常 -1删除)
+	 */
+	private String isDelete;
+
+}

+ 35 - 0
renren-admin/src/main/java/io/renren/modules/qyh/service/NewsService.java

@@ -0,0 +1,35 @@
+package io.renren.modules.qyh.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import io.renren.common.utils.PageUtils;
+import io.renren.modules.qyh.entity.NewsEntity;
+import io.renren.modules.qyh.model.dto.NewsDTO;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 青雲慧-青创赛管理
+ *
+ * @author pengc
+ * @email sunlightcs@gmail.com
+ * @date 2025-09-22 18:00:53
+ */
+public interface NewsService extends IService<NewsEntity> {
+
+    PageUtils queryPage(Map<String, Object> params);
+
+    void saveNews(NewsDTO dto);
+
+    void updateNews(NewsDTO dto);
+
+    void deleteNewsByIds(Long[] ids);
+
+    NewsEntity loadById(Long id, Boolean tw);
+
+    NewsEntity getByTitle(String title);
+
+    List<NewsEntity> getByIdList(List<Long> ids);
+
+}
+

+ 111 - 0
renren-admin/src/main/java/io/renren/modules/qyh/service/impl/NewsServiceImpl.java

@@ -0,0 +1,111 @@
+package io.renren.modules.qyh.service.impl;
+
+import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import io.renren.common.enums.IsDeleteEnum;
+import io.renren.common.exception.RRException;
+import io.renren.common.utils.PageUtils;
+import io.renren.common.utils.Query;
+import io.renren.modules.qmjz.utils.BeanCopyUtils;
+import io.renren.modules.qyh.entity.NewsEntity;
+import io.renren.modules.qyh.mapper.NewsMapper;
+import io.renren.modules.qyh.model.dto.NewsDTO;
+import io.renren.modules.qyh.service.ExpertStoreService;
+import io.renren.modules.qyh.service.NewsService;
+import lombok.RequiredArgsConstructor;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
+
+@RequiredArgsConstructor
+@Service("newsService")
+public class NewsServiceImpl extends ServiceImpl<NewsMapper, NewsEntity> implements NewsService {
+
+    @Override
+    public PageUtils queryPage(Map<String, Object> params) {
+        Integer status = MapUtil.getInt(params, "status");
+        String title = MapUtil.getStr(params, "title");
+        IPage<NewsEntity> page = this.page(new Query<NewsEntity>().getPage(params),
+                new LambdaQueryWrapper<NewsEntity>()
+                        .eq(ObjectUtil.isNotNull(status), NewsEntity::getStatus, status)
+                        .like(StrUtil.isNotBlank(title), NewsEntity::getTitle, title)
+                        .eq(NewsEntity::getIsDelete, IsDeleteEnum.NORMAL.value())
+                        .orderByDesc(NewsEntity::getCreateTime));
+        return new PageUtils(page);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void saveNews(NewsDTO dto) {
+        validateTitleExists(dto);
+
+        NewsEntity entity = new NewsEntity();
+        BeanCopyUtils.copyPropertiesIgnoreNull(dto, entity);
+        entity.setCreateTime(LocalDateTime.now());
+        entity.setUpdateTime(LocalDateTime.now());
+        baseMapper.insert(entity);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updateNews(NewsDTO dto) {
+        NewsEntity entity = this.loadById(dto.getId(), true);
+        if (!StrUtil.equals(dto.getTitle(), entity.getTitle())) {
+            validateTitleExists(dto);
+        }
+        BeanCopyUtils.copyPropertiesIgnoreNull(dto, entity);
+        entity.setUpdateTime(LocalDateTime.now());
+        baseMapper.updateById(entity);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteNewsByIds(Long[] ids) {
+        for (Long id : ids) {
+            NewsEntity entity = this.loadById(id, true);
+            entity.setIsDelete(IsDeleteEnum.DELETE.value());
+            entity.setUpdateTime(LocalDateTime.now());
+            baseMapper.updateById(entity);
+        }
+    }
+
+    @Override
+    public NewsEntity loadById(Long id, Boolean tw) {
+        NewsEntity entity = baseMapper.selectOne(new LambdaQueryWrapper<NewsEntity>().eq(NewsEntity::getId, id)
+                .eq(NewsEntity::getIsDelete, IsDeleteEnum.NORMAL.value()));
+        if (entity == null) {
+            if (tw) {
+                throw new RRException("青创赛不存在");
+            }
+        }
+        return entity;
+    }
+
+    @Override
+    public NewsEntity getByTitle(String title) {
+        return baseMapper.selectOne(new LambdaQueryWrapper<NewsEntity>().eq(NewsEntity::getTitle, title)
+                .eq(NewsEntity::getIsDelete, IsDeleteEnum.NORMAL.value()));
+    }
+
+    @Override
+    public List<NewsEntity> getByIdList(List<Long> ids) {
+        return baseMapper.selectList(new LambdaQueryWrapper<NewsEntity>().in(NewsEntity::getId, ids)
+                .eq(NewsEntity::getIsDelete, IsDeleteEnum.NORMAL.value()));
+    }
+
+
+    private void validateTitleExists(NewsDTO dto) {
+        NewsEntity target = this.getByTitle(dto.getTitle());
+        if (ObjectUtil.isNotNull(target) && StrUtil.equals(target.getTitle(), dto.getTitle())) {
+            throw new RRException("青云赛标题重复");
+        }
+    }
+
+}

+ 21 - 0
renren-admin/src/main/resources/mapper/qyh/NewsDao.xml

@@ -0,0 +1,21 @@
+<?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="io.renren.modules.qyh.mapper.NewsMapper">
+
+    <resultMap type="io.renren.modules.qyh.entity.NewsEntity" id="newsMap">
+        <result property="id" column="id"/>
+        <result property="title" column="title"/>
+        <result property="publishId" column="publish_id"/>
+        <result property="publishTime" column="publish_time"/>
+        <result property="content" column="content"/>
+        <result property="status" column="status"/>
+        <result property="createId" column="create_id"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateId" column="update_id"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="isDelete" column="is_delete"/>
+    </resultMap>
+
+
+</mapper>

+ 4 - 4
renren-admin/src/main/resources/statics/js/modules/qyh/pointsconfig.js

@@ -1,6 +1,6 @@
 $(function () {
     $("#jqGrid").jqGrid({
-        url: baseURL + 'wjxy/pointsconfig/page',
+        url: baseURL + 'qyh/pointsconfig/page',
         datatype: "json",
         colModel: [
 			{ label: 'id', name: 'id', index: 'id', width: 50, key: true },
@@ -67,7 +67,7 @@ var vm = new Vue({
 		},
 		saveOrUpdate: function (event) {
 		    $('#btnSaveOrUpdate').button('loading').delay(1000).queue(function() {
-                var url = vm.wjxyPointsConfig.id == null ? "wjxy/pointsconfig/save" : "wjxy/pointsconfig/update";
+                var url = vm.wjxyPointsConfig.id == null ? "qyh/pointsconfig/save" : "qyh/pointsconfig/update";
                 $.ajax({
                     type: "POST",
                     url: baseURL + url,
@@ -101,7 +101,7 @@ var vm = new Vue({
                     lock = true;
 		            $.ajax({
                         type: "POST",
-                        url: baseURL + "wjxy/pointsconfig/delete",
+                        url: baseURL + "qyh/pointsconfig/delete",
                         contentType: "application/json",
                         data: JSON.stringify(ids),
                         success: function(r){
@@ -118,7 +118,7 @@ var vm = new Vue({
              });
 		},
 		getInfo: function(id){
-			$.get(baseURL + "wjxy/pointsconfig/info/"+id, function(r){
+			$.get(baseURL + "qyh/pointsconfig/info/"+id, function(r){
                 vm.wjxyPointsConfig = r.wjxyPointsConfig;
             });
 		},