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
import com.ekexiu.console.system.po.Article;
3
import com.ekexiu.console.system.po.Article;
4
import com.ekexiu.console.system.pojo.ArticleInfo;
4
import com.ekexiu.console.system.pojo.ArticleInfo;
5
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.annotation.Nullable;
6
import org.jfw.apt.orm.annotation.dao.Batch;
7
import org.jfw.apt.orm.annotation.dao.Column;
6
import org.jfw.apt.orm.annotation.dao.Column;
8
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.DAO;
9
import org.jfw.apt.orm.annotation.dao.method.From;
8
import org.jfw.apt.orm.annotation.dao.method.From;
25
@DAO
24
@DAO
26
public interface ArticleDao {
25
public interface ArticleDao {
27
26
27
    @Nullable
28
    @SelectOne
29
    Article query(Connection con, String articleId) throws SQLException;
30
28
    @Nullable
31
    @Nullable
29
    @QueryVal
32
    @QueryVal
30
    @Column(handlerClass = StringHandler.class, value = "article_title")
33
    @Column(handlerClass = StringHandler.class, value = "article_title")
45
    @UpdateWith
48
    @UpdateWith
46
    @From(Article.class)
49
    @From(Article.class)
47
    int[] updateStatus(Connection con,@Batch String[] articleId,@Set String status) throws SQLException;
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
2
3
import com.ekexiu.console.system.po.Luser;
3
import com.ekexiu.console.system.po.Luser;
4
import org.jfw.apt.annotation.Nullable;
4
import org.jfw.apt.annotation.Nullable;
5
import org.jfw.apt.orm.annotation.dao.Column;
5
import org.jfw.apt.orm.annotation.dao.DAO;
6
import org.jfw.apt.orm.annotation.dao.DAO;
7
import org.jfw.apt.orm.annotation.dao.method.From;
6
import org.jfw.apt.orm.annotation.dao.method.Or;
8
import org.jfw.apt.orm.annotation.dao.method.Or;
7
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
9
import org.jfw.apt.orm.annotation.dao.method.operator.Insert;
10
import org.jfw.apt.orm.annotation.dao.method.operator.QueryVal;
8
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
11
import org.jfw.apt.orm.annotation.dao.method.operator.SelectOne;
12
import org.jfw.apt.orm.annotation.dao.method.operator.UpdateWith;
9
import org.jfw.apt.orm.annotation.dao.param.Alias;
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
import java.sql.Connection;
17
import java.sql.Connection;
12
import java.sql.SQLException;
18
import java.sql.SQLException;
24
30
25
    @Insert
31
    @Insert
26
    int insert(Connection con,Luser user)throws SQLException;
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
import org.jfw.apt.orm.annotation.entry.Table;
7
import org.jfw.apt.orm.annotation.entry.Table;
8
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
8
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
9
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
9
import org.jfw.apt.orm.core.defaultImpl.IntHandler;
10
import org.jfw.apt.orm.core.defaultImpl.LongHandler;
10
import org.jfw.apt.orm.core.enums.DE;
11
import org.jfw.apt.orm.core.enums.DE;
11
12
12
/**
13
/**
31
    private int pageViews;
32
    private int pageViews;
32
    private String status;
33
    private String status;
33
    private long shareId;
34
    private long shareId;
35
    private long sortNum;
34
36
35
    @Column(DE.id_32)
37
    @Column(DE.id_32)
36
    public String getArticleId() {
38
    public String getArticleId() {
143
        this.shareId = shareId;
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
package com.ekexiu.console.system.service;
1
package com.ekexiu.console.system.service;
2
2
3
import com.ekexiu.console.system.dao.ArticleDao;
3
import com.ekexiu.console.system.dao.ArticleDao;
4
import com.ekexiu.console.system.po.Article;
4
import com.ekexiu.console.system.pojo.ArticleInfo;
5
import com.ekexiu.console.system.pojo.ArticleInfo;
5
import org.jfw.apt.annotation.Autowrie;
6
import org.jfw.apt.annotation.Autowrie;
6
import org.jfw.apt.annotation.DefaultValue;
7
import org.jfw.apt.annotation.DefaultValue;
9
import org.jfw.apt.web.annotation.operate.Get;
10
import org.jfw.apt.web.annotation.operate.Get;
10
import org.jfw.apt.web.annotation.operate.Post;
11
import org.jfw.apt.web.annotation.operate.Post;
11
import org.jfw.apt.web.annotation.param.JdbcConn;
12
import org.jfw.apt.web.annotation.param.JdbcConn;
13
import org.jfw.apt.web.annotation.param.PathVar;
12
import org.jfw.util.PageQueryResult;
14
import org.jfw.util.PageQueryResult;
13
15
14
import java.sql.Connection;
16
import java.sql.Connection;
48
        //修改文章状态为删除
50
        //修改文章状态为删除
49
        this.articleDao.updateStatus(con, articleIds, "3");
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

293

294
    @Path("/entryCheck")
294
    @Path("/entryCheck")
295
    @Get
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
        OrgUser orgUser = this.orgUserDao.entryCheck(con, email);
297
        OrgUser orgUser = this.orgUserDao.entryCheck(con, email);
298
        if (orgUser != null) {
298
        if (orgUser != null) {
299
            return 1;//该邮箱已被注册
299
            return 1;//该邮箱已被注册
307

307

308
    @Path("/editCheck")
308
    @Path("/editCheck")
309
    @Get
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
        String orgUserId = this.orgUserDao.queryByEmail(con, email);
311
        String orgUserId = this.orgUserDao.queryByEmail(con, email);
312
        if ((orgUserId != null)&&(!Objects.equals(orgUserId, id))) {
312
        if ((orgUserId != null)&&(!Objects.equals(orgUserId, id))) {
313
            return 2;//该邮箱已被注册
313
            return 2;//该邮箱已被注册

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

1
package com.ekexiu.console.system.service;
1
package com.ekexiu.console.system.service;
2
2
3
import com.ekexiu.console.system.dao.LuserDao;
3
import com.ekexiu.console.system.dao.OrgDao;
4
import com.ekexiu.console.system.dao.OrgDao;
4
import com.ekexiu.console.system.dao.ProfessorDao;
5
import com.ekexiu.console.system.dao.ProfessorDao;
6
import com.ekexiu.console.system.po.Luser;
5
import com.ekexiu.console.system.po.Professor;
7
import com.ekexiu.console.system.po.Professor;
6
import com.ekexiu.console.system.pojo.ProfessorInfo;
8
import com.ekexiu.console.system.pojo.ProfessorInfo;
7
import com.ekexiu.console.system.pojo.UserDetail;
9
import com.ekexiu.console.system.pojo.UserDetail;
17
import org.jfw.apt.web.annotation.param.JdbcConn;
19
import org.jfw.apt.web.annotation.param.JdbcConn;
18
import org.jfw.apt.web.annotation.param.PathVar;
20
import org.jfw.apt.web.annotation.param.PathVar;
19
import org.jfw.apt.web.annotation.param.RequestBody;
21
import org.jfw.apt.web.annotation.param.RequestBody;
22
import org.jfw.util.DateUtil;
20
import org.jfw.util.PageQueryResult;
23
import org.jfw.util.PageQueryResult;
21
import org.jfw.util.StringUtil;
24
import org.jfw.util.StringUtil;
25
import org.jfw.util.exception.JfwBaseException;
22
26
23
import java.io.IOException;
27
import java.io.IOException;
24
import java.sql.Connection;
28
import java.sql.Connection;
25
import java.sql.SQLException;
29
import java.sql.SQLException;
30
import java.util.Objects;
31
import java.util.Random;
26
32
27
/**
33
/**
28
 * Created by TT on 2017/5/25.
34
 * Created by TT on 2017/5/25.
30
@Path("/sys/professor")
36
@Path("/sys/professor")
31
public class ProfessorService {
37
public class ProfessorService {
32
38
39
    public static final String DEFAULT_PASS_WORD = "11111111111111111111111111111111";
40
33
    @Autowrie
41
    @Autowrie
34
    private ProfessorDao professorDao;
42
    private ProfessorDao professorDao;
35
    @Autowrie
43
    @Autowrie
36
    private OrgDao orgDao;
44
    private OrgDao orgDao;
37
    @Autowrie
45
    @Autowrie
38
    private OrgService orgService;
46
    private OrgService orgService;
47
    @Autowrie
48
    private LuserDao luserDao;
39
49
40
    public OrgService getOrgService() {
50
    public OrgService getOrgService() {
41
        return orgService;
51
        return orgService;
61
        this.professorDao = professorDao;
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
    @Post
82
    @Post
65
    @Path
83
    @Path
66
    public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName)
84
    public String insert(@JdbcConn(true) Connection con, Professor professor, @Nullable String orgName)
160
    public void updateBusinessData(@JdbcConn(true) Connection con,String id,@Nullable int authentication,@Nullable int authStatus,@Nullable int authStatusExpert,int sortFirst)throws SQLException{
178
    public void updateBusinessData(@JdbcConn(true) Connection con,String id,@Nullable int authentication,@Nullable int authStatus,@Nullable int authStatusExpert,int sortFirst)throws SQLException{
161
        this.professorDao.updateBusinessData(con, id, authentication, authStatus, authStatusExpert, sortFirst);
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
    @Path("/editCheck")
187
    @Path("/editCheck")
188
    @Get
188
    @Get
189
    public Boolean editCheck(@JdbcConn Connection con, @Nullable String mobile, @Nullable String email,String id) throws SQLException {
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
            return false;
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
            return false;
196
            return false;
197
        }
197
        }
198
        Luser luser1 = this.luserDao.check(con, mobile);
198
        Luser luser1 = this.luserDao.check(con, mobile);