parent
03f6b2b82c
commit
657eb1c980
@ -0,0 +1,13 @@
|
||||
// 常用,公共 mock
|
||||
|
||||
export function resultBody(result, code, message) {
|
||||
return {
|
||||
code: code || 0,
|
||||
message: message || '',
|
||||
...(result || null),
|
||||
};
|
||||
}
|
||||
|
||||
export default {
|
||||
resultBody,
|
||||
};
|
||||
@ -0,0 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import { Select } from 'antd';
|
||||
|
||||
export interface DictionaryObject {
|
||||
text?: string;
|
||||
value?: string | number | boolean;
|
||||
}
|
||||
|
||||
export interface IDictionarySelectProps extends Select {
|
||||
list?: DictionaryObject[];
|
||||
}
|
||||
|
||||
export default class DictionarySelectD extends React.Component<IDictionarySelectProps, any> {}
|
||||
@ -0,0 +1,20 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { Select } from 'antd';
|
||||
|
||||
export default class DictionarySelect extends PureComponent {
|
||||
renderOptions() {
|
||||
const { list } = this.props;
|
||||
return list.map(item => {
|
||||
return (
|
||||
<Select.Option key={item.value} value={item.value}>
|
||||
{item.text}
|
||||
</Select.Option>
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const options = this.renderOptions();
|
||||
return <Select {...this.props}>{options}</Select>;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
import { queryKey, queryText } from '../../services/dictionary';
|
||||
|
||||
export default {
|
||||
namespace: 'dictionarySelect',
|
||||
|
||||
state: {
|
||||
list: [],
|
||||
text: '',
|
||||
},
|
||||
|
||||
effects: {
|
||||
*query({ payload }, { call, put }) {
|
||||
const response = yield call(queryKey, payload);
|
||||
yield put({
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
list: response.list,
|
||||
},
|
||||
});
|
||||
},
|
||||
*queryText({ payload }, { call, put }) {
|
||||
const response = yield call(queryText, payload);
|
||||
yield put({
|
||||
type: 'querySuccess',
|
||||
payload: {
|
||||
text: response.text,
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
reducers: {
|
||||
querySuccess(state, { payload }) {
|
||||
return {
|
||||
...state,
|
||||
...payload,
|
||||
};
|
||||
},
|
||||
},
|
||||
};
|
||||
@ -0,0 +1,26 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { connect } from 'dva';
|
||||
import DictionarySelect from '../../components/Dictionary/DictionarySelect';
|
||||
|
||||
@connect(({ dictionarySelect, loading }) => ({
|
||||
data: dictionarySelect,
|
||||
loading: loading.models.dictionarySelect,
|
||||
}))
|
||||
class DictionaryValueSelect extends PureComponent {
|
||||
componentDidMount() {
|
||||
const { dataKey, dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'dictionarySelect/query',
|
||||
payload: {
|
||||
dataKey,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { data } = this.props;
|
||||
return <DictionarySelect {...this.props} list={data.list} />;
|
||||
}
|
||||
}
|
||||
|
||||
export default DictionaryValueSelect;
|
||||
@ -0,0 +1,26 @@
|
||||
import React, { PureComponent } from 'react';
|
||||
import { connect } from 'dva';
|
||||
|
||||
@connect(({ dictionarySelect, loading }) => ({
|
||||
data: dictionarySelect,
|
||||
loading: loading.models.dictionarySelect,
|
||||
}))
|
||||
class DictionaryValueText extends PureComponent {
|
||||
componentDidMount() {
|
||||
const { dataKey, dispatch } = this.props;
|
||||
dispatch({
|
||||
type: 'dictionarySelect/queryText',
|
||||
payload: {
|
||||
dataKey,
|
||||
value: 1,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { data } = this.props;
|
||||
return <span>{data.text}</span>;
|
||||
}
|
||||
}
|
||||
|
||||
export default DictionaryValueText;
|
||||
@ -0,0 +1,14 @@
|
||||
import { stringify } from '@/utils/request.qs';
|
||||
import request from '@/utils/request';
|
||||
|
||||
export async function queryKey(params) {
|
||||
return request(`/admin-api/admins/dictionary/getList?${stringify(params)}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
|
||||
export async function queryText(params) {
|
||||
return request(`/admin-api/admins/dictionary/queryText?${stringify(params)}`, {
|
||||
method: 'GET',
|
||||
});
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -0,0 +1,8 @@
|
||||
##################### 业务模块 #####################
|
||||
## MobileCodeService
|
||||
modules.mobile-code-service.code-expire-time-millis = 600000
|
||||
modules.mobile-code-service.send-maximum-quantity-per-day = 10
|
||||
modules.mobile-code-service.send-frequency = 60000
|
||||
## OAuth2CodeService
|
||||
modules.oauth2-code-service.access-token-expire-time-millis = 2880000
|
||||
modules.oauth2-code-service.refresh-token-expire-time-millis = 43200000
|
||||
@ -0,0 +1,32 @@
|
||||
spring:
|
||||
# datasource
|
||||
datasource:
|
||||
url: jdbc:mysql://127.0.0.1:33061/mall_user?useSSL=false
|
||||
driver-class-name: com.mysql.jdbc.Driver
|
||||
username: root
|
||||
password: 123456
|
||||
|
||||
# server
|
||||
server:
|
||||
port: 8082
|
||||
|
||||
# mybatis
|
||||
mybatis:
|
||||
config-location: classpath:mybatis-config.xml
|
||||
mapper-locations: classpath:mapper/*.xml
|
||||
type-aliases-package: cn.iocoder.mall.user.dataobject
|
||||
|
||||
# dubbo
|
||||
dubbo:
|
||||
application:
|
||||
name: user-service
|
||||
registry:
|
||||
address: zookeeper://127.0.0.1:2181
|
||||
protocol:
|
||||
port: -1
|
||||
name: dubbo
|
||||
scan:
|
||||
base-packages: cn.iocoder.mall.user.service
|
||||
demo:
|
||||
service:
|
||||
version: 1.0.0
|
||||
@ -0,0 +1,35 @@
|
||||
<?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">
|
||||
<mapper namespace="cn.iocoder.mall.user.dao.MobileCodeMapper">
|
||||
|
||||
<insert id="insert" parameterType="MobileCodeDO">
|
||||
INSERT INTO mobile_code (
|
||||
id, mobile, code, today_index, used,
|
||||
used_uid, used_time, create_time
|
||||
) VALUES (
|
||||
#{id}, #{mobile}, #{code}, #{todayIndex}, #{used},
|
||||
#{usedUid}, #{usedTime}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="MobileCodeDO">
|
||||
UPDATE mobile_code
|
||||
<set>
|
||||
<if test="used != null"> used = #{used}, </if>
|
||||
<if test="usedUid != null"> used_uid = #{usedUid}, </if>
|
||||
<if test="usedTime != null"> used_time = #{usedTime}, </if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<select id="selectLast1ByMobile" parameterType="String" resultType="MobileCodeDO">
|
||||
SELECT
|
||||
id, mobile, code, today_index, used,
|
||||
used_uid, used_time, create_time
|
||||
FROM mobile_code
|
||||
WHERE mobile = #{mobile}
|
||||
ORDER BY id DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,22 @@
|
||||
<?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">
|
||||
<mapper namespace="cn.iocoder.mall.user.dao.OAuth2AccessTokenMapper">
|
||||
|
||||
<insert id="insert" parameterType="OAuth2AccessTokenDO">
|
||||
INSERT INTO oauth2_access_token (
|
||||
id, refresh_token, adminId, valid, expires_time,
|
||||
create_time
|
||||
) VALUES (
|
||||
#{id}, #{refreshToken}, #{adminId}, #{valid}, #{expiresTime},
|
||||
#{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectByTokenId" parameterType="String" resultType="OAuth2AccessTokenDO">
|
||||
SELECT
|
||||
id, adminId, valid, expires_time
|
||||
FROM oauth2_access_token
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,13 @@
|
||||
<?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">
|
||||
<mapper namespace="cn.iocoder.mall.user.dao.OAuth2RefreshTokenMapper">
|
||||
|
||||
<insert id="insert" parameterType="OAuth2RefreshTokenDO">
|
||||
INSERT INTO oauth2_refresh_token (
|
||||
id, adminId, valid, expires_time, create_time
|
||||
) VALUES (
|
||||
#{id}, #{adminId}, #{valid}, #{expiresTime}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,20 @@
|
||||
<?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">
|
||||
<mapper namespace="cn.iocoder.mall.user.dao.UserMapper">
|
||||
|
||||
<insert id="insert" parameterType="UserDO" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO users (
|
||||
id, mobile, create_time
|
||||
) VALUES (
|
||||
#{id}, #{mobile}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<select id="selectByMobile" parameterType="String" resultType="UserDO">
|
||||
SELECT
|
||||
id, mobile
|
||||
FROM users
|
||||
WHERE mobile = #{mobile}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,13 @@
|
||||
<?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">
|
||||
<mapper namespace="cn.iocoder.mall.user.dao.UserRegisterMapper">
|
||||
|
||||
<insert id="insert" parameterType="UserRegisterDO">
|
||||
INSERT INTO user_register (
|
||||
id, create_time
|
||||
) VALUES (
|
||||
#{id}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
</mapper>
|
||||
@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
|
||||
<settings>
|
||||
<!-- 使用驼峰命名法转换字段。 -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
</settings>
|
||||
|
||||
<typeAliases>
|
||||
<typeAlias alias="Integer" type="java.lang.Integer"/>
|
||||
<typeAlias alias="Long" type="java.lang.Long"/>
|
||||
<typeAlias alias="HashMap" type="java.util.HashMap"/>
|
||||
<typeAlias alias="LinkedHashMap" type="java.util.LinkedHashMap"/>
|
||||
<typeAlias alias="ArrayList" type="java.util.ArrayList"/>
|
||||
<typeAlias alias="LinkedList" type="java.util.LinkedList"/>
|
||||
</typeAliases>
|
||||
|
||||
</configuration>
|
||||
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.mall.user.convert;
|
||||
|
||||
import cn.iocoder.mall.user.dataobject.OAuth2AccessTokenDO;
|
||||
import cn.iocoder.mall.user.service.api.bo.OAuth2AccessTokenBO;
|
||||
import cn.iocoder.mall.user.service.api.bo.OAuth2AuthenticationBO;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2019-03-05T10:35:05+0800",
|
||||
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
|
||||
)
|
||||
public class OAuth2ConvertImpl implements OAuth2Convert {
|
||||
|
||||
@Override
|
||||
public OAuth2AccessTokenBO convertToAccessToken(OAuth2AccessTokenDO oauth2AccessTokenDO) {
|
||||
if ( oauth2AccessTokenDO == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
OAuth2AccessTokenBO oAuth2AccessTokenBO = new OAuth2AccessTokenBO();
|
||||
|
||||
oAuth2AccessTokenBO.setAccessToken( oauth2AccessTokenDO.getId() );
|
||||
oAuth2AccessTokenBO.setRefreshToken( oauth2AccessTokenDO.getRefreshToken() );
|
||||
|
||||
return oAuth2AccessTokenBO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OAuth2AuthenticationBO convertToAuthentication(OAuth2AccessTokenDO oauth2AccessTokenDO) {
|
||||
if ( oauth2AccessTokenDO == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
OAuth2AuthenticationBO oAuth2AuthenticationBO = new OAuth2AuthenticationBO();
|
||||
|
||||
oAuth2AuthenticationBO.setUid( oauth2AccessTokenDO.getUid() );
|
||||
|
||||
return oAuth2AuthenticationBO;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.user.convert;
|
||||
|
||||
import cn.iocoder.mall.user.dataobject.UserDO;
|
||||
import cn.iocoder.mall.user.service.api.bo.UserBO;
|
||||
import javax.annotation.Generated;
|
||||
|
||||
@Generated(
|
||||
value = "org.mapstruct.ap.MappingProcessor",
|
||||
date = "2019-03-05T10:35:05+0800",
|
||||
comments = "version: 1.3.0.Final, compiler: javac, environment: Java 1.8.0_181 (Oracle Corporation)"
|
||||
)
|
||||
public class UserConvertImpl implements UserConvert {
|
||||
|
||||
@Override
|
||||
public UserBO convert(UserDO userDO) {
|
||||
if ( userDO == null ) {
|
||||
return null;
|
||||
}
|
||||
|
||||
UserBO userBO = new UserBO();
|
||||
|
||||
userBO.setMobile( userDO.getMobile() );
|
||||
|
||||
return userBO;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in new issue