This commit is contained in:
Crystal.Sea 2020-08-27 07:59:03 +08:00
parent a8fafe9470
commit 88128bec08
2 changed files with 22 additions and 11 deletions

View File

@ -35,6 +35,7 @@ import org.maxkey.web.WebContext;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -47,6 +48,7 @@ import org.springframework.stereotype.Service;
public class UserInfoService extends JpaBaseService<UserInfo> { public class UserInfoService extends JpaBaseService<UserInfo> {
final static Logger _logger = LoggerFactory.getLogger(UserInfoService.class); final static Logger _logger = LoggerFactory.getLogger(UserInfoService.class);
final static String UPDATE_GRIDLIST_SQL = "UPDATE MXK_USERINFO SET GRIDLIST = ? WHERE ID = ?";
@Autowired @Autowired
private PasswordEncoder passwordEncoder; private PasswordEncoder passwordEncoder;
@ -56,6 +58,9 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
@Autowired @Autowired
KafkaProvisioningService kafkaProvisioningService; KafkaProvisioningService kafkaProvisioningService;
@Autowired
protected JdbcTemplate jdbcTemplate;
public UserInfoService() { public UserInfoService() {
super(UserInfoMapper.class); super(UserInfoMapper.class);
} }
@ -107,6 +112,22 @@ public class UserInfoService extends JpaBaseService<UserInfo> {
return false; return false;
} }
public boolean updateGridList(String gridList) {
try {
if (gridList != null && !gridList.equals("")) {
int intGridList = Integer.parseInt(gridList);
jdbcTemplate.update(UPDATE_GRIDLIST_SQL, intGridList,
WebContext.getUserInfo().getId());
WebContext.getUserInfo().setGridList(intGridList);
}
}catch(Exception e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean updateProtectedApps(UserInfo userinfo) { public boolean updateProtectedApps(UserInfo userinfo) {
try { try {
if(WebContext.getUserInfo() != null) { if(WebContext.getUserInfo() != null) {

View File

@ -34,7 +34,6 @@ import org.maxkey.web.message.MessageType;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -55,9 +54,6 @@ public class AppListController {
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Autowired
protected JdbcTemplate jdbcTemplate;
@Autowired @Autowired
AccountsService appUsersService; AccountsService appUsersService;
@ -73,13 +69,7 @@ public class AppListController {
public ModelAndView appList( public ModelAndView appList(
@RequestParam(value = "gridList", required = false) String gridList) { @RequestParam(value = "gridList", required = false) String gridList) {
ModelAndView modelAndView = new ModelAndView("main/appList"); ModelAndView modelAndView = new ModelAndView("main/appList");
userInfoService.updateGridList(gridList);
if (gridList != null && !gridList.equals("")) {
int intGridList = Integer.parseInt(gridList);
jdbcTemplate.update("UPDATE MXK_USERINFO SET GRIDLIST = ? WHERE ID = ?", intGridList,
WebContext.getUserInfo().getId());
WebContext.getUserInfo().setGridList(intGridList);
}
modelAndView.addObject("appList", queryAccessableApps()); modelAndView.addObject("appList", queryAccessableApps());
return modelAndView; return modelAndView;
} }