Selaa lähdekoodia

'代码生成'

master
dongyuangong 4 vuotta sitten
vanhempi
commit
1ce1b8cfa7
11 muutettua tiedostoa jossa 21 lisäystä ja 341 poistoa
  1. +0
    -51
      src/main/java/com/taauav/admin/controller/TauvWaterAlarmController.java
  2. +0
    -90
      src/main/java/com/taauav/admin/entity/TauvWaterAlarm.java
  3. +0
    -7
      src/main/java/com/taauav/admin/mapper/TauvWaterAlarmMapper.java
  4. +0
    -29
      src/main/java/com/taauav/admin/service/ITauvWaterAlarmService.java
  5. +0
    -97
      src/main/java/com/taauav/admin/service/impl/TauvWaterAlarmServiceImpl.java
  6. +0
    -20
      src/main/java/com/taauav/admin/vo/TauvWaterAlarmVo.java
  7. +4
    -22
      src/main/java/com/taauav/tool/mapper/GenTableColumnMapper.xml
  8. +6
    -4
      src/main/java/com/taauav/tool/mapper/GenTableMapper.xml
  9. +1
    -13
      src/main/java/com/taauav/tool/service/GenTableServiceImpl.java
  10. +9
    -7
      src/main/java/com/taauav/tool/util/VelocityUtils.java
  11. +1
    -1
      src/main/resources/vm/java/entity.java.vm

+ 0
- 51
src/main/java/com/taauav/admin/controller/TauvWaterAlarmController.java Näytä tiedosto

@@ -1,51 +0,0 @@
package com.taauav.admin.controller;

import com.taauav.admin.query.TauvWaterAlarmQuery;
import com.taauav.admin.service.ITauvWaterAlarmService;
import com.taauav.admin.vo.TauvWaterAlarmVo;
import com.taauav.common.bean.Response;
import com.taauav.common.constant.PermissionConstants;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
* 水质超标信息 控制器
*
* @author daixiantong
* @date 2020-05-14
*/
@RestController
@RequestMapping("/admin/waterAlarm")
public class TauvWaterAlarmController extends BaseController{
private static final String controllerName = "/admin/waterAlarm";
@Autowired
private ITauvWaterAlarmService waterAlarmService;
@Resource
private Response response;

/**
* 水质超标报警列表
* @param waterAlarmQuery
* @return
*/
@GetMapping("/index")
@RequiresPermissions(controllerName + ":" + PermissionConstants.LIST_PERMISSION)
public Response index(TauvWaterAlarmQuery waterAlarmQuery) {
return waterAlarmService.selectPageList(waterAlarmQuery);
}

@GetMapping("/detail")
@RequiresPermissions(controllerName + ":" + PermissionConstants.VIEW_PERMISSION)
public Response getDetail(Integer id) {
if (id == null || id <= 0) {
return response.failure("id不能为空");
}
TauvWaterAlarmVo waterAlarmVo = waterAlarmService.getDetail(id);
return response.success(waterAlarmVo);
}
}

+ 0
- 90
src/main/java/com/taauav/admin/entity/TauvWaterAlarm.java Näytä tiedosto

@@ -1,90 +0,0 @@
package com.taauav.admin.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.taauav.common.domain.Entity;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigInteger;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
* 水质报警 实体类
*
* @author daixiantong
* @date 2020-05-14
*/
@Data
public class TauvWaterAlarm extends Entity {

/**
* 巡检河道id
*/
private Integer inspectDriverId;

/**
* 报警编号
*/
private String alarmSn;

/**
* 区属id
*/
private BigInteger driverArea;

/**
* 河湖id
*/
private Integer driverId;

/**
* 河湖名称
*/
private String driverName;

/**
* 巡检日期
*/
@DateTimeFormat(pattern = "yyyy-MM-dd")
@JsonFormat(pattern = "yyyy-MM-dd")
private Date inspectTime;

/**
* 水质标准
*/
private Integer alarmStandard;

/**
* 超标信息
*/
private String alarmInfo;

/**
* 报警时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date alarmTime;

/**
* 状态描述
*/
@TableField(exist = false)
private String statusText;

/**
* 状态数组
*/
public Map<String, String> statusList() {
Map<String, String> map = new HashMap<>();
map.put("1", "未报警");
map.put("2", "已报警");
map.put("3", "已取消");
map.put("4", "处理中");
map.put("5", "处理完成");
return map;
}
}

+ 0
- 7
src/main/java/com/taauav/admin/mapper/TauvWaterAlarmMapper.java Näytä tiedosto

@@ -1,7 +0,0 @@
package com.taauav.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.taauav.admin.entity.TauvWaterAlarm;

public interface TauvWaterAlarmMapper extends BaseMapper<TauvWaterAlarm> {
}

+ 0
- 29
src/main/java/com/taauav/admin/service/ITauvWaterAlarmService.java Näytä tiedosto

@@ -1,29 +0,0 @@
package com.taauav.admin.service;

import com.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.query.TauvWaterAlarmQuery;
import com.taauav.admin.vo.TauvWaterAlarmVo;
import com.taauav.common.bean.Response;
import com.taauav.common.service.IBaseService;

/**
* 水质超标报警服务类
*
* @author daixiantong
* @date 2020-05-14
*/
public interface ITauvWaterAlarmService extends IBaseService<TauvWaterAlarm> {
/**
* 自定义分页
* @param waterAlarmQuery
* @return
*/
Response selectPageList(TauvWaterAlarmQuery waterAlarmQuery);

/**
* 获取详情数据
* @param id
* @return
*/
TauvWaterAlarmVo getDetail(Integer id);
}

+ 0
- 97
src/main/java/com/taauav/admin/service/impl/TauvWaterAlarmServiceImpl.java Näytä tiedosto

@@ -1,97 +0,0 @@
package com.taauav.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.entity.TauvWaterAlarmInfo;
import com.taauav.admin.mapper.TauvWaterAlarmInfoMapper;
import com.taauav.admin.mapper.TauvWaterAlarmMapper;
import com.taauav.admin.query.TauvWaterAlarmQuery;
import com.taauav.admin.service.ITauvWaterAlarmService;
import com.taauav.admin.vo.TauvWaterAlarmVo;
import com.taauav.common.bean.Response;
import com.taauav.common.service.impl.BaseServiceImpl;
import com.taauav.common.util.FunctionUtils;
import com.taauav.common.util.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigInteger;
import java.util.List;

/**
* 水质超标报警服务类
*
* @author daixiantong
* @date 2020-05-14
*/
@Service
public class TauvWaterAlarmServiceImpl extends BaseServiceImpl<TauvWaterAlarmMapper, TauvWaterAlarm> implements ITauvWaterAlarmService {
@Resource
private Response response;
@Autowired
private TauvWaterAlarmInfoMapper waterAlarmInfoMapper;

/**
* 自定义分页
* @param waterAlarmQuery
* @return
*/
@Override
public Response selectPageList(TauvWaterAlarmQuery waterAlarmQuery) {
IPage<TauvWaterAlarm> page = new Page<>(waterAlarmQuery.getPage(), waterAlarmQuery.getPageSize());
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("mark", 1);
if (StringUtils.isNotEmpty(waterAlarmQuery.getAlarmSn())) {
wrapper.like("alarm_sn", waterAlarmQuery.getAlarmSn());
}
if (StringUtils.isNotEmpty(waterAlarmQuery.getDriverName())) {
wrapper.like("driver_name", waterAlarmQuery.getDriverName());
}
if (StringUtils.isNotNull(waterAlarmQuery.getDriverArea()) && waterAlarmQuery.getDriverArea().compareTo(BigInteger.ZERO) > 0) {
wrapper.eq("driver_area", waterAlarmQuery.getDriverArea());
}
if (StringUtils.isNotNull(waterAlarmQuery.getStatus()) && waterAlarmQuery.getStatus() > 0) {
wrapper.eq("status", waterAlarmQuery.getStatus());
}
if (waterAlarmQuery.getStartTime() != null && waterAlarmQuery.getEndTime() != null) {
String beginTime = waterAlarmQuery.getStartTime().toString();
String endTime = waterAlarmQuery.getEndTime().toString();
if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
wrapper.between("alarm_time", beginTime + " 00:00:00", endTime + " 23:59:59");
}
}
IPage<TauvWaterAlarm> list = baseMapper.selectPage(page, wrapper);
if (list.getRecords().size() > 0) {
for (TauvWaterAlarm data : list.getRecords()) {
data.setStatusText(FunctionUtils.getArrayText(data.getStatus().toString(), data.statusList()));
}
}
return response.success(list);
}

/**
* 获取详情数据
* @param id
* @return
*/
@Override
public TauvWaterAlarmVo getDetail(Integer id) {
TauvWaterAlarm waterAlarm = getInfo(id);
if (waterAlarm != null) {
waterAlarm.setStatusText(FunctionUtils.getArrayText(waterAlarm.getStatus().toString(), waterAlarm.statusList()));
}
QueryWrapper wrapper = new QueryWrapper();
wrapper.eq("mark", 1);
wrapper.eq("water_alarm_id", id);
wrapper.orderByAsc("id");
List<TauvWaterAlarmInfo> infoList = waterAlarmInfoMapper.selectList(wrapper);
TauvWaterAlarmVo waterAlarmVo = new TauvWaterAlarmVo();
BeanUtils.copyProperties(waterAlarm, waterAlarmVo, TauvWaterAlarmVo.class);
waterAlarmVo.setInfoList(infoList);
return waterAlarmVo;
}
}

+ 0
- 20
src/main/java/com/taauav/admin/vo/TauvWaterAlarmVo.java Näytä tiedosto

@@ -1,20 +0,0 @@
package com.taauav.admin.vo;

import com.taauav.admin.entity.TauvWaterAlarm;
import com.taauav.admin.entity.TauvWaterAlarmInfo;
import lombok.Data;

import java.util.List;

/**
* @author daixiantong
* @date 2020-05-14
*/
@Data
public class TauvWaterAlarmVo extends TauvWaterAlarm {

/**
* 超标详情数组
*/
private List<TauvWaterAlarmInfo> infoList;
}

+ 4
- 22
src/main/java/com/taauav/tool/mapper/GenTableColumnMapper.xml Näytä tiedosto

@@ -22,10 +22,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" />
<result property="sort" column="sort" />
<result property="createUser" column="create_by" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_by" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>

<select id="selectDbTableColumnsByName" parameterType="java.lang.String" resultMap="GenTableColumnResult">
@@ -36,26 +37,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"



<update id="updateGenTableColumn" parameterType="com.taauav.tool.entity.GenTableColumn">
update gen_table_column
<set>
column_comment = #{columnComment},
java_type = #{javaType},
java_field = #{javaField},
is_insert = #{isInsert},
is_edit = #{isEdit},
is_list = #{isList},
is_query = #{isQuery},
is_required = #{isRequired},
query_type = #{queryType},
html_type = #{htmlType},
dict_type = #{dictType},
sort = #{sort},
update_by = #{updateBy},
update_time = sysdate()
</set>
where id = #{id}
</update>


<delete id="deleteGenTableColumnByIds" parameterType="java.lang.Long">
delete from gen_table_column where table_id in

+ 6
- 4
src/main/java/com/taauav/tool/mapper/GenTableMapper.xml Näytä tiedosto

@@ -16,11 +16,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="functionAuthor" column="function_author" />
<result property="webDir" column="web_dir" />
<result property="options" column="options" />
<result property="createUser" column="create_by" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_by" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="remark" column="remark" />
<result property="mark" column="mark" />
<collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult" />
</resultMap>

@@ -42,10 +43,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="htmlType" column="html_type" />
<result property="dictType" column="dict_type" />
<result property="sort" column="sort" />
<result property="createUser" column="create_by" />
<result property="createUser" column="create_user" />
<result property="createTime" column="create_time" />
<result property="updateUser" column="update_by" />
<result property="updateUser" column="update_user" />
<result property="updateTime" column="update_time" />
<result property="mark" column="mark" />
</resultMap>
<sql id="selectGenTableVo">
select id, table_name, table_comment, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, options, create_by, create_time, update_by, update_time, remark from gen_table

+ 1
- 13
src/main/java/com/taauav/tool/service/GenTableServiceImpl.java Näytä tiedosto

@@ -39,8 +39,7 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
//查询列信息
List<GenTableColumn> colums = table.getColumns();
setPkColumn(table, colums);
//过滤不需要生成的字段
setIgnoreColumn(table, colums);

VelocityInitializer.initVelocity();
VelocityContext context = VelocityUtils.prepareContext(table);
//获取模板列表
@@ -123,15 +122,4 @@ public class GenTableServiceImpl extends BaseServiceImpl<GenTableMapper, GenTabl
}
}

public void setIgnoreColumn(GenTable genTable, List<GenTableColumn> columns) {
for (GenTableColumn column : columns) {
if (column.getColumnName().equals("status") || column.getColumnName().equals("create_user") ||
column.getColumnName().equals("create_time") || column.getColumnName().equals("update_user") ||
column.getColumnName().equals("update_time") || column.getColumnName().equals("mark")) {
genTable.setIgnore(true);
} else {
genTable.setIgnore(false);
}
}
}
}

+ 9
- 7
src/main/java/com/taauav/tool/util/VelocityUtils.java Näytä tiedosto

@@ -26,15 +26,17 @@ public class VelocityUtils
String funcationName = genTable.getFunctionName();

List<GenTableColumn> columnList = genTable.getColumns();
List<GenTableColumn> needColumnList = new ArrayList<>();
for (int i=0; i < columnList.size(); i++) {
GenTableColumn column = columnList.get(i);
if (null == column) {
String columnName = column.getColumnName();

if (columnName.equals("status") || columnName.equals("create_user") ||
columnName.equals("create_time") || columnName.equals("update_user") ||
columnName.equals("update_time") || columnName.equals("mark")) {
continue;
}
if (column.getColumnName().equals("status") || column.getColumnName().equals("create_user") ||
column.getColumnName().equals("create_time") || column.getColumnName().equals("update_user") ||
column.getColumnName().equals("update_time") || column.getColumnName().equals("mark")) {
columnList.remove(i);
} else {
needColumnList.add(column);
}
}

@@ -52,7 +54,7 @@ public class VelocityUtils
velocityContext.put("pkColumn", genTable.getPkColumn());
velocityContext.put("importList", getImportList(genTable.getColumns()));
velocityContext.put("permissionPrefix", getPermissionPrefix(moduleName,businessName));
velocityContext.put("columns", columnList);
velocityContext.put("columns", needColumnList);
velocityContext.put("table", genTable);
return velocityContext;
}

+ 1
- 1
src/main/resources/vm/java/entity.java.vm Näytä tiedosto

@@ -22,7 +22,7 @@ public class ${ClassName} extends Entity {
private static final long serialVersionUID = 1L;

#foreach ($column in $columns)
#if(!$table.isSuperColumn($column.javaField) || $column.getIgnore)
#if(!$table.isSuperColumn($column.javaField))
/** $column.columnComment */
private $column.javaType $column.javaField;
#end

Loading…
Peruuta
Tallenna