未验证 提交 60a40708 编写于 作者: M MaxKey 提交者: GitHub

Merge pull request #35 from FranisiL/master_dev_lyp

Master dev lyp
......@@ -312,6 +312,10 @@ subprojects {
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.38'
//JULI logging implementation for embedded Tomcat
compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-logging-juli', version: '8.5.2'
//easyExcel
compile group: 'com.alibaba', name: 'easyexcel', version: '2.1.6'
}
jar {
......
......@@ -28,4 +28,7 @@ public final class ConstantsOperateMessage {
public static final String DELETE_SUCCESS = "message.action.delete.success";
public static final String DELETE_ERROR = "message.action.delete.error";
public static final String import_success = "message.action.import.success";
public static final String IMPORT_ERROR = "message.action.import.error";
}
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.domain;
......@@ -32,7 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
/**
* .
* @author Crystal.Sea
*
*
*/
@Table(name = "MXK_USERINFO")
public class UserInfo extends JpaBaseDomain {
......@@ -329,7 +329,7 @@ public class UserInfo extends JpaBaseDomain {
}
/**
*
*
*/
public UserInfo() {
super();
......@@ -469,7 +469,7 @@ public class UserInfo extends JpaBaseDomain {
this.nickName = nickName;
}
public String getNameZhSpell() {
return nameZhSpell;
......@@ -1147,7 +1147,6 @@ public class UserInfo extends JpaBaseDomain {
this.description = description;
}
/**
* @return the createdBy
*/
......
package org.maxkey.util;
import org.maxkey.domain.UserInfo;
import java.io.InputStream;
import java.util.List;
/**
* @author yapeng.li
* @since 2020/9/21 21:06
*/
public class ExcelUtils {
public static List<UserInfo> readExcel(InputStream in) throws Exception {
return null;
}
}
/*
* Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.maxkey.web.contorller;
import java.beans.PropertyEditorSupport;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
......@@ -51,6 +52,7 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
......@@ -62,81 +64,103 @@ import org.springframework.web.servlet.ModelAndView;
@RequestMapping(value = { "/userinfo" })
public class UserInfoController {
final static Logger _logger = LoggerFactory.getLogger(UserInfoController.class);
@Autowired
@Qualifier("userInfoService")
private UserInfoService userInfoService;
/**
* 查询用户列表
* @param user
* @return
*/
@RequestMapping(value={"/grid"})
@ResponseBody
public JpaPageResults<UserInfo> forwardUsersList(@ModelAttribute("userInfo") UserInfo userInfo){
return userInfoService.queryPageResults(userInfo);
}
@RequestMapping(value={"/forwardAdd"})
public ModelAndView forwardSelectUserType(){
ModelAndView modelAndView=new ModelAndView("/userinfo/userAdd");
//List<UserType> userTypeList=userTypeService.query(null);
//modelAndView.addObject("userTypeList", userTypeList);
return modelAndView;
}
@RequestMapping(value={"/list"})
public ModelAndView usersList(){
return new ModelAndView("/userinfo/usersList");
}
@RequestMapping(value={"/select"})
public ModelAndView usersSelect(){
ModelAndView modelAndView= new ModelAndView("/userinfo/userinfoSelect");
return modelAndView;
}
/**
* 新增
* @param userInfo
* @param result
* @return
*/
@RequestMapping(value="/add")
public ModelAndView addUsers(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
_logger.debug(userInfo.toString());
if(result.hasErrors()){
// new Message(WebContext.getValidErrorText(),result);
}
userInfo.setId(userInfo.generateId());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
if( userInfoService.insert(userInfo)) {
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
}
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR),MessageType.error);
return WebContext.forward("forwardUpdate/"+userInfo.getId());
}
@RequestMapping(value={"/forwardUpdate/{id}"})
public ModelAndView forwardUpdateUsers(@PathVariable("id")String id){
ModelAndView modelAndView=new ModelAndView("/userinfo/userUpdate");
UserInfo userInfo=userInfoService.get(id);
if(userInfo.getPicture()!=null){
WebContext.getSession().setAttribute(userInfo.getId(), userInfo.getPicture());
}
modelAndView.addObject("model", userInfo);
return modelAndView;
}
/**
* 查询用户列表
*
* @param user
* @return
*/
@RequestMapping(value = {"/grid"})
@ResponseBody
public JpaPageResults<UserInfo> forwardUsersList(@ModelAttribute("userInfo") UserInfo userInfo) {
return userInfoService.queryPageResults(userInfo);
}
@RequestMapping(value = {"/forwardAdd"})
public ModelAndView forwardSelectUserType() {
ModelAndView modelAndView = new ModelAndView("/userinfo/userAdd");
//List<UserType> userTypeList=userTypeService.query(null);
//modelAndView.addObject("userTypeList", userTypeList);
return modelAndView;
}
@RequestMapping(value = {"/list"})
public ModelAndView usersList() {
return new ModelAndView("/userinfo/usersList");
}
@RequestMapping(value = {"/select"})
public ModelAndView usersSelect() {
ModelAndView modelAndView = new ModelAndView("/userinfo/userinfoSelect");
return modelAndView;
}
/**
* 新增
*
* @param userInfo
* @param result
* @return
*/
@RequestMapping(value = "/add")
public ModelAndView addUsers(@Valid @ModelAttribute("userInfo") UserInfo userInfo, BindingResult result) {
_logger.debug(userInfo.toString());
if (result.hasErrors()) {
// new Message(WebContext.getValidErrorText(),result);
}
userInfo.setId(userInfo.generateId());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
if (userInfoService.insert(userInfo)) {
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS), userInfo, MessageType.success, OperateType.add, MessageScope.DB);
}
new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR), MessageType.error);
return WebContext.forward("forwardUpdate/" + userInfo.getId());
}
/**
* 用户excel导入
*
* @param userInfo
* @param result
* @return
*/
/**
*
* @param file excel文件
* @return
*/
@RequestMapping(value = "/importing")
public Object importing(MultipartFile file) throws IOException {
if (userInfoService.importing(file)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_SUCCESS), null, MessageType.success, OperateType.add, MessageScope.DB);
}else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.INSERT_ERROR), MessageType.error);
}
}
@RequestMapping(value = {"/forwardUpdate/{id}"})
public ModelAndView forwardUpdateUsers(@PathVariable("id") String id) {
ModelAndView modelAndView = new ModelAndView("/userinfo/userUpdate");
UserInfo userInfo = userInfoService.get(id);
if (userInfo.getPicture() != null) {
WebContext.getSession().setAttribute(userInfo.getId(), userInfo.getPicture());
}
modelAndView.addObject("model", userInfo);
return modelAndView;
}
/**
* 查询用户,根据id
......@@ -144,7 +168,7 @@ public class UserInfoController {
* @return
*/
@ResponseBody
@RequestMapping(value="/getUsers/{id}")
@RequestMapping(value="/getUsers/{id}")
public UserInfo getUserInfo(@PathVariable("id")String id) {
_logger.debug(id);
UserInfo userInfo = userInfoService.get(id);
......@@ -157,14 +181,14 @@ public class UserInfoController {
}
return userInfo;
}
@ResponseBody
@RequestMapping(value = "/randomPassword")
public String randomPassword() {
return userInfoService.randomPassword();
}
/**
* 修改用户
* @param userInfo
......@@ -172,133 +196,5 @@ public class UserInfoController {
* @return
*/
@RequestMapping(value="/update")
public ModelAndView updateUsers(@Valid @ModelAttribute("userInfo")UserInfo userInfo,BindingResult result) {
_logger.debug(userInfo.toString());
if(result.hasErrors()){
// new Message(WebContext.getValidErrorText(),result);
}
_logger.info(userInfo.getExtraAttributeName());
_logger.info(userInfo.getExtraAttributeValue());
//userInfo.setNameZHShortSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), true));
//userInfo.setNameZHSpell(StringUtils.hanYu2Pinyin(userInfo.getDisplayName(), false));
convertExtraAttribute(userInfo) ;
_logger.info(userInfo.getExtraAttribute());
if(userInfoService.update(userInfo)) {
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),userInfo,MessageType.success,OperateType.add,MessageScope.DB);
}
new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
return WebContext.forward("forwardUpdate/"+userInfo.getId());
}
/**
* 批量删除用户
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value="/batchDelete")
public Message batchDeleteUsers(@RequestParam("id")String id) {
_logger.debug(id);
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
}
}
/**
* 根据用户id删除用户
*
* @param id
* @return
*/
@ResponseBody
@RequestMapping(value="/delete")
public Message deleteUsersById(@RequestParam("id") String id) {
_logger.debug(id);
if(userInfoService.batchDelete(StringUtils.string2List(id, ","))) {
//provisioningPrepare.prepare(userInfo, OPERATEACTION.DELETE_ACTION);
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.DELETE_ERROR),MessageType.error);
}
}
protected void convertExtraAttribute(UserInfo userInfo) {
if(userInfo.getExtraAttributeValue()!=null){
String []extraAttributeLabel=userInfo.getExtraAttributeName().split(",");
String []extraAttributeValue=userInfo.getExtraAttributeValue().split(",");
Map<String,String> extraAttributeMap=new HashMap<String,String> ();
for(int i=0;i<extraAttributeLabel.length;i++){
extraAttributeMap.put(extraAttributeLabel[i], extraAttributeValue[i]);
}
String extraAttribute=JsonUtils.object2Json(extraAttributeMap);
userInfo.setExtraAttribute(extraAttribute);
}
}
@RequestMapping(value={"/forwardChangePassword/{id}"})
public ModelAndView forwardChangePassword(@PathVariable("id")String id){
ModelAndView modelAndView=new ModelAndView("/userinfo/changePassword");
UserInfo userInfo=userInfoService.get(id);
modelAndView.addObject("model", userInfo);
return modelAndView;
}
@RequestMapping(value={"/forwardChangeUserinfoStatus/{id}"})
public ModelAndView forwardChangeUserinfoStatus(@PathVariable("id")String id){
ModelAndView modelAndView=new ModelAndView("/userinfo/changeUserinfoStatus");
UserInfo userInfo=userInfoService.get(id);
modelAndView.addObject("model", userInfo);
return modelAndView;
}
@ResponseBody
@RequestMapping(value="/changePassword")
public Message changePassword( @ModelAttribute("userInfo")UserInfo userInfo) {
_logger.debug(userInfo.getId());
if(userInfoService.changePassword(userInfo)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
}
}
@ResponseBody
@RequestMapping(value="/changeUserinfoStatus")
public Message changeUserinfoStatus( @ModelAttribute("userInfo")UserInfo userInfo) {
_logger.debug(userInfo.getId());
if(userInfoService.update(userInfo)) {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_SUCCESS),MessageType.success);
} else {
return new Message(WebContext.getI18nValue(ConstantsOperateMessage.UPDATE_ERROR),MessageType.error);
}
}
@InitBinder
public void binder(WebDataBinder binder) {
binder.registerCustomEditor(String.class, new PropertyEditorSupport() {
@Override
public void setAsText(String value) {
if(StringUtils.isNullOrBlank(value)){
setValue(null);
}else{
setValue(value);
}
}
});
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
dateFormat.setLenient(false);
binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册