# Conflicts:
#	src/main/resources/generatorConfig.xml
main
@t2652009480 8 months ago
commit 7bfa2902a7

@ -286,7 +286,7 @@
<dependency> <dependency>
<groupId>com.alibaba</groupId> <groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId> <artifactId>easyexcel</artifactId>
<version>3.2.1</version> <version>4.0.1</version>
<exclusions> <exclusions>
<exclusion> <exclusion>
@ -309,6 +309,8 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
@ -354,6 +356,13 @@
<version>4.9.3</version> <!-- 使用最新版本 --> <version>4.9.3</version> <!-- 使用最新版本 -->
</dependency> </dependency>
<!-- ip地址-->
<dependency>
<groupId>org.lionsoul</groupId>
<artifactId>ip2region</artifactId>
<version>2.6.5</version>
</dependency>
</dependencies> </dependencies>

@ -0,0 +1,140 @@
package com.sztzjy.trade.controller.tch;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.sztzjy.trade.annotation.AnonymousAccess;
import com.sztzjy.trade.entity.dto.LoginLogDTO;
import com.sztzjy.trade.entity.dto.RestPassWordDTO;
import com.sztzjy.trade.service.TchLoginLogAndStuListService;
import com.sztzjy.trade.util.ResultEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.Date;
/**
* @author 17803
* @date 2024-08-06 10:46
*/
@RequestMapping("api/tch/loginLogAndStuList")
@RestController
@Api(tags = "教学管理(登录日志和学生列表)")
public class TchLoginLogAndStuListController {
@Autowired
private TchLoginLogAndStuListService tchLoginLogAndStuListService;
//登录和登出调用,数据更新操作,从新计算登录时长,累计登录时长,累计登录天数,是否在线
@ApiOperation("登录/退出统计")
@PostMapping("/loginLog")
@AnonymousAccess
public ResultEntity loginLog(@RequestBody LoginLogDTO loginLogDTO, HttpServletRequest request) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.loginLog(loginLogDTO, request);
}
@ApiOperation("查询登录日志")
@GetMapping("/loginLogBySchoolId")
@AnonymousAccess
public ResultEntity loginLogBySchoolId(@ApiParam("学校ID") String schoolId
, @ApiParam("当前页") Integer page,
@ApiParam("每页展示条数") Integer size) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.loginLogBySchoolId(schoolId, page, size);
}
@ApiOperation("班级下拉框")
@GetMapping("/getClassList")
@AnonymousAccess
public ResultEntity getClassList(@ApiParam("学校ID") String schoolId) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.getClassList(schoolId);
}
@ApiOperation("登录日志条件查询")
@GetMapping("/queryCondition ")
@AnonymousAccess
public ResultEntity queryCondition(@ApiParam("用户名") @RequestParam(required = false) String name,
@ApiParam("所属班级ID") @RequestParam(required = false) String classID,
@ApiParam("开始时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
@ApiParam("结束时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
@ApiParam("当前页") Integer page,
@ApiParam("每页展示条数") Integer size,
@ApiParam("学校ID") String schoolId) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.queryCondition(name, classID, startTime, endTime, page, size, schoolId);
}
@ApiOperation("日志导出")
@GetMapping("/exportExcel")
@AnonymousAccess
public void exportExcel(
@ApiParam("开始时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date startTime,
@ApiParam("结束时间") @RequestParam(required = false) @DateTimeFormat(pattern = "yyyy-MM-dd") Date endTime,
@ApiParam("学校ID") String schoolId, HttpServletResponse response) {
//"yyyy-MM-dd HH:mm:ss"
tchLoginLogAndStuListService.exportExcel(startTime, endTime, schoolId, response);
}
@ApiOperation("学生列表")
@GetMapping("/getStuListInfo")
@AnonymousAccess
public ResultEntity getStuListInfo(@ApiParam("学校ID") String schoolId,
@ApiParam("当前页") Integer page,
@ApiParam("每页展示条数") Integer size) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.getStuListInfo(schoolId, page, size);
}
@ApiOperation("学生列表删除用户")
@PostMapping("/delStuInfo")
@AnonymousAccess
public ResultEntity delStuInfo(String userId) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.delStuInfo(userId);
}
@ApiOperation("学生列表重置密码")
@PostMapping("/restPwd")
@AnonymousAccess
public ResultEntity restPwd(@RequestBody @Valid RestPassWordDTO restPassWord) {
//"yyyy-MM-dd HH:mm:ss"
return tchLoginLogAndStuListService.restPwd(restPassWord);
}
}

@ -1,6 +1,7 @@
package com.sztzjy.trade.entity; package com.sztzjy.trade.entity;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
/** /**
@ -99,6 +100,15 @@ public class StuUser {
@ApiModelProperty("综合得分(学校)(乘完权重后)") @ApiModelProperty("综合得分(学校)(乘完权重后)")
private BigDecimal totalScore; private BigDecimal totalScore;
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("0:未删除 1:已删除")
private Integer delState;
@ApiModelProperty("更新时间")
private Date updateTime;
public String getUserId() { public String getUserId() {
return userId; return userId;
} }
@ -338,4 +348,28 @@ public class StuUser {
public void setTotalScore(BigDecimal totalScore) { public void setTotalScore(BigDecimal totalScore) {
this.totalScore = totalScore; this.totalScore = totalScore;
} }
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public Integer getDelState() {
return delState;
}
public void setDelState(Integer delState) {
this.delState = delState;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
} }

@ -2,6 +2,7 @@ package com.sztzjy.trade.entity;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
public class StuUserExample { public class StuUserExample {
@ -1994,6 +1995,186 @@ public class StuUserExample {
addCriterion("total_score not between", value1, value2, "totalScore"); addCriterion("total_score not between", value1, value2, "totalScore");
return (Criteria) this; return (Criteria) this;
} }
public Criteria andCreateTimeIsNull() {
addCriterion("create_time is null");
return (Criteria) this;
}
public Criteria andCreateTimeIsNotNull() {
addCriterion("create_time is not null");
return (Criteria) this;
}
public Criteria andCreateTimeEqualTo(Date value) {
addCriterion("create_time =", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotEqualTo(Date value) {
addCriterion("create_time <>", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThan(Date value) {
addCriterion("create_time >", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("create_time >=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThan(Date value) {
addCriterion("create_time <", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeLessThanOrEqualTo(Date value) {
addCriterion("create_time <=", value, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeIn(List<Date> values) {
addCriterion("create_time in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotIn(List<Date> values) {
addCriterion("create_time not in", values, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeBetween(Date value1, Date value2) {
addCriterion("create_time between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andCreateTimeNotBetween(Date value1, Date value2) {
addCriterion("create_time not between", value1, value2, "createTime");
return (Criteria) this;
}
public Criteria andDelStateIsNull() {
addCriterion("del_state is null");
return (Criteria) this;
}
public Criteria andDelStateIsNotNull() {
addCriterion("del_state is not null");
return (Criteria) this;
}
public Criteria andDelStateEqualTo(Integer value) {
addCriterion("del_state =", value, "delState");
return (Criteria) this;
}
public Criteria andDelStateNotEqualTo(Integer value) {
addCriterion("del_state <>", value, "delState");
return (Criteria) this;
}
public Criteria andDelStateGreaterThan(Integer value) {
addCriterion("del_state >", value, "delState");
return (Criteria) this;
}
public Criteria andDelStateGreaterThanOrEqualTo(Integer value) {
addCriterion("del_state >=", value, "delState");
return (Criteria) this;
}
public Criteria andDelStateLessThan(Integer value) {
addCriterion("del_state <", value, "delState");
return (Criteria) this;
}
public Criteria andDelStateLessThanOrEqualTo(Integer value) {
addCriterion("del_state <=", value, "delState");
return (Criteria) this;
}
public Criteria andDelStateIn(List<Integer> values) {
addCriterion("del_state in", values, "delState");
return (Criteria) this;
}
public Criteria andDelStateNotIn(List<Integer> values) {
addCriterion("del_state not in", values, "delState");
return (Criteria) this;
}
public Criteria andDelStateBetween(Integer value1, Integer value2) {
addCriterion("del_state between", value1, value2, "delState");
return (Criteria) this;
}
public Criteria andDelStateNotBetween(Integer value1, Integer value2) {
addCriterion("del_state not between", value1, value2, "delState");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNull() {
addCriterion("update_time is null");
return (Criteria) this;
}
public Criteria andUpdateTimeIsNotNull() {
addCriterion("update_time is not null");
return (Criteria) this;
}
public Criteria andUpdateTimeEqualTo(Date value) {
addCriterion("update_time =", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotEqualTo(Date value) {
addCriterion("update_time <>", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThan(Date value) {
addCriterion("update_time >", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeGreaterThanOrEqualTo(Date value) {
addCriterion("update_time >=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThan(Date value) {
addCriterion("update_time <", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeLessThanOrEqualTo(Date value) {
addCriterion("update_time <=", value, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeIn(List<Date> values) {
addCriterion("update_time in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotIn(List<Date> values) {
addCriterion("update_time not in", values, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeBetween(Date value1, Date value2) {
addCriterion("update_time between", value1, value2, "updateTime");
return (Criteria) this;
}
public Criteria andUpdateTimeNotBetween(Date value1, Date value2) {
addCriterion("update_time not between", value1, value2, "updateTime");
return (Criteria) this;
}
} }
public static class Criteria extends GeneratedCriteria { public static class Criteria extends GeneratedCriteria {

@ -0,0 +1,174 @@
package com.sztzjy.trade.entity;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import org.springframework.format.annotation.DateTimeFormat;
/**
*
* @author whb
* tch_login_log
*/
@Builder
public class TchLoginLog {
@ApiModelProperty("id")
private Integer id;
@ApiModelProperty("学号")
private String studentId;
@ApiModelProperty("姓名")
private String name;
@ApiModelProperty("登入时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date loginTimeLast;
@ApiModelProperty("登出时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
private Date exitTimeLast;
@ApiModelProperty("登录时长")
private Long loginDuration;
@ApiModelProperty("是否在线(0离线1在线)")
private Byte online;
@ApiModelProperty("登录IP")
private String loginIp;
@ApiModelProperty("IP归属地")
private String ipOwnerLocation;
@ApiModelProperty("累计登录时长")
private Long totalLoginDuration;
@ApiModelProperty("累计登录天数")
private Integer totalLoginDays;
@ApiModelProperty("班级ID")
private String classId;
@ApiModelProperty("用户ID")
private String userId;
@ApiModelProperty("学校ID")
private String schoolId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getStudentId() {
return studentId;
}
public void setStudentId(String studentId) {
this.studentId = studentId == null ? null : studentId.trim();
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name == null ? null : name.trim();
}
public Date getLoginTimeLast() {
return loginTimeLast;
}
public void setLoginTimeLast(Date loginTimeLast) {
this.loginTimeLast = loginTimeLast;
}
public Date getExitTimeLast() {
return exitTimeLast;
}
public void setExitTimeLast(Date exitTimeLast) {
this.exitTimeLast = exitTimeLast;
}
public Long getLoginDuration() {
return loginDuration;
}
public void setLoginDuration(Long loginDuration) {
this.loginDuration = loginDuration;
}
public Byte getOnline() {
return online;
}
public void setOnline(Byte online) {
this.online = online;
}
public String getLoginIp() {
return loginIp;
}
public void setLoginIp(String loginIp) {
this.loginIp = loginIp == null ? null : loginIp.trim();
}
public String getIpOwnerLocation() {
return ipOwnerLocation;
}
public void setIpOwnerLocation(String ipOwnerLocation) {
this.ipOwnerLocation = ipOwnerLocation == null ? null : ipOwnerLocation.trim();
}
public Long getTotalLoginDuration() {
return totalLoginDuration;
}
public void setTotalLoginDuration(Long totalLoginDuration) {
this.totalLoginDuration = totalLoginDuration;
}
public Integer getTotalLoginDays() {
return totalLoginDays;
}
public void setTotalLoginDays(Integer totalLoginDays) {
this.totalLoginDays = totalLoginDays;
}
public String getClassId() {
return classId;
}
public void setClassId(String classId) {
this.classId = classId == null ? null : classId.trim();
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId == null ? null : userId.trim();
}
public String getSchoolId() {
return schoolId;
}
public void setSchoolId(String schoolId) {
this.schoolId = schoolId == null ? null : schoolId.trim();
}
}

@ -0,0 +1,43 @@
package com.sztzjy.trade.entity.dto;/**
* @author 17803
* @date 2024-08-06 11:05
*/
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class LoginLogDTO {
@ApiModelProperty("登入时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
Date loginTimeLast;
@ApiModelProperty("登出时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
Date exitTimeLast;
@ApiModelProperty("学校ID")
private String schoolId;
@ApiModelProperty("用户ID")
private String userId;
@ApiModelProperty("班级ID")
private String classId;
@ApiModelProperty("学号")
private String studentId;
@ApiModelProperty("姓名")
private String name;
}

@ -0,0 +1,31 @@
package com.sztzjy.trade.entity.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* @author 17803
* @date 2024-08-06 16:08
*/
@Data
@ApiModel(description="重置密码参数")
public class RestPassWordDTO {
@ApiModelProperty("用户ID")
@NotNull
private String userId;
@ApiModelProperty("第一次输入密码")
@NotNull
private String passwordOne;
@ApiModelProperty("第二次输入密码")
@NotNull
private String passwordTwo;
}

@ -3,10 +3,11 @@ package com.sztzjy.trade.mapper;
import com.sztzjy.trade.entity.StuUser; import com.sztzjy.trade.entity.StuUser;
import com.sztzjy.trade.entity.StuUserExample; import com.sztzjy.trade.entity.StuUserExample;
import java.util.List; import java.util.List;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@Mapper import org.apache.ibatis.annotations.Select;
public interface StuUserMapper { public interface StuUserMapper {
long countByExample(StuUserExample example); long countByExample(StuUserExample example);
@ -57,4 +58,11 @@ public interface StuUserMapper {
* @return * @return
*/ */
List<StuUser> selectStuList(@Param("lists") List<String> lists, String schoolId); List<StuUser> selectStuList(@Param("lists") List<String> lists, String schoolId);
@Select("SELECT class_name, class_id\n" +
"FROM stu_user\n" +
"WHERE school_id = #{schoolId}\n" +
" AND class_name IS NOT NULL\n" +
"GROUP BY class_name, class_id")
List<Map<String, Object>> getClassList(String schoolId);
} }

@ -0,0 +1,30 @@
package com.sztzjy.trade.mapper;
import com.sztzjy.trade.entity.TchLoginLog;
import com.sztzjy.trade.entity.TchLoginLogExample;
import java.util.List;
import org.apache.ibatis.annotations.Param;
public interface TchLoginLogMapper {
long countByExample(TchLoginLogExample example);
int deleteByExample(TchLoginLogExample example);
int deleteByPrimaryKey(Integer id);
int insert(TchLoginLog record);
int insertSelective(TchLoginLog record);
List<TchLoginLog> selectByExample(TchLoginLogExample example);
TchLoginLog selectByPrimaryKey(Integer id);
int updateByExampleSelective(@Param("record") TchLoginLog record, @Param("example") TchLoginLogExample example);
int updateByExample(@Param("record") TchLoginLog record, @Param("example") TchLoginLogExample example);
int updateByPrimaryKeySelective(TchLoginLog record);
int updateByPrimaryKey(TchLoginLog record);
}

@ -0,0 +1,84 @@
package com.sztzjy.trade.service;
import com.sztzjy.trade.entity.dto.LoginLogDTO;
import com.sztzjy.trade.entity.dto.RestPassWordDTO;
import com.sztzjy.trade.util.ResultEntity;
import org.apache.ibatis.annotations.Param;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
* @author 17803
* @date 2024-08-06 11:03
*/
public interface TchLoginLogAndStuListService {
//登录/退出统计
ResultEntity loginLog(LoginLogDTO loginLogDTO, HttpServletRequest request);
/**
*
* @param schoolId
* @return
*/
ResultEntity loginLogBySchoolId(@Param("schoolId") String schoolId,Integer page,Integer size);
/**
*
* @param schoolId
* @return
*/
ResultEntity getClassList(String schoolId);
/**
*
* @param name
* @param classID
* @param startTime
* @param endTime
* @return
*/
ResultEntity queryCondition(@Param("name") String name, @Param("classID") String classID, @Param("startTime") Date startTime, @Param("endTime") Date endTime,Integer page,Integer size,String schoolId);
/**
*
* @param startTime
* @param endTime
* @param schoolId
* @return
*/
void exportExcel(Date startTime, Date endTime, String schoolId, HttpServletResponse response);
/**
*
* @param schoolId
* @param page
* @param size
* @return
*/
ResultEntity getStuListInfo(String schoolId, Integer page, Integer size);
/**
*
* @param userId
* @return
*/
ResultEntity delStuInfo(@Param("userId") String userId);
/**
*
* @param restPassWord
* @return
*/
ResultEntity restPwd(RestPassWordDTO restPassWord);
}

@ -0,0 +1,424 @@
package com.sztzjy.trade.service.impl;/**
* @author 17803
* @date 2024-08-06 11:03
*/
import cn.hutool.core.convert.Convert;
import cn.hutool.core.util.IdUtil;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sztzjy.trade.entity.StuUser;
import com.sztzjy.trade.entity.StuUserExample;
import com.sztzjy.trade.entity.TchLoginLog;
import com.sztzjy.trade.entity.TchLoginLogExample;
import com.sztzjy.trade.entity.dto.LoginLogDTO;
import com.sztzjy.trade.entity.dto.RestPassWordDTO;
import com.sztzjy.trade.mapper.StuUserMapper;
import com.sztzjy.trade.mapper.TchLoginLogMapper;
import com.sztzjy.trade.service.TchLoginLogAndStuListService;
import com.sztzjy.trade.util.ResultEntity;
import com.sztzjy.trade.util.excel.FilePortUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.lionsoul.ip2region.xdb.Searcher;
@Service
@Slf4j
public class TchLoginLogAndStuListServiceImpl implements TchLoginLogAndStuListService {
@Autowired
private TchLoginLogMapper tchLoginLogMapper;
private Searcher searcher;
@Autowired
private StuUserMapper stuUserMapper;
/**
* /退
*
* @param loginLogDTO
* @return
*/
@Override
public ResultEntity loginLog(LoginLogDTO loginLogDTO, HttpServletRequest request) {
if (loginLogDTO == null) {
return new ResultEntity<>(HttpStatus.BAD_REQUEST, "空传参!");
}
// todo 登录IP IP归属地
String ip = request.getRemoteAddr();
String ipAddress = "";
if (StringUtils.isNotBlank(ip)) {
String ipHomePlace = getIpAddress(ip);
if (ipHomePlace != null) {
ipAddress = ipHomePlace;
}
}
//登录时间不为空
if (loginLogDTO.getLoginTimeLast() != null) {
//loginTimeLast 都不为 null 的情况
TchLoginLogExample example = new TchLoginLogExample();
example.createCriteria().andUserIdEqualTo(loginLogDTO.getUserId()).andSchoolIdEqualTo(loginLogDTO.getSchoolId());
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
if (tchLoginLogList.isEmpty()) { //首次登录
TchLoginLog tchLoginLog = TchLoginLog.builder()
.studentId(loginLogDTO.getStudentId())
.name(loginLogDTO.getName())
.loginTimeLast(loginLogDTO.getLoginTimeLast())
.online((byte) 1)
.loginIp(ip)
.ipOwnerLocation(ipAddress)
.totalLoginDuration(0L)
.totalLoginDays(1)
.classId(loginLogDTO.getClassId())
.userId(loginLogDTO.getUserId())
.schoolId(loginLogDTO.getSchoolId())
.build();
tchLoginLogMapper.insertSelective(tchLoginLog);
return new ResultEntity<>(HttpStatus.OK, "success");
} else {
//多次登录
TchLoginLog tchLoginLogOld = tchLoginLogList.get(0);
//累计登录天数 和登录时间判断时间是否为同一天,不相同就是登录+1
//最近一次登录
LocalDateTime localDateTime = Convert.toLocalDateTime(tchLoginLogOld.getLoginTimeLast());
//这一次登录
LocalDateTime newlocalDateTime = Convert.toLocalDateTime(loginLogDTO.getLoginTimeLast());
//判断是否为同一天
if (!localDateTime.equals(newlocalDateTime)) {
tchLoginLogOld.setTotalLoginDays(tchLoginLogOld.getTotalLoginDays() + 1);
}
tchLoginLogOld.setLoginTimeLast(loginLogDTO.getLoginTimeLast());
//在线状态
tchLoginLogOld.setOnline((byte) 1);
tchLoginLogOld.setLoginIp(ip);
tchLoginLogOld.setIpOwnerLocation(ipAddress);
tchLoginLogMapper.updateByPrimaryKey(tchLoginLogOld);
return new ResultEntity<>(HttpStatus.OK, "success");
}
}
//退出时间不为空
if (loginLogDTO.getExitTimeLast() != null) {
TchLoginLogExample example = new TchLoginLogExample();
example.createCriteria().andUserIdEqualTo(loginLogDTO.getUserId()).andSchoolIdEqualTo(loginLogDTO.getSchoolId());
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
if (tchLoginLogList.isEmpty()) { //首次登录
return new ResultEntity(HttpStatus.BAD_REQUEST, "请重新登录!");
} else {
TchLoginLog tchLoginLog = tchLoginLogList.get(0);
tchLoginLog.setExitTimeLast(loginLogDTO.getExitTimeLast());
//根据登录时间计算在线时长
Date loginTimeLast = tchLoginLog.getLoginTimeLast();
//登录时间
long loginTime = loginTimeLast.getTime();
Date exitTimeLast = loginLogDTO.getExitTimeLast();
//退出时长
long exitTime = exitTimeLast.getTime();
//在线时长 转换为秒
long timeInMinutes = (exitTime - loginTime) / 1000;
//在线时长
tchLoginLog.setLoginDuration(timeInMinutes);
//累计登录时长
tchLoginLog.setTotalLoginDuration(tchLoginLog.getTotalLoginDuration() + timeInMinutes);
tchLoginLog.setLoginIp(ip);
tchLoginLog.setIpOwnerLocation(ipAddress);
tchLoginLog.setOnline((byte) 0);
tchLoginLogMapper.updateByPrimaryKeySelective(tchLoginLog);
return new ResultEntity<>(HttpStatus.OK, "success");
}
}
return new ResultEntity(HttpStatus.BAD_REQUEST, "请重新登录!");
}
//分页查询登录日志
@Override
public ResultEntity loginLogBySchoolId(String schoolId, Integer page, Integer size) {
PageHelper.startPage(page, size);
TchLoginLogExample example = new TchLoginLogExample();
example.createCriteria().andSchoolIdEqualTo(schoolId);
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
if (!tchLoginLogList.isEmpty()) {
PageInfo<TchLoginLog> tchLoginLogPageInfo = new PageInfo<>(tchLoginLogList);
return new ResultEntity<>(HttpStatus.OK, tchLoginLogPageInfo);
} else {
return new ResultEntity<>(HttpStatus.OK);
}
}
/**
*
*
* @param schoolId
* @return
*/
@Override
public ResultEntity getClassList(String schoolId) {
// @Select("select DISTINCT class_name form stu_user where school_id=#{schoolId} AND class_name IS not NULL")
// List getClassList(String schoolId);
List nameList = stuUserMapper.getClassList(schoolId);
return new ResultEntity<>(HttpStatus.OK, nameList);
}
/**
*
*
* @param name
* @param classID
* @param startTime
* @param endTime
* @return
*/
@Override
public ResultEntity queryCondition(String name, String classID, Date startTime, Date endTime, Integer page, Integer size, String schoolId) {
PageHelper.startPage(page, size);
TchLoginLogExample example = new TchLoginLogExample();
TchLoginLogExample.Criteria criteria = example.createCriteria();
if (name != null) {
criteria.andNameLike("%" + name + "%");
}
if (classID != null) {
criteria.andClassIdEqualTo("%" + classID + "%");
}
if (startTime != null && endTime != null) {
criteria.andLoginTimeLastBetween(startTime, endTime);
}
criteria.andSchoolIdEqualTo(schoolId);
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
if (tchLoginLogList.isEmpty()) {
return new ResultEntity<>(HttpStatus.OK);
} else {
PageInfo<TchLoginLog> pageInfo = new PageInfo<>(tchLoginLogList);
return new ResultEntity<>(HttpStatus.OK, pageInfo);
}
}
/**
*
* @param startTime
* @param endTime
* @param schoolId
* @return
*/
@Override
public void exportExcel(Date startTime, Date endTime, String schoolId, HttpServletResponse response) {
TchLoginLogExample example = new TchLoginLogExample();
TchLoginLogExample.Criteria criteria = example.createCriteria();
if (startTime != null && endTime != null) {
criteria.andLoginTimeLastBetween(startTime, endTime);
}
criteria.andSchoolIdEqualTo(schoolId);
List<TchLoginLog> tchLoginLogList = tchLoginLogMapper.selectByExample(example);
if (tchLoginLogList.isEmpty()) {
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
String[] headers = {"学号", "姓名", "登入时间","登出时间","登录时长","是否在线(0:离线,1:在线)","登录IP","IP归属地","累计登录时长","累计登录天数"};
try {
FilePortUtil.exportExcel(response, title, headers, null, null);
} catch (Exception e) {
e.printStackTrace();
}
} else {
//导出的表名
String title = IdUtil.simpleUUID();
//表中第一行表头字段
String[] headers = {"学号", "姓名", "登入时间","登出时间","登录时长","是否在线(0:离线,1:在线)","登录IP","IP归属地","累计登录时长","累计登录天数"};
//具体需要写入excel需要哪些字段这些字段取自UserReward类也就是上面的实际数据结果集的泛型
List<String> listColumn = Arrays.asList("studentId", "name", "loginTimeLast",
"exitTimeLast","loginDuration",
"online","loginIp",
"ipOwnerLocation","totalLoginDuration",
"totalLoginDays");
try {
FilePortUtil.exportExcel(response, title, headers, tchLoginLogList, listColumn);
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
*
* @param schoolId
* @param page
* @param size
* @return
*/
@Override
public ResultEntity getStuListInfo(String schoolId, Integer page, Integer size) {
PageHelper.startPage(page,size);
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andSchoolIdEqualTo(schoolId).andDelStateEqualTo(0);
List<StuUser> stuUserList = stuUserMapper.selectByExample(stuUserExample);
if (stuUserList.isEmpty())
{
return new ResultEntity(HttpStatus.OK);
}else {
PageInfo<StuUser> stuUserPageInfo = new PageInfo<>(stuUserList);
return new ResultEntity<>(HttpStatus.OK,stuUserPageInfo);
}
}
/**
*
* @param userId
* @return
*/
@Override
public ResultEntity delStuInfo(String userId) {
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andUserIdEqualTo(userId);
List<StuUser> stuUserList = stuUserMapper.selectByExample(stuUserExample);
if (stuUserList.isEmpty())
{
return new ResultEntity(HttpStatus.BAD_REQUEST,"用户不存在");
}else {
stuUserList.get(0).setDelState(1);
stuUserMapper.updateByPrimaryKeySelective(stuUserList.get(0));
return new ResultEntity<>(HttpStatus.OK,"删除成功!");
}
}
/**
*
* @param restPassWord
* @return
*/
@Override
public ResultEntity restPwd(RestPassWordDTO restPassWord) {
if (!restPassWord.getPasswordOne().equals(restPassWord.getPasswordTwo()))
{
return new ResultEntity<>(HttpStatus.BAD_REQUEST,"两次输入密码不一致!");
}
StuUserExample stuUserExample = new StuUserExample();
stuUserExample.createCriteria().andUserIdEqualTo(restPassWord.getUserId());
List<StuUser> stuUserList = stuUserMapper.selectByExample(stuUserExample);
if (stuUserList.isEmpty())
{
return new ResultEntity(HttpStatus.BAD_REQUEST,"用户不存在");
}else {
stuUserList.get(0).setPassword(restPassWord.getPasswordOne());
stuUserMapper.updateByPrimaryKeySelective(stuUserList.get(0));
return new ResultEntity<>(HttpStatus.OK,"密码重置成功!");
}
}
public String getIpAddress(String ip) {
if ("127.0.0.1".equals(ip) || ip.startsWith("192.168")) {
return "局域网 ip";
}
if (searcher == null) {
try {
searcher = Searcher.newWithBuffer(IOUtils.toByteArray(new ClassPathResource("ip2region.xdb").getInputStream()));
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
String region = null;
String errorMessage = null;
try {
region = searcher.search(ip);
} catch (Exception e) {
errorMessage = e.getMessage();
if (errorMessage != null && errorMessage.length() > 256) {
errorMessage = errorMessage.substring(0, 256);
}
e.printStackTrace();
}
// 输出 region
log.info("归属地为:{}", region);
return region;
}
}

Binary file not shown.

@ -32,6 +32,9 @@
<result column="cross_border_payment_results_score" jdbcType="DECIMAL" property="crossBorderPaymentResultsScore" /> <result column="cross_border_payment_results_score" jdbcType="DECIMAL" property="crossBorderPaymentResultsScore" />
<result column="total_rank" jdbcType="INTEGER" property="totalRank" /> <result column="total_rank" jdbcType="INTEGER" property="totalRank" />
<result column="total_score" jdbcType="DECIMAL" property="totalScore" /> <result column="total_score" jdbcType="DECIMAL" property="totalScore" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="del_state" jdbcType="INTEGER" property="delState" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</resultMap> </resultMap>
<sql id="Example_Where_Clause"> <sql id="Example_Where_Clause">
<where> <where>
@ -97,7 +100,8 @@
consensus_layer_socre, exciting_layer_socre, contract_layer_socre, concept_score, consensus_layer_socre, exciting_layer_socre, contract_layer_socre, concept_score,
concept_rank, technology_socre, technology_rank, digital_currency_score, digital_currency_rank, concept_rank, technology_socre, technology_rank, digital_currency_score, digital_currency_rank,
invoice_score, supply_chain_finance_score, traceability_and_anti_counterfeiting_score, invoice_score, supply_chain_finance_score, traceability_and_anti_counterfeiting_score,
ticket_results_score, cross_border_payment_results_score, total_rank, total_score ticket_results_score, cross_border_payment_results_score, total_rank, total_score,
create_time, del_state, update_time
</sql> </sql>
<select id="selectByExample" parameterType="com.sztzjy.trade.entity.StuUserExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.sztzjy.trade.entity.StuUserExample" resultMap="BaseResultMap">
select select
@ -141,7 +145,8 @@
invoice_score, supply_chain_finance_score, invoice_score, supply_chain_finance_score,
traceability_and_anti_counterfeiting_score, ticket_results_score, traceability_and_anti_counterfeiting_score, ticket_results_score,
cross_border_payment_results_score, total_rank, cross_border_payment_results_score, total_rank,
total_score) total_score, create_time, del_state,
update_time)
values (#{userId,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, values (#{userId,jdbcType=VARCHAR}, #{studentId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{password,jdbcType=VARCHAR}, #{roleId,jdbcType=INTEGER}, #{classId,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{roleId,jdbcType=INTEGER}, #{classId,jdbcType=VARCHAR},
#{className,jdbcType=VARCHAR}, #{major,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR}, #{className,jdbcType=VARCHAR}, #{major,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR},
@ -153,7 +158,8 @@
#{invoiceScore,jdbcType=DECIMAL}, #{supplyChainFinanceScore,jdbcType=DECIMAL}, #{invoiceScore,jdbcType=DECIMAL}, #{supplyChainFinanceScore,jdbcType=DECIMAL},
#{traceabilityAndAntiCounterfeitingScore,jdbcType=DECIMAL}, #{ticketResultsScore,jdbcType=DECIMAL}, #{traceabilityAndAntiCounterfeitingScore,jdbcType=DECIMAL}, #{ticketResultsScore,jdbcType=DECIMAL},
#{crossBorderPaymentResultsScore,jdbcType=DECIMAL}, #{totalRank,jdbcType=INTEGER}, #{crossBorderPaymentResultsScore,jdbcType=DECIMAL}, #{totalRank,jdbcType=INTEGER},
#{totalScore,jdbcType=DECIMAL}) #{totalScore,jdbcType=DECIMAL}, #{createTime,jdbcType=TIMESTAMP}, #{delState,jdbcType=INTEGER},
#{updateTime,jdbcType=TIMESTAMP})
</insert> </insert>
<insert id="insertSelective" parameterType="com.sztzjy.trade.entity.StuUser"> <insert id="insertSelective" parameterType="com.sztzjy.trade.entity.StuUser">
insert into stu_user insert into stu_user
@ -248,6 +254,15 @@
<if test="totalScore != null"> <if test="totalScore != null">
total_score, total_score,
</if> </if>
<if test="createTime != null">
create_time,
</if>
<if test="delState != null">
del_state,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null"> <if test="userId != null">
@ -340,6 +355,15 @@
<if test="totalScore != null"> <if test="totalScore != null">
#{totalScore,jdbcType=DECIMAL}, #{totalScore,jdbcType=DECIMAL},
</if> </if>
<if test="createTime != null">
#{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delState != null">
#{delState,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
#{updateTime,jdbcType=TIMESTAMP},
</if>
</trim> </trim>
</insert> </insert>
<select id="countByExample" parameterType="com.sztzjy.trade.entity.StuUserExample" resultType="java.lang.Long"> <select id="countByExample" parameterType="com.sztzjy.trade.entity.StuUserExample" resultType="java.lang.Long">
@ -348,7 +372,7 @@
<include refid="Example_Where_Clause" /> <include refid="Example_Where_Clause" />
</if> </if>
</select> </select>
<update id="updateByExampleSelective" parameterType="map"> <update id="updateByExampleSelective" parameterType="map">
update stu_user update stu_user
<set> <set>
<if test="record.userId != null"> <if test="record.userId != null">
@ -441,6 +465,15 @@
<if test="record.totalScore != null"> <if test="record.totalScore != null">
total_score = #{record.totalScore,jdbcType=DECIMAL}, total_score = #{record.totalScore,jdbcType=DECIMAL},
</if> </if>
<if test="record.createTime != null">
create_time = #{record.createTime,jdbcType=TIMESTAMP},
</if>
<if test="record.delState != null">
del_state = #{record.delState,jdbcType=INTEGER},
</if>
<if test="record.updateTime != null">
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
</if>
</set> </set>
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
@ -477,7 +510,10 @@
ticket_results_score = #{record.ticketResultsScore,jdbcType=DECIMAL}, ticket_results_score = #{record.ticketResultsScore,jdbcType=DECIMAL},
cross_border_payment_results_score = #{record.crossBorderPaymentResultsScore,jdbcType=DECIMAL}, cross_border_payment_results_score = #{record.crossBorderPaymentResultsScore,jdbcType=DECIMAL},
total_rank = #{record.totalRank,jdbcType=INTEGER}, total_rank = #{record.totalRank,jdbcType=INTEGER},
total_score = #{record.totalScore,jdbcType=DECIMAL} total_score = #{record.totalScore,jdbcType=DECIMAL},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
del_state = #{record.delState,jdbcType=INTEGER},
update_time = #{record.updateTime,jdbcType=TIMESTAMP}
<if test="_parameter != null"> <if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" /> <include refid="Update_By_Example_Where_Clause" />
</if> </if>
@ -572,6 +608,15 @@
<if test="totalScore != null"> <if test="totalScore != null">
total_score = #{totalScore,jdbcType=DECIMAL}, total_score = #{totalScore,jdbcType=DECIMAL},
</if> </if>
<if test="createTime != null">
create_time = #{createTime,jdbcType=TIMESTAMP},
</if>
<if test="delState != null">
del_state = #{delState,jdbcType=INTEGER},
</if>
<if test="updateTime != null">
update_time = #{updateTime,jdbcType=TIMESTAMP},
</if>
</set> </set>
where user_id = #{userId,jdbcType=VARCHAR} where user_id = #{userId,jdbcType=VARCHAR}
</update> </update>
@ -605,10 +650,15 @@
ticket_results_score = #{ticketResultsScore,jdbcType=DECIMAL}, ticket_results_score = #{ticketResultsScore,jdbcType=DECIMAL},
cross_border_payment_results_score = #{crossBorderPaymentResultsScore,jdbcType=DECIMAL}, cross_border_payment_results_score = #{crossBorderPaymentResultsScore,jdbcType=DECIMAL},
total_rank = #{totalRank,jdbcType=INTEGER}, total_rank = #{totalRank,jdbcType=INTEGER},
total_score = #{totalScore,jdbcType=DECIMAL} total_score = #{totalScore,jdbcType=DECIMAL},
create_time = #{createTime,jdbcType=TIMESTAMP},
del_state = #{delState,jdbcType=INTEGER},
update_time = #{updateTime,jdbcType=TIMESTAMP}
where user_id = #{userId,jdbcType=VARCHAR} where user_id = #{userId,jdbcType=VARCHAR}
</update> </update>
<select id="getStartCourseNameList" resultType="com.sztzjy.trade.entity.StuUser" resultMap="BaseResultMap"> <select id="getStartCourseNameList" resultType="com.sztzjy.trade.entity.StuUser" resultMap="BaseResultMap">
SELECT * FROM stu_user SELECT * FROM stu_user
<where> <where>
@ -643,4 +693,5 @@
</foreach> </foreach>
</where> </where>
</select> </select>
</mapper> </mapper>

@ -0,0 +1,353 @@
<?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.sztzjy.trade.mapper.TchLoginLogMapper">
<resultMap id="BaseResultMap" type="com.sztzjy.trade.entity.TchLoginLog">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="student_id" jdbcType="VARCHAR" property="studentId" />
<result column="name" jdbcType="VARCHAR" property="name" />
<result column="login_time_last" jdbcType="TIMESTAMP" property="loginTimeLast" />
<result column="exit_time_last" jdbcType="TIMESTAMP" property="exitTimeLast" />
<result column="login_duration" jdbcType="BIGINT" property="loginDuration" />
<result column="online" jdbcType="TINYINT" property="online" />
<result column="login_ip" jdbcType="VARCHAR" property="loginIp" />
<result column="ip_owner_location" jdbcType="VARCHAR" property="ipOwnerLocation" />
<result column="total_login_duration" jdbcType="BIGINT" property="totalLoginDuration" />
<result column="total_login_days" jdbcType="INTEGER" property="totalLoginDays" />
<result column="class_id" jdbcType="VARCHAR" property="classId" />
<result column="user_id" jdbcType="VARCHAR" property="userId" />
<result column="school_id" jdbcType="VARCHAR" property="schoolId" />
</resultMap>
<sql id="Example_Where_Clause">
<where>
<foreach collection="oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Update_By_Example_Where_Clause">
<where>
<foreach collection="example.oredCriteria" item="criteria" separator="or">
<if test="criteria.valid">
<trim prefix="(" prefixOverrides="and" suffix=")">
<foreach collection="criteria.criteria" item="criterion">
<choose>
<when test="criterion.noValue">
and ${criterion.condition}
</when>
<when test="criterion.singleValue">
and ${criterion.condition} #{criterion.value}
</when>
<when test="criterion.betweenValue">
and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
</when>
<when test="criterion.listValue">
and ${criterion.condition}
<foreach close=")" collection="criterion.value" item="listItem" open="(" separator=",">
#{listItem}
</foreach>
</when>
</choose>
</foreach>
</trim>
</if>
</foreach>
</where>
</sql>
<sql id="Base_Column_List">
id, student_id, name, login_time_last, exit_time_last, login_duration, online, login_ip,
ip_owner_location, total_login_duration, total_login_days, class_id, user_id, school_id
</sql>
<select id="selectByExample" parameterType="com.sztzjy.trade.entity.TchLoginLogExample" resultMap="BaseResultMap">
select
<if test="distinct">
distinct
</if>
<include refid="Base_Column_List" />
from tch_login_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
<if test="orderByClause != null">
order by ${orderByClause}
</if>
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
select
<include refid="Base_Column_List" />
from tch_login_log
where id = #{id,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
delete from tch_login_log
where id = #{id,jdbcType=INTEGER}
</delete>
<delete id="deleteByExample" parameterType="com.sztzjy.trade.entity.TchLoginLogExample">
delete from tch_login_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</delete>
<insert id="insert" parameterType="com.sztzjy.trade.entity.TchLoginLog">
insert into tch_login_log (id, student_id, name,
login_time_last, exit_time_last, login_duration,
online, login_ip, ip_owner_location,
total_login_duration, total_login_days, class_id,
user_id, school_id)
values (#{id,jdbcType=INTEGER}, #{studentId,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
#{loginTimeLast,jdbcType=TIMESTAMP}, #{exitTimeLast,jdbcType=TIMESTAMP}, #{loginDuration,jdbcType=BIGINT},
#{online,jdbcType=TINYINT}, #{loginIp,jdbcType=VARCHAR}, #{ipOwnerLocation,jdbcType=VARCHAR},
#{totalLoginDuration,jdbcType=BIGINT}, #{totalLoginDays,jdbcType=INTEGER}, #{classId,jdbcType=VARCHAR},
#{userId,jdbcType=VARCHAR}, #{schoolId,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.sztzjy.trade.entity.TchLoginLog">
insert into tch_login_log
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">
id,
</if>
<if test="studentId != null">
student_id,
</if>
<if test="name != null">
name,
</if>
<if test="loginTimeLast != null">
login_time_last,
</if>
<if test="exitTimeLast != null">
exit_time_last,
</if>
<if test="loginDuration != null">
login_duration,
</if>
<if test="online != null">
online,
</if>
<if test="loginIp != null">
login_ip,
</if>
<if test="ipOwnerLocation != null">
ip_owner_location,
</if>
<if test="totalLoginDuration != null">
total_login_duration,
</if>
<if test="totalLoginDays != null">
total_login_days,
</if>
<if test="classId != null">
class_id,
</if>
<if test="userId != null">
user_id,
</if>
<if test="schoolId != null">
school_id,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">
#{id,jdbcType=INTEGER},
</if>
<if test="studentId != null">
#{studentId,jdbcType=VARCHAR},
</if>
<if test="name != null">
#{name,jdbcType=VARCHAR},
</if>
<if test="loginTimeLast != null">
#{loginTimeLast,jdbcType=TIMESTAMP},
</if>
<if test="exitTimeLast != null">
#{exitTimeLast,jdbcType=TIMESTAMP},
</if>
<if test="loginDuration != null">
#{loginDuration,jdbcType=BIGINT},
</if>
<if test="online != null">
#{online,jdbcType=TINYINT},
</if>
<if test="loginIp != null">
#{loginIp,jdbcType=VARCHAR},
</if>
<if test="ipOwnerLocation != null">
#{ipOwnerLocation,jdbcType=VARCHAR},
</if>
<if test="totalLoginDuration != null">
#{totalLoginDuration,jdbcType=BIGINT},
</if>
<if test="totalLoginDays != null">
#{totalLoginDays,jdbcType=INTEGER},
</if>
<if test="classId != null">
#{classId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
#{userId,jdbcType=VARCHAR},
</if>
<if test="schoolId != null">
#{schoolId,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<select id="countByExample" parameterType="com.sztzjy.trade.entity.TchLoginLogExample" resultType="java.lang.Long">
select count(*) from tch_login_log
<if test="_parameter != null">
<include refid="Example_Where_Clause" />
</if>
</select>
<update id="updateByExampleSelective" parameterType="map">
update tch_login_log
<set>
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.studentId != null">
student_id = #{record.studentId,jdbcType=VARCHAR},
</if>
<if test="record.name != null">
name = #{record.name,jdbcType=VARCHAR},
</if>
<if test="record.loginTimeLast != null">
login_time_last = #{record.loginTimeLast,jdbcType=TIMESTAMP},
</if>
<if test="record.exitTimeLast != null">
exit_time_last = #{record.exitTimeLast,jdbcType=TIMESTAMP},
</if>
<if test="record.loginDuration != null">
login_duration = #{record.loginDuration,jdbcType=BIGINT},
</if>
<if test="record.online != null">
online = #{record.online,jdbcType=TINYINT},
</if>
<if test="record.loginIp != null">
login_ip = #{record.loginIp,jdbcType=VARCHAR},
</if>
<if test="record.ipOwnerLocation != null">
ip_owner_location = #{record.ipOwnerLocation,jdbcType=VARCHAR},
</if>
<if test="record.totalLoginDuration != null">
total_login_duration = #{record.totalLoginDuration,jdbcType=BIGINT},
</if>
<if test="record.totalLoginDays != null">
total_login_days = #{record.totalLoginDays,jdbcType=INTEGER},
</if>
<if test="record.classId != null">
class_id = #{record.classId,jdbcType=VARCHAR},
</if>
<if test="record.userId != null">
user_id = #{record.userId,jdbcType=VARCHAR},
</if>
<if test="record.schoolId != null">
school_id = #{record.schoolId,jdbcType=VARCHAR},
</if>
</set>
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByExample" parameterType="map">
update tch_login_log
set id = #{record.id,jdbcType=INTEGER},
student_id = #{record.studentId,jdbcType=VARCHAR},
name = #{record.name,jdbcType=VARCHAR},
login_time_last = #{record.loginTimeLast,jdbcType=TIMESTAMP},
exit_time_last = #{record.exitTimeLast,jdbcType=TIMESTAMP},
login_duration = #{record.loginDuration,jdbcType=BIGINT},
online = #{record.online,jdbcType=TINYINT},
login_ip = #{record.loginIp,jdbcType=VARCHAR},
ip_owner_location = #{record.ipOwnerLocation,jdbcType=VARCHAR},
total_login_duration = #{record.totalLoginDuration,jdbcType=BIGINT},
total_login_days = #{record.totalLoginDays,jdbcType=INTEGER},
class_id = #{record.classId,jdbcType=VARCHAR},
user_id = #{record.userId,jdbcType=VARCHAR},
school_id = #{record.schoolId,jdbcType=VARCHAR}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
</if>
</update>
<update id="updateByPrimaryKeySelective" parameterType="com.sztzjy.trade.entity.TchLoginLog">
update tch_login_log
<set>
<if test="studentId != null">
student_id = #{studentId,jdbcType=VARCHAR},
</if>
<if test="name != null">
name = #{name,jdbcType=VARCHAR},
</if>
<if test="loginTimeLast != null">
login_time_last = #{loginTimeLast,jdbcType=TIMESTAMP},
</if>
<if test="exitTimeLast != null">
exit_time_last = #{exitTimeLast,jdbcType=TIMESTAMP},
</if>
<if test="loginDuration != null">
login_duration = #{loginDuration,jdbcType=BIGINT},
</if>
<if test="online != null">
online = #{online,jdbcType=TINYINT},
</if>
<if test="loginIp != null">
login_ip = #{loginIp,jdbcType=VARCHAR},
</if>
<if test="ipOwnerLocation != null">
ip_owner_location = #{ipOwnerLocation,jdbcType=VARCHAR},
</if>
<if test="totalLoginDuration != null">
total_login_duration = #{totalLoginDuration,jdbcType=BIGINT},
</if>
<if test="totalLoginDays != null">
total_login_days = #{totalLoginDays,jdbcType=INTEGER},
</if>
<if test="classId != null">
class_id = #{classId,jdbcType=VARCHAR},
</if>
<if test="userId != null">
user_id = #{userId,jdbcType=VARCHAR},
</if>
<if test="schoolId != null">
school_id = #{schoolId,jdbcType=VARCHAR},
</if>
</set>
where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="com.sztzjy.trade.entity.TchLoginLog">
update tch_login_log
set student_id = #{studentId,jdbcType=VARCHAR},
name = #{name,jdbcType=VARCHAR},
login_time_last = #{loginTimeLast,jdbcType=TIMESTAMP},
exit_time_last = #{exitTimeLast,jdbcType=TIMESTAMP},
login_duration = #{loginDuration,jdbcType=BIGINT},
online = #{online,jdbcType=TINYINT},
login_ip = #{loginIp,jdbcType=VARCHAR},
ip_owner_location = #{ipOwnerLocation,jdbcType=VARCHAR},
total_login_duration = #{totalLoginDuration,jdbcType=BIGINT},
total_login_days = #{totalLoginDays,jdbcType=INTEGER},
class_id = #{classId,jdbcType=VARCHAR},
user_id = #{userId,jdbcType=VARCHAR},
school_id = #{schoolId,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
</mapper>
Loading…
Cancel
Save