main
lwy 2 years ago
parent 65ad741fc9
commit ae4358a5a6

@ -0,0 +1,20 @@
package top.liangwy.read_statistics.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import top.liangwy.read_statistics.pojo.Dept;
import java.util.List;
/**
* @author lwy
*/
@Mapper
@Repository
public interface DeptMapper {
String getDeptName(Integer deptId);
List<Dept> getAllDeptName();
}

@ -0,0 +1,12 @@
<?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="top.liangwy.read_statistics.dao.DeptMapper">
<select id="getDeptName" parameterType="int" resultType="String">
select deptName from dept where deptId = #{deptId}
</select>
<select id="getAllDeptName" resultType="top.liangwy.read_statistics.pojo.Dept">
select * from dept where deleted = 0 order by `order`
</select>
</mapper>

@ -0,0 +1,18 @@
package top.liangwy.read_statistics.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import top.liangwy.read_statistics.pojo.Integral;
/**
* @author lwy
*/
@Mapper
@Repository
public interface IntegralMapper {
Integral getTodayIntegral(Integer id);
Integral getYesterdayIntegral(Integer id);
Boolean addUserInteralNum(Integral integral);
Boolean userInteralNumAdd30(Integral integral);
Integral getYesterdayYesterdayIntegral(Integer id);
}

@ -0,0 +1,40 @@
<?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="top.liangwy.read_statistics.dao.IntegralMapper">
<select id="getTodayIntegral" parameterType="int" resultType="top.liangwy.read_statistics.pojo.Integral">
select integralNum
from integral
where userId = #{id}
and to_days(createTime) = to_days(now())
order by createTime desc limit 1
</select>
<select id="getYesterdayIntegral" parameterType="int" resultType="top.liangwy.read_statistics.pojo.Integral">
select integralNum
from integral
where userId = #{id}
and TO_DAYS(NOW()) - TO_DAYS(createTime) = 1
and really = 0
order by createTime desc limit 1
</select>
<select id="getYesterdayYesterdayIntegral" parameterType="int" resultType="top.liangwy.read_statistics.pojo.Integral">
select integralNum
from integral
where userId = #{id}
and TO_DAYS(NOW()) - TO_DAYS(createTime) = 2
and really = 0
order by createTime desc limit 1
</select>
<insert id="addUserInteralNum" parameterType="top.liangwy.read_statistics.pojo.Integral">
insert into integral (userId, integralNum, really)
values (#{userId}, #{integralNum}, 0)
</insert>
<insert id="userInteralNumAdd30" parameterType="top.liangwy.read_statistics.pojo.Integral">
insert into integral (userId, integralNum, really)
values (#{userId}, #{integralNum}, #{really})
</insert>
</mapper>

@ -0,0 +1,17 @@
package top.liangwy.read_statistics.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author lwy
*/
@Mapper
@Repository
public interface KsMapper {
String getUserKsList();
int setUserKsList(String userKsList);
}

@ -0,0 +1,13 @@
<?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="top.liangwy.read_statistics.dao.KsMapper">
<select id="getUserKsList" resultType="String">
select userKsList from ks order by id desc limit 1;
</select>
<insert id="setUserKsList" parameterType="String">
insert into ks (userKsList) values (#{userKsList})
</insert>
</mapper>

@ -0,0 +1,17 @@
package top.liangwy.read_statistics.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author lwy
*/
@Mapper
@Repository
public interface ScanMapper {
String getUserScanList();
int setUserScanList(String userScanList);
}

@ -0,0 +1,14 @@
<?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="top.liangwy.read_statistics.dao.ScanMapper">
<select id="getUserScanList" resultType="String">
select userScanList from scan where to_days(now()) - to_days(createTime) = 0
order by createTime desc limit 1;
</select>
<insert id="setUserScanList" parameterType="String">
insert into scan (userScanList) values (#{userScanList})
</insert>
</mapper>

@ -0,0 +1,23 @@
package top.liangwy.read_statistics.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import top.liangwy.read_statistics.pojo.User;
import java.util.List;
/**
* @author lwy
*/
@Mapper
@Repository
public interface UserMapper {
List<User> getUserList();
String getUserIdByTelephone(String telephone);
List<User> getUserTelephoneByDeptName(String deptName);
List<User> getUserByDeptId(Integer deptId);
List<String> getUserTelphone();
}

@ -0,0 +1,18 @@
<?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="top.liangwy.read_statistics.dao.UserMapper">
<select id="getUserList" resultType="top.liangwy.read_statistics.pojo.User">
select * from user where deleted = 0
</select>
<select id="getUserIdByTelphone" resultType="String">
select userId from user where telphone = #{telephone} and deleted = 0 limit 1
</select>
<select id="getUserTelphoneByDeptName" resultType="top.liangwy.read_statistics.pojo.User">
select * from user, where deptName = #{deptName} and deleted = 0
</select>
<select id="getUserByDeptId" resultType="top.liangwy.read_statistics.pojo.User">
select * from user where deptId = #{deptId} and deleted = 0 order by `order`
</select>
</mapper>

@ -0,0 +1,17 @@
package top.liangwy.read_statistics.dao;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
/**
* @author lwy
*/
@Mapper
@Repository
public interface WbMapper {
String getWbUserScanList();
int setWbUserScanList(String wbUserScanList);
}

@ -0,0 +1,14 @@
<?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="top.liangwy.read_statistics.dao.WbMapper">
<select id="getWbUserScanList" resultType="String">
select wbUserScanList from wb where to_days(now()) - to_days(createTime) = 0
order by createTime desc limit 1;
</select>
<insert id="setWbUserScanList" parameterType="String">
insert into wb (wbUserScanList) values (#{wbUserScanList})
</insert>
</mapper>

@ -0,0 +1,11 @@
package top.liangwy.read_statistics.pojo;
import lombok.Data;
@Data
public class Dept {
private Integer deptId;
private String deptName;
private Integer deleted;
private Integer order;
}

@ -0,0 +1,46 @@
package top.liangwy.read_statistics.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
@Data
public class Integral {
/**
* id
*/
private Integer integralId;
/**
* id
*/
private Integer userId;
/**
*
*/
private Integer integralNum;
/**
*
*/
private Integer really;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date updateTime;
}

@ -0,0 +1,23 @@
package top.liangwy.read_statistics.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author lwy
*/
@Data
public class Ks {
private Integer id;
private String userKsList;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}

@ -0,0 +1,20 @@
package top.liangwy.read_statistics.pojo.Result;
import lombok.Data;
@Data
public class ResultMsg {
//错误信息
private String msg;
//状态
private String status;
//返回数据不需要的时候为null即可
private Object data;
public ResultMsg(String msg, String status, Object data) {
this.msg = msg;
this.status = status;
this.data = data;
}
}

@ -0,0 +1,13 @@
package top.liangwy.read_statistics.pojo.Result;
import lombok.Data;
/**
* @author lwy
*/
@Data
public class UserScan {
private String userName;
private String ksNickName;
private String scanStatus;
}

@ -0,0 +1,17 @@
package top.liangwy.read_statistics.pojo.Result;
import lombok.Data;
/**
* @author lwy
*/
@Data
public class UserScore {
private Integer userId;
private String userName;
private Integer todayScore;
private Integer yesterdayScore;
// private Integer addScore;
}

@ -0,0 +1,23 @@
package top.liangwy.read_statistics.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author lwy
*/
@Data
public class Scan {
private Integer id;
private String userScanList;
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss",
timezone = "GMT+8"
)
private Date createTime;
}

@ -0,0 +1,32 @@
package top.liangwy.read_statistics.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author lwy
*/
@Data
public class User {
private Integer userId;
private String userName;
private Integer deptId;
private String telephone;
private String ksNickName;
private String wbNickName;
private Integer deleted;
private Integer order;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
}

@ -0,0 +1,20 @@
package top.liangwy.read_statistics.pojo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* @author lwy
*/
@Data
public class Wb {
private Integer id;
private String wbUserScanList;
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
}

@ -0,0 +1,32 @@
package top.liangwy.read_statistics.utils;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import java.io.IOException;
import java.io.InputStream;
/**
* @author lwy
*/
public class MybatisUtils {
private static SqlSessionFactory sqlSessionFactory;
static {
try {
String resource = "mybatis-config.xml";
InputStream inputStream = Resources.getResourceAsStream(resource);
sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
} catch (IOException e) {
e.printStackTrace();
}
}
public static SqlSession getSqlSession() {
return sqlSessionFactory.openSession();
}
}
Loading…
Cancel
Save