Commit 2d6613be authored by 吴卿华's avatar 吴卿华

题库

parent 52f6a5c2
package com.zehong.web.controller.system;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.zehong.common.annotation.Log;
import com.zehong.common.core.controller.BaseController;
import com.zehong.common.core.domain.AjaxResult;
import com.zehong.common.enums.BusinessType;
import com.zehong.system.domain.TTrainCourseBank;
import com.zehong.system.service.ITTrainCourseBankService;
import com.zehong.common.utils.poi.ExcelUtil;
import com.zehong.common.core.page.TableDataInfo;
/**
* bankController
*
* @author zehong
* @date 2022-12-14
*/
@RestController
@RequestMapping("/system/bank")
public class TTrainCourseBankController extends BaseController
{
@Autowired
private ITTrainCourseBankService tTrainCourseBankService;
/**
* 查询bank列表
*/
//@PreAuthorize("@ss.hasPermi('system:bank:list')")
@GetMapping("/list")
public TableDataInfo list(TTrainCourseBank tTrainCourseBank)
{
startPage();
List<TTrainCourseBank> list = tTrainCourseBankService.selectTTrainCourseBankList(tTrainCourseBank);
return getDataTable(list);
}
/**
* 导出bank列表
*/
//@PreAuthorize("@ss.hasPermi('system:bank:export')")
@Log(title = "bank", businessType = BusinessType.EXPORT)
@GetMapping("/export")
public AjaxResult export(TTrainCourseBank tTrainCourseBank)
{
List<TTrainCourseBank> list = tTrainCourseBankService.selectTTrainCourseBankList(tTrainCourseBank);
ExcelUtil<TTrainCourseBank> util = new ExcelUtil<TTrainCourseBank>(TTrainCourseBank.class);
return util.exportExcel(list, "bank数据");
}
/**
* 获取bank详细信息
*/
//@PreAuthorize("@ss.hasPermi('system:bank:query')")
@GetMapping(value = "/{bankId}")
public AjaxResult getInfo(@PathVariable("bankId") Long bankId)
{
return AjaxResult.success(tTrainCourseBankService.selectTTrainCourseBankById(bankId));
}
/**
* 新增bank
*/
//@PreAuthorize("@ss.hasPermi('system:bank:add')")
@Log(title = "bank", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody TTrainCourseBank tTrainCourseBank)
{
return toAjax(tTrainCourseBankService.insertTTrainCourseBank(tTrainCourseBank));
}
/**
* 修改bank
*/
//@PreAuthorize("@ss.hasPermi('system:bank:edit')")
@Log(title = "bank", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody TTrainCourseBank tTrainCourseBank)
{
return toAjax(tTrainCourseBankService.updateTTrainCourseBank(tTrainCourseBank));
}
/**
* 删除bank
*/
//@PreAuthorize("@ss.hasPermi('system:bank:remove')")
@Log(title = "bank", businessType = BusinessType.DELETE)
@DeleteMapping("/{bankIds}")
public AjaxResult remove(@PathVariable Long[] bankIds)
{
return toAjax(tTrainCourseBankService.deleteTTrainCourseBankByIds(bankIds));
}
}
package com.zehong.system.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.zehong.common.annotation.Excel;
import com.zehong.common.core.domain.BaseEntity;
/**
* bank对象 t_train_course_bank
*
* @author zehong
* @date 2022-12-14
*/
public class TTrainCourseBank extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键id */
private Long bankId;
/** 所属部门 */
private Long deptId;
/** 题库名称 */
@Excel(name = "题库名称")
private String bankName;
/** 是否删除 0未删除 1删除 */
private Integer isDel;
public void setBankId(Long bankId)
{
this.bankId = bankId;
}
public Long getBankId()
{
return bankId;
}
public void setDeptId(Long deptId)
{
this.deptId = deptId;
}
public Long getDeptId()
{
return deptId;
}
public void setBankName(String bankName)
{
this.bankName = bankName;
}
public String getBankName()
{
return bankName;
}
public void setIsDel(Integer isDel)
{
this.isDel = isDel;
}
public Integer getIsDel()
{
return isDel;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("bankId", getBankId())
.append("deptId", getDeptId())
.append("bankName", getBankName())
.append("isDel", getIsDel())
.append("createBy", getCreateBy())
.append("createTime", getCreateTime())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}
package com.zehong.system.mapper;
import java.util.List;
import com.zehong.system.domain.TTrainCourseBank;
/**
* bankMapper接口
*
* @author zehong
* @date 2022-12-14
*/
public interface TTrainCourseBankMapper
{
/**
* 查询bank
*
* @param bankId bankID
* @return bank
*/
public TTrainCourseBank selectTTrainCourseBankById(Long bankId);
/**
* 查询bank列表
*
* @param tTrainCourseBank bank
* @return bank集合
*/
public List<TTrainCourseBank> selectTTrainCourseBankList(TTrainCourseBank tTrainCourseBank);
/**
* 新增bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int insertTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 修改bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int updateTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 删除bank
*
* @param bankId bankID
* @return 结果
*/
public int deleteTTrainCourseBankById(Long bankId);
/**
* 批量删除bank
*
* @param bankIds 需要删除的数据ID
* @return 结果
*/
public int deleteTTrainCourseBankByIds(Long[] bankIds);
}
package com.zehong.system.service;
import java.util.List;
import com.zehong.system.domain.TTrainCourseBank;
/**
* bankService接口
*
* @author zehong
* @date 2022-12-14
*/
public interface ITTrainCourseBankService
{
/**
* 查询bank
*
* @param bankId bankID
* @return bank
*/
public TTrainCourseBank selectTTrainCourseBankById(Long bankId);
/**
* 查询bank列表
*
* @param tTrainCourseBank bank
* @return bank集合
*/
public List<TTrainCourseBank> selectTTrainCourseBankList(TTrainCourseBank tTrainCourseBank);
/**
* 新增bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int insertTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 修改bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
public int updateTTrainCourseBank(TTrainCourseBank tTrainCourseBank);
/**
* 批量删除bank
*
* @param bankIds 需要删除的bankID
* @return 结果
*/
public int deleteTTrainCourseBankByIds(Long[] bankIds);
/**
* 删除bank信息
*
* @param bankId bankID
* @return 结果
*/
public int deleteTTrainCourseBankById(Long bankId);
}
package com.zehong.system.service.impl;
import java.util.List;
import com.zehong.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.zehong.system.mapper.TTrainCourseBankMapper;
import com.zehong.system.domain.TTrainCourseBank;
import com.zehong.system.service.ITTrainCourseBankService;
/**
* bankService业务层处理
*
* @author zehong
* @date 2022-12-14
*/
@Service
public class TTrainCourseBankServiceImpl implements ITTrainCourseBankService
{
@Autowired
private TTrainCourseBankMapper tTrainCourseBankMapper;
/**
* 查询bank
*
* @param bankId bankID
* @return bank
*/
@Override
public TTrainCourseBank selectTTrainCourseBankById(Long bankId)
{
return tTrainCourseBankMapper.selectTTrainCourseBankById(bankId);
}
/**
* 查询bank列表
*
* @param tTrainCourseBank bank
* @return bank
*/
@Override
public List<TTrainCourseBank> selectTTrainCourseBankList(TTrainCourseBank tTrainCourseBank)
{
return tTrainCourseBankMapper.selectTTrainCourseBankList(tTrainCourseBank);
}
/**
* 新增bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
@Override
public int insertTTrainCourseBank(TTrainCourseBank tTrainCourseBank)
{
tTrainCourseBank.setCreateTime(DateUtils.getNowDate());
return tTrainCourseBankMapper.insertTTrainCourseBank(tTrainCourseBank);
}
/**
* 修改bank
*
* @param tTrainCourseBank bank
* @return 结果
*/
@Override
public int updateTTrainCourseBank(TTrainCourseBank tTrainCourseBank)
{
tTrainCourseBank.setUpdateTime(DateUtils.getNowDate());
return tTrainCourseBankMapper.updateTTrainCourseBank(tTrainCourseBank);
}
/**
* 批量删除bank
*
* @param bankIds 需要删除的bankID
* @return 结果
*/
@Override
public int deleteTTrainCourseBankByIds(Long[] bankIds)
{
return tTrainCourseBankMapper.deleteTTrainCourseBankByIds(bankIds);
}
/**
* 删除bank信息
*
* @param bankId bankID
* @return 结果
*/
@Override
public int deleteTTrainCourseBankById(Long bankId)
{
return tTrainCourseBankMapper.deleteTTrainCourseBankById(bankId);
}
}
<?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="com.zehong.system.mapper.TTrainCourseBankMapper">
<resultMap type="TTrainCourseBank" id="TTrainCourseBankResult">
<result property="bankId" column="bank_id" />
<result property="deptId" column="dept_id" />
<result property="bankName" column="bank_name" />
<result property="isDel" column="is_del" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectTTrainCourseBankVo">
select bank_id, dept_id, bank_name, is_del, create_by, create_time, update_by, update_time from t_train_course_bank
</sql>
<select id="selectTTrainCourseBankList" parameterType="TTrainCourseBank" resultMap="TTrainCourseBankResult">
<include refid="selectTTrainCourseBankVo"/>
<where>
<if test="bankName != null and bankName != ''"> and bank_name like concat('%', #{bankName}, '%')</if>
</where>
</select>
<select id="selectTTrainCourseBankById" parameterType="Long" resultMap="TTrainCourseBankResult">
<include refid="selectTTrainCourseBankVo"/>
where bank_id = #{bankId}
</select>
<insert id="insertTTrainCourseBank" parameterType="TTrainCourseBank" useGeneratedKeys="true" keyProperty="bankId">
insert into t_train_course_bank
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="deptId != null">dept_id,</if>
<if test="bankName != null">bank_name,</if>
<if test="isDel != null">is_del,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="deptId != null">#{deptId},</if>
<if test="bankName != null">#{bankName},</if>
<if test="isDel != null">#{isDel},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateTTrainCourseBank" parameterType="TTrainCourseBank">
update t_train_course_bank
<trim prefix="SET" suffixOverrides=",">
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="bankName != null">bank_name = #{bankName},</if>
<if test="isDel != null">is_del = #{isDel},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where bank_id = #{bankId}
</update>
<delete id="deleteTTrainCourseBankById" parameterType="Long">
delete from t_train_course_bank where bank_id = #{bankId}
</delete>
<delete id="deleteTTrainCourseBankByIds" parameterType="String">
delete from t_train_course_bank where bank_id in
<foreach item="bankId" collection="array" open="(" separator="," close=")">
#{bankId}
</foreach>
</delete>
</mapper>
\ No newline at end of file
import request from '@/utils/request'
// 查询bank列表
export function listBank(query) {
return request({
url: '/system/bank/list',
method: 'get',
params: query
})
}
// 查询bank详细
export function getBank(bankId) {
return request({
url: '/system/bank/' + bankId,
method: 'get'
})
}
// 新增bank
export function addBank(data) {
return request({
url: '/system/bank',
method: 'post',
data: data
})
}
// 修改bank
export function updateBank(data) {
return request({
url: '/system/bank',
method: 'put',
data: data
})
}
// 删除bank
export function delBank(bankId) {
return request({
url: '/system/bank/' + bankId,
method: 'delete'
})
}
// 导出bank
export function exportBank(query) {
return request({
url: '/system/bank/export',
method: 'get',
params: query
})
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment