积分模块优化

master
elliott 2 years ago
parent b08a50b1d6
commit f2b5f6f351

@ -0,0 +1,55 @@
package com.flossom.hzMapper.domain;
import com.flossom.common.core.annotation.Excel;
import com.flossom.common.core.web.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* integral_global
*
* @author flossom
* @date 2023-12-11
*/
public class IntegralGlobal extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 初始奖励积分 */
@Excel(name = "初始奖励积分")
private Long integral;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setIntegral(Long integral)
{
this.integral = integral;
}
public Long getIntegral()
{
return integral;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("integral", getIntegral())
.append("createTime", getCreateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("updateTime", getUpdateTime())
.toString();
}
}

@ -0,0 +1,62 @@
package com.flossom.hzMapper.mapper;
import com.flossom.hzMapper.domain.IntegralGlobal;
import java.util.List;
/**
* Mapper
*
* @author flossom
* @date 2023-12-11
*/
public interface IntegralGlobalMapper
{
/**
*
*
* @param id
* @return
*/
public IntegralGlobal selectIntegralGlobalById(Long id);
/**
*
*
* @param integralGlobal
* @return
*/
public List<IntegralGlobal> selectIntegralGlobalList(IntegralGlobal integralGlobal);
/**
*
*
* @param integralGlobal
* @return
*/
public int insertIntegralGlobal(IntegralGlobal integralGlobal);
/**
*
*
* @param integralGlobal
* @return
*/
public int updateIntegralGlobal(IntegralGlobal integralGlobal);
/**
*
*
* @param id
* @return
*/
public int deleteIntegralGlobalById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteIntegralGlobalByIds(Long[] ids);
}

@ -0,0 +1,74 @@
<?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.flossom.hzMapper.mapper.IntegralGlobalMapper">
<resultMap type="IntegralGlobal" id="IntegralGlobalResult">
<result property="id" column="id" />
<result property="integral" column="integral" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
</resultMap>
<sql id="selectIntegralGlobalVo">
select id, integral, create_time, create_by, update_by, update_time from integral_global
</sql>
<select id="selectIntegralGlobalList" parameterType="IntegralGlobal" resultMap="IntegralGlobalResult">
<include refid="selectIntegralGlobalVo"/>
<where>
<if test="integral != null "> and integral = #{integral}</if>
</where>
</select>
<select id="selectIntegralGlobalById" parameterType="Long" resultMap="IntegralGlobalResult">
<include refid="selectIntegralGlobalVo"/>
where id = #{id}
</select>
<insert id="insertIntegralGlobal" parameterType="IntegralGlobal">
insert into integral_global
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="integral != null">integral,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="integral != null">#{integral},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateIntegralGlobal" parameterType="IntegralGlobal">
update integral_global
<trim prefix="SET" suffixOverrides=",">
<if test="integral != null">integral = #{integral},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteIntegralGlobalById" parameterType="Long">
delete from integral_global where id = #{id}
</delete>
<delete id="deleteIntegralGlobalByIds" parameterType="String">
delete from integral_global where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

@ -0,0 +1,106 @@
package com.flossom.system.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.flossom.common.core.utils.poi.ExcelUtil;
import com.flossom.common.core.web.controller.BaseController;
import com.flossom.common.core.web.domain.AjaxResult;
import com.flossom.common.core.web.page.TableDataInfo;
import com.flossom.common.log.annotation.Log;
import com.flossom.common.log.enums.BusinessType;
import com.flossom.common.security.annotation.RequiresPermissions;
import com.flossom.hzMapper.domain.IntegralGlobal;
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.flossom.system.service.IIntegralGlobalService;
/**
* Controller
*
* @author flossom
* @date 2023-12-11
*/
@RestController
@RequestMapping("/globalIntegral")
public class IntegralGlobalController extends BaseController
{
@Autowired
private IIntegralGlobalService integralGlobalService;
/**
*
*/
@RequiresPermissions("system:globalIntegral:list")
@GetMapping("/list")
public TableDataInfo list(IntegralGlobal integralGlobal)
{
startPage();
List<IntegralGlobal> list = integralGlobalService.selectIntegralGlobalList(integralGlobal);
return getDataTable(list);
}
/**
*
*/
@RequiresPermissions("system:globalIntegral:export")
@Log(title = "奖励积分", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, IntegralGlobal integralGlobal)
{
List<IntegralGlobal> list = integralGlobalService.selectIntegralGlobalList(integralGlobal);
ExcelUtil<IntegralGlobal> util = new ExcelUtil<IntegralGlobal>(IntegralGlobal.class);
util.exportExcel(response, list, "奖励积分数据");
}
/**
*
*/
@RequiresPermissions("system:globalIntegral:query")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
return success(integralGlobalService.selectIntegralGlobalById(id));
}
/**
*
*/
@RequiresPermissions("system:globalIntegral:add")
@Log(title = "奖励积分", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody IntegralGlobal integralGlobal)
{
return toAjax(integralGlobalService.insertIntegralGlobal(integralGlobal));
}
/**
*
*/
@RequiresPermissions("system:globalIntegral:edit")
@Log(title = "奖励积分", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody IntegralGlobal integralGlobal)
{
return toAjax(integralGlobalService.updateIntegralGlobal(integralGlobal));
}
/**
*
*/
@RequiresPermissions("system:globalIntegral:remove")
@Log(title = "奖励积分", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(integralGlobalService.deleteIntegralGlobalByIds(ids));
}
}

@ -0,0 +1,62 @@
package com.flossom.system.service;
import com.flossom.hzMapper.domain.IntegralGlobal;
import java.util.List;
/**
* Service
*
* @author flossom
* @date 2023-12-11
*/
public interface IIntegralGlobalService
{
/**
*
*
* @param id
* @return
*/
public IntegralGlobal selectIntegralGlobalById(Long id);
/**
*
*
* @param integralGlobal
* @return
*/
public List<IntegralGlobal> selectIntegralGlobalList(IntegralGlobal integralGlobal);
/**
*
*
* @param integralGlobal
* @return
*/
public int insertIntegralGlobal(IntegralGlobal integralGlobal);
/**
*
*
* @param integralGlobal
* @return
*/
public int updateIntegralGlobal(IntegralGlobal integralGlobal);
/**
*
*
* @param ids
* @return
*/
public int deleteIntegralGlobalByIds(Long[] ids);
/**
*
*
* @param id
* @return
*/
public int deleteIntegralGlobalById(Long id);
}

@ -0,0 +1,101 @@
package com.flossom.system.service.impl;
import java.util.List;
import com.flossom.common.core.utils.DateUtils;
import com.flossom.common.security.utils.SecurityUtils;
import com.flossom.hzMapper.domain.IntegralGlobal;
import com.flossom.hzMapper.mapper.IntegralGlobalMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.flossom.system.service.IIntegralGlobalService;
/**
* Service
*
* @author flossom
* @date 2023-12-11
*/
@Service
public class IntegralGlobalServiceImpl implements IIntegralGlobalService
{
@Autowired
private IntegralGlobalMapper integralGlobalMapper;
/**
*
*
* @param id
* @return
*/
@Override
public IntegralGlobal selectIntegralGlobalById(Long id)
{
return integralGlobalMapper.selectIntegralGlobalById(id);
}
/**
*
*
* @param integralGlobal
* @return
*/
@Override
public List<IntegralGlobal> selectIntegralGlobalList(IntegralGlobal integralGlobal)
{
return integralGlobalMapper.selectIntegralGlobalList(integralGlobal);
}
/**
*
*
* @param integralGlobal
* @return
*/
@Override
public int insertIntegralGlobal(IntegralGlobal integralGlobal)
{
integralGlobal.setCreateBy(SecurityUtils.getLoginUser().getUsername());
integralGlobal.setCreateTime(DateUtils.getNowDate());
return integralGlobalMapper.insertIntegralGlobal(integralGlobal);
}
/**
*
*
* @param integralGlobal
* @return
*/
@Override
public int updateIntegralGlobal(IntegralGlobal integralGlobal)
{
integralGlobal.setUpdateBy(SecurityUtils.getLoginUser().getUsername());
integralGlobal.setUpdateTime(DateUtils.getNowDate());
integralGlobal.setUpdateTime(DateUtils.getNowDate());
return integralGlobalMapper.updateIntegralGlobal(integralGlobal);
}
/**
*
*
* @param ids
* @return
*/
@Override
public int deleteIntegralGlobalByIds(Long[] ids)
{
return integralGlobalMapper.deleteIntegralGlobalByIds(ids);
}
/**
*
*
* @param id
* @return
*/
@Override
public int deleteIntegralGlobalById(Long id)
{
return integralGlobalMapper.deleteIntegralGlobalById(id);
}
}

@ -0,0 +1,44 @@
import request from '@/utils/request'
// 查询积分奖励列表
export function listGlobal(query) {
return request({
url: '/system/globalIntegral/list',
method: 'get',
params: query
})
}
// 查询积分奖励详细
export function getGlobal(id) {
return request({
url: '/system/globalIntegral/' + id,
method: 'get'
})
}
// 新增积分奖励
export function addGlobal(data) {
return request({
url: '/system/globalIntegral',
method: 'post',
data: data
})
}
// 修改积分奖励
export function updateGlobal(data) {
return request({
url: '/system/globalIntegral',
method: 'put',
data: data
})
}
// 删除积分奖励
export function delGlobal(id) {
return request({
url: '/system/globalIntegral/' + id,
method: 'delete'
})
}

@ -0,0 +1,259 @@
<template>
<div class="app-container">
<!-- <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">-->
<!-- <el-form-item label="初始奖励积分" prop="integral">-->
<!-- <el-input-->
<!-- v-model="queryParams.integral"-->
<!-- placeholder="请输入初始奖励积分"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<!-- <el-form-item>-->
<!-- <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>-->
<!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- <el-row :gutter="10" class="mb8">-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="primary"-->
<!-- plain-->
<!-- icon="el-icon-plus"-->
<!-- size="mini"-->
<!-- @click="handleAdd"-->
<!-- v-hasPermi="['system:globalIntegral:add']"-->
<!-- >新增</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="success"-->
<!-- plain-->
<!-- icon="el-icon-edit"-->
<!-- size="mini"-->
<!-- :disabled="single"-->
<!-- @click="handleUpdate"-->
<!-- v-hasPermi="['system:globalIntegral:edit']"-->
<!-- >修改</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="danger"-->
<!-- plain-->
<!-- icon="el-icon-delete"-->
<!-- size="mini"-->
<!-- :disabled="multiple"-->
<!-- @click="handleDelete"-->
<!-- v-hasPermi="['system:globalIntegral:remove']"-->
<!-- >删除</el-button>-->
<!-- </el-col>-->
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="warning"-->
<!-- plain-->
<!-- icon="el-icon-download"-->
<!-- size="mini"-->
<!-- @click="handleExport"-->
<!-- v-hasPermi="['system:globalIntegral:export']"-->
<!-- >导出</el-button>-->
<!-- </el-col>-->
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
<!-- </el-row>-->
<!-- <el-table v-loading="loading" :data="globalList" @selection-change="handleSelectionChange">-->
<!-- <el-table-column type="selection" width="55" align="center" />-->
<!-- <el-table-column label="主键" align="center" prop="id" />-->
<!-- <el-table-column label="初始奖励积分" align="center" prop="integral" />-->
<!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width">-->
<!-- <template slot-scope="scope">-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['system:globalIntegral:edit']"-->
<!-- >修改</el-button>-->
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-delete"-->
<!-- @click="handleDelete(scope.row)"-->
<!-- v-hasPermi="['system:globalIntegral:remove']"-->
<!-- >删除</el-button>-->
<!-- </template>-->
<!-- </el-table-column>-->
<!-- </el-table>-->
<!-- <pagination-->
<!-- v-show="total>0"-->
<!-- :total="total"-->
<!-- :page.sync="queryParams.pageNum"-->
<!-- :limit.sync="queryParams.pageSize"-->
<!-- @pagination="getList"-->
<!-- />-->
<!-- <el-form ref="form" :model="form" :rules="rules" label-width="80px">-->
<!-- <el-form-item label="初始奖励积分" prop="integral">-->
<!-- <el-input v-model="form.integral" placeholder="请输入初始奖励积分" />-->
<!-- </el-form-item>-->
<!-- </el-form>-->
<!-- <div slot="footer" class="dialog-footer">-->
<!-- <el-button type="primary" @click="submitForm"> </el-button>-->
<!-- <el-button @click="cancel"> </el-button>-->
<!-- </div>-->
<!-- 添加或修改积分奖励对话框 -->
<el-form ref="form" :model="form" :rules="rules" label-width="150px">
<el-form-item label="完善资料-初始积分" prop="integral">
<el-input v-model="form.integral" placeholder="请输入初始奖励积分" style="width: 75%;"/>
</el-form-item>
</el-form>
<div style="margin-left: 70%" >
<el-button type="primary" @click="submitForm"> </el-button>
</div>
</div>
</template>
<script>
import { listGlobal, getGlobal, delGlobal, addGlobal, updateGlobal } from "@/api/system/globalIntegral";
export default {
name: "Global",
data() {
return {
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
//
globalList: [],
//
title: "",
//
open: false,
//
queryParams: {
pageNum: 1,
pageSize: 10,
integral: null,
},
//
form: {},
//
rules: {
integral: [
{ required: true, message: '请输入奖励积分', trigger: 'blur' },
{ min: 1, max: 5, message: '长度在 1 到 5 个字符', trigger: 'blur' }
],
}
};
},
created() {
this.getList();
},
methods: {
/** 查询积分奖励列表 */
getList() {
this.loading = true;
listGlobal(this.queryParams).then(response => {
// this.globalList = response.rows;
// this.total = response.total;
this.form = response.rows.length >0 ? response.rows[0]: {};
this.loading = false;
});
},
//
cancel() {
this.open = false;
this.reset();
},
//
reset() {
this.form = {
id: null,
integral: null,
createTime: null,
createBy: null,
updateBy: null,
updateTime: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加积分奖励";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getGlobal(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改积分奖励";
});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateGlobal(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addGlobal(this.form).then(response => {
this.$modal.msgSuccess("设置成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$modal.confirm('是否确认删除积分奖励编号为"' + ids + '"的数据项?').then(function() {
return delGlobal(ids);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/global/export', {
...this.queryParams
}, `global_${new Date().getTime()}.xlsx`)
}
}
};
</script>
Loading…
Cancel
Save