Commit 27ffba4a by wnb0128

代码缩进规范--think.wang

1 parent 1df51eee
Showing 292 changed files with 1082 additions and 1026 deletions
......@@ -20,7 +20,7 @@ import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
@EnableCaching
@SpringBootApplication
@ComponentScan(basePackages = "cn.enilu.flash")
@EntityScan(basePackages="cn.enilu.flash.bean.entity")
@EntityScan(basePackages = "cn.enilu.flash.bean.entity")
@EnableJpaRepositories(basePackages = "cn.enilu.flash.dao", repositoryFactoryBeanClass = BaseRepositoryFactoryBean.class)
@EnableJpaAuditing
public class AdminApiApplication extends SpringBootServletInitializer {
......
......@@ -10,10 +10,9 @@ import org.springframework.core.io.ClassPathResource;
/**
* 加载ehcache缓存配置<br>
* @version 2018-07-24
*
* @author enilu
*
* @version 2018-07-24
*/
@Configuration
@EnableCaching
......
......@@ -14,7 +14,6 @@ import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreato
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.context.annotation.Lazy;
import javax.servlet.Filter;
import java.util.LinkedHashMap;
......@@ -50,7 +49,7 @@ public class ShiroConfig {
ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
// 添加自己的过滤器并且取名为jwt
Map<String, Filter> filterMap = Maps.newHashMap();
Map<String, Filter> filterMap = Maps.newHashMap();
filterMap.put("jwt", new JwtFilter());
factoryBean.setFilters(filterMap);
......@@ -58,23 +57,23 @@ public class ShiroConfig {
factoryBean.setUnauthorizedUrl("/401");
filterMap.put("logout", new SystemLogoutFilter());
Map<String, String> filterRuleMap = new LinkedHashMap<String,String>();
filterRuleMap.put("/account/**","anon");
Map<String, String> filterRuleMap = new LinkedHashMap<String, String>();
filterRuleMap.put("/account/**", "anon");
//swagger资源不拦截
filterRuleMap.put("/swagger-ui.html","anon");
filterRuleMap.put("/swagger-ui.html", "anon");
filterRuleMap.put("/v2/api-docs/**", "anon");
filterRuleMap.put("/webjars/**", "anon");
filterRuleMap.put("/swagger-resources","anon");
filterRuleMap.put("/images/**","anon");
filterRuleMap.put("/configuration/security","anon");
filterRuleMap.put("/configuration/ui","anon");
filterRuleMap.put("/swagger-resources", "anon");
filterRuleMap.put("/images/**", "anon");
filterRuleMap.put("/configuration/security", "anon");
filterRuleMap.put("/configuration/ui", "anon");
//druid监控地址不拦截
filterRuleMap.put("/druid/**","anon");
filterRuleMap.put("/druid/**", "anon");
//系统图片资源不拦截
filterRuleMap.put("/file/getImgStream","anon");
filterRuleMap.put("/file/download","anon");
filterRuleMap.put("/file/getImgStream", "anon");
filterRuleMap.put("/file/download", "anon");
filterRuleMap.put("/account/logout", "logout");
......
......@@ -19,9 +19,9 @@ import java.util.List;
/**
* swagger在线文档配置<br>
* 项目启动后可通过地址:http://host:ip/swagger-ui.html 查看在线文档
* @version 2018-07-24
*
* @author enilu
* @version 2018-07-24
*/
@Configuration
......
......@@ -24,7 +24,7 @@ public class UserIDAuditorConfig implements AuditorAware<Long> {
if (StringUtil.isNotEmpty(token)) {
return Optional.of(JwtUtil.getUserId(token));
}
}catch (Exception e){
} catch (Exception e) {
//返回系统用户id
return Optional.of(Constants.SYSTEM_USER_ID);
}
......
......@@ -41,7 +41,7 @@ public class AccountController extends BaseController {
private Logger logger = LoggerFactory.getLogger(AccountController.class);
@Value("${jwt.token.expire.time}")
private Long tokenExpireTime ;
private Long tokenExpireTime;
@Autowired
private ManagerService managerService;
@Autowired
......@@ -50,18 +50,20 @@ public class AccountController extends BaseController {
private UserService userService;
@Autowired
private CacheDao cacheDao;
/**
* 用户登录<br>
* 1,验证没有注册<br>
* 2,验证密码错误<br>
* 3,登录成功
*
* @param userName
* @param password
* @return
*/
@RequestMapping(value = "/login",method = RequestMethod.POST)
@RequestMapping(value = "/login", method = RequestMethod.POST)
public Object login(@RequestParam("username") String userName,
@RequestParam("password") String password){
@RequestParam("password") String password) {
try {
logger.info("用户登录:" + userName + ",密码:" + password);
//1,
......@@ -77,7 +79,7 @@ public class AccountController extends BaseController {
String token = userService.loginForToken(new JwtUser(user));
Map<String, String> result = new HashMap<>(1);
logger.info("token:{}",token);
logger.info("token:{}", token);
result.put("token", token);
LogManager.me().executeLog(LogTaskFactory.loginLog(user.getId(), HttpUtil.getIp()));
return Rets.success(result);
......@@ -89,10 +91,11 @@ public class AccountController extends BaseController {
/**
* 退出登录
*
* @return
*/
@RequestMapping(value = "/logout",method = RequestMethod.POST)
public Object logout(){
@RequestMapping(value = "/logout", method = RequestMethod.POST)
public Object logout() {
HttpServletRequest request = HttpUtil.getRequest();
String token = this.getToken(HttpUtil.getRequest());
accountService.logout(token);
......@@ -101,48 +104,49 @@ public class AccountController extends BaseController {
return Rets.success();
}
@RequestMapping(value = "/info",method = RequestMethod.GET)
public Object info( ){
@RequestMapping(value = "/info", method = RequestMethod.GET)
public Object info() {
HttpServletRequest request = HttpUtil.getRequest();
Long idUser = null;
try {
idUser = getIdUser(request);
}catch (Exception e){
} catch (Exception e) {
return Rets.expire();
}
if(idUser!=null){
User user = managerService.get(idUser);
if(StringUtil.isEmpty(user.getRoleid())){
if (idUser != null) {
User user = managerService.get(idUser);
if (StringUtil.isEmpty(user.getRoleid())) {
return Rets.failure("该用户未配置权限");
}
AuthorizationUser shiroUser = UserService.me().getAuthorizationInfo(user.getAccount());
Map map = Maps.newHashMap("name",user.getName(),"role","admin","roles", shiroUser.getRoleCodes());
map.put("permissions",shiroUser.getUrls());
Map map = Maps.newHashMap("name", user.getName(), "role", "admin", "roles", shiroUser.getRoleCodes());
map.put("permissions", shiroUser.getUrls());
Map profile = (Map) Mapl.toMaplist(user);
profile.put("dept",shiroUser.getDeptName());
profile.put("roles",shiroUser.getRoleNames());
map.put("profile",profile);
profile.put("dept", shiroUser.getDeptName());
profile.put("roles", shiroUser.getRoleNames());
map.put("profile", profile);
return Rets.success(map);
}
return Rets.failure("获取用户信息失败");
}
@RequestMapping(value = "/updatePwd",method = RequestMethod.POST)
public Object updatePwd( String oldPassword,String password, String rePassword){
@RequestMapping(value = "/updatePwd", method = RequestMethod.POST)
public Object updatePwd(String oldPassword, String password, String rePassword) {
try {
User user = managerService.get(getIdUser(HttpUtil.getRequest()));
logger.info("oldPassword:{},password:{},rePassword:{}",MD5.md5(oldPassword, user.getSalt()),password,rePassword);
logger.info("oldPassword:{},password:{},rePassword:{}", MD5.md5(oldPassword, user.getSalt()), password, rePassword);
if(!MD5.md5(oldPassword, user.getSalt()).equals(user.getPassword())){
if (!MD5.md5(oldPassword, user.getSalt()).equals(user.getPassword())) {
return Rets.failure("旧密码输入错误");
}
if(!password.equals(rePassword)){
if (!password.equals(rePassword)) {
return Rets.failure("新密码前后不一致");
}
user.setPassword(MD5.md5(password, user.getSalt()));
managerService.update(user);
//清空缓存
cacheDao.hset(CacheDao.SESSION,user.getAccount(),null);
cacheDao.hset(CacheDao.SESSION, user.getAccount(), null);
return Rets.success();
} catch (Exception e) {
logger.error(e.getMessage(), e);
......
......@@ -19,8 +19,9 @@ import java.util.Map;
public class DashboardController extends BaseController {
@Autowired
private DashboardService dashboardService;
@RequestMapping(method = RequestMethod.GET)
public Object get(){
public Object get() {
Map data = dashboardService.getDashboardData();
return Rets.success(data);
}
......
......@@ -23,12 +23,13 @@ import java.io.*;
@RequestMapping("/file")
public class FileController extends BaseController {
@Autowired
private static final Logger logger = LoggerFactory.getLogger(FileController.class);
private static final Logger logger = LoggerFactory.getLogger(FileController.class);
@Autowired
private FileService fileService;
/**
* 上传文件
*
* @param multipartFile
* @return
*/
......@@ -40,35 +41,38 @@ public class FileController extends BaseController {
FileInfo fileInfo = fileService.upload(multipartFile);
return Rets.success(fileInfo);
} catch (Exception e) {
logger.error("上传文件异常",e);
logger.error("上传文件异常", e);
return Rets.failure("上传文件失败");
}
}
/**
* 下载文件
*
* @param fileName
* @param fileName
*/
@RequestMapping(value="download",method = RequestMethod.GET)
public void download(@RequestParam(value = "fileName",required = false) String fileName,
@RequestParam(value = "idFile",required = false) Long idFile){
@RequestMapping(value = "download", method = RequestMethod.GET)
public void download(@RequestParam(value = "fileName", required = false) String fileName,
@RequestParam(value = "idFile", required = false) Long idFile) {
FileInfo fileInfo = null;
if(StringUtil.isNotEmpty(fileName)) {
if (StringUtil.isNotEmpty(fileName)) {
fileInfo = fileService.getByName(fileName);
}
if(idFile!=null){
if (idFile != null) {
fileInfo = fileService.get(idFile);
}
downloadFile(fileInfo);
}
public void downloadFile(FileInfo fileInfo){
public void downloadFile(FileInfo fileInfo) {
String fileName = fileInfo.getOriginalFileName();
HttpServletResponse response = HttpUtil.getResponse();
response.setContentType("application/x-download");
try {
fileName = new String(fileName.getBytes(), "ISO-8859-1");
response.setHeader("Content-Disposition", "attachment;filename=" + fileName);
}catch (Exception e){
} catch (Exception e) {
e.printStackTrace();
}
int length = 1024;
......@@ -83,15 +87,15 @@ public class FileController extends BaseController {
fis = new FileInputStream(file);
bis = new BufferedInputStream(fis);
int i = bis.read(buffer);
while(i != -1){
while (i != -1) {
os.write(buffer);
buffer = new byte[length];
i = bis.read(buffer);
}
} catch (Exception e) {
logger.error("download error",e);
}finally {
logger.error("download error", e);
} finally {
try {
bis.close();
fis.close();
......@@ -103,11 +107,12 @@ public class FileController extends BaseController {
/**
* 获取base64图片数据
*
* @param fileName
* @return
*/
@RequestMapping(value="getImgBase64",method = RequestMethod.GET)
public Object getImgBase64(@RequestParam("idFile")String fileName ){
@RequestMapping(value = "getImgBase64", method = RequestMethod.GET)
public Object getImgBase64(@RequestParam("idFile") String fileName) {
FileInfo fileInfo = fileService.getByName(fileName);
FileInputStream fis = null;
......@@ -120,13 +125,13 @@ public class FileController extends BaseController {
String base64 = CryptUtil.encodeBASE64(bytes);
return Rets.success(Maps.newHashMap("imgContent", base64));
} catch (Exception e) {
logger.error("get img error",e);
logger.error("get img error", e);
return Rets.failure("获取图片异常");
}finally{
} finally {
try {
fis.close();
}catch (Exception e){
logger.error("close getImgBase64 error",e);
} catch (Exception e) {
logger.error("close getImgBase64 error", e);
}
}
......@@ -134,15 +139,16 @@ public class FileController extends BaseController {
/**
* 获取图片流
*
* @param response
* @param fileName
*/
@RequestMapping(value="getImgStream",method = RequestMethod.GET)
@RequestMapping(value = "getImgStream", method = RequestMethod.GET)
public void getImgStream(HttpServletResponse response,
@RequestParam("idFile")String fileName){
@RequestParam("idFile") String fileName) {
FileInfo fileInfo = fileService.getByName(fileName);
FileInputStream fis = null;
response.setContentType("image/"+fileInfo.getRealFileName().split("\\.")[1]);
response.setContentType("image/" + fileInfo.getRealFileName().split("\\.")[1]);
try {
OutputStream out = response.getOutputStream();
File file = new File(fileInfo.getAblatePath());
......@@ -152,13 +158,13 @@ public class FileController extends BaseController {
out.write(b);
out.flush();
} catch (Exception e) {
logger.error("getImgStream error",e);
logger.error("getImgStream error", e);
} finally {
if (fis != null) {
try {
fis.close();
} catch (IOException e) {
logger.error("close getImgStream error",e);
logger.error("close getImgStream error", e);
}
}
}
......
package cn.enilu.flash.api.controller.cms;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.constant.factory.PageFactory;
import cn.enilu.flash.bean.core.BussinessLog;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.enumeration.Permission;
import cn.enilu.flash.bean.vo.front.Rets;
......@@ -11,6 +9,7 @@ import cn.enilu.flash.bean.vo.query.SearchFilter;
import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
......@@ -28,49 +27,53 @@ public class ArticleMgrController extends BaseController {
@Autowired
private ArticleService articleService;
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑文章",key="name")
@BussinessLog(value = "编辑文章", key = "name")
@RequiresPermissions(value = {Permission.ARTICLE_EDIT})
public Object save(){
public Object save() {
Article article = getFromJson(Article.class);
if(article.getId()!=null){
if (article.getId() != null) {
Article old = articleService.get(article.getId());
old.setAuthor(article.getAuthor());
old.setContent(article.getContent());
old.setIdChannel(article.getIdChannel());
old.setImg(article.getImg());
old.setTitle(article.getTitle());
articleService.update(old);
}else {
articleService.update(old);
} else {
articleService.insert(article);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除文章",key="id")
@BussinessLog(value = "删除文章", key = "id")
@RequiresPermissions(value = {Permission.ARTICLE_DEL})
public Object remove(Long id){
public Object remove(Long id) {
articleService.deleteById(id);
return Rets.success();
}
@RequestMapping(method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.ARTICLE})
public Object get(@Param("id") Long id) {
Article article = articleService.get(id);
return Rets.success(article);
}
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.ARTICLE})
public Object list(@RequestParam(required = false) String title,
@RequestParam(required = false) String author,
@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate
) {
) {
Page<Article> page = new PageFactory<Article>().defaultPage();
page.addFilter("title", SearchFilter.Operator.LIKE,title);
page.addFilter("author", SearchFilter.Operator.EQ,author);
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate,"yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate,"yyyyMMddHHmmss"));
page.addFilter("title", SearchFilter.Operator.LIKE, title);
page.addFilter("author", SearchFilter.Operator.EQ, author);
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate, "yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate, "yyyyMMddHHmmss"));
page = articleService.queryPage(page);
return Rets.success(page);
}
......
package cn.enilu.flash.api.controller.cms;
import cn.enilu.flash.utils.JsonUtil;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.core.BussinessLog;
import cn.enilu.flash.bean.entity.cms.Banner;
import cn.enilu.flash.bean.enumeration.Permission;
import cn.enilu.flash.bean.vo.front.Rets;
import cn.enilu.flash.bean.vo.query.SearchFilter;
import cn.enilu.flash.service.cms.BannerService;
import cn.enilu.flash.utils.JsonUtil;
import cn.enilu.flash.utils.StringUtil;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -30,14 +29,14 @@ public class BannerMgrController extends BaseController {
@BussinessLog(value = "编辑banner", key = "title")
@RequiresPermissions(value = {Permission.BANNER_EDIT})
public Object save(@ModelAttribute @Valid Banner banner) {
if(StringUtil.isNotEmpty(banner.getParam())){
if(!JsonUtil.isJson(banner.getParam())){
if (StringUtil.isNotEmpty(banner.getParam())) {
if (!JsonUtil.isJson(banner.getParam())) {
return Rets.failure("参数必须为json格式");
}
}
if(banner.getId()==null){
if (banner.getId() == null) {
bannerService.insert(banner);
}else {
} else {
bannerService.update(banner);
}
return Rets.success();
......@@ -55,8 +54,8 @@ public class BannerMgrController extends BaseController {
@RequiresPermissions(value = {Permission.BANNER})
public Object list(@RequestParam(required = false) String title) {
SearchFilter filter = null;
if(StringUtil.isNotEmpty(title)){
filter = SearchFilter.build("title", SearchFilter.Operator.LIKE,title);
if (StringUtil.isNotEmpty(title)) {
filter = SearchFilter.build("title", SearchFilter.Operator.LIKE, title);
}
List<Banner> list = bannerService.queryAll(filter);
return Rets.success(list);
......
package cn.enilu.flash.api.controller.cms;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.core.BussinessLog;
import cn.enilu.flash.bean.entity.cms.Channel;
import cn.enilu.flash.bean.enumeration.Permission;
import cn.enilu.flash.bean.vo.front.Rets;
import cn.enilu.flash.service.cms.ChannelService;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.ModelAttribute;
......@@ -30,9 +29,9 @@ public class ChannelMgrController extends BaseController {
@BussinessLog(value = "编辑栏目", key = "name")
@RequiresPermissions(value = {Permission.CHANNEL_EDIT})
public Object save(@ModelAttribute @Valid Channel channel) {
if(channel.getId()==null) {
if (channel.getId() == null) {
channelService.insert(channel);
}else{
} else {
channelService.update(channel);
}
return Rets.success();
......
package cn.enilu.flash.api.controller.cms;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.constant.factory.PageFactory;
import cn.enilu.flash.bean.entity.cms.Contacts;
import cn.enilu.flash.bean.enumeration.Permission;
......@@ -9,6 +8,7 @@ import cn.enilu.flash.bean.vo.query.SearchFilter;
import cn.enilu.flash.service.cms.ContactsService;
import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -24,7 +24,8 @@ import org.springframework.web.bind.annotation.RestController;
public class ContactsController extends BaseController {
@Autowired
private ContactsService contactsService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.CONTACTS})
public Object list(@RequestParam(required = false) String userName,
@RequestParam(required = false) String mobile,
......@@ -33,10 +34,10 @@ public class ContactsController extends BaseController {
) {
Page<Contacts> page = new PageFactory<Contacts>().defaultPage();
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate,"yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate,"yyyyMMddHHmmss"));
page.addFilter("userName", SearchFilter.Operator.EQ,userName);
page.addFilter("mobile", SearchFilter.Operator.EQ,mobile);
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate, "yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate, "yyyyMMddHHmmss"));
page.addFilter("userName", SearchFilter.Operator.EQ, userName);
page.addFilter("mobile", SearchFilter.Operator.EQ, mobile);
page = contactsService.queryPage(page);
return Rets.success(page);
}
......
package cn.enilu.flash.api.controller.cms;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.constant.factory.PageFactory;
import cn.enilu.flash.bean.entity.system.FileInfo;
import cn.enilu.flash.bean.enumeration.Permission;
......@@ -9,6 +8,7 @@ import cn.enilu.flash.bean.vo.query.SearchFilter;
import cn.enilu.flash.service.system.FileService;
import cn.enilu.flash.utils.StringUtil;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.vo.front.Rets;
import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.web.controller.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -18,10 +18,11 @@ public class ArticleController extends BaseController {
private Logger logger = LoggerFactory.getLogger(ArticleController.class);
@Autowired
private ArticleService articleService;
@RequestMapping(method = RequestMethod.GET)
public Object get(@Param("id") Long id,@Param("type")String type) {
logger.info("type:{},id:{}",type,id);
Article article = articleService.get(id);
public Object get(@Param("id") Long id, @Param("type") String type) {
logger.info("type:{},id:{}", type, id);
Article article = articleService.get(id);
return Rets.success(article);
}
}
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.enumeration.cms.BannerTypeEnum;
import cn.enilu.flash.bean.enumeration.cms.ChannelEnum;
......@@ -10,6 +9,7 @@ import cn.enilu.flash.bean.vo.offcialsite.Product;
import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.service.cms.BannerService;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Contacts;
import cn.enilu.flash.bean.vo.front.Rets;
import cn.enilu.flash.service.cms.ContactsService;
import cn.enilu.flash.web.controller.BaseController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -19,8 +19,9 @@ public class ContactController extends BaseController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ContactsService contactsService;
@RequestMapping(method = RequestMethod.POST)
public Object save(@Valid Contacts contacts){
public Object save(@Valid Contacts contacts) {
contactsService.insert(contacts);
return Rets.success();
}
......
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.enumeration.cms.BannerTypeEnum;
import cn.enilu.flash.bean.enumeration.cms.ChannelEnum;
......@@ -10,6 +9,7 @@ import cn.enilu.flash.bean.vo.offcialsite.News;
import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.service.cms.BannerService;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.enumeration.cms.ChannelEnum;
import cn.enilu.flash.bean.vo.front.Rets;
......@@ -12,6 +11,7 @@ import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.service.cms.BannerService;
import cn.enilu.flash.utils.Maps;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -68,7 +68,7 @@ public class OffcialSiteController extends BaseController {
solutions.add(solution);
}
dataMap.put("solutionList", solutions);
Map map = Maps.newHashMap("data",dataMap);
Map map = Maps.newHashMap("data", dataMap);
return Rets.success(map);
}
......
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.enumeration.cms.BannerTypeEnum;
import cn.enilu.flash.bean.enumeration.cms.ChannelEnum;
......@@ -11,6 +10,7 @@ import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.service.cms.BannerService;
import cn.enilu.flash.utils.Maps;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -32,7 +32,7 @@ public class OffcialSiteProductController extends BaseController {
public Object index() {
Map<String, Object> dataMap = Maps.newHashMap();
BannerVo banner = bannerService.queryBanner(BannerTypeEnum.SOLUTION.getValue());
BannerVo banner = bannerService.queryBanner(BannerTypeEnum.SOLUTION.getValue());
dataMap.put("banner", banner);
List<Product> products = new ArrayList<>();
......@@ -42,7 +42,7 @@ public class OffcialSiteProductController extends BaseController {
}
dataMap.put("productList", products);
Map map = Maps.newHashMap("data",dataMap);
Map map = Maps.newHashMap("data", dataMap);
return Rets.success(map);
}
......
package cn.enilu.flash.api.controller.front.officialsite;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.cms.Article;
import cn.enilu.flash.bean.enumeration.cms.BannerTypeEnum;
import cn.enilu.flash.bean.enumeration.cms.ChannelEnum;
......@@ -11,6 +10,7 @@ import cn.enilu.flash.service.cms.ArticleService;
import cn.enilu.flash.service.cms.BannerService;
import cn.enilu.flash.utils.Maps;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
......@@ -30,7 +30,7 @@ public class SolutionController extends BaseController {
@RequestMapping(method = RequestMethod.GET)
public Object index() {
Map<String, Object> dataMap = Maps.newHashMap();
Map<String, Object> dataMap = Maps.newHashMap();
BannerVo banner = bannerService.queryBanner(BannerTypeEnum.SOLUTION.getValue());
dataMap.put("banner", banner);
......@@ -42,7 +42,7 @@ public class SolutionController extends BaseController {
}
dataMap.put("solutionList", solutions);
Map map = Maps.newHashMap("data",dataMap);
Map map = Maps.newHashMap("data", dataMap);
return Rets.success(map);
}
......
......@@ -24,11 +24,11 @@ public class MessageController {
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.MSG})
public Object list( @RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate) {
public Object list(@RequestParam(required = false) String startDate,
@RequestParam(required = false) String endDate) {
Page<Message> page = new PageFactory<Message>().defaultPage();
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate,"yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate,"yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate, "yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate, "yyyyMMddHHmmss"));
page = messageService.queryPage(page);
page.setRecords(page.getRecords());
return Rets.success(page);
......
......@@ -2,7 +2,6 @@ package cn.enilu.flash.api.controller.message;
import cn.enilu.flash.bean.constant.factory.PageFactory;
import cn.enilu.flash.bean.core.BussinessLog;
import cn.enilu.flash.bean.entity.message.MessageSender;
import cn.enilu.flash.bean.enumeration.Permission;
import cn.enilu.flash.bean.vo.front.Rets;
......@@ -42,7 +41,7 @@ public class MessagesenderController {
@BussinessLog(value = "编辑消息发送者", key = "name")
@RequiresPermissions(value = {Permission.MSG_SENDER_EDIT})
public Object save(@ModelAttribute @Valid MessageSender messageSender) {
if(messageSender.getId()!=null){
if (messageSender.getId() != null) {
MessageSender old = messagesenderService.get(messageSender.getId());
}
messagesenderService.save(messageSender);
......
......@@ -37,9 +37,9 @@ public class MessagetemplateController {
@BussinessLog(value = "编辑消息模板", key = "name")
@RequiresPermissions(value = {Permission.MSG_TPL_EDIT})
public Object save(@ModelAttribute @Valid MessageTemplate messageTemplate) {
if(messageTemplate.getId()==null){
if (messageTemplate.getId() == null) {
messagetemplateService.insert(messageTemplate);
}else {
} else {
messagetemplateService.update(messageTemplate);
}
return Rets.success();
......
......@@ -21,52 +21,53 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/promotion/topic")
public class TopicController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private TopicService topicService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private TopicService topicService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list(@RequestParam(value = "disabled",required = false) Boolean disabled,
@RequestParam(value = "startDate",required = false) String startDate,
@RequestParam(value = "endDate",required = false) String endDate) {
Page<Topic> page = new PageFactory<Topic>().defaultPage();
page.addFilter( "disabled", disabled);
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate,"yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate,"yyyyMMddHHmmss"));
page = topicService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list(@RequestParam(value = "disabled", required = false) Boolean disabled,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate) {
Page<Topic> page = new PageFactory<Topic>().defaultPage();
page.addFilter("disabled", disabled);
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parse(startDate, "yyyyMMddHHmmss"));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parse(endDate, "yyyyMMddHHmmss"));
page = topicService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑专题", key = "name")
@RequiresPermissions(value = {Permission.TOPIC_EDIT})
public Object save(@ModelAttribute Topic topic){
if(topic.getId()==null){
topic.setPv(0L);
topicService.insert(topic);
}else {
topicService.update(topic);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除专题", key = "id")
@RequiresPermissions(value = {Permission.TOPIC_DEL})
public Object remove(Long id){
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
topicService.deleteById(id);
return Rets.success();
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑专题", key = "name")
@RequiresPermissions(value = {Permission.TOPIC_EDIT})
public Object save(@ModelAttribute Topic topic) {
if (topic.getId() == null) {
topic.setPv(0L);
topicService.insert(topic);
} else {
topicService.update(topic);
}
return Rets.success();
}
@RequestMapping(value="/changeDisabled",method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.TOPIC_EDIT})
public Object changeIsOnSale(@RequestParam("id") Long id,@RequestParam("disabled") Boolean disabled){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
topicService.changeDisabled(id,disabled);
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除专题", key = "id")
@RequiresPermissions(value = {Permission.TOPIC_DEL})
public Object remove(Long id) {
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
topicService.deleteById(id);
return Rets.success();
}
@RequestMapping(value = "/changeDisabled", method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.TOPIC_EDIT})
public Object changeIsOnSale(@RequestParam("id") Long id, @RequestParam("disabled") Boolean disabled) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
topicService.changeDisabled(id, disabled);
return Rets.success();
}
}
......@@ -16,15 +16,15 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/shop/address")
public class AddressController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AddressService addressService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AddressService addressService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list(@RequestParam(required = false)Long idUser) {
Page<Address> page = new PageFactory<Address>().defaultPage();
page.addFilter("idUser",idUser);
page = addressService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list(@RequestParam(required = false) Long idUser) {
Page<Address> page = new PageFactory<Address>().defaultPage();
page.addFilter("idUser", idUser);
page = addressService.queryPage(page);
return Rets.success(page);
}
}
......@@ -17,48 +17,51 @@ import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/shop/goods/attr/key")
public class AttrKeyController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AttrKeyService attrKeyService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private AttrKeyService attrKeyService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<AttrKey> page = new PageFactory<AttrKey>().defaultPage();
page = attrKeyService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品属性名", key = "name")
public Object save(@ModelAttribute AttrKey tShopGoodsAttrKey){
if(tShopGoodsAttrKey.getId()==null){
attrKeyService.insert(tShopGoodsAttrKey);
}else {
attrKeyService.update(tShopGoodsAttrKey);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品属性名", key = "id")
public Object remove(Long id){
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
AttrKey attrKey = attrKeyService.get(id);
if(!attrKey.getAttrVals().isEmpty()){
throw new ApplicationException(ApplicationExceptionEnum.DATA_CANNOT_REMOVE);
}
attrKeyService.deleteById(id);
return Rets.success();
}
@RequestMapping(value="updateAttrName",method = RequestMethod.POST)
@BussinessLog(value = "修改商品属性名", key = "id")
public Object updateAttrName(@RequestParam("id") Long id,@RequestParam("attrName") String attrName){
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
AttrKey attrKey = attrKeyService.get(id);
attrKey.setAttrName(attrName);
attrKeyService.update(attrKey);
return Rets.success();
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<AttrKey> page = new PageFactory<AttrKey>().defaultPage();
page = attrKeyService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品属性名", key = "name")
public Object save(@ModelAttribute AttrKey tShopGoodsAttrKey) {
if (tShopGoodsAttrKey.getId() == null) {
attrKeyService.insert(tShopGoodsAttrKey);
} else {
attrKeyService.update(tShopGoodsAttrKey);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品属性名", key = "id")
public Object remove(Long id) {
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
AttrKey attrKey = attrKeyService.get(id);
if (!attrKey.getAttrVals().isEmpty()) {
throw new ApplicationException(ApplicationExceptionEnum.DATA_CANNOT_REMOVE);
}
attrKeyService.deleteById(id);
return Rets.success();
}
@RequestMapping(value = "updateAttrName", method = RequestMethod.POST)
@BussinessLog(value = "修改商品属性名", key = "id")
public Object updateAttrName(@RequestParam("id") Long id, @RequestParam("attrName") String attrName) {
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
AttrKey attrKey = attrKeyService.get(id);
attrKey.setAttrName(attrName);
attrKeyService.update(attrKey);
return Rets.success();
}
}
......@@ -28,15 +28,15 @@ public class AttrValController {
@Autowired
private AttrKeyService attrKeyService;
@RequestMapping(value = "/getAttrByCategoryAndGoods/{idCategory}",method = RequestMethod.GET)
@RequestMapping(value = "/getAttrByCategoryAndGoods/{idCategory}", method = RequestMethod.GET)
public Object getAttrByCategoryAndGoods(@PathVariable("idCategory") Long idCategory) {
List<AttrKey> keyList = attrKeyService.queryBy(idCategory);
List<Long> idAttrKeyList = Lists.newArrayList();
for(AttrKey attrKey:keyList){
for (AttrKey attrKey : keyList) {
idAttrKeyList.add(attrKey.getId());
}
List<AttrVal> valList = Lists.newArrayList();
if(!idAttrKeyList.isEmpty()) {
if (!idAttrKeyList.isEmpty()) {
valList = attrValService.queryAll(SearchFilter.build("idAttrKey", SearchFilter.Operator.IN, idAttrKeyList));
}
return Rets.success(Maps.newHashMap(
......@@ -46,36 +46,37 @@ public class AttrValController {
}
@RequestMapping(value = "getAttrVals", method = RequestMethod.GET)
public Object getAttrVals(@RequestParam("idAttrKey")Long idAttrKey) {
List<AttrVal> list = attrValService.queryAll(SearchFilter.build("idAttrKey",idAttrKey));
public Object getAttrVals(@RequestParam("idAttrKey") Long idAttrKey) {
List<AttrVal> list = attrValService.queryAll(SearchFilter.build("idAttrKey", idAttrKey));
return Rets.success(list);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品属性值", key = "attrVal")
public Object save(@RequestParam("idAttrKey")Long idAttrKey,
@RequestParam(value = "id",required = false)Long id,
@RequestParam("attrVal")String attrVal) {
public Object save(@RequestParam("idAttrKey") Long idAttrKey,
@RequestParam(value = "id", required = false) Long id,
@RequestParam("attrVal") String attrVal) {
AttrVal entity = new AttrVal();
if(id!=null){
if (id != null) {
entity = attrValService.get(id);
}
entity = attrValService.get(Lists.newArrayList(
SearchFilter.build("idAttrKey",idAttrKey),
SearchFilter.build("attrVal",attrVal)
SearchFilter.build("idAttrKey", idAttrKey),
SearchFilter.build("attrVal", attrVal)
));
if (id == null) {
if(entity==null) {
if (entity == null) {
entity = new AttrVal();
entity.setIdAttrKey(idAttrKey);
entity.setAttrVal(attrVal);
attrValService.insert(entity);
}else{
return Rets.failure("不能添加重复的规格");
} else {
return Rets.failure("不能添加重复的规格");
}
} else {
if(entity!=null){
return Rets.failure("不能添加重复的规格");
}else {
if (entity != null) {
return Rets.failure("不能添加重复的规格");
} else {
entity = new AttrVal();
entity.setIdAttrKey(idAttrKey);
entity.setAttrVal(attrVal);
......@@ -94,9 +95,10 @@ public class AttrValController {
attrValService.deleteById(id);
return Rets.success();
}
@RequestMapping(value="updateAttrVal",method = RequestMethod.POST)
@RequestMapping(value = "updateAttrVal", method = RequestMethod.POST)
@BussinessLog(value = "修改商品属性值", key = "id")
public Object updateAttrName(@RequestParam("id") Long id,@RequestParam("attrVal") String attrVal){
public Object updateAttrName(@RequestParam("id") Long id, @RequestParam("attrVal") String attrVal) {
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
......
......@@ -15,14 +15,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/shop/cart")
public class CartController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private CartService cartService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private CartService cartService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<Cart> page = new PageFactory<Cart>().defaultPage();
page = cartService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<Cart> page = new PageFactory<Cart>().defaultPage();
page = cartService.queryPage(page);
return Rets.success(page);
}
}
......@@ -29,110 +29,117 @@ import java.util.List;
@RestController
@RequestMapping("/shop/category")
public class CategoryController extends BaseController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private CategoryService categoryService;
@Autowired
private CategoryBannerRelService categoryBannerRelService;
@Autowired
private AttrKeyService attrKeyService;
@Autowired
private GoodsService goodsService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private CategoryService categoryService;
@Autowired
private CategoryBannerRelService categoryBannerRelService;
@Autowired
private AttrKeyService attrKeyService;
@Autowired
private GoodsService goodsService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<Category> page = new PageFactory<Category>().defaultPage();
page = categoryService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/getAll",method = RequestMethod.GET)
public Object getAll() {
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<Category> page = new PageFactory<Category>().defaultPage();
page = categoryService.queryPage(page);
return Rets.success(page);
}
List<Category> categories = categoryService.queryAll();
return Rets.success(categories);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品类别", key = "name")
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object save(@ModelAttribute Category category){
if(category.getId()==null){
categoryService.insert(category);
}else {
categoryService.update(category);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品类别", key = "id")
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object remove(Long id){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
long goodsCount = goodsService.count(SearchFilter.build("idCategory",id));
if(goodsCount>0){
throw new ApplicationException(ApplicationExceptionEnum.DATA_CANNOT_REMOVE);
}
categoryService.deleteById(id);
return Rets.success();
}
@RequestMapping(value="/getBanners/{idCategory}",method = RequestMethod.GET)
public Object getBanners(@PathVariable("idCategory") Long idCategory){
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
List<CategoryBannerRel> relList = categoryBannerRelService.queryAll(SearchFilter.build("idCategory", SearchFilter.Operator.EQ,idCategory));
List<Banner> bannerList = Lists.newArrayList();
relList.forEach( item->{
bannerList.add(item.getBanner());
});
@RequestMapping(value = "/getAll", method = RequestMethod.GET)
public Object getAll() {
return Rets.success(bannerList);
}
@RequestMapping(value ="getAttrKeys/{idCategory}",method = RequestMethod.GET)
public Object getAttrKeys(@PathVariable("idCategory") Long idCategory){
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
List<AttrKey> list = attrKeyService.queryBy(idCategory);
return Rets.success(list);
List<Category> categories = categoryService.queryAll();
return Rets.success(categories);
}
}
@RequestMapping(value="/removeBanner/{idCategory}/{idBanner}",method = RequestMethod.DELETE)
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object removeBanner(@PathVariable("idCategory") Long idCategory,
@PathVariable("idBanner") Long idBanner){
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
CategoryBannerRel rel = categoryBannerRelService.get(Lists.newArrayList(
SearchFilter.build("idCategory",idCategory),
SearchFilter.build("idBanner",idBanner)
));
if(rel!=null){
categoryBannerRelService.delete(rel);
}
return Rets.success();
}
@RequestMapping(value="/setBanner/{idCategory}/{idBanner}",method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object setBanner(@PathVariable("idCategory") Long idCategory,
@PathVariable("idBanner") Long idBanner){
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
CategoryBannerRel rel = categoryBannerRelService.get(Lists.newArrayList(
SearchFilter.build("idCategory",idCategory),
SearchFilter.build("idBanner",idBanner)
));
if(rel!=null){
return Rets.success();
}
rel = new CategoryBannerRel();
rel.setIdCategory(idCategory);
rel.setIdBanner(idBanner);
categoryBannerRelService.insert(rel);
return Rets.success();
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品类别", key = "name")
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object save(@ModelAttribute Category category) {
if (category.getId() == null) {
categoryService.insert(category);
} else {
categoryService.update(category);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品类别", key = "id")
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object remove(Long id) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
long goodsCount = goodsService.count(SearchFilter.build("idCategory", id));
if (goodsCount > 0) {
throw new ApplicationException(ApplicationExceptionEnum.DATA_CANNOT_REMOVE);
}
categoryService.deleteById(id);
return Rets.success();
}
@RequestMapping(value = "/getBanners/{idCategory}", method = RequestMethod.GET)
public Object getBanners(@PathVariable("idCategory") Long idCategory) {
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
List<CategoryBannerRel> relList = categoryBannerRelService.queryAll(SearchFilter.build("idCategory", SearchFilter.Operator.EQ, idCategory));
List<Banner> bannerList = Lists.newArrayList();
relList.forEach(item -> {
bannerList.add(item.getBanner());
});
return Rets.success(bannerList);
}
@RequestMapping(value = "getAttrKeys/{idCategory}", method = RequestMethod.GET)
public Object getAttrKeys(@PathVariable("idCategory") Long idCategory) {
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
List<AttrKey> list = attrKeyService.queryBy(idCategory);
return Rets.success(list);
}
@RequestMapping(value = "/removeBanner/{idCategory}/{idBanner}", method = RequestMethod.DELETE)
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object removeBanner(@PathVariable("idCategory") Long idCategory,
@PathVariable("idBanner") Long idBanner) {
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
CategoryBannerRel rel = categoryBannerRelService.get(Lists.newArrayList(
SearchFilter.build("idCategory", idCategory),
SearchFilter.build("idBanner", idBanner)
));
if (rel != null) {
categoryBannerRelService.delete(rel);
}
return Rets.success();
}
@RequestMapping(value = "/setBanner/{idCategory}/{idBanner}", method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.CATEGORY_EDIT})
public Object setBanner(@PathVariable("idCategory") Long idCategory,
@PathVariable("idBanner") Long idBanner) {
if (idCategory == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
CategoryBannerRel rel = categoryBannerRelService.get(Lists.newArrayList(
SearchFilter.build("idCategory", idCategory),
SearchFilter.build("idBanner", idBanner)
));
if (rel != null) {
return Rets.success();
}
rel = new CategoryBannerRel();
rel.setIdCategory(idCategory);
rel.setIdBanner(idBanner);
categoryBannerRelService.insert(rel);
return Rets.success();
}
}
......@@ -15,14 +15,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/shop/favorite")
public class FavoriteController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private FavoriteService favoriteService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private FavoriteService favoriteService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<Favorite> page = new PageFactory<Favorite>().defaultPage();
page = favoriteService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<Favorite> page = new PageFactory<Favorite>().defaultPage();
page = favoriteService.queryPage(page);
return Rets.success(page);
}
}
......@@ -26,95 +26,99 @@ import java.util.List;
@RestController
@RequestMapping("/shop/goods")
public class GoodsController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private GoodsService goodsService;
@Autowired
private GoodsSkuService goodsSkuService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private GoodsService goodsService;
@Autowired
private GoodsSkuService goodsSkuService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list(@RequestParam(value = "name",required = false) String name) {
Page<Goods> page = new PageFactory<Goods>().defaultPage();
page.addFilter("name", SearchFilter.Operator.LIKE,name);
page = goodsService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/saveBaseInfo",method = RequestMethod.POST)
@BussinessLog(value = "保存商品基本信息", key = "name")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object saveBaseInfo(@RequestBody Goods goods){
if(goods.getId()==null){
goodsService.insert(goods);
}
return Rets.success(goods.getId());
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品", key = "name")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object save(@RequestBody @Valid Goods goods){
List<SearchFilter> filters = Lists.newArrayList(
SearchFilter.build("idGoods",goods.getId()),
SearchFilter.build("isDeleted",false)
);
List<GoodsSku> skuList = goodsSkuService.queryAll(filters);
if(goods.getPrice() ==null){
if(!skuList.isEmpty()){
int stock = 0;
for(GoodsSku sku:skuList){
stock+=sku.getStock();
}
goods.setStock(stock);
goods.setPrice(skuList.get(0).getPrice());
}else{
throw new ApplicationException(ApplicationExceptionEnum.DATA_ERROR);
}
}else{
if(!skuList.isEmpty()){
//如果配置了price,说明是单规格商品,则将之前配置的sku库存皆设置为0;这里最好不要删除sku记录,避免之前下过的订单无法正确关联
for(GoodsSku sku:skuList){
sku.setStock(0);
}
goodsSkuService.update(skuList);
}
}
if(goods.getId()==null){
goodsService.insert(goods);
}else {
Goods old = goodsService.get(goods.getId());
LogObjectHolder.me().set(old);
goods.setCreateBy(old.getCreateBy());
goods.setCreateTime(old.getCreateTime());
goodsService.update(goods);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品", key = "id")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object remove(Long id){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
goodsService.deleteById(id);
return Rets.success();
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list(@RequestParam(value = "name", required = false) String name) {
Page<Goods> page = new PageFactory<Goods>().defaultPage();
page.addFilter("name", SearchFilter.Operator.LIKE, name);
page = goodsService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(method = RequestMethod.GET)
public Object get(Long id){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
return Rets.success(goodsService.getDetail(id));
}
@RequestMapping(value="/changeIsOnSale",method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.GOODS_EDIT})
@BussinessLog(value = "上架/下架商品", key = "id")
public Object changeIsOnSale(@RequestParam("id") Long id,@RequestParam("isOnSale") Boolean isOnSale){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
goodsService.changeIsOnSale(id,isOnSale);
return Rets.success(goodsService.get(id));
}
@RequestMapping(value = "/saveBaseInfo", method = RequestMethod.POST)
@BussinessLog(value = "保存商品基本信息", key = "name")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object saveBaseInfo(@RequestBody Goods goods) {
if (goods.getId() == null) {
goodsService.insert(goods);
}
return Rets.success(goods.getId());
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品", key = "name")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object save(@RequestBody @Valid Goods goods) {
List<SearchFilter> filters = Lists.newArrayList(
SearchFilter.build("idGoods", goods.getId()),
SearchFilter.build("isDeleted", false)
);
List<GoodsSku> skuList = goodsSkuService.queryAll(filters);
if (goods.getPrice() == null) {
if (!skuList.isEmpty()) {
int stock = 0;
for (GoodsSku sku : skuList) {
stock += sku.getStock();
}
goods.setStock(stock);
goods.setPrice(skuList.get(0).getPrice());
} else {
throw new ApplicationException(ApplicationExceptionEnum.DATA_ERROR);
}
} else {
if (!skuList.isEmpty()) {
//如果配置了price,说明是单规格商品,则将之前配置的sku库存皆设置为0;这里最好不要删除sku记录,避免之前下过的订单无法正确关联
for (GoodsSku sku : skuList) {
sku.setStock(0);
}
goodsSkuService.update(skuList);
}
}
if (goods.getId() == null) {
goodsService.insert(goods);
} else {
Goods old = goodsService.get(goods.getId());
LogObjectHolder.me().set(old);
goods.setCreateBy(old.getCreateBy());
goods.setCreateTime(old.getCreateTime());
goodsService.update(goods);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品", key = "id")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object remove(Long id) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
goodsService.deleteById(id);
return Rets.success();
}
@RequestMapping(method = RequestMethod.GET)
public Object get(Long id) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
return Rets.success(goodsService.getDetail(id));
}
@RequestMapping(value = "/changeIsOnSale", method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.GOODS_EDIT})
@BussinessLog(value = "上架/下架商品", key = "id")
public Object changeIsOnSale(@RequestParam("id") Long id, @RequestParam("isOnSale") Boolean isOnSale) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
goodsService.changeIsOnSale(id, isOnSale);
return Rets.success(goodsService.get(id));
}
}
......@@ -30,66 +30,68 @@ import java.util.List;
@RestController
@RequestMapping("/shop/goods/sku")
public class GoodsSkuController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private GoodsSkuService goodsSkuService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private GoodsSkuService goodsSkuService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<GoodsSku> page = new PageFactory<GoodsSku>().defaultPage();
page.addFilter("isDeleted",false);
page = goodsSkuService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品SKU", key = "name")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object save(@RequestBody GoodsSku sku){
List<String> codeArr = Arrays.asList(sku.getCode().split(","));
List<String> codeNameArr = Arrays.asList(sku.getCodeName().split(","));
Collections.sort(codeArr, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareTo(s2);
}
});
Collections.sort(codeNameArr, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareTo(s2);
}
});
String code = Lists.concat(codeArr,",");
String codeName = Lists.concat(codeNameArr,",");
sku.setCode(code);
sku.setCodeName(codeName);
GoodsSku oldSku = goodsSkuService.get(Lists.newArrayList(
SearchFilter.build("idGoods",sku.getIdGoods()),
SearchFilter.build("code",code)
));
if(oldSku!=null){
LogObjectHolder.me().set(oldSku);
oldSku.setMarketingPrice(sku.getMarketingPrice());
oldSku.setPrice(sku.getPrice());
oldSku.setStock(sku.getStock());
goodsSkuService.update(oldSku);
return Rets.success(oldSku);
}else{
goodsSkuService.insert(sku);
return Rets.success(sku);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<GoodsSku> page = new PageFactory<GoodsSku>().defaultPage();
page.addFilter("isDeleted", false);
page = goodsSkuService.queryPage(page);
return Rets.success(page);
}
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品SKU", key = "id")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object remove(Long id){
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
GoodsSku sku = goodsSkuService.get(id);
sku.setIsDeleted(true);
goodsSkuService.update(sku);
return Rets.success();
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑商品SKU", key = "name")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object save(@RequestBody GoodsSku sku) {
List<String> codeArr = Arrays.asList(sku.getCode().split(","));
List<String> codeNameArr = Arrays.asList(sku.getCodeName().split(","));
Collections.sort(codeArr, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareTo(s2);
}
});
Collections.sort(codeNameArr, new Comparator<String>() {
@Override
public int compare(String s1, String s2) {
return s1.compareTo(s2);
}
});
String code = Lists.concat(codeArr, ",");
String codeName = Lists.concat(codeNameArr, ",");
sku.setCode(code);
sku.setCodeName(codeName);
GoodsSku oldSku = goodsSkuService.get(Lists.newArrayList(
SearchFilter.build("idGoods", sku.getIdGoods()),
SearchFilter.build("code", code)
));
if (oldSku != null) {
LogObjectHolder.me().set(oldSku);
oldSku.setMarketingPrice(sku.getMarketingPrice());
oldSku.setPrice(sku.getPrice());
oldSku.setStock(sku.getStock());
goodsSkuService.update(oldSku);
return Rets.success(oldSku);
} else {
goodsSkuService.insert(sku);
return Rets.success(sku);
}
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除商品SKU", key = "id")
@RequiresPermissions(value = {Permission.GOODS_EDIT})
public Object remove(Long id) {
if (StringUtil.isEmpty(id)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
GoodsSku sku = goodsSkuService.get(id);
sku.setIsDeleted(true);
goodsSkuService.update(sku);
return Rets.success();
}
}
......@@ -47,69 +47,72 @@ public class OrderController {
/**
* 获取订单统计信息
* todo 真实生产可以考虑将订单数量信息通过队列形式更新在redis等缓存中,然后从缓存获取,这里暂时从数据库直接统计
*
* @return
*/
@RequestMapping(value = "/getOrderStatistic", method = RequestMethod.GET)
public Object getOrderStatistic(){
public Object getOrderStatistic() {
List<Map> list = orderService.queryBySql("SELECT status,count(1) as count FROM `t_shop_order` GROUP BY status");
Map result = Maps.newHashMap();
for(Map map:list){
for (Map map : list) {
String statusStr = OrderEnum.getStatusStr((Integer) map.get("status"));
result.put(statusStr,map.get("count"));
result.put(statusStr, map.get("count"));
}
return Rets.success(result);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list(@RequestParam(value = "mobile", required = false) String mobile,
@RequestParam(value = "orderSn", required = false) String orderSn,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "status", required = false) String status,
@RequestParam(value = "date", required = false) String date,
@RequestParam(value = "startDate", required = false) String startDate,
@RequestParam(value = "endDate", required = false) String endDate) {
Page<Order> page = new PageFactory<Order>().defaultPage();
page.addFilter("user.mobile", mobile);
page.addFilter("orderSn", orderSn);
if(StringUtil.isNotEmpty(status)){
page.addFilter("status",OrderEnum.getStatusByStr(status));
if (StringUtil.isNotEmpty(status)) {
page.addFilter("status", OrderEnum.getStatusByStr(status));
}
if(StringUtil.isNotEmpty(date)){
if (StringUtil.isNotEmpty(date)) {
Date[] rangeDate = DateUtil.getDateRange(date);
page.addFilter("createTime", SearchFilter.Operator.GTE,rangeDate[0]);
page.addFilter("createTime", SearchFilter.Operator.LTE,rangeDate[1]);
page.addFilter("createTime", SearchFilter.Operator.GTE, rangeDate[0]);
page.addFilter("createTime", SearchFilter.Operator.LTE, rangeDate[1]);
}
if(StringUtil.isNotEmpty(startDate) && StringUtil.isNotEmpty(endDate)){
page.addFilter("createTime", SearchFilter.Operator.GTE,DateUtil.parseDate(startDate));
page.addFilter("createTime", SearchFilter.Operator.LTE,DateUtil.parseDate(endDate));
if (StringUtil.isNotEmpty(startDate) && StringUtil.isNotEmpty(endDate)) {
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parseDate(startDate));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parseDate(endDate));
}
page = orderService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/export",method = RequestMethod.GET)
@RequestMapping(value = "/export", method = RequestMethod.GET)
public Object export(@RequestParam(value = "mobile", required = false) String mobile,
@RequestParam(value = "orderSn", required = false) String orderSn) {
List<SearchFilter> filters = Lists.newArrayList();
if(StringUtil.isNotEmpty(mobile)){
if (StringUtil.isNotEmpty(mobile)) {
filters.add(SearchFilter.build("user.mobile", mobile));
}
if(StringUtil.isNotEmpty(orderSn)){
filters.add(SearchFilter.build("orderSn",orderSn));
if (StringUtil.isNotEmpty(orderSn)) {
filters.add(SearchFilter.build("orderSn", orderSn));
}
List<Order> orderList = orderService.queryAll(filters);
Map data = Maps.newHashMap("list",orderList);
String now = DateUtil.formatDate(new Date(),DateUtil.DATE_TIME_FMT);
data.put("exportTime",now);
Map data = Maps.newHashMap("list", orderList);
String now = DateUtil.formatDate(new Date(), DateUtil.DATE_TIME_FMT);
data.put("exportTime", now);
data.put("userName", JwtUtil.getUsername());
FileInfo fileInfo = fileService.createExcel("templates/orderList.xlsx","订单列表.xlsx",data);
FileInfo fileInfo = fileService.createExcel("templates/orderList.xlsx", "订单列表.xlsx", data);
return Rets.success(fileInfo);
}
@RequestMapping(value = "/sendOut/{id}", method = RequestMethod.POST)
@BussinessLog(value = "发货", key = "id")
public Object sendOut(@PathVariable("id") Long id,
@RequestParam("idExpress") Long idExpress,
@RequestParam("shippingSn") String shippingSn,
@RequestParam(value = "shippingAmount",defaultValue = "0",required = false) String shippingAmount) {
@RequestParam(value = "shippingAmount", defaultValue = "0", required = false) String shippingAmount) {
Order order = orderService.get(id);
order.setIdExpress(idExpress);
order.setShippingSn(shippingSn);
......@@ -118,12 +121,13 @@ public class OrderController {
orderService.send(order);
return Rets.success();
}
@RequestMapping(value = "/comment/{id}", method = RequestMethod.POST)
@BussinessLog(value = "管理员添加备注", key = "id")
public Object comment(@PathVariable("id") Long id,@RequestParam("message") String message) {
public Object comment(@PathVariable("id") Long id, @RequestParam("message") String message) {
Order order = orderService.get(id);
order.setAdminMessage(message);
orderService.addComment(order,message);
orderService.addComment(order, message);
return Rets.success();
}
......@@ -136,13 +140,14 @@ public class OrderController {
Order order = orderService.getByOrderSn(orderSn);
return Rets.success(order);
}
@RequestMapping(value="/getShippingInfo/{shippingSn}/{shipperCode}")
public Object getShippingInfo(String shippingSn,String shipperCode){
@RequestMapping(value = "/getShippingInfo/{shippingSn}/{shipperCode}")
public Object getShippingInfo(String shippingSn, String shipperCode) {
String apiKdniaoUserid = cfgService.getCfgValue(CfgKey.API_KDNIAO_USERID);
if (StringUtil.isEmpty(apiKdniaoUserid)) {
return Rets.failure("你没有配置快递鸟服务参数");
}
KdniaoResponse response = kdniaoService.realTimeQuery(shippingSn,shipperCode);
KdniaoResponse response = kdniaoService.realTimeQuery(shippingSn, shipperCode);
return Rets.success(response);
}
}
......@@ -15,14 +15,14 @@ import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/shop/order/item")
public class OrderItemController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private OrderItemService orderItemService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private OrderItemService orderItemService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<OrderItem> page = new PageFactory<OrderItem>().defaultPage();
page = orderItemService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<OrderItem> page = new PageFactory<OrderItem>().defaultPage();
page = orderItemService.queryPage(page);
return Rets.success(page);
}
}
......@@ -19,18 +19,20 @@ import java.util.List;
@RestController
@RequestMapping("/shop/order/log")
public class OrderLogController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private OrderLogService orderLogService;
@RequestMapping(value = "/queryByIdOrder/{idOrder}",method = RequestMethod.GET)
public Object queryByIdOrder(@PathVariable("idOrder") Long idOrder){
List<OrderLog> logList = orderLogService.queryAll(SearchFilter.build("idOrder",idOrder));
return Rets.success(logList);
}
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list() {
Page<OrderLog> page = new PageFactory<OrderLog>().defaultPage();
page = orderLogService.queryPage(page);
return Rets.success(page);
}
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private OrderLogService orderLogService;
@RequestMapping(value = "/queryByIdOrder/{idOrder}", method = RequestMethod.GET)
public Object queryByIdOrder(@PathVariable("idOrder") Long idOrder) {
List<OrderLog> logList = orderLogService.queryAll(SearchFilter.build("idOrder", idOrder));
return Rets.success(logList);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list() {
Page<OrderLog> page = new PageFactory<OrderLog>().defaultPage();
page = orderLogService.queryPage(page);
return Rets.success(page);
}
}
......@@ -24,64 +24,64 @@ import java.util.Map;
@RestController
@RequestMapping("/shop/user")
public class ShopUserController {
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ShopUserService shopUserService;
@Autowired
private CartService cartService;
@Autowired
private OrderService orderService;
private Logger logger = LoggerFactory.getLogger(getClass());
@Autowired
private ShopUserService shopUserService;
@Autowired
private CartService cartService;
@Autowired
private OrderService orderService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
public Object list(@RequestParam(required = false) String mobile, @RequestParam(required = false) String nickName,
@RequestParam(required = false) String startRegDate,
@RequestParam(required = false) String endRegDate,
@RequestParam(required = false) String startLastLoginTime,
@RequestParam(required = false) String endLastLoginTime) {
Page<ShopUser> page = new PageFactory<ShopUser>().defaultPage();
page.addFilter("mobile",mobile);
page.addFilter("nickName",nickName);
if(StringUtil.isNotEmpty(startRegDate)) {
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parseTime(startRegDate+" 00:00:00"));
}
if(StringUtil.isNotEmpty(endRegDate)) {
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parseTime(endRegDate+" 23:59:59"));
}
if(StringUtil.isNotEmpty(startLastLoginTime)) {
page.addFilter("lastLoginTime", SearchFilter.Operator.GTE, DateUtil.parseTime(startLastLoginTime+" 00:00:00"));
}
if(StringUtil.isNotEmpty(endLastLoginTime)) {
page.addFilter("lastLoginTime", SearchFilter.Operator.LTE, DateUtil.parseTime(endLastLoginTime+" 23:59:59"));
}
page = shopUserService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
public Object list(@RequestParam(required = false) String mobile, @RequestParam(required = false) String nickName,
@RequestParam(required = false) String startRegDate,
@RequestParam(required = false) String endRegDate,
@RequestParam(required = false) String startLastLoginTime,
@RequestParam(required = false) String endLastLoginTime) {
Page<ShopUser> page = new PageFactory<ShopUser>().defaultPage();
page.addFilter("mobile", mobile);
page.addFilter("nickName", nickName);
if (StringUtil.isNotEmpty(startRegDate)) {
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parseTime(startRegDate + " 00:00:00"));
}
if (StringUtil.isNotEmpty(endRegDate)) {
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parseTime(endRegDate + " 23:59:59"));
}
if (StringUtil.isNotEmpty(startLastLoginTime)) {
page.addFilter("lastLoginTime", SearchFilter.Operator.GTE, DateUtil.parseTime(startLastLoginTime + " 00:00:00"));
}
if (StringUtil.isNotEmpty(endLastLoginTime)) {
page.addFilter("lastLoginTime", SearchFilter.Operator.LTE, DateUtil.parseTime(endLastLoginTime + " 23:59:59"));
}
page = shopUserService.queryPage(page);
return Rets.success(page);
}
@RequestMapping(value="{id}",method = RequestMethod.GET)
public Object get(@PathVariable("id") Long id){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
return Rets.success(shopUserService.get(id));
}
@RequestMapping(value = "{id}", method = RequestMethod.GET)
public Object get(@PathVariable("id") Long id) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
return Rets.success(shopUserService.get(id));
}
@RequestMapping(value="/info/{id}",method = RequestMethod.GET)
public Object getInfo(@PathVariable("id") Long id){
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
ShopUser shopUser = shopUserService.get(id);
@RequestMapping(value = "/info/{id}", method = RequestMethod.GET)
public Object getInfo(@PathVariable("id") Long id) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
ShopUser shopUser = shopUserService.get(id);
SearchFilter filter = SearchFilter.build("idUser",id);
Long cartCount = cartService.count(filter);
Long orderCount = orderService.count(filter);
ShopUser shopUser1 = new ShopUser();
BeanUtils.copyProperties(shopUser,shopUser1,"password","salt");
Map<String,Object> data = Maps.newHashMap(
"cartCount",cartCount,
"orderCount",orderCount,
"info",shopUser1
);
return Rets.success(data);
}
SearchFilter filter = SearchFilter.build("idUser", id);
Long cartCount = cartService.count(filter);
Long orderCount = orderService.count(filter);
ShopUser shopUser1 = new ShopUser();
BeanUtils.copyProperties(shopUser, shopUser1, "password", "salt");
Map<String, Object> data = Maps.newHashMap(
"cartCount", cartCount,
"orderCount", orderCount,
"info", shopUser1
);
return Rets.success(data);
}
}
......@@ -45,14 +45,14 @@ public class CfgController extends BaseController {
/**
* 查询参数列表
*/
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.CFG})
public Object list(@RequestParam(required = false) String cfgName, @RequestParam(required = false) String cfgValue) {
Page<Cfg> page = new PageFactory<Cfg>().defaultPage();
if(StringUtil.isNotEmpty(cfgName)){
if (StringUtil.isNotEmpty(cfgName)) {
page.addFilter(SearchFilter.build("cfgName", SearchFilter.Operator.LIKE, cfgName));
}
if(StringUtil.isNotEmpty(cfgValue)){
if (StringUtil.isNotEmpty(cfgValue)) {
page.addFilter(SearchFilter.build("cfgValue", SearchFilter.Operator.LIKE, cfgValue));
}
page = cfgService.queryPage(page);
......@@ -61,61 +61,65 @@ public class CfgController extends BaseController {
/**
* 分组查询参数
*
* @param cfgGroup
* @return
*/
@RequestMapping(value = "/getByPrefix",method = RequestMethod.GET)
@RequestMapping(value = "/getByPrefix", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.CFG})
public Object list(@RequestParam(required = false) String cfgGroup) {
List<Cfg> list = cfgService.queryAll(SearchFilter.build("cfgName", SearchFilter.Operator.LIKEL,cfgGroup));
List<Cfg> list = cfgService.queryAll(SearchFilter.build("cfgName", SearchFilter.Operator.LIKEL, cfgGroup));
Map map = Maps.newHashMap();
for(Cfg cfg:list){
map.put(cfg.getCfgName(),cfg.getCfgValue());
for (Cfg cfg : list) {
map.put(cfg.getCfgName(), cfg.getCfgValue());
}
return Rets.success(Maps.newHashMap("list",list,"map",map));
return Rets.success(Maps.newHashMap("list", list, "map", map));
}
/**
* 导出参数列表
*
* @param cfgName
* @param cfgValue
* @return
*/
@RequestMapping(value = "/export",method = RequestMethod.GET)
@RequestMapping(value = "/export", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.CFG})
public Object export(@RequestParam(required = false) String cfgName, @RequestParam(required = false) String cfgValue) {
Page<Cfg> page = new PageFactory<Cfg>().defaultPage();
if(StringUtil.isNotEmpty(cfgName)){
if (StringUtil.isNotEmpty(cfgName)) {
page.addFilter(SearchFilter.build("cfgName", SearchFilter.Operator.LIKE, cfgName));
}
if(StringUtil.isNotEmpty(cfgValue)){
if (StringUtil.isNotEmpty(cfgValue)) {
page.addFilter(SearchFilter.build("cfgValue", SearchFilter.Operator.LIKE, cfgValue));
}
page = cfgService.queryPage(page);
FileInfo fileInfo = fileService.createExcel("templates/config.xlsx","系统参数.xlsx",Maps.newHashMap("list",page.getRecords()));
FileInfo fileInfo = fileService.createExcel("templates/config.xlsx", "系统参数.xlsx", Maps.newHashMap("list", page.getRecords()));
return Rets.success(fileInfo);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑参数", key = "cfgName")
@RequiresPermissions(value = {Permission.CFG_EDIT})
public Object save(@ModelAttribute @Valid Cfg cfg){
if(cfg.getId()!=null){
public Object save(@ModelAttribute @Valid Cfg cfg) {
if (cfg.getId() != null) {
Cfg old = cfgService.get(cfg.getId());
LogObjectHolder.me().set(old);
old.setCfgName(cfg.getCfgName());
old.setCfgValue(cfg.getCfgValue());
old.setCfgDesc(cfg.getCfgDesc());
cfgService.saveOrUpdate(old);
}else {
} else {
cfgService.saveOrUpdate(cfg);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除参数", key = "id")
@RequiresPermissions(value = {Permission.CFG_DEL})
public Object remove(@RequestParam Long id){
logger.info("id:{}",id);
public Object remove(@RequestParam Long id) {
logger.info("id:{}", id);
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
......@@ -123,14 +127,14 @@ public class CfgController extends BaseController {
return Rets.success();
}
@RequestMapping(value="saveGroup",method = RequestMethod.POST)
@RequestMapping(value = "saveGroup", method = RequestMethod.POST)
@BussinessLog(value = "编辑参数")
@RequiresPermissions(value = {Permission.CFG_EDIT})
public Object saveGroup(String json){
public Object saveGroup(String json) {
Map<String,String> map = Json.fromJson(Map.class,json);
for(Map.Entry<String,String> entry:map.entrySet()){
cfgService.update(entry.getKey(),entry.getValue());
Map<String, String> map = Json.fromJson(Map.class, json);
for (Map.Entry<String, String> entry : map.entrySet()) {
cfgService.update(entry.getKey(), entry.getValue());
}
return Rets.success();
}
......
......@@ -33,20 +33,22 @@ public class DeptContoller extends BaseController {
@Autowired
private DeptService deptService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.DEPT})
public Object list(){
public Object list() {
List<DeptNode> list = deptService.queryAllNode();
return Rets.success(list);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑部门", key = "simplename")
@RequiresPermissions(value = {Permission.DEPT_EDIT})
public Object save(@ModelAttribute @Valid Dept dept){
public Object save(@ModelAttribute @Valid Dept dept) {
if (BeanUtil.isOneEmpty(dept, dept.getSimplename())) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
if(dept.getId()!=null){
if (dept.getId() != null) {
Dept old = deptService.get(dept.getId());
LogObjectHolder.me().set(old);
old.setPid(dept.getPid());
......@@ -56,17 +58,18 @@ public class DeptContoller extends BaseController {
old.setTips(dept.getTips());
deptService.deptSetPids(old);
deptService.update(old);
}else {
} else {
deptService.deptSetPids(dept);
deptService.insert(dept);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除部门", key = "id")
@RequiresPermissions(value = {Permission.DEPT_DEL})
public Object remove(@RequestParam Long id){
logger.info("id:{}",id);
public Object remove(@RequestParam Long id) {
logger.info("id:{}", id);
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
......
......@@ -35,11 +35,11 @@ public class DictController extends BaseController {
/**
* 获取所有字典列表
*/
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.DICT})
public Object list(String name) {
if(StringUtil.isNotEmpty(name)){
if (StringUtil.isNotEmpty(name)) {
List<Dict> list = dictService.findByNameLike(name);
return Rets.success(new DictWarpper(BeanUtil.objectsToMaps(list)).warp());
}
......@@ -61,11 +61,11 @@ public class DictController extends BaseController {
@RequestMapping(method = RequestMethod.PUT)
@BussinessLog(value = "修改字典", key = "dictName")
@RequiresPermissions(value = {Permission.DICT_EDIT})
public Object update(Long id,String dictName, String dictValues) {
public Object update(Long id, String dictName, String dictValues) {
if (BeanUtil.isOneEmpty(dictName, dictValues)) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
dictService.editDict(id,dictName, dictValues);
dictService.editDict(id, dictName, dictValues);
return Rets.success();
}
......
......@@ -30,6 +30,7 @@ public class ExpressController {
/**
* 分页查询物流公司
*
* @return
*/
@RequestMapping(value = "/list", method = RequestMethod.GET)
......@@ -43,6 +44,7 @@ public class ExpressController {
/**
* 获取全部非禁用的物流公司列表
*
* @return
*/
@RequestMapping(value = "/queryAll", method = RequestMethod.GET)
......@@ -79,14 +81,14 @@ public class ExpressController {
return Rets.success();
}
@RequestMapping(value="/changeDisabled",method = RequestMethod.POST)
@RequestMapping(value = "/changeDisabled", method = RequestMethod.POST)
@RequiresPermissions(value = {Permission.EXPRESS_EDIT})
@BussinessLog(value = "启用禁用物流公司", key = "id")
public Object changeIsOnSale(@RequestParam("id") Long id, @RequestParam("disabled") Boolean disabled){
public Object changeIsOnSale(@RequestParam("id") Long id, @RequestParam("disabled") Boolean disabled) {
if (id == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
expressService.changeDisabled(id,disabled);
expressService.changeDisabled(id, disabled);
return Rets.success();
}
}
package cn.enilu.flash.api.controller.system;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.constant.factory.PageFactory;
import cn.enilu.flash.bean.constant.state.BizLogType;
import cn.enilu.flash.bean.entity.system.OperationLog;
......@@ -13,6 +12,7 @@ import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.HttpUtil;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.warpper.LogWarpper;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -44,7 +44,7 @@ public class LogController extends BaseController {
Page<OperationLog> page = new PageFactory<OperationLog>().defaultPage();
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parseDate(beginTime));
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parseDate(endTime));
page.addFilter( "logname", SearchFilter.Operator.LIKE, logName);
page.addFilter("logname", SearchFilter.Operator.LIKE, logName);
if (logType != null) {
page.addFilter(SearchFilter.build("logtype", SearchFilter.Operator.EQ, BizLogType.valueOf(logType)));
}
......
package cn.enilu.flash.api.controller.system;
import cn.enilu.flash.utils.StringUtil;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.constant.factory.PageFactory;
import cn.enilu.flash.bean.entity.system.LoginLog;
import cn.enilu.flash.bean.enumeration.Permission;
......@@ -10,8 +8,10 @@ import cn.enilu.flash.bean.vo.query.SearchFilter;
import cn.enilu.flash.service.system.LoginLogService;
import cn.enilu.flash.utils.BeanUtil;
import cn.enilu.flash.utils.DateUtil;
import cn.enilu.flash.utils.StringUtil;
import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.warpper.LogWarpper;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -32,19 +32,20 @@ import java.util.List;
public class LoginLogController extends BaseController {
@Autowired
private LoginLogService loginlogService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.LOGIN_LOG})
public Object list(@RequestParam(required = false) String beginTime,
@RequestParam(required = false) String endTime,
@RequestParam(required = false) String logName) {
Page<LoginLog> page = new PageFactory<LoginLog>().defaultPage();
if(StringUtil.isNotEmpty(beginTime)) {
if (StringUtil.isNotEmpty(beginTime)) {
page.addFilter("createTime", SearchFilter.Operator.GTE, DateUtil.parseDate(beginTime));
}
if(StringUtil.isNotEmpty(endTime)) {
if (StringUtil.isNotEmpty(endTime)) {
page.addFilter("createTime", SearchFilter.Operator.LTE, DateUtil.parseDate(endTime));
}
page.addFilter( "logname", SearchFilter.Operator.LIKE, logName);
page.addFilter("logname", SearchFilter.Operator.LIKE, logName);
Page pageResult = loginlogService.queryPage(page);
pageResult.setRecords((List<LoginLog>) new LogWarpper(BeanUtil.objectsToMaps(pageResult.getRecords())).warp());
return Rets.success(pageResult);
......
......@@ -54,6 +54,7 @@ public class MenuController extends BaseController {
List<RouterMenu> list = menuService.getSideBarMenus(shiroUser.getRoleList());
return Rets.success(list);
}
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.MENU})
public Object list() {
......@@ -66,7 +67,7 @@ public class MenuController extends BaseController {
@RequiresPermissions(value = {Permission.MENU_EDIT})
public Object save(@ModelAttribute @Valid Menu menu) {
//判断是否存在该编号
if(menu.getId()==null) {
if (menu.getId() == null) {
String existedMenuName = ConstantFactory.me().getMenuNameByCode(menu.getCode());
if (StringUtil.isNotEmpty(existedMenuName)) {
throw new ApplicationException(ApplicationExceptionEnum.EXISTED_THE_MENU);
......@@ -76,9 +77,9 @@ public class MenuController extends BaseController {
//设置父级菜单编号
menuService.menuSetPcode(menu);
if(menu.getId()==null){
if (menu.getId() == null) {
menuService.insert(menu);
}else {
} else {
Menu old = menuService.get(menu.getId());
LogObjectHolder.me().set(old);
menuService.update(menu);
......@@ -95,7 +96,7 @@ public class MenuController extends BaseController {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
//演示环境不允许删除初始化的菜单
if(id.intValue()<70){
if (id.intValue() < 70) {
return Rets.failure("演示环境不允许删除初始菜单");
}
//缓存菜单的名称
......@@ -112,7 +113,7 @@ public class MenuController extends BaseController {
public Object menuTreeListByRoleId(Integer roleId) {
List<Long> menuIds = menuService.getMenuIdsByRoleId(roleId);
List<ZTreeNode> roleTreeList = null;
if (menuIds==null||menuIds.isEmpty()) {
if (menuIds == null || menuIds.isEmpty()) {
roleTreeList = menuService.menuTreeList(null);
} else {
roleTreeList = menuService.menuTreeList(menuIds);
......@@ -121,10 +122,10 @@ public class MenuController extends BaseController {
List<Node> list = menuService.generateMenuTreeForRole(roleTreeList);
//element-ui中tree控件中如果选中父节点会默认选中所有子节点,所以这里将所有非叶子节点去掉
Map<Long,ZTreeNode> map = cn.enilu.flash.utils.Lists.toMap(roleTreeList,"id");
Map<Long,List<ZTreeNode>> group = cn.enilu.flash.utils.Lists.group(roleTreeList,"pId");
for(Map.Entry<Long,List<ZTreeNode>> entry:group.entrySet()){
if(entry.getValue().size()>1){
Map<Long, ZTreeNode> map = cn.enilu.flash.utils.Lists.toMap(roleTreeList, "id");
Map<Long, List<ZTreeNode>> group = cn.enilu.flash.utils.Lists.group(roleTreeList, "pId");
for (Map.Entry<Long, List<ZTreeNode>> entry : group.entrySet()) {
if (entry.getValue().size() > 1) {
roleTreeList.remove(map.get(entry.getKey()));
}
}
......@@ -132,7 +133,7 @@ public class MenuController extends BaseController {
List<Long> checkedIds = Lists.newArrayList();
for (ZTreeNode zTreeNode : roleTreeList) {
if (zTreeNode.getChecked() != null && zTreeNode.getChecked()
&&zTreeNode.getpId().intValue()!=0) {
&& zTreeNode.getpId().intValue() != 0) {
checkedIds.add(zTreeNode.getId());
}
}
......
package cn.enilu.flash.api.controller.system;
import cn.enilu.flash.web.controller.BaseController;
import cn.enilu.flash.bean.entity.system.Notice;
import cn.enilu.flash.bean.vo.front.Rets;
import cn.enilu.flash.service.system.NoticeService;
import cn.enilu.flash.web.controller.BaseController;
import com.google.common.base.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -22,15 +22,16 @@ import java.util.List;
public class NoticeController extends BaseController {
@Autowired
private NoticeService noticeService;
/**
* 获取通知列表
*/
@RequestMapping(value = "/list")
public Object list(String condition) {
List<Notice> list = null;
if(Strings.isNullOrEmpty(condition)) {
list = noticeService.queryAll();
}else{
if (Strings.isNullOrEmpty(condition)) {
list = noticeService.queryAll();
} else {
list = noticeService.findByTitleLike(condition);
}
return Rets.success(list);
......
......@@ -44,13 +44,14 @@ public class RoleController extends BaseController {
private RoleService roleService;
@Autowired
private ManagerService managerService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.ROLE})
public Object list(String name){
public Object list(String name) {
List roles = null;
if(Strings.isNullOrEmpty(name)) {
roles = roleService.queryAll();
}else{
if (Strings.isNullOrEmpty(name)) {
roles = roleService.queryAll();
} else {
roles = roleService.findByName(name);
}
return Rets.success(new RoleWarpper(BeanUtil.objectsToMaps(roles)).warp());
......@@ -59,33 +60,34 @@ public class RoleController extends BaseController {
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑角色", key = "name")
@RequiresPermissions(value = {Permission.ROLE_EDIT})
public Object save(@Valid Role role){
if(role.getId()==null) {
public Object save(@Valid Role role) {
if (role.getId() == null) {
roleService.insert(role);
}else{
} else {
Role old = roleService.get(role.getId());
LogObjectHolder.me().set(old);
roleService.update(role);
}
return Rets.success();
}
@RequestMapping(method = RequestMethod.DELETE)
@BussinessLog(value = "删除角色", key = "roleId")
@RequiresPermissions(value = {Permission.ROLE_DEL})
public Object remove(@RequestParam Long roleId){
logger.info("id:{}",roleId);
if (roleId==null) {
public Object remove(@RequestParam Long roleId) {
logger.info("id:{}", roleId);
if (roleId == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
if(roleId.intValue()<2){
if (roleId.intValue() < 2) {
return Rets.failure("不能删除初始角色");
}
List<User> userList = managerService.queryAll(SearchFilter.build("roleid", SearchFilter.Operator.EQ,String.valueOf(roleId)));
if(!userList.isEmpty()){
List<User> userList = managerService.queryAll(SearchFilter.build("roleid", SearchFilter.Operator.EQ, String.valueOf(roleId)));
if (!userList.isEmpty()) {
return Rets.failure("有用户使用该角色,禁止删除");
}
//不能删除超级管理员角色
if(roleId.intValue() ==Const.ADMIN_ROLE_ID){
if (roleId.intValue() == Const.ADMIN_ROLE_ID) {
return Rets.failure("禁止删除超级管理员角色");
}
//缓存被删除的角色名称
......@@ -94,7 +96,7 @@ public class RoleController extends BaseController {
return Rets.success();
}
@RequestMapping(value = "/savePermisson",method = RequestMethod.POST)
@RequestMapping(value = "/savePermisson", method = RequestMethod.POST)
@BussinessLog(value = "配置角色权限", key = "roleId")
@RequiresPermissions(value = {Permission.ROLE_EDIT})
public Object setAuthority(Long roleId, String
......
......@@ -15,7 +15,6 @@ import cn.enilu.flash.utils.factory.Page;
import cn.enilu.flash.web.controller.BaseController;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
......@@ -23,6 +22,7 @@ import javax.validation.Valid;
/**
* Created on 2018/4/9 0009.
* 系统参数
*
* @author enilu
*/
@RestController
......@@ -42,9 +42,9 @@ public class TaskController extends BaseController {
@RequestMapping(value = "/list")
@RequiresPermissions(value = {Permission.TASK})
public Object list(String name) {
if(StringUtil.isNullOrEmpty(name)) {
if (StringUtil.isNullOrEmpty(name)) {
return Rets.success(taskService.queryAll());
}else{
} else {
return Rets.success(taskService.queryAllByNameLike(name));
}
}
......@@ -56,9 +56,9 @@ public class TaskController extends BaseController {
@BussinessLog(value = "编辑定时任务", key = "name")
@RequiresPermissions(value = {Permission.TASK_EDIT})
public Object add(@ModelAttribute @Valid Task task) {
if(task.getId()==null) {
if (task.getId() == null) {
taskService.save(task);
}else{
} else {
Task old = taskService.get(task.getId());
LogObjectHolder.me().set(old);
old.setName(task.getName());
......@@ -83,28 +83,29 @@ public class TaskController extends BaseController {
return Rets.success();
}
@RequestMapping(value = "/disable",method = RequestMethod.POST)
@RequestMapping(value = "/disable", method = RequestMethod.POST)
@BussinessLog(value = "禁用定时任务", key = "taskId")
@RequiresPermissions(value = {Permission.TASK_EDIT})
public Object disable(@RequestParam Long taskId ) {
public Object disable(@RequestParam Long taskId) {
taskService.disable(taskId);
return Rets.success();
}
@RequestMapping(value = "/enable",method = RequestMethod.POST)
@RequestMapping(value = "/enable", method = RequestMethod.POST)
@BussinessLog(value = "启用定时任务", key = "taskId")
@RequiresPermissions(value = {Permission.TASK_EDIT})
public Object enable(@RequestParam Long taskId ) {
public Object enable(@RequestParam Long taskId) {
taskService.enable(taskId);
return Rets.success();
}
@RequestMapping(value="/logList")
@RequestMapping(value = "/logList")
@RequiresPermissions(value = {Permission.TASK})
public Object logList(@RequestParam Long taskId) {
public Object logList(@RequestParam Long taskId) {
Page<TaskLog> page = new PageFactory<TaskLog>().defaultPage();
page.addFilter(SearchFilter.build("idTask", SearchFilter.Operator.EQ,taskId));
page.addFilter(SearchFilter.build("idTask", SearchFilter.Operator.EQ, taskId));
page = taskLogService.queryPage(page);
return Rets.success(page);
}
......
......@@ -43,28 +43,30 @@ import java.util.List;
public class UserController extends BaseController {
@Autowired
private ManagerService managerService;
@RequestMapping(value = "/list",method = RequestMethod.GET)
@RequestMapping(value = "/list", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.USER})
public Object list(@RequestParam(required = false) String account,
@RequestParam(required = false) String name){
@RequestParam(required = false) String name) {
Page page = new PageFactory().defaultPage();
if(StringUtil.isNotEmpty(name)){
if (StringUtil.isNotEmpty(name)) {
page.addFilter(SearchFilter.build("name", SearchFilter.Operator.LIKE, name));
}
if(StringUtil.isNotEmpty(account)){
if (StringUtil.isNotEmpty(account)) {
page.addFilter(SearchFilter.build("account", SearchFilter.Operator.LIKE, account));
}
page.addFilter(SearchFilter.build("status",SearchFilter.Operator.GT,0));
page.addFilter(SearchFilter.build("status", SearchFilter.Operator.GT, 0));
page = managerService.queryPage(page);
List list = (List) new UserWarpper(BeanUtil.objectsToMaps(page.getRecords())).warp();
page.setRecords(list);
return Rets.success(page);
}
@RequestMapping(method = RequestMethod.POST)
@BussinessLog(value = "编辑管理员", key = "name")
@RequiresPermissions(value = {Permission.USER_EDIT})
public Object save( @Valid UserDto user,BindingResult result){
if(user.getId()==null) {
public Object save(@Valid UserDto user, BindingResult result) {
if (user.getId() == null) {
// 判断账号是否重复
User theUser = managerService.findByAccount(user.getAccount());
if (theUser != null) {
......@@ -75,11 +77,11 @@ public class UserController extends BaseController {
user.setPassword(MD5.md5(user.getPassword(), user.getSalt()));
user.setStatus(ManagerStatus.OK.getCode());
managerService.insert(UserFactory.createUser(user, new User()));
}else{
} else {
User oldUser = managerService.get(user.getId());
LogObjectHolder.me().set(oldUser);
managerService.update(UserFactory.updateUser(user,oldUser));
managerService.update(UserFactory.updateUser(user, oldUser));
}
return Rets.success();
}
......@@ -87,11 +89,11 @@ public class UserController extends BaseController {
@BussinessLog(value = "删除管理员", key = "userId")
@RequestMapping(method = RequestMethod.DELETE)
@RequiresPermissions(value = {Permission.USER_DEL})
public Object remove(@RequestParam Long userId){
public Object remove(@RequestParam Long userId) {
if (userId == null) {
throw new ApplicationException(ApplicationExceptionEnum.REQUEST_NULL);
}
if(userId.intValue()<=2){
if (userId.intValue() <= 2) {
return Rets.failure("不能删除初始用户");
}
User user = managerService.get(userId);
......@@ -99,8 +101,9 @@ public class UserController extends BaseController {
managerService.update(user);
return Rets.success();
}
@BussinessLog(value="设置用户角色",key="userId")
@RequestMapping(value="/setRole",method = RequestMethod.GET)
@BussinessLog(value = "设置用户角色", key = "userId")
@RequestMapping(value = "/setRole", method = RequestMethod.GET)
@RequiresPermissions(value = {Permission.USER_EDIT})
public Object setRole(@RequestParam("userId") Long userId, @RequestParam("roleIds") String roleIds) {
if (BeanUtil.isOneEmpty(userId, roleIds)) {
......
......@@ -33,7 +33,7 @@ public class StartJob implements ApplicationRunner {
@Override
public void run(ApplicationArguments applicationArguments) throws Exception {
log.info("start Job >>>>>>>>>>>>>>>>>>>>>>>");
List<Task> tasks = taskService.queryAll(SearchFilter.build("disabled", SearchFilter.Operator.EQ,false));
List<Task> tasks = taskService.queryAll(SearchFilter.build("disabled", SearchFilter.Operator.EQ, false));
for (Task task : tasks) {
jobService.addJob(jobService.getJob(task));
}
......
......@@ -15,26 +15,26 @@ import javax.servlet.http.HttpSession;
*/
public class SessionUtils {
public static HttpSession getSession() {
if (RequestContextHolder.getRequestAttributes() == null) {
return null;
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
return request.getSession();
}
public static HttpServletRequest getRequest() {
if (RequestContextHolder.getRequestAttributes() == null) {
return null;
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
return request;
}
public static ServletContext getServletContext() {
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
return context.getServletContext();
}
public static HttpSession getSession() {
if (RequestContextHolder.getRequestAttributes() == null) {
return null;
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
return request.getSession();
}
public static HttpServletRequest getRequest() {
if (RequestContextHolder.getRequestAttributes() == null) {
return null;
}
HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
return request;
}
public static ServletContext getServletContext() {
WebApplicationContext context = ContextLoader.getCurrentWebApplicationContext();
return context.getServletContext();
}
}
\ No newline at end of file
......@@ -9,5 +9,4 @@ spring.datasource.password=123456
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.sql-script-encoding=utf-8
spring.jpa.show-sql=true
#server.servlet.context-path=/api
......@@ -3,11 +3,9 @@ debug=false
spring.datasource.url=jdbc:mysql://my-db:3306/linjiashop?useUnicode=true&characterEncoding=UTF8
spring.datasource.username=linjiashop
spring.datasource.password=linjiaSHOP@191028
#spring.jpa.hibernate.ddl-auto=create
#\u9ED8\u8BA4\u4F7F\u7528InnoDB\u5F15\u64CE
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect
spring.datasource.sql-script-encoding=utf-8
spring.jpa.show-sql=true
#server.servlet.context-path=/api
##\u6253\u5305\u90E8\u7F72\u7684\u65F6\u5019\u5C06\u8BE5\u914D\u7F6E\u66F4\u6539\u4E3Aprod
spring.profiles.active=dev
server.port=8082
server.tomcat.max-threads=800
spring.main.allow-bean-definition-overriding=true
spring.jpa.hibernate.use-new-id-generator-mappings=false
### token\u6709\u6548\u671F\uFF1A\u5206\u949F
jwt.token.expire.time=30
### 0\u8868\u793A\u540E\u7AEF\u7528\u6237\uFF0C\u4E0D\u8981\u66F4\u6539
jwt.user.type=0
###\u76D1\u63A7\u914D\u7F6E begin###
# WebStatFilter\u914D\u7F6E\uFF0C\u8BF4\u660E\u8BF7\u53C2\u8003Druid Wiki\uFF0C\u914D\u7F6EWebStatFilter
spring.datasource.druid.web-stat-filter.enabled=true
spring.datasource.druid.web-stat-filter.url-pattern=/*
spring.datasource.druid.web-stat-filter.exclusions=*.js,*.gif,*.jpg,*.png,*.css,*.ico,/druid/*
# StatViewServlet\u914D\u7F6E\uFF0Ci\u8BF4\u660E\u8BF7\u53C2\u8003Druid Wiki\uFF0C\u914D\u7F6E_StatViewServlet\u914D\u7F6E
sprinag.datasource.druid.stat-view-servlet.enabled= true
spring.datasource.druid.stat-view-servlet.url-pattern= /druid/*
spring.datasource.druid.stat-view-servlet.reset-enable= false
spring.datasource.druid.stat-view-servlet.login-username= druiduser
spring.datasource.druid.stat-view-servlet.login-password= druidpassword
spring.datasource.druid.stat-view-servlet.allow= 127.0.0.1
sprinag.datasource.druid.stat-view-servlet.enabled=true
spring.datasource.druid.stat-view-servlet.url-pattern=/druid/*
spring.datasource.druid.stat-view-servlet.reset-enable=false
spring.datasource.druid.stat-view-servlet.login-username=druiduser
spring.datasource.druid.stat-view-servlet.login-password=druidpassword
spring.datasource.druid.stat-view-servlet.allow=127.0.0.1
###\u76D1\u63A7\u914D\u7F6E end###
spring.datasource.driverClassName=com.mysql.jdbc.Driver
spring.cache.ehcache.config=classpath:ehcache.xml
################### spring\u914D\u7F6E ###################
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8
......@@ -38,7 +33,6 @@ spring.devtools.restart.additional-paths=src/main/java
#false\u4E3A\u542F\u7528jdk\u9ED8\u8BA4\u52A8\u6001\u4EE3\u7406,true\u4E3Acglib\u52A8\u6001\u4EE3\u7406
spring.aop.proxy-target-class=true
logging.level.org.springframework.boot.autoconfigure=ERROR
################### \u90AE\u4EF6\u670D\u52A1\u914D\u7F6E ###################
spring.mail.host=smtp.qq.com
spring.mail.username=287291649@qq.com
......@@ -47,6 +41,5 @@ spring.mail.port=465
spring.mail.protocol=smtp
spring.mail.properties.mail.smtp.auth=true
spring.mail.properties.mail.smtp.ssl.enable=true
spring.servlet.multipart.enabled=true
spring.servlet.multipart.max-file-size=10MB
......@@ -2,7 +2,7 @@
<ehcache xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="ehcache.xsd"
updateCheck="false" monitoring="autodetect"
dynamicConfig="true" >
dynamicConfig="true">
<diskStore path="java.io.tmpdir/ehcache"/>
......@@ -18,9 +18,9 @@
<!-- 全局变量:永不过期-->
<cache name="CONSTANT"
maxElementsInMemory="50000"
maxElementsInMemory="50000"
eternal="true"
clearOnFlush="false"
clearOnFlush="false"
overflowToDisk="true"
diskSpoolBufferSizeMB="1024"
maxElementsOnDisk="100000"
......@@ -68,7 +68,7 @@
timeToIdleSeconds="86400"
timeToLiveSeconds="86400"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU" />
memoryStoreEvictionPolicy="LFU"/>
<cache name="HOUR"
maxElementsInMemory="10000"
......@@ -76,7 +76,7 @@
timeToIdleSeconds="3600"
timeToLiveSeconds="3600"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU" />
memoryStoreEvictionPolicy="LFU"/>
<cache name="MINUTE"
maxElementsInMemory="10000"
......@@ -84,30 +84,30 @@
timeToIdleSeconds="60"
timeToLiveSeconds="60"
overflowToDisk="false"
memoryStoreEvictionPolicy="LFU" />
memoryStoreEvictionPolicy="LFU"/>
</ehcache>
<!--
maxElementsInMemory="10000" //Cache中最多允许保存的数据对象的数量
external="false" //缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期
timeToLiveSeconds="3600" //缓存的存活时间,从开始创建的时间算起
timeToIdleSeconds="3600" //多长时间不访问该缓存,那么ehcache 就会清除该缓存
<!--
maxElementsInMemory="10000" //Cache中最多允许保存的数据对象的数量
external="false" //缓存中对象是否为永久的,如果是,超时设置将被忽略,对象从不过期
timeToLiveSeconds="3600" //缓存的存活时间,从开始创建的时间算起
timeToIdleSeconds="3600" //多长时间不访问该缓存,那么ehcache 就会清除该缓存
这两个参数很容易误解,看文档根本没用,我仔细分析了ehcache的代码。结论如下:
1、timeToLiveSeconds的定义是:以创建时间为基准开始计算的超时时长;
2、timeToIdleSeconds的定义是:在创建时间和最近访问时间中取出离现在最近的时间作为基准计算的超时时长;
3、如果仅设置了timeToLiveSeconds,则该对象的超时时间=创建时间+timeToLiveSeconds,假设为A;
4、如果没设置timeToLiveSeconds,则该对象的超时时间=min(创建时间,最近访问时间)+timeToIdleSeconds,假设为B;
5、如果两者都设置了,则取出A、B最少的值,即min(A,B),表示只要有一个超时成立即算超时。
这两个参数很容易误解,看文档根本没用,我仔细分析了ehcache的代码。结论如下:
1、timeToLiveSeconds的定义是:以创建时间为基准开始计算的超时时长;
2、timeToIdleSeconds的定义是:在创建时间和最近访问时间中取出离现在最近的时间作为基准计算的超时时长;
3、如果仅设置了timeToLiveSeconds,则该对象的超时时间=创建时间+timeToLiveSeconds,假设为A;
4、如果没设置timeToLiveSeconds,则该对象的超时时间=min(创建时间,最近访问时间)+timeToIdleSeconds,假设为B;
5、如果两者都设置了,则取出A、B最少的值,即min(A,B),表示只要有一个超时成立即算超时。
overflowToDisk="true" //内存不足时,是否启用磁盘缓存
diskSpoolBufferSizeMB //设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区
maxElementsOnDisk //硬盘最大缓存个数
diskPersistent //是否缓存虚拟机重启期数据The default value is false
diskExpiryThreadIntervalSeconds //磁盘失效线程运行时间间隔,默认是120秒。
memoryStoreEvictionPolicy="LRU" //当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)。
clearOnFlush //内存数量最大时是否清除
maxEntriesLocalHeap="0" //堆内存中最大缓存对象数,0没有限制
maxEntriesLocalDisk="1000" //硬盘最大缓存个数。
-->
overflowToDisk="true" //内存不足时,是否启用磁盘缓存
diskSpoolBufferSizeMB //设置DiskStore(磁盘缓存)的缓存区大小。默认是30MB。每个Cache都应该有自己的一个缓冲区
maxElementsOnDisk //硬盘最大缓存个数
diskPersistent //是否缓存虚拟机重启期数据The default value is false
diskExpiryThreadIntervalSeconds //磁盘失效线程运行时间间隔,默认是120秒。
memoryStoreEvictionPolicy="LRU" //当达到maxElementsInMemory限制时,Ehcache将会根据指定的策略去清理内存。默认策略是LRU(最近最少使用)。你可以设置为FIFO(先进先出)或是LFU(较少使用)。
clearOnFlush //内存数量最大时是否清除
maxEntriesLocalHeap="0" //堆内存中最大缓存对象数,0没有限制
maxEntriesLocalDisk="1000" //硬盘最大缓存个数。
-->
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="10 seconds" debug="false">
<!-- 应用名称 -->
<contextName>api</contextName>
<!-- 应用名称 -->
<contextName>api</contextName>
<!-- 向控制台输出日志 -->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-M-d HH:mm:ss} [%thread] %p [%logger{0}]:%L %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 向控制台输出日志 -->
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-M-d HH:mm:ss} [%thread] %p [%logger{0}]:%L %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 向文件输出日志 -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/data/app/linjiashop/runtime/log/api_%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>1000</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-M-d HH:mm:ss} [%thread] %p [%logger{0}]:%L %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- 向文件输出日志 -->
<appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>/data/app/linjiashop/runtime/log/api_%d{yyyy-MM-dd}.log</fileNamePattern>
<maxHistory>1000</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%d{yyyy-M-d HH:mm:ss} [%thread] %p [%logger{0}]:%L %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
</appender>
<!-- druid连接池的日志级别 -->
<logger name="com.alibaba.druid" level="DEBUG" />
<!-- druid连接池的日志级别 -->
<logger name="com.alibaba.druid" level="DEBUG"/>
<!-- snow_credit的日志级别 -->
<logger name="cn.enilu.flash" level="DEBUG" />
<!-- snow_credit的日志级别 -->
<logger name="cn.enilu.flash" level="DEBUG"/>
<!-- root级别的logger -->
<root level="INFO">
<appender-ref ref="file" />
<appender-ref ref="stdout" />
</root>
<!-- root级别的logger -->
<root level="INFO">
<appender-ref ref="file"/>
<appender-ref ref="stdout"/>
</root>
</configuration>
......@@ -22,11 +22,11 @@
</properties>
<dependencies>
<!-- <dependency>-->
<!-- <groupId>cn.enilu</groupId>-->
<!-- <artifactId>linjiashop-generator</artifactId>-->
<!-- <version>1.0.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>cn.enilu</groupId>-->
<!-- <artifactId>linjiashop-generator</artifactId>-->
<!-- <version>1.0.0-SNAPSHOT</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......
......@@ -3,6 +3,7 @@ package cn.enilu.flash.bean.constant;
/**
* 系统参数key列表
* 所有“系统管理”-“参数管理”中配置的参数的key都在此定义
*
* @author :enilu
* @date :Created in 1/19/2020 4:37 PM
*/
......
......@@ -27,7 +27,7 @@ public interface CacheKey {
String ORG_NAME = "org_name_";
String DIC_ALL = "dic_all_";
String CFG = "cfg_";
String MENU_NAME = "menu_name_" ;
String SYS_USER_NAME = "SYS_USER_NAME" ;
String FILE_INFO = "file_info" ;
String MENU_NAME = "menu_name_";
String SYS_USER_NAME = "SYS_USER_NAME";
String FILE_INFO = "file_info";
}
......@@ -20,12 +20,12 @@ public class PageFactory<T> {
HttpServletRequest request = HttpUtil.getRequest();
//每页多少条数据
int limit = 10;
if(request.getParameter("limit")!=null) {
if (request.getParameter("limit") != null) {
limit = Integer.valueOf(request.getParameter("limit"));
}
String pageNum = "1";
if(request.getParameter("page")!=null){
if (request.getParameter("page") != null) {
pageNum = request.getParameter("page");
}
//每页的偏移量(本页当前有多少条)
......
......@@ -8,6 +8,7 @@ import java.util.Set;
/**
* 自定义Authentication对象,使得Subject除了携带用户的登录名外还可以携带更多信息
*
* @author :enilu
* @date :Created in 2019/7/30 22:58
*/
......@@ -16,7 +17,7 @@ public class AuthorizationUser implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
* 主键ID
*/
private Long id;
/**
......@@ -27,7 +28,7 @@ public class AuthorizationUser implements Serializable {
private String name;
private Long deptId;
/**
* 角色集
* 角色集
*/
private List<Long> roleList;
/**
......
package cn.enilu.flash.bean.core;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.annotation.*;
/**
* 权限注解 用于检查权限 规定访问权限
......
......@@ -8,34 +8,34 @@ import java.util.Date;
/**
* 用户传输bean
*
*
* @author stylefeng
* @Date 2017/5/5 22:40
*/
@Data
public class UserDto{
public class UserDto {
private Long id;
private Long id;
@NotBlank(message = "账号不能为空")
private String account;
@NotBlank(message = "密码不能为空")
private String password;
private String salt;
@NotBlank(message = "姓名不能为空")
private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birthday;
private Integer sex;
private String email;
private String phone;
private String roleid;
private Long deptid;
private Long eduorgid;
private Integer status;
private Date createtime;
private Integer version;
private String avatar;
@NotBlank(message = "账号不能为空")
private String account;
@NotBlank(message = "密码不能为空")
private String password;
private String salt;
@NotBlank(message = "姓名不能为空")
private String name;
@DateTimeFormat(pattern = "yyyy-MM-dd")
private Date birthday;
private Integer sex;
private String email;
private String phone;
private String roleid;
private Long deptid;
private Long eduorgid;
private Integer status;
private Date createtime;
private Integer version;
private String avatar;
}
......@@ -15,30 +15,30 @@ import java.io.Serializable;
import java.util.Date;
/**
* 后端业务实体基类
* Created on 2019/1/8 0002.
*
* @author enilu
*/
@MappedSuperclass
@Data
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
public abstract class BaseEntity implements Serializable {
@Id
@GeneratedValue
private Long id;
@CreationTimestamp
@Column(name = "create_time",columnDefinition="DATETIME COMMENT '创建时间/注册时间'")
@Column(name = "create_time", columnDefinition = "DATETIME COMMENT '创建时间/注册时间'")
private Date createTime;
@Column(name = "create_by",columnDefinition="bigint COMMENT '创建人'")
@Column(name = "create_by", columnDefinition = "bigint COMMENT '创建人'")
@CreatedBy
private Long createBy;
@UpdateTimestamp
@Column(name = "modify_time",columnDefinition="DATETIME COMMENT '最后更新时间'")
@Column(name = "modify_time", columnDefinition = "DATETIME COMMENT '最后更新时间'")
private Date modifyTime;
@LastModifiedBy
@Column(name = "modify_by",columnDefinition="bigint COMMENT '最后更新人'")
@Column(name = "modify_by", columnDefinition = "bigint COMMENT '最后更新人'")
private Long modifyBy;
}
......@@ -14,23 +14,24 @@ import java.util.Date;
/**
* 前端业务实体基类
*
* @author :enilu
* @date :Created in 2019/10/29 19:09
*/
@MappedSuperclass
@Data
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
public abstract class ShopBaseEntity implements Serializable {
@Id
@GeneratedValue
private Long id;
@CreationTimestamp
@Column(name = "create_time",columnDefinition="DATETIME COMMENT '创建时间/注册时间'")
@Column(name = "create_time", columnDefinition = "DATETIME COMMENT '创建时间/注册时间'")
private Date createTime;
@UpdateTimestamp
@Column(name = "modify_time",columnDefinition="DATETIME COMMENT '最后更新时间'")
@Column(name = "modify_time", columnDefinition = "DATETIME COMMENT '最后更新时间'")
private Date modifyTime;
}
......@@ -11,8 +11,8 @@ import javax.persistence.EntityListeners;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
@Entity(name="t_cms_article")
@Table(appliesTo = "t_cms_article",comment = "文章")
@Entity(name = "t_cms_article")
@Table(appliesTo = "t_cms_article", comment = "文章")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Article extends BaseEntity {
......
......@@ -10,8 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.validation.constraints.NotBlank;
@Entity(name="t_cms_banner")
@Table(appliesTo = "t_cms_banner",comment = "文章")
@Entity(name = "t_cms_banner")
@Table(appliesTo = "t_cms_banner", comment = "文章")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Banner extends BaseEntity {
......
......@@ -10,8 +10,8 @@ import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.validation.constraints.NotBlank;
@Entity(name="t_cms_channel")
@Table(appliesTo = "t_cms_channel",comment = "文章栏目")
@Entity(name = "t_cms_channel")
@Table(appliesTo = "t_cms_channel", comment = "文章栏目")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Channel extends BaseEntity {
......
......@@ -8,9 +8,9 @@ import javax.persistence.Column;
import javax.persistence.Entity;
import javax.validation.constraints.NotBlank;
@Entity(name="t_cms_contacts")
@Entity(name = "t_cms_contacts")
@Data
@Table(appliesTo = "t_cms_contacts",comment = "邀约信息")
@Table(appliesTo = "t_cms_contacts", comment = "邀约信息")
public class Contacts extends BaseEntity {
@Column(columnDefinition = "VARCHAR(64) COMMENT '邀约人名称'")
@NotBlank(message = "名称不能为空")
......
......@@ -11,17 +11,17 @@ import javax.persistence.Entity;
* 历史消息
*/
@Data
@Entity(name="t_message")
@Table(appliesTo = "t_message",comment = "历史消息")
@Entity(name = "t_message")
@Table(appliesTo = "t_message", comment = "历史消息")
public class Message extends BaseEntity {
@Column(name="tpl_code",columnDefinition = "VARCHAR(32) COMMENT '模板编码'")
@Column(name = "tpl_code", columnDefinition = "VARCHAR(32) COMMENT '模板编码'")
private String tplCode;
@Column(name="content",columnDefinition = "TEXT COMMENT '消息内容'")
@Column(name = "content", columnDefinition = "TEXT COMMENT '消息内容'")
private String content;
@Column(name="receiver",columnDefinition = "VARCHAR(64) COMMENT '接收者'")
@Column(name = "receiver", columnDefinition = "VARCHAR(64) COMMENT '接收者'")
private String receiver;
@Column(name="type",columnDefinition = "VARCHAR(32) COMMENT '消息类型,0:短信,1:邮件'")
@Column(name = "type", columnDefinition = "VARCHAR(32) COMMENT '消息类型,0:短信,1:邮件'")
private Integer type;
@Column(name="state",columnDefinition = "VARCHAR(32) COMMENT '消息类型,0:初始,1:成功,2:失败'")
@Column(name = "state", columnDefinition = "VARCHAR(32) COMMENT '消息类型,0:初始,1:成功,2:失败'")
private Integer state;
}
......@@ -14,17 +14,17 @@ import javax.validation.constraints.NotBlank;
* 消息发送者
*/
@Data
@Entity(name="t_message_sender")
@Table(appliesTo = "t_message_sender",comment = "消息发送者")
@Entity(name = "t_message_sender")
@Table(appliesTo = "t_message_sender", comment = "消息发送者")
@EntityListeners(AuditingEntityListener.class)
public class MessageSender extends BaseEntity {
@Column(name="name",columnDefinition = "VARCHAR(64) COMMENT '名称'")
@Column(name = "name", columnDefinition = "VARCHAR(64) COMMENT '名称'")
@NotBlank(message = "名称并能为空")
private String name;
@Column(name="class_name",columnDefinition = "VARCHAR(64) COMMENT '发送类'")
@Column(name = "class_name", columnDefinition = "VARCHAR(64) COMMENT '发送类'")
@NotBlank(message = "发送类不能为空")
private String className;
@Column(name="tpl_code",columnDefinition = "VARCHAR(64) COMMENT '短信运营商模板编号'")
@Column(name = "tpl_code", columnDefinition = "VARCHAR(64) COMMENT '短信运营商模板编号'")
private String tplCode;
}
......@@ -13,27 +13,27 @@ import javax.validation.constraints.NotNull;
* 消息模板
*/
@Data
@Entity(name="t_message_template")
@Table(appliesTo = "t_message_template",comment = "消息模板")
@Entity(name = "t_message_template")
@Table(appliesTo = "t_message_template", comment = "消息模板")
@EntityListeners(AuditingEntityListener.class)
public class MessageTemplate extends BaseEntity {
@Column(name="code",columnDefinition = "VARCHAR(32) COMMENT '编号'")
@Column(name = "code", columnDefinition = "VARCHAR(32) COMMENT '编号'")
@NotBlank(message = "编号不能为空")
private String code;
@NotBlank(message = "标题不能为空")
@Column(name="title",columnDefinition = "VARCHAR(64) COMMENT '标题'")
@Column(name = "title", columnDefinition = "VARCHAR(64) COMMENT '标题'")
private String title;
@NotBlank(message = "内容并能为空")
@Column(name="content",columnDefinition = "TEXT COMMENT '内容'")
@Column(name = "content", columnDefinition = "TEXT COMMENT '内容'")
private String content;
@Column(name="cond",columnDefinition = "VARCHAR(32) COMMENT '发送条件'")
@Column(name = "cond", columnDefinition = "VARCHAR(32) COMMENT '发送条件'")
private String cond;
@Column(name="id_message_sender",columnDefinition = "BIGINT COMMENT '发送者id'")
@Column(name = "id_message_sender", columnDefinition = "BIGINT COMMENT '发送者id'")
@NotNull(message = "发送器不能为空")
private Long idMessageSender;
@Column(name="type",columnDefinition = "VARCHAR(32) COMMENT '消息类型,0:短信,1:邮件'")
@Column(name = "type", columnDefinition = "VARCHAR(32) COMMENT '消息类型,0:短信,1:邮件'")
private Integer type;
@JoinColumn(name="id_message_sender", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_message_sender", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private MessageSender messageSender;
}
......@@ -16,23 +16,23 @@ import java.util.List;
* @date :Created in 1/8/2020 8:10 PM
*/
@Data
@Entity(name="t_promotion_topic")
@Table(appliesTo = "t_promotion_topic",comment = "专题")
@Entity(name = "t_promotion_topic")
@Table(appliesTo = "t_promotion_topic", comment = "专题")
@EntityListeners(AuditingEntityListener.class)
public class Topic extends BaseEntity {
public class Topic extends BaseEntity {
@Column(columnDefinition = "VARCHAR(64) COMMENT '标题'")
private String title;
@Column(name="id_article",columnDefinition = "BIGINT COMMENT '专题文章'")
@Column(name = "id_article", columnDefinition = "BIGINT COMMENT '专题文章'")
private Long idArticle;
@JoinColumn(name="id_article", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_article", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Article article;
@Column(name="id_goods_list",columnDefinition = "VARCHAR(64) COMMENT '商品id列表'")
@Column(name = "id_goods_list", columnDefinition = "VARCHAR(64) COMMENT '商品id列表'")
private String idGoodsList;
@Column(columnDefinition = "BIGINT COMMENT '阅读量'")
private Long pv=0L;
private Long pv = 0L;
@Column(columnDefinition = "TINYINT COMMENT '是否禁用'")
private boolean disabled=false;
private boolean disabled = false;
@Transient
private List<Goods> goodsList = Lists.newArrayList();
......
/**
* 推广相关实体
*
* @author :enilu
* @date :Created in 1/8/2020 8:16 PM
*/
......
......@@ -12,8 +12,8 @@ import javax.persistence.Entity;
* @date :Created in 2019/10/29 17:39
*/
@Data
@Table(appliesTo = "t_shop_address",comment = "收货地址")
@Entity(name="t_shop_address")
@Table(appliesTo = "t_shop_address", comment = "收货地址")
@Entity(name = "t_shop_address")
public class Address extends ShopBaseEntity {
@Column(columnDefinition = "BIGINT COMMENT '用户id'")
private Long idUser;
......@@ -35,12 +35,12 @@ public class Address extends ShopBaseEntity {
@Column(columnDefinition = "VARCHAR(6) COMMENT '邮政编码'")
private String postCode;
@Column(columnDefinition = "tinyint COMMENT '是否默认'")
private Boolean isDefault=false;
private Boolean isDefault = false;
@Column(columnDefinition = "tinyint COMMENT '是否删除'")
private Boolean isDelete= false;
private Boolean isDelete = false;
public String getWholeAddressInfo(){
return getProvince()+" "+getCity()+getDistrict()+getAddressDetail();
public String getWholeAddressInfo() {
return getProvince() + " " + getCity() + getDistrict() + getAddressDetail();
}
}
......@@ -15,18 +15,19 @@ import java.util.List;
*/
@Data
@Table(appliesTo = "t_shop_attr_key",comment = "商品属性名")
@Entity(name="t_shop_attr_key")
@Table(appliesTo = "t_shop_attr_key", comment = "商品属性名")
@Entity(name = "t_shop_attr_key")
@EntityListeners(AuditingEntityListener.class)
public class AttrKey extends BaseEntity {
@Column(name="attr_name",columnDefinition = "VARCHAR(32) COMMENT '属性名'")
@Column(name = "attr_name", columnDefinition = "VARCHAR(32) COMMENT '属性名'")
private String attrName;
@Column(name="id_category",columnDefinition = "BIGINT COMMENT '商品类别id'")
@Column(name = "id_category", columnDefinition = "BIGINT COMMENT '商品类别id'")
private Long idCategory;
@OneToMany(cascade = {CascadeType.ALL})
@JoinColumn(name="id_attr_key")
@JoinColumn(name = "id_attr_key")
@JsonIgnore
@org.hibernate.annotations.ForeignKey(name="none") //该注解配合ManyToOne端的@ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT) 配置可以取消关联外键的创建
@org.hibernate.annotations.ForeignKey(name = "none")
//该注解配合ManyToOne端的@ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT) 配置可以取消关联外键的创建
private List<AttrVal> attrVals;
}
......@@ -15,13 +15,13 @@ import javax.persistence.EntityListeners;
*/
@Data
@Table(appliesTo = "t_shop_attr_val",comment = "商品属性值")
@Entity(name="t_shop_attr_val")
@Table(appliesTo = "t_shop_attr_val", comment = "商品属性值")
@Entity(name = "t_shop_attr_val")
@EntityListeners(AuditingEntityListener.class)
public class AttrVal extends BaseEntity {
@Column(name="id_attr_key",columnDefinition = "BIGINT COMMENT '属性id'")
@Column(name = "id_attr_key", columnDefinition = "BIGINT COMMENT '属性id'")
private Long idAttrKey;
@Column(name="attr_val",columnDefinition = "VARCHAR(32) COMMENT '属性值'")
@Column(name = "attr_val", columnDefinition = "VARCHAR(32) COMMENT '属性值'")
private String attrVal;
// @JoinColumn(name = "id_attr_key", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
// @ManyToOne(fetch = FetchType.LAZY)
......
......@@ -12,35 +12,37 @@ import java.math.BigDecimal;
* @date :Created in 2019/10/29 17:40
*/
@Data
@Table(appliesTo = "t_shop_cart",comment = "购物车")
@Entity(name="t_shop_cart")
@Table(appliesTo = "t_shop_cart", comment = "购物车")
@Entity(name = "t_shop_cart")
public class Cart extends ShopBaseEntity {
@Column(name="id_user",columnDefinition = "BIGINT COMMENT '用户id'")
@Column(name = "id_user", columnDefinition = "BIGINT COMMENT '用户id'")
private Long idUser;
@JoinColumn(name="id_user", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_user", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private ShopUser user;
@Column(name="id_goods",columnDefinition = "BIGINT COMMENT '商品id'")
@Column(name = "id_goods", columnDefinition = "BIGINT COMMENT '商品id'")
private Long idGoods;
@JoinColumn(name="id_goods", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_goods", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Goods goods;
@Column(name="id_sku",columnDefinition = "BIGINT COMMENT 'skuId'")
@Column(name = "id_sku", columnDefinition = "BIGINT COMMENT 'skuId'")
private Long idSku;
@JoinColumn(name="id_sku", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_sku", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private GoodsSku sku;
@Column(columnDefinition = "varchar(16) COMMENT '数量'")
private BigDecimal count;
@Transient
private BigDecimal price;
public BigDecimal getPrice(){
if(idSku!=null){
public BigDecimal getPrice() {
if (idSku != null) {
return sku.getPrice();
}
return goods.getPrice();
}
public String getTitle(){
return idSku!=null?getGoods().getName()+" "+getSku().getCodeName():getGoods().getName();
public String getTitle() {
return idSku != null ? getGoods().getName() + " " + getSku().getCodeName() : getGoods().getName();
}
}
......@@ -17,8 +17,8 @@ import java.util.List;
* @date :Created in 2019/10/29 17:40
*/
@Data
@Table(appliesTo = "t_shop_category",comment = "商品类别")
@Entity(name="t_shop_category")
@Table(appliesTo = "t_shop_category", comment = "商品类别")
@Entity(name = "t_shop_category")
@EntityListeners(AuditingEntityListener.class)
public class Category extends BaseEntity {
@Column(columnDefinition = "VARCHAR(16) COMMENT '名称'")
......
......@@ -14,19 +14,19 @@ import javax.persistence.*;
* @date :Created in 11/15/2019 2:16 PM
*/
@Data
@Entity(name="t_shop_category_banner_rel")
@Table(appliesTo = "t_shop_category_banner_rel",comment = "类别banner关联表")
@Entity(name = "t_shop_category_banner_rel")
@Table(appliesTo = "t_shop_category_banner_rel", comment = "类别banner关联表")
@EntityListeners(AuditingEntityListener.class)
public class CategoryBannerRel extends BaseEntity {
@Column(name = "id_category",columnDefinition = "BIGINT COMMENT '类别id'")
@Column(name = "id_category", columnDefinition = "BIGINT COMMENT '类别id'")
private Long idCategory;
@Column(name = "id_banner",columnDefinition = "BIGINT COMMENT 'banner id'")
@Column(name = "id_banner", columnDefinition = "BIGINT COMMENT 'banner id'")
private Long idBanner;
@JoinColumn(name="id_category", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_category", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
@NotFound
private Category category;
@JoinColumn(name="id_banner", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_banner", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Banner banner;
......
......@@ -11,17 +11,17 @@ import javax.persistence.*;
* @date :Created in 1/21/2020 11:13 AM
*/
@Data
@Entity(name="t_shop_favorite")
@Table(appliesTo = "t_shop_favorite",comment = "用户收藏")
@Entity(name = "t_shop_favorite")
@Table(appliesTo = "t_shop_favorite", comment = "用户收藏")
public class Favorite extends ShopBaseEntity {
@Column(name="id_user",columnDefinition = "BIGINT COMMENT '用户id'")
@Column(name = "id_user", columnDefinition = "BIGINT COMMENT '用户id'")
private Long idUser;
@JoinColumn(name="id_user", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_user", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private ShopUser user;
@Column(name="id_goods",columnDefinition = "BIGINT COMMENT '商品id'")
@Column(name = "id_goods", columnDefinition = "BIGINT COMMENT '商品id'")
private Long idGoods;
@JoinColumn(name="id_goods", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_goods", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Goods goods;
}
......@@ -14,8 +14,8 @@ import java.math.BigDecimal;
* @date :Created in 2019/10/29 17:39
*/
@Data
@Table(appliesTo = "t_shop_goods",comment = "商品")
@Entity(name="t_shop_goods")
@Table(appliesTo = "t_shop_goods", comment = "商品")
@Entity(name = "t_shop_goods")
@EntityListeners(AuditingEntityListener.class)
public class Goods extends BaseEntity {
@NotBlank(message = "商品名称不能为空")
......@@ -24,10 +24,10 @@ public class Goods extends BaseEntity {
@Column(columnDefinition = "VARCHAR(64) COMMENT '小图'")
private String pic;
@Column(columnDefinition = "VARCHAR(512) COMMENT '大图相册列表,以逗号分隔'")
private String gallery;
@Column(name="id_category",columnDefinition = "BIGINT COMMENT '类别id'")
private String gallery;
@Column(name = "id_category", columnDefinition = "BIGINT COMMENT '类别id'")
private Long idCategory;
@JoinColumn(name="id_category", insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_category", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Category category;
@Column(columnDefinition = "VARCHAR(255) COMMENT '产品简介'")
......@@ -39,21 +39,21 @@ public class Goods extends BaseEntity {
* 如果商品是多规格,则存所有库存之和
*/
@Column(columnDefinition = "INT COMMENT '库存数量'")
private Integer stock=0;
private Integer stock = 0;
/**
* 如果商品是多规格,则存最低价
*/
@Column(columnDefinition = "VARCHAR(16) COMMENT '价格'")
private BigDecimal price;
@Column(columnDefinition = "tinyint COMMENT '是否删除'")
private Boolean isDelete= false;
private Boolean isDelete = false;
@Column(columnDefinition = "tinyint COMMENT '是否上架'")
private Boolean isOnSale = false;
@Column(columnDefinition = "tinyint COMMENT '是否新品推荐'")
private Boolean isNew = false;
@Column(columnDefinition = "tinyint COMMENT '是否人气商品'")
private Boolean isHot = false;
@Column(name="like_num",columnDefinition = "INT COMMENT '收藏数'")
@Column(name = "like_num", columnDefinition = "INT COMMENT '收藏数'")
private Integer likeNum;
}
......@@ -16,23 +16,23 @@ import java.math.BigDecimal;
*/
@Data
@Table(appliesTo = "t_shop_goods_sku",comment = "商品SKU")
@Entity(name="t_shop_goods_sku")
@Table(appliesTo = "t_shop_goods_sku", comment = "商品SKU")
@Entity(name = "t_shop_goods_sku")
@EntityListeners(AuditingEntityListener.class)
public class GoodsSku extends BaseEntity {
@Column(name="code",columnDefinition = "VARCHAR(32) COMMENT 'sku编码,格式:逗号分割的属性值id'")
@Column(name = "code", columnDefinition = "VARCHAR(32) COMMENT 'sku编码,格式:逗号分割的属性值id'")
private String code;
@Column(name="code_name",columnDefinition = "VARCHAR(32) COMMENT 'sku名称,格式:逗号分割的属性值'")
@Column(name = "code_name", columnDefinition = "VARCHAR(32) COMMENT 'sku名称,格式:逗号分割的属性值'")
private String codeName;
@Column(name="id_goods",columnDefinition = "BIGINT COMMENT '商品id'")
@Column(name = "id_goods", columnDefinition = "BIGINT COMMENT '商品id'")
private Long idGoods;
@Column(name="price",columnDefinition = "VARCHAR(32) COMMENT '价格'")
@Column(name = "price", columnDefinition = "VARCHAR(32) COMMENT '价格'")
private BigDecimal price;
@Column(name="marketing_price",columnDefinition = "VARCHAR(32) COMMENT '市场价,原价'")
@Column(name = "marketing_price", columnDefinition = "VARCHAR(32) COMMENT '市场价,原价'")
private BigDecimal marketingPrice;
@Column(name="stock",columnDefinition = "INT COMMENT '库存'")
@Column(name = "stock", columnDefinition = "INT COMMENT '库存'")
private Integer stock;
@Column(columnDefinition = "TINYINT COMMENT '是否删除1:是,0:否'")
private Boolean isDeleted=false;
private Boolean isDeleted = false;
}
......@@ -17,12 +17,12 @@ import java.util.List;
* @date :Created in 2019/10/29 17:40
*/
@Data
@Table(appliesTo = "t_shop_order",comment = "订单")
@Entity(name="t_shop_order")
@Table(appliesTo = "t_shop_order", comment = "订单")
@Entity(name = "t_shop_order")
public class Order extends ShopBaseEntity {
@Column(name="id_user",columnDefinition = "BIGINT COMMENT '用户id'")
@Column(name = "id_user", columnDefinition = "BIGINT COMMENT '用户id'")
private Long idUser;
@JoinColumn(name="id_user", referencedColumnName="id",insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_user", referencedColumnName = "id", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private ShopUser user;
@Column(columnDefinition = "VARCHAR(32) COMMENT '订单号'")
......@@ -36,13 +36,13 @@ public class Order extends ShopBaseEntity {
* 收件人信息使用 下面三个字段代替
*/
@Deprecated
@Column(name="id_address",columnDefinition = "BIGINT COMMENT '收货信息'")
@Column(name = "id_address", columnDefinition = "BIGINT COMMENT '收货信息'")
private Long idAddress;
/**
* 收件人信息使用 下面三个字段代替
* 收件人信息使用 下面三个字段代替
*/
@Deprecated
@JoinColumn(name="id_address", referencedColumnName="id",insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_address", referencedColumnName = "id", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Address address;
......@@ -55,7 +55,7 @@ public class Order extends ShopBaseEntity {
@OneToMany(cascade = {CascadeType.ALL})
@JoinColumn(name = "id_order")
@org.hibernate.annotations.ForeignKey(name="none")
@org.hibernate.annotations.ForeignKey(name = "none")
@JsonManagedReference
private List<OrderItem> items;
@Column(columnDefinition = "VARCHAR(64) COMMENT '订单备注'")
......@@ -74,9 +74,9 @@ public class Order extends ShopBaseEntity {
private BigDecimal realPrice;
@Column(columnDefinition = "DATETIME COMMENT '出库时间'")
private Date shippingTime;
@Column(name="id_express",columnDefinition = "BIGINT COMMENT '快递公司'")
@Column(name = "id_express", columnDefinition = "BIGINT COMMENT '快递公司'")
private Long idExpress;
@JoinColumn(name="id_express", referencedColumnName="id",insertable = false, updatable = false,foreignKey = @ForeignKey(name="none",value = ConstraintMode.NO_CONSTRAINT))
@JoinColumn(name = "id_express", referencedColumnName = "id", insertable = false, updatable = false, foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
@ManyToOne(fetch = FetchType.LAZY)
private Express express;
@Column(columnDefinition = "VARCHAR(32) COMMENT '快递单号'")
......@@ -93,26 +93,28 @@ public class Order extends ShopBaseEntity {
private Date payTime;
public String getStatusName(){
if(status!=null) {
public String getStatusName() {
if (status != null) {
return OrderEnum.get(status).getValue();
}
return null;
}
public String getPayStatusName(){
if(payStatus!=null) {
public String getPayStatusName() {
if (payStatus != null) {
return OrderEnum.getPayStatus(payStatus).getValue();
}
return null;
}
public String getPayTypeName(){
if(payType!=null) {
public String getPayTypeName() {
if (payType != null) {
return OrderEnum.get(payType).getValue();
}
return null;
}
public Boolean hasPayed(){
public Boolean hasPayed() {
return OrderEnum.PayStatusEnum.UN_SEND.getId().equals(payStatus);
}
}
......@@ -5,18 +5,20 @@ import lombok.Data;
import org.hibernate.annotations.Table;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.*;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
/**
* @author :enilu
* @date :Created in 2020/2/6 22:27
*/
@Data
@Table(appliesTo = "t_shop_order_log",comment = "订单日志")
@Entity(name="t_shop_order_log")
@Table(appliesTo = "t_shop_order_log", comment = "订单日志")
@Entity(name = "t_shop_order_log")
@EntityListeners(AuditingEntityListener.class)
public class OrderLog extends ShopBaseEntity {
@Column(name="id_order",columnDefinition = "BIGINT COMMENT '所属订单id'")
@Column(name = "id_order", columnDefinition = "BIGINT COMMENT '所属订单id'")
private Long idOrder;
@Column(columnDefinition = "VARCHAR(64) COMMENT '日志详情'")
private String descript;
......
......@@ -17,16 +17,16 @@ import java.util.Date;
* @date :Created in 2019/10/29 17:41
*/
@Data
@Table(appliesTo = "t_shop_user",comment = "用户")
@Entity(name="t_shop_user")
@JsonIgnoreProperties(value = { "hibernateLazyInitializer", "handler" })
public class ShopUser implements Serializable {
@Table(appliesTo = "t_shop_user", comment = "用户")
@Entity(name = "t_shop_user")
@JsonIgnoreProperties(value = {"hibernateLazyInitializer", "handler"})
public class ShopUser implements Serializable {
@Id
@GeneratedValue
private Long id;
@CreatedDate
@Column(columnDefinition="DATETIME COMMENT '注册时间'")
@Column(columnDefinition = "DATETIME COMMENT '注册时间'")
private Date createTime;
@Column(columnDefinition = "VARCHAR(16) COMMENT '手机号'")
private String mobile;
......
......@@ -15,18 +15,18 @@ import javax.validation.constraints.NotBlank;
*
* @author enilu
*/
@Entity(name="t_sys_cfg")
@Table(appliesTo = "t_sys_cfg",comment = "系统参数")
@Entity(name = "t_sys_cfg")
@Table(appliesTo = "t_sys_cfg", comment = "系统参数")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Cfg extends BaseEntity {
public class Cfg extends BaseEntity {
@NotBlank(message = "参数名不能为空")
@Column(name = "cfg_name",columnDefinition = "VARCHAR(256) COMMENT '参数名'")
@Column(name = "cfg_name", columnDefinition = "VARCHAR(256) COMMENT '参数名'")
private String cfgName;
@NotBlank(message = "参数值不能为空")
@Column(name = "cfg_value",columnDefinition = "VARCHAR(512) COMMENT '参数值'")
@Column(name = "cfg_value", columnDefinition = "VARCHAR(512) COMMENT '参数值'")
private String cfgValue;
@Column(name = "cfg_desc",columnDefinition = "TEXT COMMENT '备注'")
@Column(name = "cfg_desc", columnDefinition = "TEXT COMMENT '备注'")
private String cfgDesc;
}
......@@ -15,8 +15,8 @@ import javax.validation.constraints.NotBlank;
*
* @author enilu
*/
@Entity(name="t_sys_dept")
@Table(appliesTo = "t_sys_dept",comment = "部门")
@Entity(name = "t_sys_dept")
@Table(appliesTo = "t_sys_dept", comment = "部门")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Dept extends BaseEntity {
......
......@@ -14,8 +14,8 @@ import javax.persistence.EntityListeners;
*
* @author enilu
*/
@Entity(name="t_sys_dict")
@Table(appliesTo = "t_sys_dict",comment = "字典")
@Entity(name = "t_sys_dict")
@Table(appliesTo = "t_sys_dict", comment = "字典")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Dict extends BaseEntity {
......
......@@ -15,8 +15,8 @@ import javax.persistence.EntityListeners;
* 物流公司
*/
@Data
@Table(appliesTo = "t_sys_express",comment = "物流公司")
@Entity(name="t_sys_express")
@Table(appliesTo = "t_sys_express", comment = "物流公司")
@Entity(name = "t_sys_express")
@EntityListeners(AuditingEntityListener.class)
public class Express extends BaseEntity {
@Column(columnDefinition = "VARCHAR(32) COMMENT '公司名称'")
......
......@@ -9,8 +9,8 @@ import javax.persistence.Entity;
import javax.persistence.Transient;
@Data
@Entity(name="t_sys_file_info")
@Table(appliesTo = "t_sys_file_info",comment = "文件")
@Entity(name = "t_sys_file_info")
@Table(appliesTo = "t_sys_file_info", comment = "文件")
public class FileInfo extends BaseEntity {
@Column
private String originalFileName;
......
......@@ -15,8 +15,8 @@ import java.util.Date;
*
* @author enilu
*/
@Entity(name="t_sys_login_log")
@Table(appliesTo = "t_sys_login_log",comment = "登录日志")
@Entity(name = "t_sys_login_log")
@Table(appliesTo = "t_sys_login_log", comment = "登录日志")
@Data
public class LoginLog {
@Id
......@@ -33,6 +33,6 @@ public class LoginLog {
@Column
private String ip;
@CreationTimestamp
@Column(columnDefinition="DATETIME COMMENT '创建时间'")
@Column(columnDefinition = "DATETIME COMMENT '创建时间'")
private Date createTime;
}
......@@ -16,39 +16,39 @@ import javax.validation.constraints.NotBlank;
* @author enilu
*/
@Entity(name = "t_sys_menu")
@Table(appliesTo = "t_sys_menu",comment = "菜单")
@Table(appliesTo = "t_sys_menu", comment = "菜单")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Menu extends BaseEntity {
@Column(columnDefinition = "VARCHAR(32) COMMENT '编号'",unique = true,nullable = false)
@NotBlank(message="编号不能为空")
public class Menu extends BaseEntity {
@Column(columnDefinition = "VARCHAR(32) COMMENT '编号'", unique = true, nullable = false)
@NotBlank(message = "编号不能为空")
private String code;
@Column(columnDefinition = "VARCHAR(64) COMMENT '父菜单编号'",nullable = false)
@Column(columnDefinition = "VARCHAR(64) COMMENT '父菜单编号'", nullable = false)
private String pcode;
@Column(columnDefinition = "VARCHAR(128) COMMENT '递归父级菜单编号'")
private String pcodes;
@Column(columnDefinition = "VARCHAR(64) COMMENT '名称'",nullable = false)
@Column(columnDefinition = "VARCHAR(64) COMMENT '名称'", nullable = false)
@NotBlank(message = "名称不能为空")
private String name;
@Column(columnDefinition = "VARCHAR(32) COMMENT '图标'")
private String icon;
@Column(columnDefinition = "VARCHAR(32) COMMENT '链接'")
private String url;
@Column(columnDefinition = "INT COMMENT '顺序'",nullable = false)
@Column(columnDefinition = "INT COMMENT '顺序'", nullable = false)
private Integer num;
@Column(columnDefinition = "INT COMMENT '级别'",nullable = false)
@Column(columnDefinition = "INT COMMENT '级别'", nullable = false)
private Integer levels;
@Column(columnDefinition = "INT COMMENT '是否是菜单1:菜单,0:按钮'",nullable = false)
@Column(columnDefinition = "INT COMMENT '是否是菜单1:菜单,0:按钮'", nullable = false)
private Integer ismenu;
@Column(columnDefinition = "VARCHAR(32) COMMENT '鼠标悬停提示信息'")
private String tips;
@Column(columnDefinition = "INT COMMENT '状态1:启用,0:禁用'",nullable = false)
@Column(columnDefinition = "INT COMMENT '状态1:启用,0:禁用'", nullable = false)
private Integer status;
@Column(columnDefinition = "INT COMMENT '是否默认打开1:是,0:否'")
private Integer isopen;
@Column(columnDefinition = "VARCHAR(64) COMMENT '組件配置'")
private String component;
@Column(columnDefinition = "tinyint COMMENT '是否隐藏'")
private Boolean hidden=false;
private Boolean hidden = false;
}
......@@ -16,7 +16,7 @@ import javax.persistence.EntityListeners;
*/
@Entity(name = "t_sys_notice")
@Table(appliesTo = "t_sys_notice",comment = "通知")
@Table(appliesTo = "t_sys_notice", comment = "通知")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Notice extends BaseEntity {
......
......@@ -16,7 +16,7 @@ import java.util.Date;
*/
@Entity(name = "t_sys_operation_log")
@Table(appliesTo = "t_sys_operation_log",comment = "操作日志")
@Table(appliesTo = "t_sys_operation_log", comment = "操作日志")
@Data
public class OperationLog {
......@@ -33,7 +33,7 @@ public class OperationLog {
private String classname;
@Column
private String method;
@Column(name="create_time")
@Column(name = "create_time")
private Date createTime;
@Column
private String succeed;
......
......@@ -14,7 +14,7 @@ import javax.persistence.Id;
* @author enilu
*/
@Entity(name = "t_sys_relation")
@Table(appliesTo = "t_sys_relation",comment = "菜单角色关系")
@Table(appliesTo = "t_sys_relation", comment = "菜单角色关系")
@Data
public class Relation {
@Id
......
......@@ -16,7 +16,7 @@ import javax.validation.constraints.NotBlank;
* @author enilu
*/
@Entity(name = "t_sys_role")
@Table(appliesTo = "t_sys_role",comment = "角色")
@Table(appliesTo = "t_sys_role", comment = "角色")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Role extends BaseEntity {
......
......@@ -13,7 +13,7 @@ import javax.validation.constraints.NotBlank;
import java.util.Date;
@Entity(name = "t_sys_task")
@Table(appliesTo = "t_sys_task",comment = "定时任务")
@Table(appliesTo = "t_sys_task", comment = "定时任务")
@Data
@EntityListeners(AuditingEntityListener.class)
public class Task extends BaseEntity {
......@@ -22,32 +22,32 @@ public class Task extends BaseEntity {
@NotBlank(message = "名称不能为空")
private String name;
@Column(name="job_group", columnDefinition = "VARCHAR(50) COMMENT '任务组名'")
@Column(name = "job_group", columnDefinition = "VARCHAR(50) COMMENT '任务组名'")
private String jobGroup;
@Column(name="job_class", columnDefinition = "VARCHAR(255) COMMENT '执行类'")
@Column(name = "job_class", columnDefinition = "VARCHAR(255) COMMENT '执行类'")
@NotBlank(message = "执行类不能为空")
private String jobClass;
@Column(name="note", columnDefinition = "VARCHAR(255) COMMENT '任务说明'")
@Column(name = "note", columnDefinition = "VARCHAR(255) COMMENT '任务说明'")
private String note;
@Column(name="cron", columnDefinition = "VARCHAR(50) COMMENT '定时规则'")
@Column(name = "cron", columnDefinition = "VARCHAR(50) COMMENT '定时规则'")
@NotBlank(message = "定时规则不能为空")
private String cron;
@Column(name="concurrent", columnDefinition = "TINYINT COMMENT '是否允许并发'")
@Column(name = "concurrent", columnDefinition = "TINYINT COMMENT '是否允许并发'")
private boolean concurrent;
@Column(name="data", columnDefinition = "TEXT COMMENT '执行参数'")
@Column(name = "data", columnDefinition = "TEXT COMMENT '执行参数'")
private String data;
@Column(name="exec_at", columnDefinition = "DateTime COMMENT '执行时间'")
@Column(name = "exec_at", columnDefinition = "DateTime COMMENT '执行时间'")
private Date execAt;
@Column(name="exec_result", columnDefinition = "VARCHAR(64) COMMENT '执行结果'")
@Column(name = "exec_result", columnDefinition = "VARCHAR(64) COMMENT '执行结果'")
private String execResult;
@Column(name="disabled", columnDefinition = "TINYINT COMMENT '是否禁用'")
@Column(name = "disabled", columnDefinition = "TINYINT COMMENT '是否禁用'")
private boolean disabled;
}
......@@ -15,10 +15,10 @@ import java.util.Date;
* User: Yao
* Date: 2017-06-22 11:12:48
*/
@Table(appliesTo="t_sys_task_log",comment = "定时任务日志")
@Entity(name="t_sys_task_log")
@Table(appliesTo = "t_sys_task_log", comment = "定时任务日志")
@Entity(name = "t_sys_task_log")
@Data
public class TaskLog{
public class TaskLog {
public static final int EXE_FAILURE_RESULT = 0;
public static final int EXE_SUCCESS_RESULT = 1;
......
......@@ -16,10 +16,10 @@ import java.util.Date;
* @author enilu
*/
@Entity(name = "t_sys_user")
@Table(appliesTo = "t_sys_user",comment = "账号")
@Table(appliesTo = "t_sys_user", comment = "账号")
@Data
@EntityListeners(AuditingEntityListener.class)
public class User extends BaseEntity {
public class User extends BaseEntity {
@Column
private String avatar;
@Column
......
......@@ -10,10 +10,11 @@ public enum MessageTemplateEnum {
/**
* 注册验证码
*/
REGISTER_CODE("REGISTER_CODE","注册验证码");
REGISTER_CODE("REGISTER_CODE", "注册验证码");
private String code;
private String name;
MessageTemplateEnum(String code,String name){
MessageTemplateEnum(String code, String name) {
this.name = name;
this.code = code;
}
......@@ -24,4 +25,5 @@ public enum MessageTemplateEnum {
public String getName() {
return name;
}}
}
}
......@@ -3,6 +3,7 @@ package cn.enilu.flash.bean.enumeration;
/**
* 权限编码列表<br>
* 权限编码需要和菜单中的菜单编码一致
*
* @author :enilu
* @date :Created in 2019/7/31 11:05
*/
......@@ -62,7 +63,7 @@ public interface Permission {
String FILE_UPLOAD = "fileUpload";
//商城管理
String CATEGORY_EDIT="categoryEdit";
String CATEGORY_EDIT = "categoryEdit";
String GOODS_EDIT = "goodsEdit";
//营销管理
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!