V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  jorneyr  ›  全部回复第 83 页 / 共 88 页
回复总数  1749
1 ... 75  76  77  78  79  80  81  82  83  84 ... 88  
我还真干了用 accessToken 刷新 accessToken 的蠢事, 就是为了前端不再次登录.
2018-12-11 09:36:12 +08:00
回复了 zkeeper 创建的主题 程序员 间歇性的感觉人生没有意义, 这样正常吗?
间歇性迷茫, 也是经常这样
用经典的 Tomcat 部署, 多个 Web 可以把都有的 jar 包放到 Tomcat 的共享 lib 里, 不需要每个应用都各自加载一次这些 jar 包, 这样可以省掉不少资源.
2018-12-06 09:30:18 +08:00
回复了 konikoo 创建的主题 Android 小米,华为的全面屏手势大家用起来不冲突吗?
自己用华为, 同事用小米, 2 个都是新买的 1500 的手机, 感觉华为的全面屏手势没有小米的流畅
熟练掌握常用的数据结构和算法, 就是大学学的那一本书.
2018-12-01 22:43:53 +08:00
回复了 nohup 创建的主题 程序员 你们担心国产输入法会窃取你的隐私吗?
逃离中国是你最好的选择
2018-11-27 09:59:13 +08:00
回复了 wqawd520 创建的主题 程序员 大伙们给点建议,是转 Java 还是继续走.net/.net core 呢?
为什么不是 PHP 呢?
PHP 的老是嘲笑 Java 的都在加班啊!
2018-11-25 07:28:55 +08:00
回复了 cnfzv 创建的主题 程序员 如果 SSH 仅允许密钥登录,还有必要禁用 ROOT 登录吗?
我们不管啥都是 root 登录, 运维给的, 嘎嘎
谁的程序还不有点 Bug 啊, 不要对自己的程序太自信.
2018-11-22 17:15:33 +08:00
回复了 zynlp 创建的主题 程序员 分享一下我的 c++项目重构经验
我也这么认为的
2018-11-20 17:47:57 +08:00
回复了 waterlaw 创建的主题 程序员 写了一个 RSA + Base64 加密的程序,要不来试试?
@Yanni0507 应该 RSA 加密的结果是字节数组, 很多是不可见字符, BASE64 把字节数组转为字符进行发送
2018-11-19 18:00:57 +08:00
回复了 ajan 创建的主题 全球工单系统 韵达的开发是不是从“小米”挖来的?
连个随机数都不加啊, 假装一下嘛
2018-11-17 11:29:38 +08:00
回复了 0xff0x77 创建的主题 程序员 今天看到有人说 CRUD, 其实 CRUD 也是有牛逼和渣渣之分的。
Hibernate, MyBatis 都是 CRUD, 有人可以把 CRUD 做成艺术
2018-11-16 07:52:37 +08:00
回复了 KasuganoSoras 创建的主题 程序员 其实 NotePad++ 也可以非常好看
知足常乐, 虽然还是很丑
2018-11-15 19:53:50 +08:00
回复了 seiye 创建的主题 Apple 这个配置升级 MacOS Mojave 会不会卡到死?
我的 2013 15 寸 MBP 最低配跑 Mojave 很快, 一点也不卡, 按道理你的配置比我的高一些.
压缩操作询问好几次, 麻烦
2018-11-14 13:34:52 +08:00
回复了 xoxo419 创建的主题 程序员 查了一些 api 接口认证的方式 大家用的那种方式比较多呢?
OAuth 2.0 和 API KEY
2018-11-13 16:12:19 +08:00
回复了 Jex 创建的主题 Java 有多少 Java 程序员用 jOOQ ?
@qiyuey 有更好的办法吗?
2018-11-13 15:01:38 +08:00
回复了 Jex 创建的主题 Java 有多少 Java 程序员用 jOOQ ?
看一个我们的 mapper 吧, 绝大部分都不是单表语句, 觉得 MyBatis 比较合适:

```xml
<?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">

<!--namespace 非常重要:必须是 Mapper 类的全路径-->
<mapper namespace="ebag.mapper.ClazzMapper">
<!-- 老师或者学生的列 -->
<sql id="student_or_teacher_columns">
user.id AS id,
user.username AS username,
user.nickname AS nickname,
user.avatar AS avatar,
user.school_id AS school_id,
user.is_enabled AS is_enabled,
user.gender AS gender,
clazz.name AS clazz_name,
clazz.code AS clazz_code,
clazz.phase AS clazz_phase,
clazz.id AS clazz_id,
cts.subject AS clazz_subject
</sql>

<!-- 查找学校的班级 -->
<select id="findClazzesBySchoolId" resultType="Clazz">
SELECT id, school_id AS schoolId, code, name, phase, grade, type,
enrollment_year AS enrollmentYear, graduation_year AS graduationYear
FROM clazz
WHERE school_id = #{schoolId} AND is_history=#{history}
</select>

<!-- 查询指定 ID 的班级 -->
<select id="findClazzById" parameterType="long" resultType="Clazz">
SELECT id, school_id AS schoolId, code, name, phase, grade, type,
enrollment_year AS enrollmentYear, graduation_year AS graduationYear
FROM clazz WHERE id = #{clazzId}
</select>

<!-- 查找学校的老师 -->
<select id="findTeachersBySchoolId" resultMap="teacherResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM (
SELECT * FROM user
WHERE school_id = #{schoolId} AND role = 'ROLE_TEACHER'
LIMIT #{offset}, #{count}
) AS user
LEFT JOIN clazz_teacher_subject AS cts ON cts.teacher_id = user.id
LEFT JOIN clazz ON clazz.id = cts.clazz_id
</select>

<!-- 使用账号查找学校的老师 -->
<select id="findTeachersBySchoolIdAndUsernameLike" resultMap="teacherResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM (
SELECT * FROM user
WHERE school_id = #{schoolId} AND role = 'ROLE_TEACHER' AND username LIKE CONCAT('%', #{username}, '%')
LIMIT #{offset}, #{count}
) AS user
LEFT JOIN clazz_teacher_subject AS cts ON cts.teacher_id = user.id
LEFT JOIN clazz ON clazz.id = cts.clazz_id
</select>

<!-- 使用昵称查找学校的老师 -->
<select id="findTeachersBySchoolIdAndNicknameLike" resultMap="teacherResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM (
SELECT * FROM user
WHERE school_id = #{schoolId} AND role = 'ROLE_TEACHER' AND nickname LIKE CONCAT('%', #{nickname}, '%')
LIMIT #{offset}, #{count}
) AS user
LEFT JOIN clazz_teacher_subject AS cts ON cts.teacher_id = user.id
LEFT JOIN clazz ON clazz.id = cts.clazz_id
</select>

<!-- 查找学校的学生 -->
<select id="findStudentsBySchoolId" resultMap="studentResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM (
SELECT * FROM user
WHERE school_id = #{schoolId} AND role='ROLE_STUDENT'
LIMIT #{offset}, #{count}
) AS user
LEFT JOIN clazz_student AS cs ON cs.student_id = user.id
LEFT JOIN clazz ON clazz.id = cs.clazz_id
LEFT JOIN clazz_teacher_subject cts ON cts.clazz_id = cs.clazz_id
</select>

<!-- 使用账号查找学校的学生 -->
<!-- 注意 LIMIT 必须放到子查询内部,否则数量限制不对 -->
<select id="findStudentsBySchoolIdAndUsernameLike" resultMap="studentResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM (
SELECT * FROM user
WHERE school_id = #{schoolId} AND role='ROLE_STUDENT' AND username LIKE CONCAT('%', #{username}, '%')
LIMIT #{offset}, #{count}
) AS user
LEFT JOIN clazz_student AS cs ON cs.student_id = user.id
LEFT JOIN clazz ON clazz.id = cs.clazz_id
LEFT JOIN clazz_teacher_subject cts ON cts.clazz_id = cs.clazz_id
</select>

<!-- 使用名字查找学校的学生 -->
<select id="findStudentsBySchoolIdAndNicknameLike" resultMap="studentResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM (
SELECT * FROM user
WHERE school_id = #{schoolId} AND role='ROLE_STUDENT' AND nickname LIKE CONCAT('%', #{nickname}, '%')
LIMIT #{offset}, #{count}
) AS user
LEFT JOIN clazz_student AS cs ON cs.student_id = user.id
LEFT JOIN clazz ON clazz.id = cs.clazz_id
LEFT JOIN clazz_teacher_subject cts ON cts.clazz_id = cs.clazz_id
</select>

<!-- 查找班级下的老师 -->
<select id="findTeachersByClazzId" resultMap="teacherResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM clazz_teacher_subject cts
LEFT JOIN clazz ON clazz.id = cts.clazz_id
LEFT JOIN user ON user.id = cts.teacher_id
WHERE cts.clazz_id = #{clazzId}
</select>

<!-- 查找班级下的所有学生 -->
<select id="findStudentsByClazzId" resultMap="studentResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM clazz_student cs
LEFT JOIN user ON user.id = cs.student_id
LEFT JOIN clazz ON clazz.id = cs.clazz_id
LEFT JOIN clazz_teacher_subject cts ON cts.clazz_id = cs.clazz_id
WHERE cs.clazz_id=#{clazzId}
ORDER BY cs.student_username
</select>

<!-- 查找指定 ID 的老师 -->
<select id="findTeacherById" resultMap="teacherResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM clazz_teacher_subject cts
LEFT JOIN clazz ON clazz.id = cts.clazz_id
LEFT JOIN user ON user.id = cts.teacher_id
WHERE cts.teacher_id = #{teacherId}
</select>

<!-- 查找指定 ID 的老师 -->
<select id="findTeacherByClazzIdAndSubject" resultMap="teacherResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM clazz_teacher_subject cts
LEFT JOIN clazz ON clazz.id = cts.clazz_id
LEFT JOIN user ON user.id = cts.teacher_id
WHERE cts.clazz_id = #{clazzId} AND cts.subject = #{subject}
</select>

<!-- 查找指定 ID 的学生 -->
<select id="findStudentById" parameterType="long" resultMap="studentResultMap">
SELECT <include refid="student_or_teacher_columns"/>
FROM clazz_student cs
LEFT JOIN clazz ON clazz.id = cs.clazz_id
LEFT JOIN clazz_teacher_subject cts ON cts.clazz_id = cs.clazz_id
LEFT JOIN user ON user.id = cs.student_id
WHERE cs.student_id = #{studentId}
</select>

<!--查询班级学生人数-->
<select id="findStudentCount" resultType="int">
SELECT count(*) FROM clazz_student WHERE clazz_student.clazz_id = #{clazzId}
</select>

<!-- 启用或禁用老师 -->
<update id="enableTeacher">
UPDATE clazz_teacher_subject SET is_enabled=#{enabled} WHERE teacher_id=#{teacherId};
UPDATE user SET is_enabled=#{enabled} WHERE id=#{teacherId};
</update>

<!-- 启用或禁用学生 -->
<update id="enableStudent">
UPDATE clazz_student SET is_enabled=#{enabled} WHERE student_id=#{studentId};
UPDATE user SET is_enabled=#{enabled} WHERE id=#{studentId};
</update>

<!-- 删除老师 -->
<delete id="deleteTeacher">
DELETE FROM user WHERE id = #{teacherId};
DELETE FROM clazz_teacher_subject WHERE teacher_id = #{teacherId};
</delete>

<!-- 删除学生 -->
<delete id="deleteStudent">
DELETE FROM user WHERE id = #{studentId};
DELETE FROM clazz_student WHERE student_id = #{studentId};
</delete>

<!-- 插入或更新已有班级 -->
<insert id="insertOrUpdateClazz" parameterType="Clazz">
INSERT INTO clazz (id, school_id, code, name, phase, grade, type, enrollment_year, graduation_year, created_time)
VALUES (#{id}, #{schoolId}, #{code}, #{name}, #{phase}, #{grade}, #{type}, #{enrollmentYear}, #{graduationYear}, now())

ON DUPLICATE KEY
UPDATE name = #{name}, phase = #{phase}, grade = #{grade}, type = #{type},
enrollment_year = #{enrollmentYear}, graduation_year = #{graduationYear}
</insert>

<!-- 插入班级学生关系 -->
<insert id="insertClazzStudent">
INSERT INTO clazz_student (school_id, clazz_code, student_username, created_time)
SELECT #{schoolId}, #{clazzCode}, #{studentUsername}, now()
FROM dual
WHERE NOT EXISTS (
SELECT 1 FROM clazz_student
WHERE school_id = #{schoolId} AND clazz_code = #{clazzCode} AND student_username = #{studentUsername}
)
</insert>

<!-- 插入班级老师学科关系 -->
<insert id="insertClazzTeacherSubject">
INSERT INTO clazz_teacher_subject (school_id, clazz_code, teacher_username, subject, created_time)
SELECT #{schoolId}, #{clazzCode}, #{teacherUsername}, #{subject}, now()
FROM dual
WHERE NOT EXISTS (
SELECT 1 FROM clazz_teacher_subject
WHERE school_id = #{schoolId} AND clazz_code = #{clazzCode} AND teacher_username = #{teacherUsername} AND subject = #{subject}
)
</insert>
...
```
2018-11-09 10:33:42 +08:00
回复了 ethan5 创建的主题 MacBook Pro 想如手 MBP,大佬们给点意见,买什么配置的呢
我 MBP 2015 15 寸低配 8G 内存的都还在搞开发, Java Web (项目中同时跑 10 个左右的支持软件: Tomcat, Nginx, ZooKeeper, ActiveMQ, MySQL, MongoDB, LibreOffice, FFmpeg, Redis, ElasticSearch), Qt 等 (当然还开着 IDEA, Atom , QQ, 微信等 10 几个其他软件), 性能都没问题, 感觉你不必买配置很高的.
1 ... 75  76  77  78  79  80  81  82  83  84 ... 88  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5906 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 60ms · UTC 02:10 · PVG 10:10 · LAX 18:10 · JFK 21:10
Developed with CodeLauncher
♥ Do have faith in what you're doing.