智慧保安后台管理-外网-验收版本
zengh
2021-07-16 1a8fdd1e29e2e69a452eedbd65cca97c01ee3e84
考试管理
1 files modified
8 files added
521 ■■■■■ changed files
src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java 134 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java 13 ●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/entity/ExamPaper.java 70 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java 52 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml 78 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/ExamPaperService.java 41 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java 43 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java 43 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java 47 ●●●●● patch | view | raw | blame | history
src/main/java/org/springblade/modules/exam/controller/ExamPaperController.java
New file
@@ -0,0 +1,134 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.vo.ExamPaperVO;
import org.springblade.modules.exam.wrapper.ExamPaperWrapper;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;
import java.util.Map;
/**
 * 控制器
 *
 * @author Chill
 */
@RestController
@RequestMapping("/exampaper")
@AllArgsConstructor
public class ExamPaperController extends BladeController {
    private final ExamPaperService examPaperService;
    /**
     * 详情
     */
    @GetMapping("/detail")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "详情", notes = "传入notice")
    public R<ExamPaperVO> detail(ExamPaper notice) {
        ExamPaper detail = examPaperService.getOne(Condition.getQueryWrapper(notice));
        return R.data(ExamPaperWrapper.build().entityVO(detail));
    }
    /**
     * 分页
     */
    @GetMapping("/list")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
        @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
    })
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "分页", notes = "传入notice")
    public R<IPage<ExamPaperVO>> list(@ApiIgnore @RequestParam Map<String, Object> notice, Query query) {
        IPage<ExamPaper> pages = examPaperService.page(Condition.getPage(query), Condition.getQueryWrapper(notice, ExamPaper.class));
        return R.data(ExamPaperWrapper.build().pageVO(pages));
    }
    /**
     * 多表联合查询自定义分页
     */
    @GetMapping("/page")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "category", value = "公告类型", paramType = "query", dataType = "integer"),
        @ApiImplicitParam(name = "title", value = "公告标题", paramType = "query", dataType = "string")
    })
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "分页", notes = "传入notice")
    public R<IPage<ExamPaperVO>> page(@ApiIgnore ExamPaperVO notice, Query query) {
        IPage<ExamPaperVO> pages = examPaperService.selectExamPaperPage(Condition.getPage(query), notice);
        return R.data(pages);
    }
    /**
     * 新增
     */
    @PostMapping("/save")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "新增", notes = "传入notice")
    public R save(@RequestBody ExamPaper notice) {
        return R.status(examPaperService.save(notice));
    }
    /**
     * 修改
     */
    @PostMapping("/update")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "修改", notes = "传入notice")
    public R update(@RequestBody ExamPaper notice) {
        return R.status(examPaperService.updateById(notice));
    }
    /**
     * 新增或修改
     */
    @PostMapping("/submit")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "新增或修改", notes = "传入notice")
    public R submit(@RequestBody ExamPaper notice) {
        return R.status(examPaperService.saveOrUpdate(notice));
    }
    /**
     * 删除
     */
    @PostMapping("/remove")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "逻辑删除", notes = "传入notice")
    public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
        boolean temp = examPaperService.deleteLogic(Func.toLongList(ids));
        return R.status(temp);
    }
}
src/main/java/org/springblade/modules/exam/controller/ExamSubjectChoicesController.java
@@ -42,7 +42,8 @@
    /**
     * 自定义分页
     * @param query page,size
     *
     * @param query              page,size
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/page")
@@ -63,6 +64,7 @@
    /**
     * 新增
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/save")
@@ -73,6 +75,7 @@
    /**
     * 修改
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/update")
@@ -82,13 +85,14 @@
    /**
     * 新增或修改
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @PostMapping("/submit")
    public R submit(@RequestBody ExamSubjectChoices examSubjectChoices) {
        if (null!=examSubjectChoices.getId()){
        if (null != examSubjectChoices.getId()) {
            examSubjectChoices.setCreateDate(new Date());
        }else {
        } else {
            examSubjectChoices.setModifyDate(new Date());
        }
        return R.status(examSubjectChoicesService.saveOrUpdate(examSubjectChoices));
@@ -96,6 +100,7 @@
    /**
     * 删除
     *
     * @param ids 选择题信息ids 数组
     */
    @PostMapping("/remove")
@@ -105,6 +110,7 @@
    /**
     * 详情
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/detail")
@@ -119,6 +125,7 @@
    /**
     * 详情(包含选项信息)
     *
     * @param examSubjectChoices 选择题信息对象
     */
    @GetMapping("/details")
src/main/java/org/springblade/modules/exam/entity/ExamPaper.java
New file
@@ -0,0 +1,70 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.core.tenant.mp.TenantEntity;
import java.util.Date;
/**
 * 实体类
 *
 * @author Chill
 */
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("blade_notice")
public class ExamPaper extends TenantEntity {
    private static final long serialVersionUID = 1L;
    /**
     * 标题
     */
    @ApiModelProperty(value = "标题")
    private String title;
    /**
     * 通知类型
     */
    @ApiModelProperty(value = "通知类型")
    private Integer category;
    /**
     * 发布日期
     */
    @ApiModelProperty(value = "发布日期")
    private Date releaseTime;
    /**
     * 内容
     */
    @ApiModelProperty(value = "内容")
    private String content;
    /**
     * 单位id
     */
    @TableField("dept_id")
    private Long deptId;
}
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.java
New file
@@ -0,0 +1,52 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.vo.NoticeVO;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.vo.ExamPaperVO;
import java.util.List;
/**
 * Mapper 接口
 *
 * @author Chill
 */
public interface ExamPaperMapper extends BaseMapper<ExamPaper> {
    /**
     * 前N条数据
     *
     * @param number 数量
     * @return List<Notice>
     */
    List<ExamPaper> topList(Integer number);
    /**
     * 自定义分页
     *
     * @param page   分页
     * @param exam 实体
     * @return List<NoticeVO>
     */
    List<ExamPaperVO> selectNoticePage(IPage page, ExamPaperVO exam);
}
src/main/java/org/springblade/modules/exam/mapper/ExamPaperMapper.xml
New file
@@ -0,0 +1,78 @@
<?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="org.springblade.modules.exam.mapper.ExamPaperMapper">
    <!-- 通用查询映射结果 -->
    <resultMap id="noticeResultMap" type="org.springblade.modules.exam.entity.ExamPaper">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="release_time" property="releaseTime"/>
        <result column="title" property="title"/>
        <result column="content" property="content"/>
    </resultMap>
    <!-- 通用查询映射结果 -->
    <resultMap id="noticeVOResultMap" type="org.springblade.modules.exam.vo.ExamPaperVO">
        <result column="id" property="id"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="status" property="status"/>
        <result column="is_deleted" property="isDeleted"/>
        <result column="release_time" property="releaseTime"/>
        <result column="title" property="title"/>
        <result column="content" property="content"/>
    </resultMap>
    <select id="topList" resultMap="noticeResultMap">
        select * from blade_notice limit #{number}
    </select>
    <select id="selectNoticePage" resultMap="noticeVOResultMap">
        SELECT
        n.*,
        d.dict_value AS categoryName
        FROM
        blade_notice n
        LEFT JOIN
        ( SELECT * FROM blade_dict WHERE code = 'notice' ) d
        ON
        n.category = d.dict_key
        <if test="notice.deptId!=null and notice.jurisdiction!=null">
            left join
            blade_user bu
            on
            bu.dept_id = n.dept_id
        </if>
        WHERE
        n.is_deleted = 0
        <if test="notice.title!=null">
            and n.title like concat(concat('%', #{notice.title}), '%')
        </if>
        <if test="notice.category!=null">
            and n.category = #{notice.category}
        </if>
        <if test="notice.deptId!=null and notice.jurisdiction!=null">
            and (n.dept_id = #{notice.deptId} or bu.jurisdiction = #{notice.jurisdiction}
            or n.dept_id = 1123598813738675201
            )
        </if>
        <if test="notice.deptId!=null and notice.jurisdiction==null">
            and (n.dept_id = #{notice.deptId} and n.category=2
            or n.dept_id = 1123598813738675201
            )
        </if>
        <if test="notice.startTime!=null and notice.startTime!=''">
            and n.release_time &gt;= #{notice.startTime}
        </if>
        <if test="notice.endTime!=null and notice.endTime!=''">
            and n.release_time &lt;= #{notice.endTime}
        </if>
    </select>
</mapper>
src/main/java/org/springblade/modules/exam/service/ExamPaperService.java
New file
@@ -0,0 +1,41 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import org.springblade.modules.desk.entity.Notice;
import org.springblade.modules.desk.vo.NoticeVO;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.vo.ExamPaperVO;
/**
 * 服务类
 *
 * @author Chill
 */
public interface ExamPaperService extends BaseService<ExamPaper> {
    /**
     * 自定义分页
     * @param page
     * @param exam
     * @return
     */
    IPage<ExamPaperVO> selectExamPaperPage(IPage<ExamPaperVO> page, ExamPaperVO exam);
}
src/main/java/org/springblade/modules/exam/service/impl/ExamPaperServiceImpl.java
New file
@@ -0,0 +1,43 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.service.impl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.mapper.ExamPaperMapper;
import org.springblade.modules.exam.service.ExamPaperService;
import org.springblade.modules.exam.vo.ExamPaperVO;
import org.springframework.stereotype.Service;
/**
 * 服务实现类
 *
 * @author Chill
 */
@Service
public class ExamPaperServiceImpl extends BaseServiceImpl<ExamPaperMapper, ExamPaper> implements ExamPaperService {
    @Override
    public IPage<ExamPaperVO> selectExamPaperPage(IPage<ExamPaperVO> page, ExamPaperVO exam) {
        // 若不使用mybatis-plus自带的分页方法,则不会自动带入tenantId,所以我们需要自行注入
        exam.setTenantId(AuthUtil.getTenantId());
        return page.setRecords(baseMapper.selectNoticePage(page, exam));
    }
}
src/main/java/org/springblade/modules/exam/vo/ExamPaperVO.java
New file
@@ -0,0 +1,43 @@
package org.springblade.modules.exam.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springblade.modules.desk.entity.Notice;
/**
 * 通知公告视图类
 *
 * @author Chill
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class ExamPaperVO extends Notice {
    @ApiModelProperty(value = "通知类型名")
    private String categoryName;
    @ApiModelProperty(value = "租户编号")
    private String tenantId;
    /**
     * 通知开始时间
     */
    private String startTime;
    /**
     * 通知结束时间
     */
    private String endTime;
    /**
     * 行政区(辖区)id
     */
    private Long jurisdiction;
    /**
     * 用户id
     */
    private Long userId;
}
src/main/java/org/springblade/modules/exam/wrapper/ExamPaperWrapper.java
New file
@@ -0,0 +1,47 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.springblade.modules.exam.wrapper;
import org.springblade.common.cache.DictCache;
import org.springblade.common.enums.DictEnum;
import org.springblade.core.mp.support.BaseEntityWrapper;
import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.modules.exam.entity.ExamPaper;
import org.springblade.modules.exam.vo.ExamPaperVO;
import java.util.Objects;
/**
 * Notice包装类,返回视图层所需的字段
 *
 * @author Chill
 */
public class ExamPaperWrapper extends BaseEntityWrapper<ExamPaper, ExamPaperVO> {
    public static ExamPaperWrapper build() {
        return new ExamPaperWrapper();
    }
    @Override
    public ExamPaperVO entityVO(ExamPaper notice) {
        ExamPaperVO noticeVO = Objects.requireNonNull(BeanUtil.copy(notice, ExamPaperVO.class));
        String dictValue = DictCache.getValue(DictEnum.NOTICE, noticeVO.getCategory());
        noticeVO.setCategoryName(dictValue);
        return noticeVO;
    }
}