Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
42d8ff5f
Commit
42d8ff5f
authored
Apr 13, 2018
by
zhh
Browse files
初始项目信息导入
parents
Changes
293
Hide whitespace changes
Inline
Side-by-side
mall-demo/src/main/java/com/macro/mall/MallDemoApplication.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall
;
import
org.mybatis.spring.annotation.MapperScan
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.web.servlet.config.annotation.ViewControllerRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter
;
@SpringBootApplication
@MapperScan
(
"com.macro.mall.mapper"
)
public
class
MallDemoApplication
extends
WebMvcConfigurerAdapter
{
@Override
public
void
addViewControllers
(
ViewControllerRegistry
registry
)
{
registry
.
addViewController
(
"/login"
).
setViewName
(
"login"
);
}
public
static
void
main
(
String
[]
args
)
{
SpringApplication
.
run
(
MallDemoApplication
.
class
,
args
);
}
}
mall-demo/src/main/java/com/macro/mall/demo/bo/AdminUserDetails.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.bo
;
import
com.macro.mall.model.UmsAdmin
;
import
org.springframework.security.core.GrantedAuthority
;
import
org.springframework.security.core.authority.SimpleGrantedAuthority
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
java.util.Arrays
;
import
java.util.Collection
;
/**
* SpringSecurity需要的用户详情
*/
public
class
AdminUserDetails
implements
UserDetails
{
private
UmsAdmin
umsAdmin
;
public
AdminUserDetails
(
UmsAdmin
umsAdmin
)
{
this
.
umsAdmin
=
umsAdmin
;
}
@Override
public
Collection
<?
extends
GrantedAuthority
>
getAuthorities
()
{
//返回当前用户的权限
return
Arrays
.
asList
(
new
SimpleGrantedAuthority
(
"TEST"
));
}
@Override
public
String
getPassword
()
{
return
umsAdmin
.
getPassword
();
}
@Override
public
String
getUsername
()
{
return
umsAdmin
.
getUsername
();
}
@Override
public
boolean
isAccountNonExpired
()
{
return
true
;
}
@Override
public
boolean
isAccountNonLocked
()
{
return
true
;
}
@Override
public
boolean
isCredentialsNonExpired
()
{
return
true
;
}
@Override
public
boolean
isEnabled
()
{
return
true
;
}
}
mall-demo/src/main/java/com/macro/mall/demo/bo/CommonResult.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.bo
;
import
com.github.pagehelper.PageInfo
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 通用返回对象
*/
public
class
CommonResult
{
public
static
final
int
SUCCESS
=
0
;
public
static
final
int
FAILED
=
1
;
public
static
final
int
VALIDATE_FAILED
=
2
;
private
int
code
;
private
String
message
;
private
Object
data
;
/**
* 普通成功返回
*
* @param data 获取的数据
*/
public
CommonResult
success
(
Object
data
)
{
this
.
code
=
SUCCESS
;
this
.
message
=
"操作成功"
;
this
.
data
=
data
;
return
this
;
}
/**
* 返回分页成功数据
*/
public
CommonResult
pageSuccess
(
List
data
)
{
PageInfo
pageInfo
=
new
PageInfo
(
data
);
long
totalPage
=
pageInfo
.
getTotal
()
/
pageInfo
.
getPageSize
();
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"pageSize"
,
pageInfo
.
getPageSize
());
result
.
put
(
"totalPage"
,
totalPage
);
result
.
put
(
"pageNum"
,
pageInfo
.
getPageNum
());
result
.
put
(
"list"
,
pageInfo
.
getList
());
this
.
code
=
SUCCESS
;
this
.
message
=
"操作成功"
;
this
.
data
=
result
;
return
this
;
}
/**
* 普通失败提示信息
*/
public
CommonResult
failed
()
{
this
.
code
=
FAILED
;
this
.
message
=
"操作失败"
;
return
this
;
}
/**
* 参数验证失败使用
*
* @param message 错误信息
*/
public
CommonResult
validateFailed
(
String
message
)
{
this
.
code
=
VALIDATE_FAILED
;
this
.
message
=
message
;
return
this
;
}
public
int
getCode
()
{
return
code
;
}
public
void
setCode
(
int
code
)
{
this
.
code
=
code
;
}
public
String
getMessage
()
{
return
message
;
}
public
void
setMessage
(
String
message
)
{
this
.
message
=
message
;
}
public
Object
getData
()
{
return
data
;
}
public
void
setData
(
Object
data
)
{
this
.
data
=
data
;
}
}
mall-demo/src/main/java/com/macro/mall/demo/config/SecurityConfig.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.config
;
import
com.macro.mall.demo.bo.AdminUserDetails
;
import
com.macro.mall.mapper.UmsAdminMapper
;
import
com.macro.mall.model.UmsAdmin
;
import
com.macro.mall.model.UmsAdminExample
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.security.authentication.encoding.Md5PasswordEncoder
;
import
org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder
;
import
org.springframework.security.config.annotation.web.builders.HttpSecurity
;
import
org.springframework.security.config.annotation.web.configuration.EnableWebSecurity
;
import
org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter
;
import
org.springframework.security.core.userdetails.UserDetails
;
import
org.springframework.security.core.userdetails.UserDetailsService
;
import
org.springframework.security.core.userdetails.UsernameNotFoundException
;
import
java.util.List
;
/**
* SpringSecurity的配置
*/
@Configuration
@EnableWebSecurity
public
class
SecurityConfig
extends
WebSecurityConfigurerAdapter
{
@Autowired
private
UmsAdminMapper
umsAdminMapper
;
@Override
protected
void
configure
(
HttpSecurity
http
)
throws
Exception
{
http
.
authorizeRequests
()
//配置权限
// .antMatchers("/").access("hasRole('TEST')")//该路径需要TEST角色
// .antMatchers("/brand/list").authenticated()//该路径需要登录认证
// .antMatchers("/brand/list").hasAuthority("TEST")//该路径需要TEST权限
.
antMatchers
(
"/**"
).
permitAll
()
.
and
()
//启用基于http的认证
.
httpBasic
()
.
realmName
(
"/"
)
.
and
()
//配置登录页面
.
formLogin
()
.
loginPage
(
"/login"
)
.
failureUrl
(
"/login?error=true"
)
.
and
()
//配置退出路径
.
logout
()
.
logoutSuccessUrl
(
"/"
)
// .and()//记住密码功能
// .rememberMe()
// .tokenValiditySeconds(60*60*24)
// .key("rememberMeKey")
.
and
()
//关闭跨域伪造
.
csrf
()
.
disable
();
}
@Override
protected
void
configure
(
AuthenticationManagerBuilder
auth
)
throws
Exception
{
auth
.
userDetailsService
(
userDetailsService
()).
passwordEncoder
(
new
Md5PasswordEncoder
());
}
@Bean
public
UserDetailsService
userDetailsService
()
{
//获取登录用户信息
return
new
UserDetailsService
()
{
@Override
public
UserDetails
loadUserByUsername
(
String
username
)
throws
UsernameNotFoundException
{
UmsAdminExample
example
=
new
UmsAdminExample
();
example
.
createCriteria
().
andUsernameEqualTo
(
username
);
List
<
UmsAdmin
>
umsAdminList
=
umsAdminMapper
.
selectByExample
(
example
);
if
(
umsAdminList
!=
null
&&
umsAdminList
.
size
()
>
0
)
{
return
new
AdminUserDetails
(
umsAdminList
.
get
(
0
));
}
throw
new
UsernameNotFoundException
(
"用户名或密码错误"
);
}
};
}
}
mall-demo/src/main/java/com/macro/mall/demo/config/Swagger2Config.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.config
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
springfox.documentation.builders.ApiInfoBuilder
;
import
springfox.documentation.builders.PathSelectors
;
import
springfox.documentation.builders.RequestHandlerSelectors
;
import
springfox.documentation.service.ApiInfo
;
import
springfox.documentation.spi.DocumentationType
;
import
springfox.documentation.spring.web.plugins.Docket
;
import
springfox.documentation.swagger2.annotations.EnableSwagger2
;
/**
* Swagger2API文档的配置
*/
@Configuration
@EnableSwagger2
public
class
Swagger2Config
{
@Bean
public
Docket
createRestApi
(){
return
new
Docket
(
DocumentationType
.
SWAGGER_2
)
.
apiInfo
(
apiInfo
())
.
select
()
.
apis
(
RequestHandlerSelectors
.
basePackage
(
"com.macro.mall.demo"
))
.
paths
(
PathSelectors
.
any
())
.
build
();
}
private
ApiInfo
apiInfo
()
{
return
new
ApiInfoBuilder
()
.
title
(
"SwaggerUI演示"
)
.
description
(
"Demo模块"
)
.
contact
(
"macro"
)
.
version
(
"1.0"
)
.
build
();
}
}
mall-demo/src/main/java/com/macro/mall/demo/controller/DemoController.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.controller
;
import
com.macro.mall.demo.bo.CommonResult
;
import
com.macro.mall.demo.dto.PmsBrandDto
;
import
com.macro.mall.demo.service.DemoService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.ui.Model
;
import
org.springframework.validation.BindingResult
;
import
org.springframework.validation.annotation.Validated
;
import
org.springframework.web.bind.annotation.*
;
/**
* 测试controller
*/
@Api
(
value
=
"demo"
,
description
=
"demo详情"
)
@Controller
public
class
DemoController
{
@Autowired
private
DemoService
demoService
;
private
static
final
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
DemoController
.
class
);
@ApiOperation
(
value
=
"此处为首页"
)
@RequestMapping
(
value
=
"/"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
String
hello
()
{
return
"This is home!"
;
}
@ApiOperation
(
value
=
"获取品牌列表界面(网页显示)"
)
@RequestMapping
(
value
=
"/list"
,
method
=
RequestMethod
.
GET
)
public
String
getBrandListPage
(
Model
model
)
{
model
.
addAttribute
(
"brandList"
,
demoService
.
listAllBrand
());
return
"demo"
;
}
@ApiOperation
(
value
=
"获取全部品牌列表"
)
@RequestMapping
(
value
=
"/brand/listAll"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
getBrandList
()
{
return
new
CommonResult
().
success
(
demoService
.
listAllBrand
());
}
@ApiOperation
(
value
=
"添加品牌"
)
@RequestMapping
(
value
=
"/brand/create"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
createBrand
(
@Validated
@RequestBody
PmsBrandDto
pmsBrand
,
BindingResult
result
)
{
if
(
result
.
hasErrors
())
{
return
new
CommonResult
().
validateFailed
(
result
.
getFieldError
().
getDefaultMessage
());
}
CommonResult
commonResult
;
int
count
=
demoService
.
createBrand
(
pmsBrand
);
if
(
count
==
1
)
{
commonResult
=
new
CommonResult
().
success
(
pmsBrand
);
LOGGER
.
debug
(
"createBrand success:{}"
,
pmsBrand
);
}
else
{
commonResult
=
new
CommonResult
().
failed
();
LOGGER
.
debug
(
"createBrand failed:{}"
,
pmsBrand
);
}
return
commonResult
;
}
@ApiOperation
(
value
=
"更新品牌"
)
@RequestMapping
(
value
=
"/brand/update/{id}"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
updateBrand
(
@PathVariable
(
"id"
)
Long
id
,
@Validated
@RequestBody
PmsBrandDto
pmsBrandDto
,
BindingResult
result
)
{
if
(
result
.
hasErrors
()){
return
new
CommonResult
().
validateFailed
(
result
.
getFieldError
().
getDefaultMessage
());
}
CommonResult
commonResult
;
int
count
=
demoService
.
updateBrand
(
id
,
pmsBrandDto
);
if
(
count
==
1
)
{
commonResult
=
new
CommonResult
().
success
(
pmsBrandDto
);
LOGGER
.
debug
(
"updateBrand success:{}"
,
pmsBrandDto
);
}
else
{
commonResult
=
new
CommonResult
().
failed
();
LOGGER
.
debug
(
"updateBrand failed:{}"
,
pmsBrandDto
);
}
return
commonResult
;
}
@ApiOperation
(
value
=
"删除品牌"
)
@RequestMapping
(
value
=
"/brand/delete/{id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
deleteBrand
(
@PathVariable
(
"id"
)
Long
id
)
{
int
count
=
demoService
.
deleteBrand
(
id
);
if
(
count
==
1
)
{
LOGGER
.
debug
(
"deleteBrand success :id={}"
,
id
);
return
new
CommonResult
().
success
(
null
);
}
else
{
LOGGER
.
debug
(
"deleteBrand failed :id={}"
,
id
);
return
new
CommonResult
().
failed
();
}
}
@ApiOperation
(
value
=
"分页获取品牌列表"
)
@RequestMapping
(
value
=
"/brand/list"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
listBrand
(
@RequestParam
(
value
=
"pageNum"
,
defaultValue
=
"1"
)
Integer
pageNum
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"3"
)
Integer
pageSize
)
{
return
new
CommonResult
().
pageSuccess
(
demoService
.
listBrand
(
pageNum
,
pageSize
));
}
@ApiOperation
(
value
=
"根据编号查询品牌信息"
)
@RequestMapping
(
value
=
"/brand/{id}"
,
method
=
RequestMethod
.
GET
)
@ResponseBody
public
Object
brand
(
@PathVariable
(
"id"
)
Long
id
)
{
return
new
CommonResult
().
success
(
demoService
.
getBrand
(
id
));
}
}
mall-demo/src/main/java/com/macro/mall/demo/dto/PmsBrandDto.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.dto
;
import
com.macro.mall.demo.validator.FlagValidator
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
javax.validation.constraints.Min
;
import
javax.validation.constraints.NotNull
;
/**
* 品牌传递参数
*/
@ApiModel
(
value
=
"PmsBrandDto"
)
public
class
PmsBrandDto
{
@ApiModelProperty
(
value
=
"品牌名称"
,
required
=
true
)
@NotNull
(
message
=
"名称不能为空"
)
private
String
name
;
@ApiModelProperty
(
value
=
"品牌首字母"
,
required
=
true
)
@NotNull
(
message
=
"首字母不能为空"
)
private
String
firstLetter
;
@ApiModelProperty
(
value
=
"排序字段"
)
@Min
(
value
=
0
,
message
=
"排序最小为0"
)
private
Integer
sort
;
@ApiModelProperty
(
value
=
"是否为厂家制造商"
)
@FlagValidator
(
values
=
{
"0"
,
"1"
},
message
=
"厂家状态不正确"
)
private
Integer
factoryStatus
;
@ApiModelProperty
(
value
=
"是否进行显示"
)
@FlagValidator
(
values
=
{
"0"
,
"1"
},
message
=
"显示状态不正确"
)
private
Integer
showStatus
;
@ApiModelProperty
(
value
=
"品牌logo"
)
private
String
logo
;
@ApiModelProperty
(
value
=
"品牌大图"
)
private
String
bigPic
;
@ApiModelProperty
(
value
=
"品牌故事"
)
private
String
brandStory
;
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getFirstLetter
()
{
return
firstLetter
;
}
public
void
setFirstLetter
(
String
firstLetter
)
{
this
.
firstLetter
=
firstLetter
;
}
public
Integer
getSort
()
{
return
sort
;
}
public
void
setSort
(
Integer
sort
)
{
this
.
sort
=
sort
;
}
public
Integer
getFactoryStatus
()
{
return
factoryStatus
;
}
public
void
setFactoryStatus
(
Integer
factoryStatus
)
{
this
.
factoryStatus
=
factoryStatus
;
}
public
Integer
getShowStatus
()
{
return
showStatus
;
}
public
void
setShowStatus
(
Integer
showStatus
)
{
this
.
showStatus
=
showStatus
;
}
public
String
getLogo
()
{
return
logo
;
}
public
void
setLogo
(
String
logo
)
{
this
.
logo
=
logo
;
}
public
String
getBigPic
()
{
return
bigPic
;
}
public
void
setBigPic
(
String
bigPic
)
{
this
.
bigPic
=
bigPic
;
}
public
String
getBrandStory
()
{
return
brandStory
;
}
public
void
setBrandStory
(
String
brandStory
)
{
this
.
brandStory
=
brandStory
;
}
}
mall-demo/src/main/java/com/macro/mall/demo/service/DemoService.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.service
;
import
com.macro.mall.demo.dto.PmsBrandDto
;
import
com.macro.mall.model.PmsBrand
;
import
java.util.List
;
/**
* DemoService接口
*/
public
interface
DemoService
{
List
<
PmsBrand
>
listAllBrand
();
int
createBrand
(
PmsBrandDto
pmsBrandDto
);
int
updateBrand
(
Long
id
,
PmsBrandDto
pmsBrandDto
);
int
deleteBrand
(
Long
id
);
List
<
PmsBrand
>
listBrand
(
int
pageNum
,
int
pageSize
);
PmsBrand
getBrand
(
Long
id
);
}
mall-demo/src/main/java/com/macro/mall/demo/service/impl/DemoServiceImpl.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.service.impl
;
import
com.github.pagehelper.PageHelper
;
import
com.macro.mall.demo.dto.PmsBrandDto
;
import
com.macro.mall.demo.service.DemoService
;
import
com.macro.mall.mapper.PmsBrandMapper
;
import
com.macro.mall.model.PmsBrand
;
import
com.macro.mall.model.PmsBrandExample
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
/**
* DemoService实现类
*/
@Service
public
class
DemoServiceImpl
implements
DemoService
{
@Autowired
private
PmsBrandMapper
brandMapper
;
@Override
public
List
<
PmsBrand
>
listAllBrand
()
{
return
brandMapper
.
selectByExample
(
new
PmsBrandExample
());
}
@Override
public
int
createBrand
(
PmsBrandDto
pmsBrandDto
)
{
PmsBrand
pmsBrand
=
new
PmsBrand
();
BeanUtils
.
copyProperties
(
pmsBrandDto
,
pmsBrand
);
return
brandMapper
.
insertSelective
(
pmsBrand
);
}
@Override
public
int
updateBrand
(
Long
id
,
PmsBrandDto
pmsBrandDto
)
{
PmsBrand
pmsBrand
=
new
PmsBrand
();
BeanUtils
.
copyProperties
(
pmsBrandDto
,
pmsBrand
);
pmsBrand
.
setId
(
id
);
return
brandMapper
.
updateByPrimaryKeySelective
(
pmsBrand
);
}
@Override
public
int
deleteBrand
(
Long
id
)
{
return
brandMapper
.
deleteByPrimaryKey
(
id
);
}
@Override
public
List
<
PmsBrand
>
listBrand
(
int
pageNum
,
int
pageSize
)
{
PageHelper
.
startPage
(
pageNum
,
pageSize
);
return
brandMapper
.
selectByExample
(
new
PmsBrandExample
());
}
@Override
public
PmsBrand
getBrand
(
Long
id
)
{
return
brandMapper
.
selectByPrimaryKey
(
id
);
}
}
mall-demo/src/main/java/com/macro/mall/demo/validator/FlagValidator.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.validator
;
import
javax.validation.Constraint
;
import
javax.validation.Payload
;
import
java.lang.annotation.*
;
/**
* 用户验证状态是否在指定范围内的注解
*/
@Documented
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Target
({
ElementType
.
FIELD
,
ElementType
.
PARAMETER
})
@Constraint
(
validatedBy
=
FlagValidatorClass
.
class
)
public
@interface
FlagValidator
{
String
[]
values
()
default
{};
String
message
()
default
"flag is not found"
;
Class
<?>[]
groups
()
default
{};
Class
<?
extends
Payload
>[]
payload
()
default
{};
}
mall-demo/src/main/java/com/macro/mall/demo/validator/FlagValidatorClass.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.demo.validator
;
import
javax.validation.ConstraintValidator
;
import
javax.validation.ConstraintValidatorContext
;
/**
* 状态标记校验器
*/
public
class
FlagValidatorClass
implements
ConstraintValidator
<
FlagValidator
,
Integer
>
{
private
String
[]
values
;
@Override
public
void
initialize
(
FlagValidator
flagValidator
)
{
this
.
values
=
flagValidator
.
values
();
}
@Override
public
boolean
isValid
(
Integer
value
,
ConstraintValidatorContext
constraintValidatorContext
)
{
boolean
isValid
=
false
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++){
if
(
values
[
i
].
equals
(
String
.
valueOf
(
value
))){
isValid
=
true
;
break
;
}
}
return
isValid
;
}
}
mall-demo/src/main/resources/application.properties
0 → 100644
View file @
42d8ff5f
#数据库连接池配置
spring.datasource.url
=
jdbc:mysql://localhost:3306/mall
spring.datasource.username
=
root
spring.datasource.password
=
root
#mybatis配置
mybatis.mapper-locations
=
classpath:mapper/*.xml,classpath*:com/**/mapper/*.xml
#日志配置DEBUG,INFO,WARN,ERROR
logging.level.root
=
warn
#单独配置日志级别
logging.level.com.macro.mall
=
debug
#配置日志生成路径
#logging.path=/var/logs
#配置日志文件名称
#
logging.file
=
demo_log.log
\ No newline at end of file
mall-demo/src/main/resources/static/style.css
0 → 100644
View file @
42d8ff5f
h2
{
color
:
blue
;
}
body
{
background-color
:
#cccccc
;
font-family
:
arial
,
helvetica
,
sans-serif
;
}
.bookHeadline
{
font-size
:
12pt
;
font-weight
:
bold
;
}
.bookDescription
{
font-size
:
10pt
;
}
label
{
font-weight
:
bold
;
}
.error
{
color
:
red
;
}
.errorPage
{
text-align
:
center
;
}
.oops
{
font-size
:
76pt
;
}
\ No newline at end of file
mall-demo/src/main/resources/templates/demo.html
0 → 100644
View file @
42d8ff5f
<!DOCTYPE html>
<html
lang=
"en"
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<meta
charset=
"UTF-8"
/>
<title>
Demo Brand List
</title>
<link
rel=
"stylesheet"
th:href=
"@{/style.css}"
/>
</head>
<body>
<h2>
all brand list
</h2>
<ul>
<li
th:each=
"brand : ${brandList}"
>
<span
th:text=
"${brand.id}"
></span>
<span
th:text=
"${brand.name}"
></span>
</li>
</ul>
</body>
</html>
\ No newline at end of file
mall-demo/src/main/resources/templates/login.html
0 → 100644
View file @
42d8ff5f
<html
xmlns:th=
"http://www.thymeleaf.org"
>
<head>
<title>
Login
</title>
<link
rel=
"stylesheet"
th:href=
"@{/style.css}"
></link>
</head>
<body
onload=
'document.f.username.focus();'
>
<div
id=
"loginForm"
>
<h3>
Login With Username and Password
</h3>
<div
class=
"error"
th:if=
"${param.error}"
>
Incorrect username or password. Try again.
</div>
<form
name=
'f'
th:action=
"@{/login}"
method=
'POST'
>
<table>
<tr>
<td>
User:
</td>
<td><input
type=
'text'
name=
'username'
value=
''
/></td>
</tr>
<tr>
<td>
Password:
</td>
<td><input
type=
'password'
name=
'password'
/></td>
</tr>
<tr>
<td
colspan=
'2'
><input
name=
"submit"
type=
"submit"
value=
"Login"
/></td>
</tr>
</table>
</form>
</div>
</body>
</html>
\ No newline at end of file
mall-demo/src/test/java/com/macro/mall/MallDemoApplicationTests.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.boot.test.context.SpringBootTest
;
import
org.springframework.test.context.junit4.SpringRunner
;
@RunWith
(
SpringRunner
.
class
)
@SpringBootTest
public
class
MallDemoApplicationTests
{
@Test
public
void
contextLoads
()
{
}
}
mall-mbg/pom.xml
0 → 100644
View file @
42d8ff5f
<?xml version="1.0" encoding="UTF-8"?>
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<parent>
<artifactId>
mall
</artifactId>
<groupId>
com.macro
</groupId>
<version>
1.0-SNAPSHOT
</version>
</parent>
<modelVersion>
4.0.0
</modelVersion>
<artifactId>
mall-mbg
</artifactId>
<dependencies>
<!-- MyBatis 生成器 -->
<dependency>
<groupId>
org.mybatis.generator
</groupId>
<artifactId>
mybatis-generator-core
</artifactId>
<version>
1.3.3
</version>
</dependency>
<!-- MyBatis-->
<dependency>
<groupId>
org.mybatis
</groupId>
<artifactId>
mybatis
</artifactId>
<version>
3.4.2
</version>
</dependency>
<!--Mysql数据库驱动-->
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.42
</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
mall-mbg/src/main/java/com/macro/mall/Generator.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall
;
import
org.mybatis.generator.api.MyBatisGenerator
;
import
org.mybatis.generator.config.Configuration
;
import
org.mybatis.generator.config.xml.ConfigurationParser
;
import
org.mybatis.generator.internal.DefaultShellCallback
;
import
java.io.InputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 用于生产MBG的代码
*/
public
class
Generator
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
//MBG 执行过程中的警告信息
List
<
String
>
warnings
=
new
ArrayList
<
String
>();
//当生成的代码重复时,覆盖原代码
boolean
overwrite
=
true
;
//读取我们的 MBG 配置文件
InputStream
is
=
Generator
.
class
.
getResourceAsStream
(
"/generatorConfig.xml"
);
ConfigurationParser
cp
=
new
ConfigurationParser
(
warnings
);
Configuration
config
=
cp
.
parseConfiguration
(
is
);
is
.
close
();
DefaultShellCallback
callback
=
new
DefaultShellCallback
(
overwrite
);
//创建 MBG
MyBatisGenerator
myBatisGenerator
=
new
MyBatisGenerator
(
config
,
callback
,
warnings
);
//执行生成代码
myBatisGenerator
.
generate
(
null
);
//输出警告信息
for
(
String
warning
:
warnings
)
{
System
.
out
.
println
(
warning
);
}
}
}
mall-mbg/src/main/java/com/macro/mall/mapper/CmsHelpCategoryMapper.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.mapper
;
import
com.macro.mall.model.CmsHelpCategory
;
import
com.macro.mall.model.CmsHelpCategoryExample
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
public
interface
CmsHelpCategoryMapper
{
int
countByExample
(
CmsHelpCategoryExample
example
);
int
deleteByExample
(
CmsHelpCategoryExample
example
);
int
deleteByPrimaryKey
(
Long
id
);
int
insert
(
CmsHelpCategory
record
);
int
insertSelective
(
CmsHelpCategory
record
);
List
<
CmsHelpCategory
>
selectByExample
(
CmsHelpCategoryExample
example
);
CmsHelpCategory
selectByPrimaryKey
(
Long
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
CmsHelpCategory
record
,
@Param
(
"example"
)
CmsHelpCategoryExample
example
);
int
updateByExample
(
@Param
(
"record"
)
CmsHelpCategory
record
,
@Param
(
"example"
)
CmsHelpCategoryExample
example
);
int
updateByPrimaryKeySelective
(
CmsHelpCategory
record
);
int
updateByPrimaryKey
(
CmsHelpCategory
record
);
}
\ No newline at end of file
mall-mbg/src/main/java/com/macro/mall/mapper/CmsHelpMapper.java
0 → 100644
View file @
42d8ff5f
package
com.macro.mall.mapper
;
import
com.macro.mall.model.CmsHelp
;
import
com.macro.mall.model.CmsHelpExample
;
import
java.util.List
;
import
org.apache.ibatis.annotations.Param
;
public
interface
CmsHelpMapper
{
int
countByExample
(
CmsHelpExample
example
);
int
deleteByExample
(
CmsHelpExample
example
);
int
deleteByPrimaryKey
(
Long
id
);
int
insert
(
CmsHelp
record
);
int
insertSelective
(
CmsHelp
record
);
List
<
CmsHelp
>
selectByExampleWithBLOBs
(
CmsHelpExample
example
);
List
<
CmsHelp
>
selectByExample
(
CmsHelpExample
example
);
CmsHelp
selectByPrimaryKey
(
Long
id
);
int
updateByExampleSelective
(
@Param
(
"record"
)
CmsHelp
record
,
@Param
(
"example"
)
CmsHelpExample
example
);
int
updateByExampleWithBLOBs
(
@Param
(
"record"
)
CmsHelp
record
,
@Param
(
"example"
)
CmsHelpExample
example
);
int
updateByExample
(
@Param
(
"record"
)
CmsHelp
record
,
@Param
(
"example"
)
CmsHelpExample
example
);
int
updateByPrimaryKeySelective
(
CmsHelp
record
);
int
updateByPrimaryKeyWithBLOBs
(
CmsHelp
record
);
int
updateByPrimaryKey
(
CmsHelp
record
);
}
\ No newline at end of file
Prev
1
2
3
4
5
6
…
15
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment