shichongfu
2023-04-25 ce0b49552668d3331055e2b1a1447a743dc54939
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
 *
 */
package com.product.admin.service;
 
import com.product.admin.config.CmnConst;
import com.product.common.lang.StringUtils;
import com.product.core.cache.DataPoolCacheImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.product.core.dao.BaseDao;
import com.product.core.entity.FieldSetEntity;
import com.product.core.exception.BaseException;
import com.product.core.service.support.AbstractBaseService;
import com.product.core.spring.context.SpringMVCContextHolder;
import com.product.module.sys.entity.SystemUser;
 
/**
 * Copyright LX-BASE
 *
 * @Title:
 * @Project: LX-BASE-SERVER
 * @Date: 2020年6月12日 下午6:29:16
 * @Author: 郑盟
 * @Description:
 */
@Component
public class UserDefaultLanguageService extends AbstractBaseService {
    @Autowired
    public BaseDao baseDao;
 
 
    /**
     * 修改员工默认语言
     * @param fs
     * @return
     * @throws BaseException
     */
    public boolean updateLanguage(FieldSetEntity fs) throws BaseException {
        String userId = null;
        SystemUser currentUser = SpringMVCContextHolder.getCurrentUser();
        if (currentUser != null) {
            userId = currentUser.getUuid();
        }
        if (StringUtils.isEmpty(userId) || StringUtils.isEmpty(fs.getString(CmnConst.LANGUAGE_CODE))) {
            return false;
        }
        boolean update = baseDao.executeUpdate("UPDATE product_sys_users SET default_language=? where uuid =?", new Object[]{fs.getString("language_code"), userId});
        if (update && currentUser != null) {
            //2020年12月30日11:57:37 xupengcheng 更新用户默认语言
            currentUser.setLanguageCode(fs.getString(CmnConst.LANGUAGE_CODE));
            currentUser.setDefault_language(fs.getString(CmnConst.LANGUAGE_CODE));
            //token与用户关联,放入缓存中
            DataPoolCacheImpl.getInstance().updateSessionUser(currentUser);
        }
        return update;
    }
}