XMTT 6 years ago
parent
commit
21ab4e6921

+ 104 - 0
src/main/java/com/ekexiu/portal/platform/Console.java

@ -0,0 +1,104 @@
1
package com.ekexiu.portal.platform;
2
3
import org.jfw.apt.annotation.Autowrie;
4
import org.jfw.apt.web.annotation.Path;
5
import org.jfw.apt.web.annotation.operate.Get;
6
import org.jfw.apt.web.annotation.operate.Post;
7
import org.jfw.apt.web.annotation.param.JdbcConn;
8
import org.jfw.apt.web.annotation.param.PathVar;
9
import org.jfw.util.StringUtil;
10
11
import java.sql.Connection;
12
import java.sql.SQLException;
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.Objects;
16
17
/**
18
 * Created by TT on 2018/5/21.
19
 */
20
@Path("/platformConsole")
21
public class Console {
22
23
    @Autowrie
24
    private PlatformDao platformDao;
25
26
    public PlatformDao getPlatformDao() {
27
        return platformDao;
28
    }
29
30
    public void setPlatformDao(PlatformDao platformDao) {
31
        this.platformDao = platformDao;
32
    }
33
34
    /*
35
	运营系统使用
36
	 */
37
    @Path("/createAccount")
38
    @Post
39
    public void createAccount(@JdbcConn(true) Connection con, String name, String email) throws SQLException {
40
        String id = StringUtil.buildUUID();
41
        PlatformUser platformUser = new PlatformUser();
42
        platformUser.setId(id);
43
        platformUser.setEmail(email);
44
        platformUser.setPasswd(StringUtil.md5("123456"));
45
        platformUser.setState("1");
46
        this.platformDao.insert(con, platformUser);
47
        PlatformInfo platformInfo = new PlatformInfo();
48
        platformInfo.setId(id);
49
        platformInfo.setName(name);
50
        this.platformDao.insert(con, platformInfo);
51
    }
52
53
    @Path("/updateAccount")
54
    @Post
55
    public void updateAccount(@JdbcConn(true) Connection con, String id, String name, String email) throws SQLException {
56
        this.platformDao.updateEmail(con, id, email);
57
        this.platformDao.updateName(con, id, name);
58
    }
59
60
    @Path("/createCheck")
61
    @Get
62
    public int createCheck(@JdbcConn Connection con, String name, String email) throws SQLException {
63
        PlatformUser platformUser = this.platformDao.queryUser(con, email);
64
        if (platformUser != null) {
65
            return 2;//该邮箱已被注册
66
        }
67
        PlatformInfo platformInfo = this.platformDao.queryInfoByName(con, name);
68
        if ((platformInfo != null) && (this.platformDao.queryUserById(con, platformInfo.getId()) != null)) {
69
            return 3;//该平台已注册帐号
70
        }
71
        return 1;//可以创建
72
    }
73
74
    @Path("/editCheck")
75
    @Get
76
    public int editCheck(@JdbcConn Connection con, String id, String name, String email) throws SQLException {
77
        PlatformUser platformUser = this.platformDao.queryUser(con, email);
78
        if ((platformUser != null)&&(!Objects.equals(platformUser.getId(), id))) {
79
            return 2;//该邮箱已被注册
80
        }
81
        PlatformInfo platformInfo = this.platformDao.queryInfoByName(con, name);
82
        if ((platformInfo != null) && (!Objects.equals(platformInfo.getId(), id))) {
83
            return 3;//该平台已注册帐号
84
        }
85
        return 1;
86
    }
87
88
    @Get
89
    @Path("/queryAccount/{id}")
90
    public Map<String, Object> queryAccount(@JdbcConn Connection con,@PathVar String id)throws SQLException {
91
        PlatformInfo platformInfo = this.platformDao.queryInfo(con, id);
92
        PlatformUser platformUser = this.platformDao.queryUserById(con, id);
93
        Map<String, Object> map = new HashMap<String, Object>();
94
        map.put("id", id);
95
        map.put("email", platformUser.getEmail());
96
        map.put("name", platformInfo.getName());
97
        return map;
98
    }
99
100
101
102
103
104
}

+ 24 - 4
src/main/java/com/ekexiu/portal/platform/PlatformDao.java

@ -1,9 +1,5 @@
1 1
package com.ekexiu.portal.platform;
2 2

3
import java.sql.Connection;
4
import java.sql.SQLException;
5
import java.util.List;
6

7 3
import org.jfw.apt.annotation.Nullable;
8 4
import org.jfw.apt.orm.annotation.dao.DAO;
9 5
import org.jfw.apt.orm.annotation.dao.method.Exclude;
@ -28,6 +24,10 @@ import org.jfw.apt.orm.annotation.dao.param.SqlColumn;
28 24
import org.jfw.apt.orm.core.defaultImpl.StringHandler;
29 25
import org.jfw.util.PageQueryResult;
30 26

27
import java.sql.Connection;
28
import java.sql.SQLException;
29
import java.util.List;
30

31 31
@DAO
32 32
public interface PlatformDao {
33 33

@ -172,4 +172,24 @@ public interface PlatformDao {
172 172
	PageQueryResult<ButtedProfessorInfo> queryButtedProfessorInfo(Connection con,
173 173
			@SqlColumn(handlerClass = StringHandler.class, value = { "B.PID=?" }) String pid, int pageSize, int pageNo) throws SQLException;
174 174

175
	/*
176
	运营系统
177
	 */
178
	@Insert
179
	int insert(Connection con, PlatformInfo platformInfo) throws SQLException;
180

181
	@Insert
182
	int insert(Connection con, PlatformUser platformUser) throws SQLException;
183

184
	@UpdateWith
185
	@From(PlatformUser.class)
186
	int updateEmail(Connection con, String id, @Set String email) throws SQLException;
187

188
	@UpdateWith
189
	@From(PlatformInfo.class)
190
	int updateName(Connection con,String id,@Set String name)throws SQLException;
191

192
	@Nullable
193
	@SelectOne
194
	PlatformInfo queryInfoByName(Connection con, String name) throws SQLException;
175 195
}

+ 3 - 0
src/main/java/com/ekexiu/portal/platform/PlatformInfo.java

@ -3,6 +3,8 @@ package com.ekexiu.portal.platform;
3 3
import org.jfw.apt.orm.annotation.entry.Column;
4 4
import org.jfw.apt.orm.annotation.entry.PrimaryKey;
5 5
import org.jfw.apt.orm.annotation.entry.Table;
6
import org.jfw.apt.orm.annotation.entry.Unique;
7
import org.jfw.apt.orm.annotation.entry.Uniques;
6 8
import org.jfw.apt.orm.core.defaultImpl.FixLenStringHandler;
7 9
import org.jfw.apt.orm.core.enums.DE;
8 10

@ -11,6 +13,7 @@ import org.jfw.apt.orm.core.enums.DE;
11 13
 * @author Saga
12 14
 *
13 15
 */
16
@Uniques(@Unique(name="PLATFORMINFO_NAME_UN",clolumns="name"))
14 17
@PrimaryKey("id")
15 18
@Table
16 19
public class PlatformInfo {

+ 1 - 0
src/main/resources/database.sql

@ -2295,6 +2295,7 @@ CREATE TABLE PLATFORM_INFO (
2295 2295
	CREATE_TIME CHAR(14) NOT NULL,
2296 2296
	MODIFY_TIME CHAR(14) NOT NULL);
2297 2297
ALTER TABLE PLATFORM_INFO ADD PRIMARY KEY (ID);
2298
ALTER TABLE PLATFORM_INFO ADD UNIQUE (name);
2298 2299

2299 2300
COMMENT ON TABLE PLATFORM_INFO is '平台信息表';
2300 2301
COMMENT ON COLUMN PLATFORM_INFO.NAME is '平台名称';