Browse Source

Merge branch 'next'

# Conflicts:
#	src/main/java/com/ekexiu/console/system/dao/ArticleDao.java
XMTT 7 years ago
parent
commit
1ad75dd9ee

+ 8 - 1
src/main/java/com/ekexiu/console/system/dao/ArticleDao.java

@ -3,7 +3,6 @@ package com.ekexiu.console.system.dao;
3 3
import com.ekexiu.console.system.po.Article;
4 4
import com.ekexiu.console.system.pojo.ArticleInfo;
5 5
import org.jfw.apt.annotation.Nullable;
6
import org.jfw.apt.orm.annotation.dao.Batch;
7 6
import org.jfw.apt.orm.annotation.dao.Column;
8 7
import org.jfw.apt.orm.annotation.dao.DAO;
9 8
import org.jfw.apt.orm.annotation.dao.method.From;
@ -25,6 +24,10 @@ import java.sql.SQLException;
25 24
@DAO
26 25
public interface ArticleDao {
27 26
27
    @Nullable
28
    @SelectOne
29
    Article query(Connection con, String articleId) throws SQLException;
30
28 31
    @Nullable
29 32
    @QueryVal
30 33
    @Column(handlerClass = StringHandler.class, value = "article_title")
@ -45,4 +48,8 @@ public interface ArticleDao {
45 48
    @UpdateWith
46 49
    @From(Article.class)
47 50
    int[] updateStatus(Connection con,@Batch String[] articleId,@Set String status) throws SQLException;
51
52
    @UpdateWith
53
    @From(Article.class)
54
    int updateSortNum(Connection con, String articleId, @Set long sortNum) throws SQLException;
48 55
}

+ 26 - 0
src/main/java/com/ekexiu/console/system/dao/LuserDao.java

@ -2,11 +2,17 @@ package com.ekexiu.console.system.dao;
2 2
3 3
import com.ekexiu.console.system.po.Luser;
4 4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.Column;
5 6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.From;
6 8
import org.jfw.apt.orm.annotation.dao.method.Or;
7 9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
8 11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
12
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
9 13
import org.jfw.apt.orm.annotation.dao.param.Alias;
14
import org.jfw.apt.orm.annotation.dao.param.Set;
15
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
10 16
11 17
import java.sql.Connection;
12 18
import java.sql.SQLException;
@ -24,4 +30,24 @@ public interface LuserDao {
24 30
25 31
    @Insert
26 32
    int insert(Connection con,Luser user)throws SQLException;
33
34
    @Nullable
35
    @QueryVal
36
    @Column(handlerClass=StringHandler.class,value="id")
37
    @From(Luser.class)
38
    String queryByEmail(Connection con,String email)throws SQLException;
39
40
    @Nullable
41
    @QueryVal
42
    @Column(handlerClass=StringHandler.class,value="id")
43
    @From(Luser.class)
44
    String queryByPhone(Connection con,String mobilePhone)throws SQLException;
45
46
    @UpdateWith
47
    @From(Luser.class)
48
    int updateAccount(Connection con, String id, @Set String mobilePhone, @Set String email)throws SQLException;
49
50
    @SelectOne
51
    @Nullable
52
    Luser query(Connection con, String id) throws SQLException;
27 53
}

+ 9 - 0
src/main/java/com/ekexiu/console/system/po/Article.java

@ -7,6 +7,7 @@ import org.jfw.apt.orm.annotation.entry.PrimaryKey;
7 7
import org.jfw.apt.orm.annotation.entry.Table;
8 8
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
9 9
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
10
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
10 11
import org.jfw.apt.orm.core.enums.DE;
11 12
12 13
/**
@ -31,6 +32,7 @@ public class Article implements CreateTimeSupported, ModifyTimeSupported {
31 32
    private int pageViews;
32 33
    private String status;
33 34
    private long shareId;
35
    private long sortNum;
34 36
35 37
    @Column(DE.id_32)
36 38
    public String getArticleId() {
@ -143,6 +145,13 @@ public class Article implements CreateTimeSupported, ModifyTimeSupported {
143 145
        this.shareId = shareId;
144 146
    }
145 147
148
    @Column(handlerClass=LongHandler.class,dbType="BIGINT",fixSqlValueWithInsert="0",insertable=true,renewable=false,nullable=false,queryable=true)
149
    public long getSortNum() {
150
        return sortNum;
151
    }
146 152
153
    public void setSortNum(long sortNum) {
154
        this.sortNum = sortNum;
155
    }
147 156
}
148 157

+ 14 - 0
src/main/java/com/ekexiu/console/system/service/ArticleService.java

@ -1,6 +1,7 @@
1 1
package com.ekexiu.console.system.service;
2 2
3 3
import com.ekexiu.console.system.dao.ArticleDao;
4
import com.ekexiu.console.system.po.Article;
4 5
import com.ekexiu.console.system.pojo.ArticleInfo;
5 6
import org.jfw.apt.annotation.Autowrie;
6 7
import org.jfw.apt.annotation.DefaultValue;
@ -9,6 +10,7 @@ import org.jfw.apt.web.annotation.Path;
9 10
import org.jfw.apt.web.annotation.operate.Get;
10 11
import org.jfw.apt.web.annotation.operate.Post;
11 12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
import org.jfw.apt.web.annotation.param.PathVar;
12 14
import org.jfw.util.PageQueryResult;
13 15
14 16
import java.sql.Connection;
@ -48,4 +50,16 @@ public class ArticleService {
48 50
        //修改文章状态为删除
49 51
        this.articleDao.updateStatus(con, articleIds, "3");
50 52
    }
53
54
    @Post
55
    @Path("/sortNum")
56
    public void updateSortNum(@JdbcConn(true) Connection con,String articleId,long sortNum) throws SQLException{
57
        this.articleDao.updateSortNum(con, articleId, sortNum);
58
    }
59
60
    @Get
61
    @Path("/id/{id}")
62
    public Article query(@JdbcConn Connection con, @PathVar String id) throws SQLException {
63
        return this.articleDao.query(con, id);
64
    }
51 65
}

+ 2 - 2
src/main/java/com/ekexiu/console/system/service/OrgService.java

@ -293,7 +293,7 @@ public class OrgService extends com.ekexiu.console.service.Upload {
293 293

294 294
    @Path("/entryCheck")
295 295
    @Get
296
    public int entryCheck(@JdbcConn Connection con, String name, String email) throws SQLException, JfwBaseException {
296
    public int entryCheck(@JdbcConn Connection con, String name, String email) throws SQLException {
297 297
        OrgUser orgUser = this.orgUserDao.entryCheck(con, email);
298 298
        if (orgUser != null) {
299 299
            return 1;//该邮箱已被注册
@ -307,7 +307,7 @@ public class OrgService extends com.ekexiu.console.service.Upload {
307 307

308 308
    @Path("/editCheck")
309 309
    @Get
310
    public int editCheck(@JdbcConn Connection con, String name, String email,String id) throws SQLException, JfwBaseException {
310
    public int editCheck(@JdbcConn Connection con, String name, String email,String id) throws SQLException {
311 311
        String orgUserId = this.orgUserDao.queryByEmail(con, email);
312 312
        if ((orgUserId != null)&&(!Objects.equals(orgUserId, id))) {
313 313
            return 2;//该邮箱已被注册

+ 105 - 0
src/main/java/com/ekexiu/console/system/service/ProfessorService.java

@ -1,7 +1,9 @@
1 1
package com.ekexiu.console.system.service;
2 2
3
import com.ekexiu.console.system.dao.LuserDao;
3 4
import com.ekexiu.console.system.dao.OrgDao;
4 5
import com.ekexiu.console.system.dao.ProfessorDao;
6
import com.ekexiu.console.system.po.Luser;
5 7
import com.ekexiu.console.system.po.Professor;
6 8
import com.ekexiu.console.system.pojo.ProfessorInfo;
7 9
import com.ekexiu.console.system.pojo.UserDetail;
@ -17,12 +19,16 @@ import org.jfw.apt.web.annotation.operate.Put;
17 19
import org.jfw.apt.web.annotation.param.JdbcConn;
18 20
import org.jfw.apt.web.annotation.param.PathVar;
19 21
import org.jfw.apt.web.annotation.param.RequestBody;
22
import org.jfw.util.DateUtil;
20 23
import org.jfw.util.PageQueryResult;
21 24
import org.jfw.util.StringUtil;
25
import org.jfw.util.exception.JfwBaseException;
22 26
23 27
import java.io.IOException;
24 28
import java.sql.Connection;
25 29
import java.sql.SQLException;
30
import java.util.Objects;
31
import java.util.Random;
26 32
27 33
/**
28 34
 * Created by TT on 2017/5/25.
@ -30,12 +36,16 @@ import java.sql.SQLException;
30 36
@Path("/sys/professor")
31 37
public class ProfessorService {
32 38
39
    public static final String DEFAULT_PASS_WORD = "11111111111111111111111111111111";
40
33 41
    @Autowrie
34 42
    private ProfessorDao professorDao;
35 43
    @Autowrie
36 44
    private OrgDao orgDao;
37 45
    @Autowrie
38 46
    private OrgService orgService;
47
    @Autowrie
48
    private LuserDao luserDao;
39 49
40 50
    public OrgService getOrgService() {
41 51
        return orgService;
@ -61,6 +71,14 @@ public class ProfessorService {
61 71
        this.professorDao = professorDao;
62 72
    }
63 73
74
    public LuserDao getLuserDao() {
75
        return luserDao;
76
    }
77
78
    public void setLuserDao(LuserDao luserDao) {
79
        this.luserDao = luserDao;
80
    }
81
64 82
    @Post
65 83
    @Path
66 84
    public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName)
@ -160,4 +178,91 @@ public class ProfessorService {
160 178
    public void updateBusinessData(@JdbcConn(true) Connection con,String id,@Nullable int authentication,@Nullable int authStatus,@Nullable int authStatusExpert,int sortFirst)throws SQLException{
161 179
        this.professorDao.updateBusinessData(con, id, authentication, authStatus, authStatusExpert, sortFirst);
162 180
    }
181
182
    @Path("/createCheck")
183
    @Get
184
    public boolean entryCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email) throws SQLException {
185
        Luser luser1 = this.luserDao.check(con, mobile);
186
        Luser luser2 = this.luserDao.check(con, email);
187
        return luser1 == null && luser2 == null;
188
    }
189
190
    @Path("/updateCheck")
191
    @Get
192
    public int editCheck(@JdbcConn Connection con,@Nullable String mobile, @Nullable String email,String id) throws SQLException {
193
        String luserId = this.luserDao.queryByEmail(con, email);
194
        if ((luserId != null)&&(!Objects.equals(luserId, id))) {
195
            return 2;//该邮箱已被注册
196
        }
197
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
198
        if ((luserId1 != null) && (!Objects.equals(luserId1, id))) {
199
            return 3;//该手机已被注册
200
        }
201
        return 1;
202
    }
203
204
    @Post
205
    @Path("/createAccount")
206
    public void insert(@JdbcConn(true) Connection con,String name, @Nullable String mobile,@Nullable String email)throws SQLException,JfwBaseException {
207
208
        String luserId = this.luserDao.queryByEmail(con, email);
209
        if (luserId != null) {
210
            throw new JfwBaseException(40001, "邮箱已被注册");
211
        }
212
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
213
        if (luserId1 != null) {
214
            throw new JfwBaseException(40002, "该电话已被注册");
215
        }
216
        String id = StringUtil.buildUUID();
217
        Luser luser = new Luser();
218
        luser.setId(id);
219
        Random rd = new Random();
220
        int code = rd.nextInt(1000000);
221
        String inviteCode = String.format("%06d", code);
222
        luser.setInviteCode(inviteCode);
223
        luser.setEmail(email);
224
        luser.setMobilePhone(mobile);
225
        luser.setPasswd(DEFAULT_PASS_WORD);
226
        luser.setUserType("0");
227
        luser.setCreateTime(DateUtil.formatDateTime(System.currentTimeMillis()));
228
        this.luserDao.insert(con, luser);
229
230
        Professor professor = new Professor();
231
        professor.setId(id);
232
        professor.setName(name);
233
        professor.setEmail(email);
234
        professor.setPhone(mobile);
235
        professor.setAuthType(1);
236
        professor.setAuthStatus(0);
237
        professor.setAuthStatusExpert(0);
238
        professor.setSortFirst(0);
239
        professor.setProfessorState(0);
240
        professor.setAuthentication(0);
241
        professor.setOrgAuth("0");
242
        this.professorDao.insert(con, professor);
243
    }
244
245
    @Post
246
    @Path("/updateAccount")
247
    public void updateAccount(@JdbcConn(true) Connection con,@Nullable String mobile, @Nullable String email,String id) throws SQLException, JfwBaseException {
248
        String luserId = this.luserDao.queryByEmail(con, email);
249
        if ((luserId != null)&&(!Objects.equals(luserId, id))) {
250
            throw new JfwBaseException(40001, "该邮箱已被注册");
251
        }
252
        String luserId1 = this.luserDao.queryByPhone(con, mobile);
253
        if ((luserId1 != null) && (!Objects.equals(luserId1, id))) {
254
            throw new JfwBaseException(40002, "该电话已被注册");
255
        }
256
        this.luserDao.updateAccount(con, id, mobile, email);
257
    }
258
259
    @Get
260
    @Path("/luserId/{id}")
261
    public Luser queryAccount(@JdbcConn Connection con, @PathVar String id)throws SQLException {
262
        Luser luser = this.luserDao.query(con, id);
263
        if (luser != null) {
264
            luser.setPasswd(null);
265
        }
266
        return luser;
267
    }
163 268
}

+ 4 - 4
src/main/java/com/ekexiu/console/system/service/UserInfoService.java

@ -187,12 +187,12 @@ public class UserInfoService {
187 187
    @Path("/editCheck")
188 188
    @Get
189 189
    public Boolean editCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email,String id) throws SQLException {
190
        String orgId = this.userInfoDao.queryByKey(con, mobile);
191
        if ((orgId != null) && (!Objects.equals(orgId, id))){
190
        String userInfoId = this.userInfoDao.queryByKey(con, mobile);
191
        if ((userInfoId != null) && (!Objects.equals(userInfoId, id))){
192 192
            return false;
193 193
        }
194
        String orgId1 = this.userInfoDao.queryByKey(con, email);
195
        if ((orgId1 != null) && (!Objects.equals(orgId, id))){
194
        String userInfoId1 = this.userInfoDao.queryByKey(con, email);
195
        if ((userInfoId1 != null) && (!Objects.equals(userInfoId1, id))){
196 196
            return false;
197 197
        }
198 198
        Luser luser1 = this.luserDao.check(con, mobile);