V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  jorneyr  ›  全部回复第 83 页 / 共 88 页
回复总数  1742
1 ... 75  76  77  78  79  80  81  82  83  84 ... 88  
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 几个其他软件), 性能都没问题, 感觉你不必买配置很高的.
2018-11-04 17:36:59 +08:00
回复了 blackccc 创建的主题 程序员 程序员买什么笔记本好?最近刚好想换电脑
联系美国做活动 6 折不允许中国人买, 看过小米的, 感觉小米游戏本不错啊.
2018-11-04 16:45:03 +08:00
回复了 jorneyr 创建的主题 Apple 2013 年的 15 寸最低配 MBP 安装了 Mojave
@jerain 系统设置 -> Accisibility -> Mouse & Trackpad -> Trackpad Options 里设置一下
2018-11-04 13:18:34 +08:00
回复了 cc959798 创建的主题 程序员 请问大的互联网研发岗位一般背景调查都调查些什么?
一般都是简单打电话问下前同事你说的是不是真的, 只会简单的了解下, 例如是否在这里工作, 平时表现怎么样, 性格怎么样, 和其他同事闹不闹矛盾等, 都是些日常的问题, 不会问薪资待遇.
2018-11-02 09:15:19 +08:00
回复了 szhshp 创建的主题 程序员 你们见过最狗屎的架构是什么样的
PPT 架构师, 君子动口不动手
2018-10-30 15:00:18 +08:00
回复了 Ginray 创建的主题 macOS MAC 下有什么能够转换文件编码的文本编辑器吗?类似于 Notepad++
iconv 命令转一下, 还可以批量转呢
2018-10-24 10:22:10 +08:00
回复了 xinhangliu 创建的主题 程序员 我为什么开始使用 Firefox
最喜欢的还是 Safari, 在 Mac 上的体验不是 Chrome 和 Firefox 能比的
2018-10-23 09:08:55 +08:00
回复了 xmd19970616 创建的主题 macOS 2018 mac 下有没有推荐的类似 xshell 软件 包括 xshell
iTerm 加上 profile 自动登录 ssh 很舒服 https://qtdebug.com/mac-iterm-ssh/
1 ... 75  76  77  78  79  80  81  82  83  84 ... 88  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2476 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 44ms · UTC 02:29 · PVG 10:29 · LAX 18:29 · JFK 21:29
Developed with CodeLauncher
♥ Do have faith in what you're doing.