|
@@ -13,8 +13,11 @@ import com.minpay.common.service.IQrcodeService;
|
|
|
import com.minpay.common.service.impl.QrcodeServiceImpl;
|
|
|
import com.minpay.common.util.*;
|
|
|
import com.minpay.db.table.mapper.VmPersonInfMapper;
|
|
|
+import com.minpay.db.table.mapper.VmPersonRoleInfMapper;
|
|
|
import com.minpay.db.table.model.VmPersonInf;
|
|
|
import com.minpay.db.table.model.VmPersonInfExample;
|
|
|
+import com.minpay.db.table.model.VmPersonRoleInf;
|
|
|
+import com.minpay.db.table.model.VmPersonRoleInfExample;
|
|
|
import com.minpay.db.table.own.mapper.PersonManageMapper;
|
|
|
import com.minpay.db.table.own.mapper.SequenceMapper;
|
|
|
import com.minpay.huicai.util.EquCodeCreateUtil;
|
|
@@ -33,6 +36,9 @@ import com.startup.minpay.frame.target.MINAction;
|
|
|
import com.startup.minpay.frame.target.MINComponent;
|
|
|
import com.startup.minpay.frame.target.MINParam;
|
|
|
import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.fileupload.FileItem;
|
|
|
+import org.apache.commons.fileupload.FileItemFactory;
|
|
|
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
@@ -193,14 +199,17 @@ public class PersManageAction implements IMINAction {
|
|
|
if(CommonUtil.isEmpty((String) result.get("openId"))) {
|
|
|
throw new MINBusinessException("JA0001", "非法登录!");
|
|
|
}
|
|
|
+ //用户表可以存在 角色表不可以
|
|
|
+
|
|
|
VmPersonInfExample personex = new VmPersonInfExample();
|
|
|
personex.createCriteria().andChannelEqualTo(channel).andTypeEqualTo(type).andOpenidEqualTo((String) result.get("openId"));
|
|
|
List<VmPersonInf> perLst = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonInfMapper.class).selectByExample(personex);
|
|
|
- if(perLst.size() > 0 ){
|
|
|
- throw new MINBusinessException("用户已存在!");
|
|
|
+ if(perLst.size() > 1 ){
|
|
|
+ throw new MINBusinessException("用户异常,请联系管理员!");
|
|
|
}
|
|
|
|
|
|
- if(perLst.size() == 0) {
|
|
|
+ if(perLst.size() == 0) { //新用户,新角色
|
|
|
+ /**添加用户*/
|
|
|
//获取用户主键
|
|
|
String perId = Service.lookup(IMINDataBaseService.class).getMybatisMapper(SequenceMapper.class).getSequence("VM_PERSON_INF_NO");
|
|
|
person.setId(perId);
|
|
@@ -219,11 +228,36 @@ public class PersManageAction implements IMINAction {
|
|
|
person.setRole(role);
|
|
|
person.setUserId(branchId);
|
|
|
Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonInfMapper.class).insertSelective(person);
|
|
|
- }else{
|
|
|
+ /**添加角色*/
|
|
|
+ String roleId = Service.lookup(IMINDataBaseService.class).getMybatisMapper(SequenceMapper.class).getSequence("VM_PERSON_ROLE_ID");
|
|
|
+ VmPersonRoleInf vmPersonRoleInf = new VmPersonRoleInf();
|
|
|
+ vmPersonRoleInf.setId(roleId);
|
|
|
+ vmPersonRoleInf.setBranchId(branchId);
|
|
|
+ vmPersonRoleInf.setPersonId(perId);
|
|
|
+ vmPersonRoleInf.setRole(role);
|
|
|
+ Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonRoleInfMapper.class).insertSelective(vmPersonRoleInf);
|
|
|
+ }else{ //有用户,无角色
|
|
|
VmPersonInf vmPersonInf = perLst.get(0);
|
|
|
if("0".equals(vmPersonInf.getIsUser())){
|
|
|
vmPersonInf.setIsUser("1");
|
|
|
Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonInfMapper.class).updateByPrimaryKeySelective(person);
|
|
|
+
|
|
|
+ }else{
|
|
|
+ /**查询是否有此角色*/
|
|
|
+ VmPersonRoleInfExample vmPersonRoleInfExample = new VmPersonRoleInfExample();
|
|
|
+ vmPersonRoleInfExample.createCriteria().andRoleEqualTo(role).andPersonIdEqualTo(vmPersonInf.getId()).andStateEqualTo("00");
|
|
|
+ List<VmPersonRoleInf> vmPersonRoleInfList = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonRoleInfMapper.class).selectByExample(vmPersonRoleInfExample);
|
|
|
+ if(vmPersonRoleInfList.size() > 0){
|
|
|
+ throw new MINBusinessException("已有此角色,无需再次添加");
|
|
|
+ }
|
|
|
+ /**添加角色*/
|
|
|
+ String roleId = Service.lookup(IMINDataBaseService.class).getMybatisMapper(SequenceMapper.class).getSequence("VM_PERSON_ROLE_ID");
|
|
|
+ VmPersonRoleInf vmPersonRoleInf = new VmPersonRoleInf();
|
|
|
+ vmPersonRoleInf.setId(roleId);
|
|
|
+ vmPersonRoleInf.setBranchId(branchId);
|
|
|
+ vmPersonRoleInf.setPersonId(vmPersonInf.getId());
|
|
|
+ vmPersonRoleInf.setRole(role);
|
|
|
+ Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmPersonRoleInfMapper.class).insertSelective(vmPersonRoleInf);
|
|
|
}
|
|
|
}
|
|
|
return res;
|
|
@@ -290,7 +324,7 @@ public class PersManageAction implements IMINAction {
|
|
|
* @param flash 是否刷新
|
|
|
*/
|
|
|
@MINAction(value = CREATE_QRCODE, transaction = IMINTransactionEnum.CMT)
|
|
|
- public static MINActionResult createQrCode(
|
|
|
+ public MINActionResult createQrCode(
|
|
|
@MINParam(key = "flash") String flash,
|
|
|
@MINParam(key = "role") String role,
|
|
|
MINSession session)throws MINBusinessException, FileNotFoundException, WriterException, IOException {
|
|
@@ -346,7 +380,7 @@ public class PersManageAction implements IMINAction {
|
|
|
String urls = iQrcodeService.createQrCode("-1",paramStr.toString(),"-1");
|
|
|
//String urlString = URLEncoder.encode(, "GBK");
|
|
|
http://shjservices.personalpay.cn/adm
|
|
|
- // 生成二维码图片到本地
|
|
|
+ // 生成二维码图片到本地+
|
|
|
try {
|
|
|
EquCodeCreateUtil.createQrCode(outputStream,urls,900,"JPEG");
|
|
|
} catch (com.google.zxing.WriterException e) {
|
|
@@ -356,14 +390,43 @@ public class PersManageAction implements IMINAction {
|
|
|
outputStream.close();
|
|
|
// 上传图片到服务器
|
|
|
InputStream inputSteam = new FileInputStream(file);
|
|
|
- String url = UpLoadFile.uploadImg(inputSteam,"jpg",channel,"00");
|
|
|
-
|
|
|
+ String ambient = Service.lookup(IPublicService.class)
|
|
|
+ .getSysParValue("AMBIENT");//当前环境
|
|
|
+ FileItem fileItem = createFileItem(file ,"itemFileName");
|
|
|
+ Map<String, Object> map = null;
|
|
|
+ if("00".equals(ambient)){//测试
|
|
|
+ map =Service.lookup(IPublicService.class).uploadFile(fileItem, "00", 0, true,"V01");
|
|
|
+ }
|
|
|
+ if("01".equals(ambient)){//生产
|
|
|
+ map =Service.lookup(IPublicService.class).uploadFileBD(fileItem, "00", 0, true,"V01");
|
|
|
+ }
|
|
|
+ String url = String.valueOf(map.get("url"));
|
|
|
inputSteam.close();
|
|
|
// 删除本地图片
|
|
|
file.delete();
|
|
|
res.set("url", url);
|
|
|
return res;
|
|
|
}
|
|
|
-
|
|
|
+ /*
|
|
|
+ 创建FileItem
|
|
|
+ */
|
|
|
+ private FileItem createFileItem(File file, String fieldName) {
|
|
|
+ FileItemFactory factory = new DiskFileItemFactory(16, null);
|
|
|
+ FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName());
|
|
|
+ int bytesRead = 0;
|
|
|
+ byte[] buffer = new byte[8192];
|
|
|
+ try {
|
|
|
+ FileInputStream fis = new FileInputStream(file);
|
|
|
+ OutputStream os = item.getOutputStream();
|
|
|
+ while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
|
|
|
+ os.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ os.close();
|
|
|
+ fis.close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return item;
|
|
|
+ }
|
|
|
|
|
|
}
|